下面是使用 tkinter 库创建一个编辑框并获取当前时间的 Python3 代码示例:

import tkinter as tk
import time

def get_current_time():
    current_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
    text_box.insert(tk.END, current_time + '\n')

root = tk.Tk()
root.title('Current Time')

# 创建一个编辑框
text_box = tk.Text(root, height=10, width=40)
text_box.pack()

# 创建一个按钮
button = tk.Button(root, text='获取当前时间', command=get_current_time)
button.pack()

root.mainloop()

运行这个程序,将会创建一个窗口,包含一个编辑框和一个按钮。当用户点击'获取当前时间'按钮时,程序将会获取当前时间并将其添加到编辑框中。

Python3 Tkinter 编辑框获取当前时间

原文地址: https://www.cveoy.top/t/topic/oc3W 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录