Title: Signature.html
The program I'm modifying uses Tkinter widgets and passes values between a non-Tkinter (OperationalSettings class) object and an object of class OperationalSettingsDialog(tkSimpleDialog.Dialog).  The former saves changed dialog values in the main program, Sentuser_GUI (main loop), via (global) self variables, which are initially set by Sentuser_GUI. The latter object just manages the GUI and communicates changed values.  Control variables are used and they are hard-coded into assignment statements. I'm trying to remove the hard-coding, and allow assignment to the GUI self variables, while maintaining types.

>From Sentuser_GUI,
=============Sentuser==========
        self.settingsMenu = Menu(menu)
        menu.add_cascade(label="Settings",menu=self.settingsMenu)
        self.settingsMenu.add_command(label="Schedule, Site, and Operation...",        command=self.OperationalSettings)
            ...

===========End Sentuser=========
sets up a top level menu for the dialog and menu item settingsMenu, which is a dialog.

>From OperationalSettings,
==============Op Settings========
    def OperationalSettings(self):
        print "OSett self = ", self, "type =", type(self)
        print
        set_loc_dict = {}
        set_loc_dict[ "ok" ] = False
        set_loc_dict[ "color" ] = 2
        if self.gray_scale:
            set_loc_dict[ "color"] = 1
        set_loc_dict[ "hourly_rate" ] = self.hourly_rate
        s
et_loc_dict["start_time"] = self.start_time
             ...
        dialog = OperationalSettingsDialog( self.master, set_loc_dict )
             ...
        if dialog.colorVar.get() == 1:
            self.gray_scale = True
        else:
            self.gray_scale = False
             ...
===========End Op Settings========

Part of OperationalSettingsDialog is shown below.

The self.gray_scale coding example is hard-code that needs to be replaced to allow the type to remain the same for (configuration) names like gray_scale to be pulled from a list, and yet make an assignment as boolean or whatever type is associated with the name. There are 20+ names. The True (boolean notion) is really only available from dialog.colorVar.get(), so how can I set self.gray_scale to a boolean value?  I don't see how setattr will help here. The name list does show the type corresponding to the name, but it seems of no real value.



OperationalSettingsDialog uses control variables, as in,
=================Op Settings Dialog================
class OperationalSettingsDialog(tkSimpleDialog.Dialog):

    def __init__(self, parent, sdict):
        self.sdict = sdict
        tkSimpleDialog.Dialog.__init__(self, parent)
       
    def body(self,master):
        self.title("Operational Settings")
        self.colorVar = IntVar()
        Radiobutton( master, text="Gray Scale",
                     value=1, variable=self.colorVar).grid(row=0, sticky=W)
                   ...
=============End Settings Dialog========

--
           Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

             (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)
            

                In mathematics you don't understand things. 
                 You just get used to them.” -- John Von Neumann
                    (P.S. The same is true in life.)

                    Web Page: <www.speckledwithstars.net/>
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to