python实时显示时间_python编程,使用Tkinter中的文本框显示系统时间

展开全部

Python编程中e69da5e887aa62616964757a686964616f31333337396234,用Tkinter中的文本框获取系统当前的时间并且显示,代码如下:import sys

from tkinter import *

import time

def tick():

global time1

# 从运行程序的计算机上面获取当前的系统时间

time2 = time.strftime('%H:%M:%S')

# 如果时间发生变化,代码自动更新显示的系统时间

if time2 != time1:

time1 = time2

clock.config(text=time2)

# calls itself every 200 milliseconds

# to update the time display as needed

# could use >200 ms, but display gets jerky

clock.after(200, tick)

root = Tk()

time1 = ''

status = Label(root, text="v1.0", bd=1, relief=SUNKEN, anchor=W)

status.grid(row=0, column=0)

clock = Label(root, font=('times', 20, 'bold'), bg='green')

clock.grid(row=0, column=1)

tick()

root.mainloop()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值