Start på Pass 3
This commit is contained in:
22
Pass 3/gui_example1.py
Executable file
22
Pass 3/gui_example1.py
Executable file
@@ -0,0 +1,22 @@
|
||||
from tkinter import Tk, Label, Button
|
||||
|
||||
class MyFirstGUI:
|
||||
def __init__(self, master):
|
||||
self.master = master
|
||||
master.title("A simple GUI")
|
||||
|
||||
self.label = Label(master, text="This is our first GUI!")
|
||||
self.label.pack()
|
||||
|
||||
self.greet_button = Button(master, text="Greet", command=self.greet)
|
||||
self.greet_button.pack()
|
||||
|
||||
self.close_button = Button(master, text="Close", command=master.quit)
|
||||
self.close_button.pack()
|
||||
|
||||
def greet(self):
|
||||
print("Greetings!")
|
||||
|
||||
root = Tk()
|
||||
my_gui = MyFirstGUI(root)
|
||||
root.mainloop()
|
||||
Reference in New Issue
Block a user