Best practice to rganize the code

Hello List,
i build a mildly complex wxPython App for the presentation of Loans. The
application has the following structure

Frame
+- ButtonPanel
+- Menu
+- Splitterwindow
   +- leftpanel
   > several Input Controls with labels
   +- rightpanel
      +- Notebook
         +- overviewpanel
         > several Output Controls and labels
         +- gridpanel
         > grid with numbers
         +- plotpanel
              matplotlib plot
      +- errorpanel
          several texts. This panel is visikle
            instead of the Notebook if something goes wrong

The whole thing works in principle but the code is a mess. I have it organized
as the ASCII-Art above shows. There is a function 'make_rightpanel' and a
function 'make_plotpanel' and so on.

This in itself is no problem but these functions are hard to read. They define
controls, they define sizers and place the controls in the sizers.

So in essence these functions define the contents of
the frame and the layout structure in one step and this smells.

Here is a short example(yagut.* arhe thin wrappers around the wx-CVontrols):

···

-------
def make_errorsizer(parent):
    sizer = yagut.BoxSizer(parent,name='error',orient=wx.VERTICAL)
    s1 = wx.BoxSizer(wx.HORIZONTAL)
    sizer.Add(yagut.Label(parent,-1,name = "error_label" ))
    sizer.Add((60, 20), 0, wx.EXPAND)
    s1.Add(yagut.Label(parent,-1,name = "error_text" ),wx.EXPAND)
    sizer.Add(s1)
    s2 = wx.BoxSizer(wx.HORIZONTAL)
    s2.Add(yagut.Label(parent,-1,name = "error_help" ),wx.EXPAND)
    sizer.Add(s2)
    return sizer

-------

In an ideal world one would define all controls in one step as a flat list of
objects and then define the hierarchical sizer structure in a second step and
place the controls in this structure.

Problem is: Notebooks, Splitters and friends introduce a hierarchy
of Panels and the controls must be placed in panels to display properly.

So we have 2 parallel hierarchies - one of panels and one of sizers and this
speaks trouble.

How do people handle this ?

All the best !

Norbert

I guess you’ll get different approaches, and I’d be interested in hearing about them too, but I find that the way Boa Constructor handles it is useful for me to keep things straight. Below is code that is 100% generated by Boa and took about 10 minutes to do with it. You can get a sense for how it segregates sizers, panels, splitters, and notebooks in a way that is pretty clean, I feel.

···

On Sat, Mar 15, 2008 at 11:08 AM, Norbert Klamann Norbert.Klamann@projecthome.de wrote:

Hello List,

i build a mildly complex wxPython App for the presentation of Loans. The

application has the following structure

Frame

± ButtonPanel

± Menu

± Splitterwindow

± leftpanel

several Input Controls with labels

± rightpanel

  +- Notebook

     +- overviewpanel

     >    several Output Controls and labels

     +- gridpanel

     >    grid with numbers

     +- plotpanel

          matplotlib plot

  +- errorpanel

      several texts. This panel is visikle

        instead of the Notebook if something goes wrong

The whole thing works in principle but the code is a mess. I have it organized

as the ASCII-Art above shows. There is a function ‘make_rightpanel’ and a

function ‘make_plotpanel’ and so on.

This in itself is no problem but these functions are hard to read. They define

controls, they define sizers and place the controls in the sizers.

So in essence these functions define the contents of

the frame and the layout structure in one step and this smells.

Here is a short example(yagut.* arhe thin wrappers around the wx-CVontrols):


def make_errorsizer(parent):

sizer = yagut.BoxSizer(parent,name='error',orient=wx.VERTICAL)

s1 = wx.BoxSizer(wx.HORIZONTAL)

sizer.Add(yagut.Label(parent,-1,name = "error_label" ))

sizer.Add((60, 20), 0, wx.EXPAND)

s1.Add(yagut.Label(parent,-1,name = "error_text" ),wx.EXPAND)

