python tkinter弹窗的输入输出
殷殷殷先森丶 人气:0代码如下:
from tkinter import * tk = Tk() tk.title('test') tk.geometry('350x350') # 输入框1 now_nub1 = Label(tk, text='1、请输入数字:') now_nub1.grid(row=1, column=1, sticky='E') now_bok1 = Spinbox(tk, values=[i for i in range(1, 999999)], width=5) now_bok1.grid(row=1, column=2, sticky='NW') # 输入框2 now_nub2 = Label(tk, text='2、请输入数字:') now_nub2.grid(row=2, column=1, sticky='E') now_bok2 = Spinbox(tk, values=[i for i in range(1, 999999)], width=5) now_bok2.grid(row=2, column=2, sticky='NW') # 输入框3 now_nub3 = Label(tk, text='3、请输入数字:') now_nub3.grid(row=3, column=1, sticky='E') now_bok3 = Spinbox(tk, values=[i for i in range(1, 999999)], width=5) now_bok3.grid(row=3, column=2, sticky='NW') # 输出结果 Output_results = Label(tk, text='输出结果:') Output_results.grid(row=8, column=1, sticky='NW') result_data_Text = Text(tk, width=20, height=10) #处理结果展示 result_data_Text.grid(row=10, column=2, rowspan=15, columnspan=10) def value(): now_lis = [now_bok1.get(), now_bok2.get(), now_bok3.get()] now_lis.sort() result_data_Text = Label(tk, text='第一名:%s\n第二名:%s\n第三名:%s' % (now_lis[2], now_lis[1], now_lis[0])) result_data_Text.grid(row=10, column=2, rowspan=15, columnspan=10) AnNiu = Button(tk, text='提交', fg='blue', bd=2, width=10, command=value) AnNiu.grid(row=5, column=2, sticky='NW') tk.mainloop()
结果如下:
加载全部内容