def __init__(self, parent=None, **args): Frame.__init__(self, parent, args) self.pack() self.tools() Label(self, text="Check demos").pack() self.vars = [] for key in demos.keys(): var = IntVar() Checkbutton(self, text=key, variable=var, command=demos[key]).pack(side=LEFT) self.vars.append(var)
def __init__(self, parent=None, **args): Frame.__init__(self, parent, args) self.pack( ) self.tools( ) Label(self, text="Check demos").pack( ) self.vars = [] for key in demos.keys( ): var = IntVar( ) Checkbutton(self, text=key, variable=var, command=demos[key]).pack(side=LEFT) self.vars.append(var)
Scale(self, label='Pick demo numbe', command=self.onMove, variable=self.var, from_=0, to=len(demos) - 1, length=200, tickinterval=1, showvalue=YES, orient='horizontal').pack() Quitter(self).pack(side=RIGHT) Button(self, text="Run demo", command=self.onRun).pack(side=LEFT) Button(self, text="State", command=self.report).pack(side=RIGHT) def onMove(self, value): print('in onMove', value) def onRun(self): pos = self.var.get() print('You picked', pos) demo = list(demos.values())[pos] print(demo()) def report(self): print(self.var.get()) if __name__ == '__main__': print(list(demos.keys())) Demo().mainloop()
self.var = IntVar() Scale(self, label='Pick demo number', command=self.onMove, # catch moves variable=self.var, # reflects position from_=0, to=len(demos)-1).pack() Scale(self, label='Pick demo number', command=self.onMove, # catch moves variable=self.var, # reflects position from_=0, to=len(demos)-1, length=200, tickinterval=1, showvalue=YES, orient='horizontal').pack() Quitter(self).pack(side=RIGHT) Button(self, text="Run demo", command=self.onRun).pack(side=LEFT) Button(self, text="State", command=self.report).pack(side=RIGHT) def onMove(self, value): print('in onMove', value) def onRun(self): pos = self.var.get() print('You picked', pos) demo = list(demos.values())[pos] # map from position to value (3.X view) print(demo()) # or demos[ list(demos.keys())[pos] ]() def report(self): print(self.var.get()) if __name__ == '__main__': print(list(demos.keys())) Demo().mainloop()
def onRun(self): pos = self.var.get() print "You picked", pos pick = demos.keys()[pos] # map from position to key print demos[pick]()
label="Pick demo number", command=self.onMove, # catch moves variable=self.var, # reflects position from_=0, to=len(demos) - 1, length=200, tickinterval=1, showvalue=YES, orient="horizontal", ).pack() Quitter(self).pack(side=RIGHT) Button(self, text="Run Demo", command=self.onRun).pack(side=LEFT) Button(self, text="State", command=self.report).pack(side=RIGHT) def onMove(self, value): print "in onMove", value def onRun(self): pos = self.var.get() print "You picked", pos pick = demos.keys()[pos] # map from position to key print demos[pick]() def report(self): print self.var.get() if __name__ == "__main__": print demos.keys() Demo().mainloop()
def onRun(self): pos = self.var.get() print 'You picked', pos pick = demos.keys()[pos] # map from position to key print demos[pick]()
self, label='Pick demo number', command=self.onMove, # catch moves variable=self.var, # reflects position from_=0, to=len(demos) - 1, length=200, tickinterval=1, showvalue=YES, orient='horizontal').pack() Quitter(self).pack(side=RIGHT) Button(self, text="Run demo", command=self.onRun).pack(side=LEFT) Button(self, text="State", command=self.report).pack(side=RIGHT) def onMove(self, value): print 'in onMove', value def onRun(self): pos = self.var.get() print 'You picked', pos pick = demos.keys()[pos] # map from position to key print demos[pick]() def report(self): print self.var.get() if __name__ == '__main__': print demos.keys() Demo().mainloop()