[Python-talk] Pickling Question

Ric Werme ewerme at comcast.net
Sat Jul 18 10:15:33 EDT 2009


> I don't know about being off the track yet...

You're way off track!

I haven't weighed in because I haven't done any wxpython stuff in over
a year, and because I don't have sample code with radio box widgets.
Your wxpython distribution may include my roses program and there's
stuff in there that you can use almost directly.

Oh, duh - all that code is at http://wermenh.com/roses/index.html

clroses.py is a non-wxpython knowledgeable class that is called by
a wxpython (wxroses.py) or TK driver.

I do have SpinCtrl widgets that have values, so close enough.  When they
change, wxroses code executes:

    # Called when user changes the SpinCtrl value.
    def OnSpin(self, event):
        name = self.st.GetLabel()
        value = self.sc.GetValue()
        if verbose:
            print 'OnSpin', name, '=', value
        self.callback(name, value)	# Call MyFrame.OnSpinback to call clroses

and that calls:

    # Called when data in spin boxes changes.
    def OnSpinback(self, name, value):
        if verbose:
            print 'OnSpinback', name, value
        if name == 'Style':
            self.SetStyle(value)
        elif name == 'Sincr':
            self.SetSincr(value)
        elif name == 'Petal':
            self.SetPetals(value)
...

not very elegant, but easy to follow.

Those set methods are in the roses class (clroses.py), e.g.:

    # NW control window - key parameters
    def SetStyle(self, value):
        self.style = value % self.nvec
        self.restart()

So, all in all, I have a program that keeps its internal state up to date
as events happen.  When events occur, I can print diagnostic info, so
that makes debugging easier, or act on the data immediately if I care to,
e.g. the restart() method.

One goal I had with the roses hack was to create a simple enough to
follow program that uses a representative subset of wx widgets that
its framework could be used a lot of other programs.  Consider writing
a new program with using the 5-10% of my code that's useful to you and
you ought to be able to add radio boxes and whatnot pretty easily.

  -Ric




More information about the Python-talk mailing list