Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #gui.py
- import time
- import tkinter
- class GUI(object):
- #GUI.create()
- #loads interface
- def create (self, parent):
- #remember the root
- self.window = parent
- #simplify tkinter variables
- left = tkinter.LEFT
- right = tkinter.RIGHT
- self.container = tkinter.Frame(parent)
- self.button1 = tkinter.Button(self.container)
- #self.button2 = tkinter.Button(self.container)
- self.button1["text"]= "Hello, World!"
- self.button1["background"]= "white"
- self.button1.bind("<Button-1>", self.button1Click)
- self.button1.bind("<ButtonRelease-1>", self.button1Release)
- #self.button2["text"]= "Hello, World2!"
- #self.button2["background"]= "white"
- self.container.pack()
- self.button1.pack(side = left)
- #self.button2.pack(side = left)
- print("Window created")
- def run (self, parent):
- #mainloop
- parent.mainloop()
- #on window close
- print("WIndows closed!")
- time.sleep(1)
- def button1Click(self, event):
- self.button1["text"] = "Click!"
- def button1Release(self, event):
- self.button1["text"] = "Hello, World!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement