代码如下:
import tkinter as tk from tkinter import * from tkinter import font from tkinter import ttk import time import datetime root_window = tk.Tk() root_window.geometry('480x320') root_window.title("EBCTools") tk.font.Font(family="Helvetica", size=16) # 设置标题样式 style = ttk.Style() style.configure("TFrame", background="blue") # 设置窗口背景颜色 style.configure("TFrame", foreground="black") # 设置文本颜色(标题颜色) # 设置标题颜色 root_window.style = style root_window.iconbitmap('logo.ico') lb1 = Label(root_window,text="输入cid") lb1.place(relx=0.09, rely=0.1, relwidth=0.8, relheight=0.1) input = Entry(root_window) input.place(relx=0.32, rely=0.2, relwidth=0.3, relheight=0.1) txt = Text(root_window) txt.configure(background='white') txt.place(rely=0.6, relheight=0.4,relwidth=1) var=tk.StringVar def run1 (): var_cid = input.get() if var_cid != '': input.delete(0,END) txt.insert(END,"cid = ") txt.insert(END,var_cid) txt.insert(END,"\n") if var_cid == '': null_txt = 'cid为空,请输入cid!' txt.insert(END,null_txt) txt.insert(END,'\n') btn1 = Button(root_window, text='确认', command=run1) btn1.place(relx=0.32, rely=0.4, relwidth=0.3, relheight=0.1) root_window.mainloop()