def __init__(self, parent=None, **options): Frame.__init__(self, parent, **options) self.pack() Label(self, text='Scale demos').pack() self.var = IntVar() Scale(self, label='Pick demo number', command=self.onMove, variable=self.var, from_=0, to=len(demos) - 1).pack() Scale(self, label='Pick demo number', 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 __init__(self, parent=None, **options): Frame.__init__(self, parent, **options) self.pack() Label(self, text='Basic demos').pack() for (key, value) in demos.items(): Button(self, text=key, command=value).pack(side=TOP, fill=BOTH) Quitter(self).pack(side=TOP, fill=BOTH)
def __init__(self, parent=None, **options): Frame.__init__(self, parent, **options) self.pack() Label(self, text='Basic demos').pack() for key in demos: func = (lambda key=key: self.printit(key)) Button(self, text=key, command=func).pack(side=TOP, fill=BOTH) Quitter(self).pack(side=TOP, fill=BOTH)
def __init__(self, parent=None, file=None): frm = Frame(parent) frm.pack(fill=X) Button(frm, text='Save', command=self.onSave).pack(side=LEFT) Button(frm, text='Cut', command=self.onCut).pack(side=LEFT) Button(frm, text='Paste', command=self.onPaste).pack(side=LEFT) Button(frm, text='Find', command=self.onFind).pack(side=LEFT) Quitter(frm).pack(side=LEFT) ScrolledText.__init__(self, parent, file=file) self.text.config(font=('courier', 9, 'normal'))
def __init__(self, parent=None, **options): Frame.__init__(self, parent, **options) self.pack() Label(self, text='Radio demos').pack(side=TOP) self.var = StringVar() for key in demos: Radiobutton(self, text=key, command=self.onPress, variable=self.var, value=key).pack(anchor=NW) self.var.set(key) # при запуске выбрать последний переключатель Button(self, text='State', command=self.report).pack(fill=X) Quitter(self).pack(fill=X)
def __init__(self, parent=None, picks=[], side=LEFT, anchor=W): Frame.__init__(self, parent) self.var = StringVar() self.var.set(picks[0]) for pick in picks: rad = Radiobutton(self, text=pick, value=pick, variable=self.var) rad.pack(side=side, anchor=anchor, expand=YES) def state(self): return self.var.get() if __name__ == '__main__': root = Tk() lng = Checkbar(root, ['Python', 'C#', 'Java', 'C++']) gui = Radiobar(root, ['win', 'x11', 'mac'], side=TOP, anchor=NW) tgl = Checkbar(root, ['All']) gui.pack(side=LEFT, fill=Y) lng.pack(side=TOP, fill=X) tgl.pack(side=LEFT) lng.config(relief=GROOVE, bd=2) gui.config(relief=RIDGE, bd=2) def all_states(): print(gui.state(), lng.state(), tgl.state()) from GUI.gui.quitter import Quitter Quitter(root).pack(side=RIGHT) Button(root, text='Peek', command=all_states).pack(side=RIGHT) root.mainloop()
def tools(self): frm = Frame(self) frm.pack(side=RIGHT) Button(frm, text='State', command=self.report).pack(fill=X) Quitter(frm).pack(fill=X)
demoModules = ['demoDlg', 'demoCheck', 'demoRadio', 'demoScale'] parts = [] def addComponents(root): for demo in demoModules: module = __import__(demo) part = module.Demo(root) part.config(bd=2, relief=GROOVE) part.pack(side=LEFT, expand=YES, fill=BOTH) parts.append(part) def dumpSate(): for part in parts: print(part.__module__ + ':', end=' ') if hasattr(part, 'report'): part.report() else: print('none') root = Tk() root.title('Frames') Label(root, text='Multiple Frame demo', bg='white').pack() Button(root, text='States', command=dumpSate).pack(fill=X) Quitter(root).pack(fill=X, pady=4) addComponents(root) root.mainloop()