from tkinter import Tk,Button,Canvas,messagebox,OptionMenu,StringVar from os import startfile,path,getcwd,system from sys import exit as ex #----------Made by 悠然自得、添亮了(肝肝甘甘的野生电脑)----------# #设置尺寸为None值 chicun = None # 创建主窗口 root = UI.Window() #创建调整大小窗口 root2 = UI.Window() #暂时隐藏副窗口 root2.withdraw() #设置尺寸 root.geometry("400x300") root2.geometry("100x150") #标题设置 root.title("设置") #设置背景色 root.configure(background='gray') root2.configure(background='gray') #不可放大缩小:设置 root.resizable(width=False, height=False) root2.resizable(width=False, height=False) def Button1(): global chicun chicun = '500x300' root2.withdraw() def Button2(): global chicun chicun = '750x450' root2.withdraw() def Button3(): global chicun chicun = '1000x600' root2.withdraw() #副窗口按钮 button1 = Button(root2.Widget, text="500x300",overrelief='sunken',bd=4,command=Button1) button1.pack(side="top", pady=8) button2 = Button(root2.Widget, text="750x450",overrelief='sunken',bd=4,command=Button2) button2.pack(side="top", pady=8) button3 = Button(root2.Widget, text="1000x600",overrelief='sunken',bd=4,command=Button3) button3.pack(side="top", pady=8) def open4(): root = UI.Window() root.withdraw() messagebox.showinfo('操作系统信息',f'名称:MikOS \n版本号:{Kernel["VerSion"]}\nPowered by Python Tkinter\n© 2023 G Dev Hub MikOS Dev Team') messagebox.showinfo('终端信息', f'名称:MayDOS \n版本号:{DOS["VerSion"]}© 2023 MayDOS Team') root.mainloop() # 创建按钮 button1 = Button(root.Widget, text="设置窗口大小", command=None, width=20,overrelief='sunken',bd=4) button2 = Button(root.Widget, text="修改背景", command=None, width=20,overrelief='sunken',bd=4) button3 = Button(root.Widget, text="修改配置文件", command=None, width=20,overrelief='sunken',bd=4) button4 = Button(root.Widget, text="终端", command=None, width=20,overrelief='sunken',bd=4) button5 = Button(root.Widget, text="关于系统", command=open4, width=20,overrelief='sunken',bd=4) # 将按钮竖着并排显示在窗口中 button1.grid(row=0, column=0, padx=40, pady=(16,0)) button2.grid(row=1, column=0, padx=40, pady=(10,0)) button3.grid(row=2, column=0, padx=40, pady=(10,0)) button4.grid(row=3, column=0, padx=40, pady=(10,0)) button5.grid(row=4, column=0, padx=40, pady=(10,0)) root2.protocol("WM_DELETE_WINDOW", root2.withdraw) root.protocol("WM_DELETE_WINDOW",ex) # 运行主程序 root.mainloop()