首页 > 编程语言 > 详细

python GUI - tkinter 01

时间:2020-03-22 11:01:45      阅读:61      评论:0      收藏:0      [点我收藏+]

技术分享图片

 

#!/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

原文:https://www.cnblogs.com/ilovecpp/p/12544161.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!