Event handling updates a panel - how?

Hello,

I would like to know what is the correct approach (which classes to use) to do the following.

I have a ComboBox (Dropdown) with a list of people. Upon choosing an option from this list, I want to load this person’s information.

Currently, I have something like the code below. When the program launches, It displays correctly and it even works the first time I change a person, but on subsequent changes it crashes.

I would appreciate if I could get directions on how to achieve what I want. Also, if I am doing something not in the ‘wxPython’ way (I am new to wxPython and Python in general), I would appreciate if those errors were pointed out as well.

Thank you,
Martin

class PanelPersonsList(wx.Panel):

def __init__(self, parent, personsList):
    wx.Panel.__init__(self, parent)

    # Creates sizers
    grid = wx.GridBagSizer(hgap=2, vgap=3)

    personSizer = wx.BoxSizer(wx.VERTICAL)
    personWindow = wx.Window(self, -1, (0,80), (600,600), wx.SUNKEN_BORDER)

    personSizer.Add(jovemWindow, 1, wx.EXPAND)


    # Creates the dropdown
    names = []

    for person in personsList:
        names.append([person.name](http://person.name))

    nameList = wx.ComboBox(self, size=(480,-1), choices=names, value=names[0], style=wx.CB_DROPDOWN)
    grid.Add(namelist, pos=(0,0))

    panelPerson = MyPanel(personWindow, personslist[0])
    panelPerson.Show()

    grid.Add(personSizer, pos=(0,1))

    self.SetSizerAndFit(grid)

    # Configure event
    self.Bind(wx.EVT_COMBOBOX, lambda event: self.onChooseName(personWindow, event, personsList, grid, panelPerson), nameList)

def onChooseName(self, parent, event, personsList, grid, panelPerson):

    grid.Detach(panelPerson)
    panelPerson.Hide()

    panelPerson.Destroy()
    p = personsList.GetPerson(event.GetString()) # Given the name of a person, looks for a person with this name in the list and returns it

    panelPerson = MyPanel(parent, p)

class MyPanel(wx.Panel):

def __init__(self, parent, person):
    wx.Panel.__init__(self, parent)

    # Create a panel with info about this person

Hello,

I would like to know what is the correct approach (which classes to use)
to do the following.

I have a ComboBox (Dropdown) with a list of people. Upon choosing an
option from this list, I want to load this person's information.

Currently, I have something like the code below. When the program
launches, It displays correctly and it even works the first time I
change a person, but on subsequent changes it crashes.

Raises an exception or a a hard crash? Which platform and version are you using?

I would appreciate if I could get directions on how to achieve what I
want. Also, if I am doing something not in the 'wxPython' way (I am new
to wxPython and Python in general), I would appreciate if those errors
were pointed out as well.

Thank you,
Martin

class PanelPersonsList(wx.Panel):
     def __init__(self, parent, personsList):
         wx.Panel.__init__(self, parent)

         # Creates sizers
         grid = wx.GridBagSizer(hgap=2, vgap=3)
         personSizer = wx.BoxSizer(wx.VERTICAL)
         personWindow = wx.Window(self, -1, (0,80), (600,600),
wx.SUNKEN_BORDER)
         personSizer.Add(jovemWindow, 1, wx.EXPAND)

Where does jovemWindow come from?

         # Creates the dropdown
         names =
         for person in personsList:
             names.append(person.name <http://person.name>)
         nameList = wx.ComboBox(self, size=(480,-1), choices=names,
value=names[0], style=wx.CB_DROPDOWN)
         grid.Add(namelist, pos=(0,0))

         panelPerson = MyPanel(personWindow, personslist[0])
         panelPerson.Show()

This is not in a sizer. What do you do with it? Where should it be positioned?

         grid.Add(personSizer, pos=(0,1))

         self.SetSizerAndFit(grid)

         # Configure event
         self.Bind(wx.EVT_COMBOBOX, lambda event:
self.onChooseName(personWindow, event, personsList, grid, panelPerson),
nameList)

This is probably the root of the it-breaks-the-second-time problem. When you do this event binding the values of panelPerson and the others are tied into the lambda with the values they have right now, but in the event handler you are destroying panelPerson and then creating a new one, but that will not be the value that is used the next time in the lambda as it will still be using the original. Instead you should save those values in the instance (using self.personPanel, etc.) and then change onChooseName to take only the event parameter and also access these things via the instance.

     def onChooseName(self, parent, event, personsList, grid, panelPerson):
         grid.Detach(panelPerson)

It wasn't in the sizer, so trying to detach it is probably another part of your problem.

         panelPerson.Hide()
         panelPerson.Destroy()
         p = personsList.GetPerson(event.GetString()) # Given the name
of a person, looks for a person with this name in the list and returns it
         panelPerson = MyPanel(parent, p)

Again, it's not being put in a sizer.

class MyPanel(wx.Panel):
     def __init__(self, parent, person):
         wx.Panel.__init__(self, parent)

         # Create a panel with info about this person

Also, since you are new here this message is a freebie, in the future you should include a complete runnable sample program that shows the problem you are having, otherwise you risk being ignored. See MakingSampleApps - wxPyWiki

···

On 10/7/11 3:34 PM, Martin Ichilevici de Oliveira wrote:

--
Robin Dunn
Software Craftsman

Hi Martin,

Hello,

  I would like to know what is the correct approach (which classes

to use) to do the following.

  I have a ComboBox (Dropdown) with a list of people. Upon choosing

an option from this list, I want to load this person’s
information.

  Currently, I have something like the code below. When the program

launches, It displays correctly and it even works the first time I
change a person, but on subsequent changes it crashes.

  I would appreciate if I could get directions on how to achieve

what I want. Also, if I am doing something not in the ‘wxPython’
way (I am new to wxPython and Python in general), I would
appreciate if those errors were pointed out as well.

  Thank you,

  Martin



          class

PanelPersonsList(wx.Panel):

              def

init(self, parent, personsList):

wx.Panel.init(self, parent)

                  #

Creates sizers

                  grid =

wx.GridBagSizer(hgap=2, vgap=3)

personSizer = wx.BoxSizer(wx.VERTICAL)

personWindow = wx.Window(self, -1, (0,80), (600,600),
wx.SUNKEN_BORDER)

personSizer.Add(jovemWindow, 1, wx.EXPAND)

                  #

Creates the dropdown

                  names =

                  for

person in personsList:

names.append(person.name)

                  nameList

= wx.ComboBox(self, size=(480,-1), choices=names,
value=names[0], style=wx.CB_DROPDOWN)

grid.Add(namelist, pos=(0,0))

panelPerson = MyPanel(personWindow, personslist[0])

panelPerson.Show()

grid.Add(personSizer, pos=(0,1))

self.SetSizerAndFit(grid)

                  #

Configure event

self.Bind(wx.EVT_COMBOBOX, lambda event:
self.onChooseName(personWindow, event, personsList, grid,
panelPerson), nameList)

              def

onChooseName(self, parent, event, personsList, grid,
panelPerson):

grid.Detach(panelPerson)

panelPerson.Hide()

panelPerson.Destroy()

                  p =

personsList.GetPerson(event.GetString()) # Given the name of a
person, looks for a person with this name in the list and
returns it

panelPerson = MyPanel(parent, p)

          class

MyPanel(wx.Panel):

              def

init(self, parent, person):

wx.Panel.init(self, parent)

                  # Create

a panel with info about this person
Why are you destroying/creating the panelPerson? Why not just
pass/set the new person information? I.e. add to your “MyPanel”
class a method “SetPersonInformation” and save a reference for it
when you instantiate it e.g. “self.panelPerson” and then call
"self.panelPerson.SetPersonInformation(personinfo) whenever a person
is selected.

Using the name as the key to get the person information seems a bit

odd too. How do you deal with two persons which have the same name?

I guess that "MyPanel" has a bunch of controls which need to be

filled, for this you might want to look into validators (check out
the wiki and there has been a recent thread ““Realtime” update on
enter VALIDATORS” which had a small sample for this (just needed two
changes to make it work as mentioned in my last response on that
thread.

Werner
···

On 10/08/2011 12:34 AM, Martin Ichilevici de Oliveira wrote:

Hi,

Although I’m also very new at both python (<month) and wx python (<week), I was struggling with some of the same things, so I can give you some advice. If what I’m saying is not true, I hope that some of the more experienced guys will jump in and correct me.

Since Robin mentioned sizers, this is a concept I was really struggling with but as far as I understand here’s how it works. If you will be using the program you are writing just on your particular system, then you can simply position all the widgets by hand by specifying the pos=(x,y) option when you are creating the widget. However if you think your program will be used on a different system, which might have a different font and so on, it is best to put all the widgets in a sizer, say how the widgets should be places inside the sizer and then the sizer automatically takes care that there’s no overlap, the font sizes are taken into consideration and so on.

In the sizer you can place either widgets (such as wx.Button, wx.CheckBox, wx.TextCtrl and so on) or various types of windows (such as wx.ScrolledWindow, wx.Panel and so on) or even other sizers. In the most general case that I’ve used so far, I have my main frame, which is associated with a sizer and in that sizer I’ve put other secondary sizers (containing widgets) and panels, associated with other sizers, again containing widgets. In such a way you can create a hierarchy of sizers.

Since the above is quite a mouthful, I’m attaching a simple example which I just wrote. Suppose that you want to create a frame, which is associated with a sizer and contains two panels, each one of which is also associated with a sizer. In each panel you want to put two buttons - in the left panel two buttons horizontally and in the right panel two buttons vertically. Here’s how you would do it:

···

#!/usr/bin/env python

import wx

class MyExampleFrame(wx.Frame):
def init(self,parent,id):
#Create the main frame
wx.Frame.init(self,parent,id)

  #Create the three necessary sizers
  self.main_sizer = wx.BoxSizer(orient=wx.HORIZONTAL)
  self.left_panel_sizer = wx.BoxSizer(orient=wx.HORIZONTAL)
  self.right_panel_sizer = wx.BoxSizer(orient=wx.VERTICAL)

  #Create the left panel and set the background colour as a visual aid
  self.left_panel = wx.Panel(self, -1)
  self.left_panel.SetBackgroundColour('blue')
  #Create the two buttons that will go in the left panel
  #MAKE SURE THAT THEIR PARENT IS THE LEFT PANEL AND NOT SELF!!!
  self.left_button = wx.Button(parent=self.left_panel, id=-1, label='left')
  self.right_button = wx.Button(parent=self.left_panel, id=-1, label='right')
  #Add the buttons to the left panel sizer
  self.left_panel_sizer.Add(self.left_button, 0, wx.ALL, 5)
  self.left_panel_sizer.Add(self.right_button, 0, wx.ALL, 5)
  #Set the left panel sizer to control the size of the left panel
  self.left_panel.SetSizer(self.left_panel_sizer)
  #Fit everything that is in the left panel in the smallest possible space
  self.left_panel_sizer.Fit(self.left_panel)
 
 
  #Do the same thing as above for the right panel
  self.right_panel = wx.Panel(self,-1)
  self.right_panel.SetBackgroundColour('red')   
  self.top_button = wx.Button(parent=self.right_panel, id=-1, label='top')
  self.bottom_button = wx.Button(parent=self.right_panel, id=-1, label='bottom')     
  self.right_panel_sizer.Add(self.top_button, 0, wx.ALL, 5)
  self.right_panel_sizer.Add(self.bottom_button, 0, wx.ALL, 5)     
  self.right_panel.SetSizer(self.right_panel_sizer)     
  self.right_panel_sizer.Fit(self.right_panel)

  #Add the left and right panels to the main sizer
  #MAKE SURE TO ADD THE PANELS AND NOT THE PANEL SIZERS, WHICH WILL GIVE A SEGMENTATION FAULT
  self.main_sizer.Add(self.left_panel, 0, wx.ALIGN_CENTRE_VERTICAL)     
  self.main_sizer.Add(self.right_panel, 0, wx.ALIGN_CENTRE_VERTICAL)

  #Set the main sizer to control self (self = the main application frame)
  self.SetSizer(self.main_sizer)
  #I saw this line recommended in a website, but it doesn't seem to make a difference
  self.SetAutoLayout(True)
  #Fit everything which is in the main frame in the smallest possible space
  self.main_sizer.Fit(self)

if name==‘main’:
app=wx.PySimpleApp()
mainframe=MyExampleFrame(parent=None,id=-1)
mainframe.Show()
app.MainLoop()


I hope that the above example will clear up things regarding the relationships between sizers, panels, widgets. In the above example I’ve put all the variable names with a ‘self.’ in front. This is in case you want to access those variables in other functions in the class. Otherwise (as in this particular example) they are unnecessary.

Best,
Jopeto

PS. Some things which I still don’t quite understand myself and hopefully will have time to figure out in the future are:

  1. Should I have the “self.SetAutoLayout(True)” since it doesn’t really seem to do anything?
  2. What does the “id=-1” mean in the creation of each widget? I’ve never seen any other value than -1, so it seems a bit unnecessary to me to have to specify it every time.
  3. Is there a difference between wx.PySimpleApp() and wx.App()? In the above example it doesn’t seem to make a difference. There’s some stuff about an ‘OnInit’ method that differentiates them but that’s still beyond me.
  4. Sometimes I see code on the internet that has wx.App(True) or wx.App(False) and I have no idea what that boolean parameter sets.

Date: Fri, 7 Oct 2011 21:15:58 -0700
From: robin@alldunn.com
To: wxpython-users@googlegroups.com
Subject: Re: [wxPython-users] Event handling updates a panel - how?

On 10/7/11 3:34 PM, Martin Ichilevici de Oliveira wrote:

Hello,

I would like to know what is the correct approach (which classes to use)
to do the following.

I have a ComboBox (Dropdown) with a list of people. Upon choosing an
option from this list, I want to load this person’s information.

Currently, I have something like the code below. When the program
launches, It displays correctly and it even works the first time I
change a person, but on subsequent changes it crashes.

Raises an exception or a a hard crash? Which platform and version are
you using?

I would appreciate if I could get directions on how to achieve what I
want. Also, if I am doing something not in the ‘wxPython’ way (I am new
to wxPython and Python in general), I would appreciate if those errors
were pointed out as well.

Thank you,
Martin

class PanelPersonsList(wx.Panel):
def init(self, parent, personsList):
wx.Panel.init(self, parent)

Creates sizers

grid = wx.GridBagSizer(hgap=2, vgap=3)
personSizer = wx.BoxSizer(wx.VERTICAL)
personWindow = wx.Window(self, -1, (0,80), (600,600),
wx.SUNKEN_BORDER)
personSizer.Add(jovemWindow, 1, wx.EXPAND)

Where does jovemWindow come from?

Creates the dropdown

names =
for person in personsList:
names.append(person.name http://person.name)
nameList = wx.ComboBox(self, size=(480,-1), choices=names,
value=names[0], style=wx.CB_DROPDOWN)
grid.Add(namelist, pos=(0,0))

panelPerson = MyPanel(personWindow, personslist[0])
panelPerson.Show()

This is not in a sizer. What do you do with it? Where should it be
positioned?

grid.Add(personSizer, pos=(0,1))

self.SetSizerAndFit(grid)

Configure event

self.Bind(wx.EVT_COMBOBOX, lambda event:
self.onChooseName(personWindow, event, personsList, grid, panelPerson),
nameList)

This is probably the root of the it-breaks-the-second-time problem.
When you do this event binding the values of panelPerson and the others
are tied into the lambda with the values they have right now, but in the
event handler you are destroying panelPerson and then creating a new
one, but that will not be the value that is used the next time in the
lambda as it will still be using the original. Instead you should save
those values in the instance (using self.personPanel, etc.) and then
change onChooseName to take only the event parameter and also access
these things via the instance.

def onChooseName(self, parent, event, personsList, grid, panelPerson):
grid.Detach(panelPerson)

It wasn’t in the sizer, so trying to detach it is probably another part
of your problem.

panelPerson.Hide()
panelPerson.Destroy()
p = personsList.GetPerson(event.GetString()) # Given the name
of a person, looks for a person with this name in the list and returns it
panelPerson = MyPanel(parent, p)

Again, it’s not being put in a sizer.

class MyPanel(wx.Panel):
def init(self, parent, person):
wx.Panel.init(self, parent)

Create a panel with info about this person

Also, since you are new here this message is a freebie, in the future
you should include a complete runnable sample program that shows the
problem you are having, otherwise you risk being ignored. See
MakingSampleApps - wxPyWiki


Robin Dunn
Software Craftsman
http://wxPython.org


To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Hi,

Hi,

      Although I'm also very new at both python (<month) and wx

python (<week), I was struggling with some of the same
things, so I can give you some advice. If what I’m saying is
not true, I hope that some of the more experienced guys will
jump in and correct me.

      Since Robin mentioned sizers, this is a concept I was really

struggling with but as far as I understand here’s how it
works. If you will be using the program you are writing just
on your particular system, then you can simply position all
the widgets by hand by specifying the pos=(x,y) option when
you are creating the widget. However if you think your program
will be used on a different system, which might have a
different font and so on, it is best to put all the widgets in
a sizer, say how the widgets should be places inside the sizer
and then the sizer automatically takes care that there’s no
overlap, the font sizes are taken into consideration and so
on.

Sizers are a p.... but I think today they are the only way of doing

UI’s with wxPython, fixed position will very very quickly fall apart
even on the same platform as the ui doesn’t adapt to the users
machine and setting (resolution, font). If you want to give even
more choice to the user of your application you should also look at
wx.lib.aui.

      In the sizer you can place either widgets (such as wx.Button,

wx.CheckBox, wx.TextCtrl and so on) or various types of
windows (such as wx.ScrolledWindow, wx.Panel and so on) or
even other sizers. In the most general case that I’ve used so
far, I have my main frame, which is associated with a sizer
and in that sizer I’ve put other secondary sizers (containing
widgets) and panels, associated with other sizers, again
containing widgets. In such a way you can create a hierarchy
of sizers.

      Since the above is quite a mouthful, I'm attaching a simple

example which I just wrote. Suppose that you want to create a
frame, which is associated with a sizer and contains two
panels, each one of which is also associated with a sizer. In
each panel you want to put two buttons - in the left panel two
buttons horizontally and in the right panel two buttons
vertically. Here’s how you would do it:

I attach your code redone (more or less) using sized_controls, not

to correct you but to show an alternative. The sized controls make
it a bit less tedious to work with sizers (in my view) and have the
additional advantage that they define the border as per platform
specific HIG’s.

      I hope that the above example will clear up

things regarding the relationships between sizers, panels,
widgets. In the above example I’ve put all the variable names
with a ‘self.’ in front. This is in case you want to access
those variables in other functions in the class. Otherwise (as
in this particular example) they are unnecessary.

      Best,

      Jopeto



      PS. Some things which I still don't quite understand myself

and hopefully will have time to figure out in the future are:

      1. Should I have the "self.SetAutoLayout(True)" since it

doesn’t really seem to do anything?

IIRC, this was needed in some older version of wxPython.

      2. What does the "id=-1" mean in the creation of

each widget? I’ve never seen any other value than -1, so it
seems a bit unnecessary to me to have to specify it every
time.

I prefer using wx.ID_ANY which makes it clearer also the -1 is the

same thing - i.e. I don’t care what ID this widget is getting. See
in the attached on two of the buttons I do care - see also the
wxPython demo - Stock Buttons. There are still some other cases in
wxPython where the ID is

      3. Is there a difference between wx.PySimpleApp()

and wx.App()? In the above example it doesn’t seem to make a
difference. There’s some stuff about an ‘OnInit’ method that
differentiates them but that’s still beyond me.

with wx.App you have the OnInit and OnExit which allow you to do

some application setup OnInit and to clean things up OnExit. In the
attached I added in the WIT - run it and press ctrl-alt-i to see
what this gives you.

      4. Sometimes I see code on the internet that has

wx.App(True) or wx.App(False) and I have no idea what that
boolean parameter sets.

This is the redirect parameter.

Werner

sizersample.py (2.34 KB)

···

http://xoomer.virgilio.it/infinity77/wxPython/Widgets/wx.App.html

Oops, send pressed a bit to soon

...

I prefer using wx.ID_ANY which makes it clearer also the -1 is the same thing - i.e. I don't care what ID this widget is getting. See in the attached on two of the buttons I do care - see also the wxPython demo - Stock Buttons. There are still some other cases in wxPython where the ID is

needed to have a meaning - I can think of wx.Menu but there might be other areas too.

Werner

···

On 10/08/2011 11:31 AM, werner wrote:

Thanks, that was quite useful!

···

Date: Sat, 8 Oct 2011 11:39:19 +0200
From: wbruhin@free.fr
To: wxpython-users@googlegroups.com
Subject: Re: [wxPython-users] Event handling updates a panel - how?

Oops, send pressed a bit to soon

On 10/08/2011 11:31 AM, werner wrote:

I prefer using wx.ID_ANY which makes it clearer also the -1 is the
same thing - i.e. I don’t care what ID this widget is getting. See in
the attached on two of the buttons I do care - see also the wxPython
demo - Stock Buttons. There are still some other cases in wxPython
where the ID is

needed to have a meaning - I can think of wx.Menu but there might be
other areas too.

Werner


To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Hi,

      Although I'm also very new at both python (<month) and wx

python (<week), I was struggling with some of the same
things, so I can give you some advice. If what I’m saying is
not true, I hope that some of the more experienced guys will
jump in and correct me.

Welcome to the wonderful world of (wx)Python!

<Code Snipped>

Best,

      Jopeto



      PS. Some things which I still don't quite understand myself

and hopefully will have time to figure out in the future are:

      1. Should I have the "self.SetAutoLayout(True)" since it

doesn’t really seem to do anything?

Not 100% sure myself but I believe that it controls whether you need

to explicity tell your application when a new layout is needed or it
tries to detect it for you. If you have points when there is a
major change in your layout that will go slowly if the window is
trying to do a new layout between stages then you will need to turn
off Auto Layout until you are done.

      2. What does the "id=-1" mean in the creation of

each widget? I’ve never seen any other value than -1, so it
seems a bit unnecessary to me to have to specify it every
time.

You need to specify a unique id for each item, you have the option

of specifying you own so that you can take control of things like
when the item is enabled, etc., by id number. -1 translates to let
the system create a new unique id for this control. You can still
do things like enable/disable the control in other ways such as find
by label or getting the id that windows assigns and keeping track of
it. Like a lot of things in the wx world there are several ways of
doing things and many of them a kept for backwards & cross
platform compatibility - (you may moan a little at some of them but
the first time you move yours source code onto a different
platform/os and it just works you will cheer).

      3. Is there a difference between wx.PySimpleApp()

and wx.App()? In the above example it doesn’t seem to make a
difference. There’s some stuff about an ‘OnInit’ method that
differentiates them but that’s still beyond me.

To quote the built in helps:
wx.App - * Normally you would derive from this class and implement
an
OnInit method that creates a frame and then calls
self.SetTopWindow(frame).*

wx.PySimpleApp - *      A simple application class.  You can just

create one of these and
then then make your top level windows later, and not have to worry
about OnInit. For example::

      app = wx.PySimpleApp()
      frame = wx.Frame(None, title='Hello World')
      frame.Show()
      app.MainLoop()*

A tip for you try opening a command prompt and typing:
***python
    import wx
    a=wx.App
    s=wx.PySimpleApp
    help(a)
    help(s)***
This will let you have a look at the built in documentation.  You

can even do the same for your own code as long as you document your
scripts and classes with the treble quote notation. Try the
following, (bold italic is what you type and italic the replies,
spaces are as usual vital):
***python
class myClass()
“”"
A class of my own.
“”"
def MyFn():
“”"
Some information about my function.
“”"
pass
def MyOtherFn():
“”"
This is another function.
“”"
pass

    m = MyClass
    help(m)
 *** You will see:
*Help on class MyClass in module __main__:

  class MyClass
   >  A class of my own.
   >
   >  Methods defined here:
   >
   >  MyFn()
   >      Some information about my function.
   >
   >  MyOtherFn()
   >      This is another function.****
    dir(m)***
*['MyFn', 'MyOtherFn', '__doc__', '__module__']****
    help(m.MyFn)
 ** Help on method MyFn in module __main__:

  MyFn() unbound __main__.MyClass method
      Some information about my function.
  • This approach will let you explore your own and others code
    

documentation.

      4. Sometimes I see code on the internet that has

wx.App(True) or wx.App(False) and I have no idea what that
boolean parameter sets.

This is also written as wx.App(redirect=True) or in full

wx.App(redirect=True, filename=None) which translates on windows/mac
as stdout and stderr should be redirected to a popup window so any
print or error outputs popup in a fresh window. If a filename is
given then such outputs will go to the file, if redirect = False,
then such output will go to the command window that the script was
started from, (if you started it by clicking on the script it will
be lost). Note that you can also toggle the application redirect
flag depending on the stage you are at or user options.

I hope the above is helpful.

BTW - Try to get into the habit of bottom posting, (where your text

goes at the end or after the bit you are answering), as it is the
preferred practice on this forum. It does make it a lot easier to
read the developing discussions that way.

Gadget/Steve
···

On 08/10/2011 9:32 AM, G. Nikiforov wrote:

1. Should I have the "self.SetAutoLayout(True)" since it doesn't
really seem to do anything?

IIRC, this was needed in some older version of wxPython.

I think it was only actually needed for one development release, and autolayout was automatically turned on when the sizer is set ever since then. The API is still there for times when you may want to turn autolayout off by passing False.

3. Is there a difference between wx.PySimpleApp() and wx.App()? In the
above example it doesn't seem to make a difference. There's some stuff
about an 'OnInit' method that differentiates them but that's still
beyond me.

There is no real difference any more. The last little sliver of difference has now vanished in the 2.9 series and wx.PySimpleApp has been marked deprecated in the current development version of the code.

···

On 10/8/11 2:31 AM, werner wrote:

--
Robin Dunn
Software Craftsman