sizer.Add(s1)

s2 = wx.BoxSizer(wx.HORIZONTAL)

s2.Add(yagut.Label(parent,-1,name = "error_help" ),wx.EXPAND)

sizer.Add(s2)

return sizer

In an ideal world one would define all controls in one step as a flat list of

objects and then define the hierarchical sizer structure in a second step and

place the controls in this structure.

Problem is: Notebooks, Splitters and friends introduce a hierarchy

of Panels and the controls must be placed in panels to display properly.

So we have 2 parallel hierarchies - one of panels and one of sizers and this

speaks trouble.

How do people handle this ?

All the best !

Norbert

#---------------------------------------------------------------------------------------

#Boa:Frame:Frame1

import wx

def create(parent):
return Frame1(parent)

[wxID_FRAME1, wxID_FRAME1BUTTON1, wxID_FRAME1BUTTON2, wxID_FRAME1BUTTON3,

wxID_FRAME1CHECKBOX1, wxID_FRAME1CHECKBOX2, wxID_FRAME1CHECKBOX3,
wxID_FRAME1CHOICE1, wxID_FRAME1CHOICE2, wxID_FRAME1NOTEBOOK1,
wxID_FRAME1PANEL1, wxID_FRAME1PANEL10, wxID_FRAME1PANEL11,
wxID_FRAME1PANEL12, wxID_FRAME1PANEL13, wxID_FRAME1PANEL2, wxID_FRAME1PANEL3,

wxID_FRAME1PANEL4, wxID_FRAME1PANEL5, wxID_FRAME1PANEL6, wxID_FRAME1PANEL7,
wxID_FRAME1PANEL8, wxID_FRAME1PANEL9, wxID_FRAME1RADIOBUTTON1,
wxID_FRAME1RADIOBUTTON2, wxID_FRAME1RADIOBUTTON3, wxID_FRAME1SPLITTERWINDOW1,

wxID_FRAME1STATICTEXT1, wxID_FRAME1STATICTEXT2, wxID_FRAME1TEXTCTRL1,
] = [wx.NewId() for _init_ctrls in range(30)]

class Frame1(wx.Frame):
def _init_coll_boxSizer7_Items(self, parent):
# generated method, don’t edit

    parent.AddSizer(self.flexGridSizer1, 0, border=0, flag=0)

def _init_coll_flexGridSizer1_Items(self, parent):
    # generated method, don't edit

    parent.AddWindow(self.button1, 0, border=0, flag=0)

    parent.AddWindow(self.button2, 0, border=0, flag=0)
    parent.AddWindow(self.button3, 0, border=0, flag=0)
    parent.AddWindow(self.radioButton1, 0, border=0, flag=0)
    parent.AddWindow(self.radioButton2, 0, border=0, flag=0)

    parent.AddWindow(self.radioButton3, 0, border=0, flag=0)
    parent.AddWindow(self.checkBox1, 0, border=0, flag=0)
    parent.AddWindow(self.checkBox2, 0, border=0, flag=0)
    parent.AddWindow(self.checkBox3, 0, border=0, flag=0)

    parent.AddWindow(self.choice1, 0, border=0, flag=0)
    parent.AddWindow(self.choice2, 0, border=0, flag=0)

def _init_coll_boxSizer6_Items(self, parent):
    # generated method, don't edit

    parent.AddWindow(self.splitterWindow1, 1, border=0, flag=wx.EXPAND)

def _init_coll_boxSizer4_Items(self, parent):
    # generated method, don't edit

    parent.AddWindow(self.staticText1, 0, border=5, flag=wx.ALL)

def _init_coll_boxSizer8_Items(self, parent):
    # generated method, don't edit

    parent.AddWindow(self.staticText2, 0, border=5, flag=wx.EXPAND)

