python GUI - tkinter 01
Posted pythoncoder
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python GUI - tkinter 01相关的知识,希望对你有一定的参考价值。
#!/usr/bin/python3 import tkinter as tk window = tk.Tk() window.title(\'yyyyy\') window.geometry("200x100") var = tk.StringVar() # l = tk.Label(window, text=\'OMG! this is TK\', bg=\'green\', font=(\'Arial\', 12), width=15, height=2) l = tk.Label(window, textvariable=var, bg=\'green\', font=(\'Arial\', 12), width=15, height=2) l.pack() on_hit = False def hit_me(): global on_hit if(on_hit) == False: on_hit = True var.set(\'you hit me\') else: on_hit = False var.set(\'\') b = tk.Button(window, text=\'click me\', width=15, height=2, command=hit_me) b.pack() window.mainloop()
以上是关于python GUI - tkinter 01的主要内容,如果未能解决你的问题,请参考以下文章
如何成功抽象以下代码行? (Python Tkinter GUI)
Python GUI | 利用Tkinter制作签名设计软件!
Python tkinter(GUI编程)模块最完整讲解(上)