【发布时间】:2018-12-03 15:40:27
【问题描述】:
我想在 ### 中添加一个自定义最小化按钮,但我真的不知道怎么做。
我试过找了一下,但只找到了 Python 2 个不再适用于 Python 3 的结果。
如果 linux 和 windows 都可以(在开始时进行操作系统检查,我可以自己进行)并且不使用导入的模块,那将是最好的关闭基本的 Python 模块。
这是我当前的代码:
from tkinter import *
import ctypes
root = Tk()
usr32 = ctypes.windll.user32
res1 = usr32.GetSystemMetrics(0)
res2 = usr32.GetSystemMetrics(1)
#-------------------------------
def ext():
exit()
def minim():
###
root.resizable(0, 0)
root.geometry(str(int(res1 * 0.15)) + "x" + str(int(res2 * 0.1)))
root.overrideredirect(1)
back = Frame(root, bg='black')
back.pack_propagate(0)
back.pack(fill=BOTH, expand=1)
b_Frame = Frame(back, bg="#505050")
b_Frame.place(x=0, y=0, anchor="nw", width=res1 * 0.15, height=res2 * 0.025)
Ext_but = Button(b_Frame, text="X", bg="#FF6666", fg="white", command=ext)
Ext_but.place(x=res1 - res1 * 0.8665, y=0, anchor="nw", width=res1 * 0.016, height=res2 * 0.025)
Min_but = Button(b_Frame, text="_", bg="#FF6666", fg="white", command=minim)
Min_but.place(x=res1 - res1 * 0.8825, y=0, anchor="nw", width=res1 * 0.016, height=res2 * 0.025)
#-------------------------------
root.mainloop()
【问题讨论】:
标签: python-3.x windows tkinter