Python tkinter学习笔记

Python窗口程序可以选择PyQt,也可以选择tkinter、wxPython、Traits,要求高的话推荐PyQt吧,很强大
import tkinter as tk

count = 123

window = tk.Tk()
window.title('title')
window.geometry('500x400')

label1 = tk.Label(window, 
    text='this is a label',  
    bg='green',   
    font=('Arial', 16),    
    width=15, height=2  
    )
label1.pack()  

var = tk.StringVar()
label2 = tk.Label(window, 
    textvariable=var,  
    bg='red', font=('Arial', 16), width=15, height=2)
label2.pack() 

var.set(count)

def button1_pressed():
    global count
    count += 1
    var.set(count)

button1 = tk.Button(window, 
    text='button1',     
    width=15, height=2, 
    command=button1_pressed)     #
button1.pack()

window.mainloop()


发表于:2017-10-25 10:28:33

原文链接(转载请保留): http://www.multisilicon.com/blog/a23272837.html

友情链接: MICROIC
首页