@@ -69,37 +69,39 @@ def refresh_down_time():
6969 diff_time -= 1
7070
7171
72- # 设置页面数据
73- tk_obj = Tk ()
74- tk_obj .geometry ('400x280' )
75- tk_obj .resizable (0 , 0 )
76- tk_obj .config (bg = 'white' )
77- tk_obj .title ('倒计时应用' )
78- Label (tk_obj , text = '下班倒计时' , font = '宋体 20 bold' , bg = 'white' ).pack ()
79- # 设置当前时间
80- Label (tk_obj , font = '宋体 15 bold' , text = '当前时间:' , bg = 'white' ).place (x = 50 , y = 60 )
81- curr_time = Label (tk_obj , font = '宋体 15' , text = '' , fg = 'gray25' , bg = 'white' )
82- curr_time .place (x = 160 , y = 60 )
83- refresh_current_time ()
84- # 设置下班时间
85- Label (tk_obj , font = '宋体 15 bold' , text = '下班时间:' , bg = 'white' ).place (x = 50 , y = 110 )
86- # 下班时间-小时
87- work_hour = StringVar ()
88- Entry (tk_obj , textvariable = work_hour , width = 2 , font = '宋体 12' ).place (x = 160 , y = 115 )
89- work_hour .set ('18' )
90- # 下班时间-分钟
91- work_minute = StringVar ()
92- Entry (tk_obj , textvariable = work_minute , width = 2 , font = '宋体 12' ).place (x = 185 , y = 115 )
93- work_minute .set ('00' )
94- # 下班时间-秒数
95- work_second = StringVar ()
96- Entry (tk_obj , textvariable = work_second , width = 2 , font = '宋体 12' ).place (x = 210 , y = 115 )
97- work_second .set ('00' )
98- # 设置剩余时间
99- Label (tk_obj , font = '宋体 15 bold' , text = '剩余时间:' , bg = 'white' ).place (x = 50 , y = 160 )
100- down_label = Label (tk_obj , font = '宋体 23' , text = '' , fg = 'gray25' , bg = 'white' )
101- down_label .place (x = 160 , y = 155 )
102- down_label .config (text = '00时00分00秒' )
103- # 开始计时按钮
104- Button (tk_obj , text = 'START' , bd = '5' , command = refresh_down_time , bg = 'green' , font = '宋体 10 bold' ).place (x = 150 , y = 220 )
105- tk_obj .mainloop ()
72+ # 程序主入口
73+ if __name__ == "__main__" :
74+ # 设置页面数据
75+ tk_obj = Tk ()
76+ tk_obj .geometry ('400x280' )
77+ tk_obj .resizable (0 , 0 )
78+ tk_obj .config (bg = 'white' )
79+ tk_obj .title ('倒计时应用' )
80+ Label (tk_obj , text = '下班倒计时' , font = '宋体 20 bold' , bg = 'white' ).pack ()
81+ # 设置当前时间
82+ Label (tk_obj , font = '宋体 15 bold' , text = '当前时间:' , bg = 'white' ).place (x = 50 , y = 60 )
83+ curr_time = Label (tk_obj , font = '宋体 15' , text = '' , fg = 'gray25' , bg = 'white' )
84+ curr_time .place (x = 160 , y = 60 )
85+ refresh_current_time ()
86+ # 设置下班时间
87+ Label (tk_obj , font = '宋体 15 bold' , text = '下班时间:' , bg = 'white' ).place (x = 50 , y = 110 )
88+ # 下班时间-小时
89+ work_hour = StringVar ()
90+ Entry (tk_obj , textvariable = work_hour , width = 2 , font = '宋体 12' ).place (x = 160 , y = 115 )
91+ work_hour .set ('18' )
92+ # 下班时间-分钟
93+ work_minute = StringVar ()
94+ Entry (tk_obj , textvariable = work_minute , width = 2 , font = '宋体 12' ).place (x = 185 , y = 115 )
95+ work_minute .set ('00' )
96+ # 下班时间-秒数
97+ work_second = StringVar ()
98+ Entry (tk_obj , textvariable = work_second , width = 2 , font = '宋体 12' ).place (x = 210 , y = 115 )
99+ work_second .set ('00' )
100+ # 设置剩余时间
101+ Label (tk_obj , font = '宋体 15 bold' , text = '剩余时间:' , bg = 'white' ).place (x = 50 , y = 160 )
102+ down_label = Label (tk_obj , font = '宋体 23' , text = '' , fg = 'gray25' , bg = 'white' )
103+ down_label .place (x = 160 , y = 155 )
104+ down_label .config (text = '00时00分00秒' )
105+ # 开始计时按钮
106+ Button (tk_obj , text = 'START' , bd = '5' , command = refresh_down_time , bg = 'green' , font = '宋体 10 bold' ).place (x = 150 , y = 220 )
107+ tk_obj .mainloop ()
0 commit comments