Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > 7b973fb3c8298f606d9b435aff551ab6 > files > 2826

python2-twisted-19.2.1-1.1.mga7.armv7hl.rpm

#!/usr/bin/env python

# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.


"""
An example of using Twisted with Tkinter.
Displays a frame with buttons that responds to mouse clicks.

Run this example by typing in:
 python tkinterdemo.py
"""


from __future__ import print_function

import sys

if sys.version_info >= (3,):
    from tkinter import Tk, Frame, Button, LEFT
else:
    from Tkinter import Tk, Frame, Button, LEFT
from twisted.internet import reactor, tksupport


class App(object):

    def onQuit(self):
        print("Quit!")
        reactor.stop()

    def onButton(self):
        print("Hello!")

    def __init__(self, master):
        frame = Frame(master)
        frame.pack()

        q = Button(frame, text="Quit!", command=self.onQuit)
        b = Button(frame, text="Hello!", command=self.onButton)

        q.pack(side=LEFT)
        b.pack(side=LEFT)


if __name__ == '__main__':
    root = Tk()
    tksupport.install(root)
    app = App(root)
    reactor.run()