def _init_coll_boxSizer5_Items(self, parent):

    # generated method, don't edit

    parent.AddWindow(self.panel9, 0, border=0, flag=wx.EXPAND)
    parent.AddWindow(self.textCtrl1, 0, border=5, flag=wx.ALL | wx.EXPAND)
    parent.AddWindow(self.panel10, 1, border=0, flag=wx.EXPAND)

def _init_coll_boxSizer3_Items(self, parent):
    # generated method, don't edit

    parent.AddWindow(self.panel7, 0, border=0, flag=wx.GROW | wx.EXPAND)
    parent.AddWindow(self.panel8, 1, border=0, flag=wx.GROW | wx.EXPAND)

def _init_coll_boxSizer1_Items(self, parent):
    # generated method, don't edit

    parent.AddWindow(self.panel2, 0, border=0, flag=wx.GROW | wx.EXPAND)
    parent.AddWindow(self.panel3, 1, border=0, flag=wx.GROW | wx.EXPAND)

def _init_coll_boxSizer2_Items(self, parent):
    # generated method, don't edit

    parent.AddWindow(self.notebook1, 1, border=10, flag=wx.ALL | wx.EXPAND)

def _init_coll_notebook1_Pages(self, parent):

    # generated method, don't edit

    parent.AddPage(imageId=-1, page=self.panel6, select=False,
          text='Pages0')
    parent.AddPage(imageId=-1, page=self.panel5, select=True, text='Pages1')

    parent.AddPage(imageId=-1, page=self.panel4, select=False,
          text='Pages2')
    parent.AddPage(imageId=-1, page=self.panel13, select=False,
          text='Pages3')

def _init_sizers(self):
    # generated method, don't edit
    self.boxSizer1 = wx.BoxSizer(orient=wx.VERTICAL)

    self.boxSizer2 = wx.BoxSizer(orient=wx.VERTICAL)

    self.boxSizer3 = wx.BoxSizer(orient=wx.VERTICAL)

    self.boxSizer4 = wx.BoxSizer(orient=wx.VERTICAL)

    self.boxSizer5 = wx.BoxSizer(orient=wx.VERTICAL)

    self.boxSizer6 = wx.BoxSizer(orient=wx.VERTICAL)

    self.boxSizer7 = wx.BoxSizer(orient=wx.VERTICAL)

    self.flexGridSizer1 = wx.FlexGridSizer(cols=3, hgap=1, rows=1, vgap=0)

    self.boxSizer8 = wx.BoxSizer(orient=wx.VERTICAL)

    self._init_coll_boxSizer1_Items(self.boxSizer1)
    self._init_coll_boxSizer2_Items(self.boxSizer2)

    self._init_coll_boxSizer3_Items(self.boxSizer3)
    self._init_coll_boxSizer4_Items(self.boxSizer4)
    self._init_coll_boxSizer5_Items(self.boxSizer5)
    self._init_coll_boxSizer6_Items(self.boxSizer6)

    self._init_coll_boxSizer7_Items(self.boxSizer7)
    self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
    self._init_coll_boxSizer8_Items(self.boxSizer8)

    self.panel13.SetSizer(self.boxSizer7)

    self.panel1.SetSizer(self.boxSizer1)
    self.panel2.SetSizer(self.boxSizer8)
    self.panel3.SetSizer(self.boxSizer2)
    self.panel4.SetSizer(self.boxSizer6)
    self.panel5.SetSizer(self.boxSizer5)

    self.panel6.SetSizer(self.boxSizer3)
    self.panel7.SetSizer(self.boxSizer4)

