Python: simple tkinter script added
This commit is contained in:
27
Programming/Python/files/test_tkinter
Executable file
27
Programming/Python/files/test_tkinter
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info >= (3,6):
|
||||
from tkinter import *
|
||||
else:
|
||||
from Tkinter import *
|
||||
|
||||
class App:
|
||||
def __init__(self, master):
|
||||
frame = Frame(master)
|
||||
frame.pack()
|
||||
self.button = Button(frame,
|
||||
text="QUIT",
|
||||
command=frame.quit)
|
||||
self.button.pack(side=LEFT)
|
||||
self.slogan = Button(frame,
|
||||
text="Hello",
|
||||
command=self.write_slogan)
|
||||
self.slogan.pack(side=LEFT)
|
||||
def write_slogan(self):
|
||||
print ("Tkinter is easy to use!")
|
||||
|
||||
root = Tk()
|
||||
app = App(root)
|
||||
root.mainloop()
|
||||
Reference in New Issue
Block a user