import tkinter as tk
window = tk.Tk()
window.title('GUI test')
window.geometry('500x400')
# 内容
lable1 = tk.Label(window,text = 'input',
bg = 'pink',
width=15, height=2)
lable1.place(x = 70, y = 100, anchor='nw')
lable2 = tk.Label(window,text = 'output',
bg = 'pink',
width=15, height=2)
lable2.place(x = 70, y = 200, anchor='nw')
data = tk.Text(window, width=30, height=2)
data.place(x = 200, y = 100, anchor='nw')
output = tk.Text(window,width=30, height=2)
output.place(x = 200, y= 200, anchor='nw')
def process():
result = data.get('0.0', 'end')
# 处理一下数据
result1 = str(10)
output.insert('1.0', result1)
b = tk.Button(window, width=10, height=2,
text = 'process',
command = process)
b.place(x = 300, y = 300, anchor='nw')
window.mainloop()
Python GUI交互界面的简单搭建
于 2024-05-29 13:11:12 首次发布