def _init_ctrls(self, prnt):
    # generated method, don't edit
    wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,

          pos=wx.Point(246, 123), size=wx.Size(402, 489),
          style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
    self.SetClientSize(wx.Size(394, 455))

    self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1', parent=self,

          pos=wx.Point(0, 0), size=wx.Size(394, 455),
          style=wx.TAB_TRAVERSAL)

    self.panel2 = wx.Panel(id=wxID_FRAME1PANEL2, name='panel2',
          parent=self.panel1, pos=wx.Point(0, 0), size=wx.Size(394, 26),

          style=wx.SIMPLE_BORDER | wx.TAB_TRAVERSAL)
    self.panel2.SetBackgroundColour(wx.Colour(255, 255, 255))

    self.panel3 = wx.Panel(id=wxID_FRAME1PANEL3, name='panel3',
          parent=self.panel1, pos=wx.Point(0, 26), size=wx.Size(394, 429),

          style=wx.TAB_TRAVERSAL)
    self.panel3.SetBackgroundColour(wx.Colour(0, 128, 192))

    self.notebook1 = wx.Notebook(id=wxID_FRAME1NOTEBOOK1, name='notebook1',
          parent=self.panel3, pos=wx.Point(10, 10), size=wx.Size(374, 409),

          style=0)

    self.panel4 = wx.Panel(id=wxID_FRAME1PANEL4, name='panel4',
          parent=self.notebook1, pos=wx.Point(0, 0), size=wx.Size(366, 383),
          style=wx.TAB_TRAVERSAL)

    self.panel5 = wx.Panel(id=wxID_FRAME1PANEL5, name='panel5',
          parent=self.notebook1, pos=wx.Point(0, 0), size=wx.Size(366, 383),
          style=wx.TAB_TRAVERSAL)

    self.panel6 = wx.Panel(id=wxID_FRAME1PANEL6, name='panel6',

          parent=self.notebook1, pos=wx.Point(0, 0), size=wx.Size(366, 383),
          style=wx.TAB_TRAVERSAL)

    self.panel7 = wx.Panel(id=wxID_FRAME1PANEL7, name='panel7',
          parent=self.panel6, pos=wx.Point(0, 0), size=wx.Size(366, 37),

          style=wx.TAB_TRAVERSAL)
    self.panel7.SetBackgroundColour(wx.Colour(0, 128, 128))

    self.panel8 = wx.Panel(id=wxID_FRAME1PANEL8, name='panel8',
          parent=self.panel6, pos=wx.Point(0, 37), size=wx.Size(366, 346),

          style=wx.TAB_TRAVERSAL)
    self.panel8.SetBackgroundColour(wx.Colour(255, 255, 0))

    self.staticText1 = wx.StaticText(id=wxID_FRAME1STATICTEXT1,
          label=u'Some text', name='staticText1', parent=self.panel7,

          pos=wx.Point(5, 5), size=wx.Size(115, 27), style=0)
    self.staticText1.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.NORMAL,
          False, u'Tahoma'))

    self.panel9 = wx.Panel(id=wxID_FRAME1PANEL9, name='panel9',

          parent=self.panel5, pos=wx.Point(0, 0), size=wx.Size(366, 100),
          style=wx.TAB_TRAVERSAL)
    self.panel9.SetBackgroundColour(wx.Colour(255, 128, 255))

    self.textCtrl1 = wx.TextCtrl(id=wxID_FRAME1TEXTCTRL1, name='textCtrl1',

          parent=self.panel5, pos=wx.Point(5, 105), size=wx.Size(356, 92),
          style=0, value='textCtrl1')

    self.panel10 = wx.Panel(id=wxID_FRAME1PANEL10, name='panel10',

          parent=self.panel5, pos=wx.Point(0, 202), size=wx.Size(366, 181),
          style=wx.TAB_TRAVERSAL)
    self.panel10.SetBackgroundColour(wx.Colour(64, 128, 128))

    self.splitterWindow1 = wx.SplitterWindow(id=wxID_FRAME1SPLITTERWINDOW1,

          name='splitterWindow1', parent=self.panel4, pos=wx.Point(0, 0),
          size=wx.Size(366, 383), style=wx.SP_3D)

    self.panel11 = wx.Panel(id=wxID_FRAME1PANEL11, name='panel11',

          parent=self.splitterWindow1, pos=wx.Point(0, 0), size=wx.Size(162,
          383), style=wx.TAB_TRAVERSAL)
    self.panel11.SetBackgroundColour(wx.Colour(0, 0, 255))

    self.panel12 = wx.Panel(id=wxID_FRAME1PANEL12, name='panel12',

          parent=self.splitterWindow1, pos=wx.Point(166, 0),
          size=wx.Size(200, 383), style=wx.TAB_TRAVERSAL)
    self.panel12.SetBackgroundColour(wx.Colour(128, 128, 255))
    self.splitterWindow1.SplitVertically(self.panel11, self.panel12, 162)

    self.panel13 = wx.Panel(id=wxID_FRAME1PANEL13, name='panel13',
          parent=self.notebook1, pos=wx.Point(0, 0), size=wx.Size(366, 383),
          style=wx.TAB_TRAVERSAL)

    self.button1 = wx.Button(id=wxID_FRAME1BUTTON1, label='button1',

          name='button1', parent=self.panel13, pos=wx.Point(0, 0),
          size=wx.Size(75, 23), style=0)

    self.button2 = wx.Button(id=wxID_FRAME1BUTTON2, label='button2',
          name='button2', parent=self.panel13, pos=wx.Point(131, 0),

          size=wx.Size(75, 23), style=0)

    self.button3 = wx.Button(id=wxID_FRAME1BUTTON3, label='button3',
          name='button3', parent=self.panel13, pos=wx.Point(262, 0),
          size=wx.Size(75, 23), style=0)

    self.radioButton1 = wx.RadioButton(id=wxID_FRAME1RADIOBUTTON1,
          label='radioButton1', name='radioButton1', parent=self.panel13,
          pos=wx.Point(0, 23), size=wx.Size(81, 13), style=0)

    self.radioButton2 = wx.RadioButton(id=wxID_FRAME1RADIOBUTTON2,
          label='radioButton2', name='radioButton2', parent=self.panel13,
          pos=wx.Point(131, 23), size=wx.Size(81, 13), style=0)

    self.radioButton3 = wx.RadioButton(id=wxID_FRAME1RADIOBUTTON3,
          label='radioButton3', name='radioButton3', parent=self.panel13,
          pos=wx.Point(262, 23), size=wx.Size(81, 13), style=0)

    self.checkBox1 = wx.CheckBox(id=wxID_FRAME1CHECKBOX1, label='checkBox1',
          name='checkBox1', parent=self.panel13, pos=wx.Point(0, 36),
          size=wx.Size(70, 13), style=0)

    self.checkBox2 = wx.CheckBox(id=wxID_FRAME1CHECKBOX2, label='checkBox2',
          name='checkBox2', parent=self.panel13, pos=wx.Point(131, 36),
          size=wx.Size(70, 13), style=0)

    self.checkBox3 = wx.CheckBox(id=wxID_FRAME1CHECKBOX3, label='checkBox3',
          name='checkBox3', parent=self.panel13, pos=wx.Point(262, 36),
          size=wx.Size(70, 13), style=0)

    self.choice1 = wx.Choice(choices=[], id=wxID_FRAME1CHOICE1,
          name='choice1', parent=self.panel13, pos=wx.Point(0, 49),
          size=wx.Size(130, 21), style=0)

    self.choice2 = wx.Choice(choices=[], id=wxID_FRAME1CHOICE2,

          name='choice2', parent=self.panel13, pos=wx.Point(131, 49),
          size=wx.Size(130, 21), style=0)

    self.staticText2 = wx.StaticText(id=wxID_FRAME1STATICTEXT2,
          label=u'Some blue static text', name='staticText2',

          parent=self.panel2, pos=wx.Point(0, 0), size=wx.Size(197, 25),
          style=0)
    self.staticText2.SetFont(wx.Font(16, wx.SWISS, wx.NORMAL, wx.NORMAL,
          False, u'Tahoma'))

    self.staticText2.SetForegroundColour(wx.Colour(0, 0, 255))

    self._init_coll_notebook1_Pages(self.notebook1)

    self._init_sizers()

