コード例 #1
0
 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)
コード例 #2
0
 def __init__(self, parent=None):
     Frame.__init__(self, parent)
     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)
コード例 #3
0
 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'))
コード例 #4
0
 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)  # select last to start
     Button(self, text='State', command=self.report).pack(fill=X)
     Quitter(self).pack(fill=X)
コード例 #5
0
 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)
コード例 #6
0
 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)
コード例 #7
0
from tkinter import *
from Gui.Tour.quitter import Quitter


def fetch():
    print('Input => “%s”' % ent.get())
    # ent.delete('0', END)


root = Tk()
ent = Entry(root, show='*')  # от меня: отображать все символы звездочкой (полезно для паролей)
ent.insert(0, 'Type words here')
ent.pack(side=TOP, fill=X)

ent.focus()

ent.bind('<Return>', (lambda event: fetch()))
ent.bind('<Button-1>',
         (lambda event: ent.delete('0', END)))  # от меня: очищать поле при клике мышкой, чтоб руками не удалять
btn = Button(root, text='Fetch', command=fetch)
btn.pack(side=LEFT)
Quitter(root).pack(side=RIGHT)
root.mainloop()
コード例 #8
0
from tkinter import *
from tkinter.colorchooser import askcolor
from Gui.Tour.quitter import Quitter


def setBgColor():
    (triple, hexstr) = askcolor()
    if hexstr:
        print(hexstr)
        push.config(bg=hexstr)


root = Tk()
push = Button(root, text='Set Background Color', command=setBgColor)
push.config(height=3, font=('times', 20, 'bold'))
push.pack(expand=YES, fill=BOTH)
q = Quitter(root)
q.pack(side=TOP, expand=YES, fill=BOTH)
root.mainloop()
コード例 #9
0
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)  # или передать параметры конструктору Demo()
        part.pack(side=LEFT, expand=YES, fill=BOTH)
        parts.append(part)


def dumpState():
    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=dumpState).pack(fill=X)
Quitter(root).pack(fill=X)
addComponents(root)
root.mainloop()