Beispiel #1
0
def _selftest():
    from Tkinter import Button, mainloop

    # mixin usage
    class content:
        "same code used as a Tk, Toplevel, and Frame"

        def __init__(self):
            Button(self, text='Larch', command=self.quit).pack()
            Button(self, text='Sing ', command=self.destroy).pack()

    class contentmix(MainWindow, content):
        def __init__(self):
            MainWindow.__init__(self, 'mixin', 'Main')
            content.__init__(self)

    contentmix()

    class contentmix(PopupWindow, content):
        def __init__(self):
            PopupWindow.__init__(self, 'mixin', 'Popup')
            content.__init__(self)

    prev = contentmix()

    class contentmix(ComponentWindow, content):
        def __init__(self):  # nested frame
            ComponentWindow.__init__(self, prev)  # on prior window
            content.__init__(self)  # Sing erases frame

    contentmix()

    # subclass usage
    class contentsub(PopupWindow):
        def __init__(self):
            PopupWindow.__init__(self, 'popup', 'subclass')
            Button(self, text='Pine', command=self.quit).pack()
            Button(self, text='Sing', command=self.destroy).pack()

    contentsub()

    # non-class usage
    win = PopupWindow('popup', 'attachment')
    Button(win, text='Redwood', command=win.quit).pack()
    Button(win, text='Sing   ', command=win.destroy).pack()
    mainloop()
Beispiel #2
0
def _selftest():
    # использовать как подмешиваемый класс
    class content:
        "используется так же, как Tk, Toplevel, Frame"

        def __init__(self):
            Button(self, text='Larch', command=self.quit).pack()
            Button(self, text='Sing', command=self.destroy).pack()

    class contentmix(MainWindow, content):
        def __init__(self):
            MainWindow.__init__(self, 'mixin', 'Main')
            content.__init__(self)

    contentmix()

    class contentmix(PopupWindow, content):
        def __init__(self):
            PopupWindow.__init__(self, 'mixin', 'Popup')
            content.__init__(self)

    prev = contentmix()

    class contentmix(ComponentWindow, content):
        def __init__(self):
            ComponentWindow.__init__(self, prev)
            content.__init__(self)

    contentmix()

    # использовать в подклассах
    class contentsub(PopupWindow):
        def __init__(self):
            PopupWindow.__init__(self, 'popup', 'subclass')
            Button(self, text='Pine', command=self.quit).pack()
            Button(self, text='Sing', command=self.destroy).pack()

    contentsub()

    # использование в процедурном программном коде
    win = PopupWindow('popup', 'attachment')
    Button(win, text='Redwood', command=win.quit).pack()
    Button(win, text='Sing   ', command=win.destroy).pack()
    mainloop()
Beispiel #3
0
def _selftest():
    # 使用mixin
    class content:
        "same code used as a Tk, Toplevel, and Frame"

        def __init__(self):
            Button(self, text='Larch', command=self.quit).pack()
            Button(self, text='Sing', command=self.destroy).pack()

    class contentmix(MainWindow, content):
        def __init__(self):
            MainWindow.__init__(self, 'mixin', 'Main')
            content.__init__(self)

    contentmix()

    class contentmix(PopupWindow, content):
        def __init__(self):
            PopupWindow.__init__(self, 'mixin', 'Popup')
            content.__init__(self)

    prev = contentmix()

    class contentmix(ComponentWindow, content):
        def __init__(self):  # 嵌套框架
            ComponentWindow.__init__(self, prev)  # 在前一个Sing窗口
            content.__init__(self)  # 擦除了框架

    contentmix()

    # 使用子类
    class contentsub(PopupWindow):
        def __init__(self):
            PopupWindow.__init__(self, 'popup', 'subclass', 'fish2.ico')
            Button(self, text='Pine', command=self.quit).pack()
            Button(self, text='Sing', command=self.destroy).pack()

    contentsub()

    # 不使用类
    win = PopupWindow('popup', 'attachment')
    Button(win, text='Redwood', command=win.quit).pack()
    Button(win, text='Sing', command=win.destroy).pack()
    mainloop()
Beispiel #4
0
def _selftest():
    #mixin usage

    class content:
        def __init__(self):
            Button(self, text='Larch', command=self.quit).pack()
            Button(self, text='Sing', command=self.destroy).pack()

    class contentmix(MainWindow, content):
        def __init__(self):
            MainWindow.__init__(self, 'Mixin', 'Main')
            content.__init__(self)

    contentmix()

    class contentmix(PopupWindow, content):
        def __init__(self):
            PopupWindow.__init__(self, 'Mixin', 'Main')
            content.__init__(self)

    prev = contentmix()

    class contentmix(ComponentWindow, content):
        def __init__(self):
            ComponentWindow.__init__(self, 'Mixin', 'Main')
            content.__init__(self)

    contentmix()

    class contentsub(PopupWindow, content):
        def __init__(self):
            PopupWindow.__init__(self, 'Popup', 'subclass')
            content.__init__(self)

    contentsub()

    #non-class usage
    win = PopupWindow()
    Button(win, text='Redwood', command=win.quit).pack()
    Button(win, text='Sing', command=win.destroy).pack()
    mainloop()
Beispiel #5
0
def _selftest():
    class content:
        def __init__(self):
            Button(self, text='Larch', command=self.quit).pack()
            Button(self, text='Sing', command=self.destroy).pack()

    class contentmix(MainWindow, content):
        def __init__(self):
            MainWindow.__init__(self, 'mixin', 'Main')
            content.__init__(self)

    contentmix()

    class contentmix(PopupWindow, content):
        def __init__(self):
            PopupWindow.__init__(self, 'mixin', 'Main')
            content.__init__(self)

    prev = contentmix()

    class contentmix(ComponentWindow, content):
        def __init__(self):
            ComponentWindow.__init__(self, prev)
            content.__init__(self)

    contentmix()

    class contentsub(PopupWindow):
        def __init__(self):
            PopupWindow.__init__(self, 'popup', 'subclass')

            Button(self, text='Pine', command=self.quit).pack()
            Button(self, text='Sing', command=self.destroy).pack()

    contentsub()

    win = PopupWindow('popup', 'attachment')
    Button(win, text='Redwood', command=win.quit).pack()
    Button(win, text='Sing ', command=win.destroy).pack()
    mainloop()
 def __init__(self):
     PopupWindow.__init__(self, 'popup', 'subclass')
     Button(self, text='Pine', command=self.quit).pack()
     Button(self, text='Sing', command=self.destroy).pack()
 def __init__(self):
     PopupWindow.__init__(self, 'mixin', 'Popup')
     content.__init__(self)
Beispiel #8
0
 def __init__(self):
     PopupWindow.__init__(self, 'popup', 'subclass')
     Button(self, text='Pine', command=self.quit).pack()
     Button(self, text='Sing', command=self.destroy).pack()
Beispiel #9
0
 def __init__(self):
     PopupWindow.__init__(self, 'mixin', 'Popup')
     content.__init__(self)
Beispiel #10
0
 def __init__(self):
     PopupWindow.__init__(self, 'Popup', 'subclass')
     content.__init__(self)
Beispiel #11
0
 def __init__(self):
     PopupWindow.__init__(self, 'Mixin', 'Main')
     content.__init__(self)
Beispiel #12
0
 def __init__(self, config=ClockConfig, name=''):
     PopupWindow.__init__(self, appname, name)
     clock = Clock(config, self)
     clock.pack(expand=YES, fill=BOTH)