def __init__(self, parent):
    self._init_ctrls(parent)

if name == ‘main’:
app = wx.PySimpleApp()
frame = create(None)
frame.Show()

app.MainLoop()

C M <cmpython gmail.com> writes:

[An Example of BOA generated Code snipped]

What I like about this Code :

The frame knows all Controls and sizers by name. So we can write code to hide

or show a certain sizer without knowing its visual position .

This is a good thing IMO.

I don’t think sizers themselves can be hidden or what that would mean if they could. I think of it as you can hide panels or controls, and the sizer will be smart about it and resize the remaining shown controls/panels accordingly, which is great. I definitely like to be able to deal with the controls by object name (“self.panel1”) if I can. In cases where controls are user-generated, then I have used FindWindowByName and that works well.

The code shows the typical weaknesses of builder-generated code : Generic names

of the controls and unnecessary parameters (IDs, pos-parameters and most of the

size parameters).

You can give each new control a name you want from within Boa, and I sometimes do this, particularly for any button, where it is useful to remember what the point of pushing it is. I don’t make use of the IDs, but I just ignore them.

It is very hard to imagine the visual structure of the view from the code.

If by visual structure of the view you mean just how things are laid out, I agree, but this doesn’t bother me in that I can see the structure in the Boa Designer or by running the code (I am not consciously doing things by MVC yet, though I have to learn that eventually, so maybe you mean something else?).

