Skip to content

Commit

Permalink
update tk class
Browse files Browse the repository at this point in the history
  • Loading branch information
purpleflameangle committed Jun 4, 2019
1 parent f957f66 commit ec87f47
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions venv/pythonlearn/tkinter/guione.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import tkinter as tk



# 创建一个主窗口,用于容纳整个gui程序
root = tk.Tk()
# 设置主窗口对象的标题栏
Expand All @@ -15,4 +14,27 @@
Label.pack()
# 注意,这时候窗体还是不会显示的
# 除非执行下面这条代码
Label.mainloop()
Label.mainloop()


root = tk.Tk()
root.title("hello world")
label = tk.Label(root, text="this is label:hell world")
label.pack()
label.mainloop()


class App:
def __init__(self, root):
frame = tk.Frame(root)
frame.pack()
self.hi_there = tk.Button(frame, text="hello world", fg=self.say_hi())
self.hi_there.pack(side=tk.LEFT)

def say_hi(self):
print("hello world")


root = tk.Tk()
app = App(root)
root.mainloop()

0 comments on commit ec87f47

Please sign in to comment.