[wxPython-users] Many Similar Dialogs For Date Entry

Rich Shepard rshepard at appl-ecosys.com
Mon Feb 5 16:52:44 PST 2007


On Fri, 2 Feb 2007, Chris Mellon wrote:

> Python with dictionary:
>
> def processID(id):
> mapper = {
>   SWITCH_ONE:process_one,
>   SWITCH_TWO:process_two
> }
> mapper[id]()

   I have not properly implemented the syntax for selecting the appropriate
dialog box, based on the curve shape selected in the radio box. The result
is nothing: no error thrown by python, no dialog box display, no idea where
I am in the code. I've put in print statements and run the application using
_winpdb.py.

   When I press the "Add" button, it just sits there and looks back at me.
I'm rather stymied since I cannot get output to learn just where I am in the
code.

   Here is the revised dictionary in the method, and one of the functions
that I'm trying to call via data entry:

   def OnFzySetAdd(self, event):
     self.name = self.fzySet.GetValue()
     self.parent = self.parVar.GetValue()
     self.shape = self.fzySetType.GetStringSelection()
     print self.shape, '\n'

     # dictionary as a switch statement:
     switch = {'Linear Increasing': linup,
               'Linear Decreasing': lindwn,
 		# ...
               'Rectangle': rect}
     if self.shape in switch:
       switch[self.shape]()

   def linup():
     self.dir = 'increasing'
     newLup = lineUpDlg()
     result = newLup.ShowModal()
     if result == wx.ID_OK:
       self.fzySetList.Append(name)
       stmt1 = """insert into fuzzyset (name, parent, shape, left_edge,
                                        right_edge, direction) values
                                        (?,?,?,?,?,?)"""
       self.appData.cur.execute(stmt1,(self.name, self.parent, self.shape, float(self.left),
                                       float(self.right), self.dir))
     newLup.Destroy()

Rich

-- 
Richard B. Shepard, Ph.D.               |    The Environmental Permitting
Applied Ecosystem Services, Inc.        |          Accelerator(TM)
<http://www.appl-ecosys.com>     Voice: 503-667-4517      Fax: 503-667-8863




More information about the wxpython-users mailing list