So I think that it is indeed better to organize the code along the visual

structure AND make the controls accesssible to the frame.

Sounds good. Good luck, and I hope others offer more ideas, as it is useful for everyone to see various ways of organizing code.

CM

···

On Sun, Mar 16, 2008 at 9:07 AM, Norbert Klamann Norbert.Klamann@projecthome.de wrote:

Hello,

After fooling around for a few hours with this, I'm getting to the point where I believe the Bind() doesn't allow functions with arguments. Every example I've pulled on the web supports this but so far I haven't found any docs that say this too.

Using lambda functions should do what you want.

self.Bind(wx.EVT_BUTTON, lambda evt: self.OnShow(evt, '7'), id=1)

Ideas?
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Regards,

Cody Precord

···

On Mar 16, 2008, at 12:53 PM, Matt Webster wrote:

Actually, you can hide/show the contents of sizers by calling
Hide()/Show() on the sizer. After doing so, use Layout() on the
parent sizer to re-layout the page.

···

At 11:01 AM 3/16/2008, you wrote:

On Sun, Mar 16, 2008 at 9:07 AM, > Norbert Klamann > Norbert.Klamann@projecthome.de > wrote:

C M <cmpython
gmail.com> writes:

[An Example of BOA generated Code snipped]

What I like about this Code :

The frame knows all Controls and sizers by name. So we can write code to
hide

or show a certain sizer without knowing its visual position .

This is a good thing IMO.

I don’t think sizers themselves can be hidden or what that would mean if
they could. [snip…]

thanks Peter,

I'll take a look at that.

cheers,
Stef

Peter Damoc wrote:

Actually there is a library that does something like this:

Google Code Archive - Long-term storage for Google Code Project Hosting.

When dealing with code complexity I try to think about 2 things:
1. How can I turn this into an API
2. How can I turn this into Ravioli

I fail miserably most of the time... but when I succeed is rather nice.

