What I am trying to do is call a class function from a menu, for example

                displaySubMenu.add_radiobutton(label="Medium", 
                variable=radarPanelSize, command=radarWidgets.refresh) 

class radarWidgets:
        def __init__(self,root):
                self.window = root
        def refresh(self):
                global radar
                global refreshTimer
                self.refreshTimer.cancel()
                logging.debug("handlesRadarRefreshByTimer()")
                #
                # destroy the existing frame the radar is in
                #
                self.w.destroy()
                self.lblLastUpdate.destroy()
                self.btnRefresh.destroy()
                #
                # rebuild the radarWidgets
                #
                self.createImage()
                self.refreshTimer = threading.Timer( 900, self.refresh)
                self.refreshTimer.start()

This doesn't work because the instance of radarWidgets was defined in a 
different class ......

class mainDisplay:
        def __init__(self,root):
                self.window = root
        def show(self):         
                #
                # Configure the base frame
                # 
                base=Frame(self.window,bg=backColor,width=1200, height=800)
                base.grid()
                frameRadar = Frame(base, bd=0, bg=backColor)
                frameRadar.grid(row=2,column=1,sticky=N+E+S+W)
                #
                radar = radarWidgets(frameRadar)
                radar.show()

so the actual instance is called "radar".  If I put the instance name in the 
menu item, I get an error that "radar" is unknown.  If I use 
RadarWidgets.refresh ins the command for the menu, I get the error:

TypeError: unbound method refresh() must be called with radarWidgets instance 
as first argument (got nothing instead)

Any ideas?

Thanks!



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to