Peter.

    Mark Erbaugh wrote:
    >
    >> Hello List,
    >> i build a mildly complex wxPython App for the presentation of
    Loans. The
    >> application has the following structure
    >>
    >> Frame
    >> +- ButtonPanel
    >> +- Menu
    >> +- Splitterwindow
    >> +- leftpanel
    >> > several Input Controls with labels
    >> +- rightpanel
    >> +- Notebook
    >> +- overviewpanel
    >> > several Output Controls and labels
    >> +- gridpanel
    >> > grid with numbers
    >> +- plotpanel
    >> matplotlib plot
    >> +- errorpanel
    >> several texts. This panel is visikle
    >> instead of the Notebook if something goes wrong
    >>
    >> The whole thing works in principle but the code is a mess.
    A mess ....
    ... your "code" above is really beautiful !!!
    Coming from Delphi,
    I can't imagine that no one has already made a routine
    to convert the above code into real working Python code.
    (As soon as I really understand sizers, I think I'll do it)

    cheers,
    Stef

    ---------------------------------------------------------------------
    To unsubscribe, e-mail:
    wxPython-users-unsubscribe@lists.wxwidgets.org
    <mailto:wxPython-users-unsubscribe@lists.wxwidgets.org>
    For additional commands, e-mail:
    wxPython-users-help@lists.wxwidgets.org
    <mailto:wxPython-users-help@lists.wxwidgets.org>

--
There is NO FATE, we are the creators.

Het UMC St Radboud staat geregistreerd bij de Kamer van Koophandel in het handelsregister onder nummer 41055629.
The Radboud University Nijmegen Medical Centre is listed in the Commercial Register of the Chamber of Commerce under file number 41055629.

···

On Sun, Mar 16, 2008 at 7:30 PM, Stef Mientki <s.mientki@ru.nl > <mailto:s.mientki@ru.nl>> wrote:
    > On Sat, 2008-03-15 at 15:08 +0000, Norbert Klamann wrote:

Cody Precord wrote:

Hello,

After fooling around for a few hours with this, I'm getting to the point where I believe the Bind() doesn't allow functions with arguments. Every example I've pulled on the web supports this but so far I haven't found any docs that say this too.

Using lambda functions should do what you want.

self.Bind(wx.EVT_BUTTON, lambda evt: self.OnShow(evt, '7'), id=1)

Also take a look at the recipes in the Python Cookbook for "curry" such as http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52549

···

On Mar 16, 2008, at 12:53 PM, Matt Webster wrote:

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hi Stef,

I would advise caution about redesigning. Redesign is NEVER as easy as it looks. NEVER!

as for self overdose… it is a double edge sword. I understand the benefits of explicitness but I also like to be able to define context.
This is what wxpita does IMHO. You provide the names for the components and it uses the context to mount the objects.

Good luck.

Peter

···

On Tue, Mar 18, 2008 at 3:57 PM, Stef Mientki s.mientki@ru.nl wrote:

hi Peter,

Peter Damoc wrote:

From what I’ve understood from Feihong (wxpita creator) the code is

in for a redesign.

It does the job even now BUT its usability depends on how you are used

to program.

Right now is geared towards quick scripting.

After doing just a few forms with my scripting,

I’m so enthusiast that I’m going to do all my new forms with it,

and translate every old form when I touch it.

So it will finally satisfy all my needs.

The part where you didn’t understood it is normal. You have to first

understand the problem its trying to solve.

For me the lights turned on when I saw how little “self”

I don’t think this is a blessing,

when I started Python about a year ago,

I tried to avoid self as much as possible,

tried to create the “with” clause from Delphi,

used for a while “s” instead of self,

but finally got back to self, and now I think it’s a good thing.

and sizer stuff was in the code. :slight_smile:

My implementation even doesn’t allow sizers :wink:

I’m saturated on “self”.

Then just don’t write object oriented programs :wink:

Peter

cheers,

Stef

Het UMC St Radboud staat geregistreerd bij de Kamer van Koophandel in het handelsregister onder nummer 41055629.

The Radboud University Nijmegen Medical Centre is listed in the Commercial Register of the Chamber of Commerce under file number 41055629.


To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org

For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org


There is NO FATE, we are the creators.