Python 没有装饰的窗户

Python 没有装饰的窗户,python,tkinter,Python,Tkinter,在python 3.6.3上使用此测试代码 tkinter.Tcl.eval'info patchlevel'返回'8.6.6' 我的操作系统是Mint 18.3肉桂3.6.7,但我希望我的代码是跨平台的。 我使用控制台运行脚本: from tkinter import * from tkinter import ttk def valid(*args): print("Dans valid", nom.get()) root.quit() root = Tk() root

在python 3.6.3上使用此测试代码


tkinter.Tcl.eval'info patchlevel'返回'8.6.6' 我的操作系统是Mint 18.3肉桂3.6.7,但我希望我的代码是跨平台的。 我使用控制台运行脚本:

from tkinter import *
from tkinter import ttk

def valid(*args):
    print("Dans valid", nom.get())
    root.quit()

root = Tk()

rootW = 300
rootH = 200
x = (root.winfo_screenwidth() - rootW)//2
y = (root.winfo_screenheight() - rootH)//2
root.geometry(f'{rootW}x{rootH}+{x}+{y}')

mainFrame = ttk.Frame(root,  padding="5")
mainFrame.grid(column=0, row=0, sticky=(N, W, E, S))
mainFrame.columnconfigure(0, weight=1)
mainFrame.rowconfigure(0, weight=1)

nom = StringVar()
nomEntry = ttk.Entry(mainFrame,  width=20,  textvariable=nom)
nomEntry.grid(column=2, row=2, sticky=(E))
ttk.Label(mainFrame, text="Inscription").grid(column=2, row=1, sticky=W)
ttk.Label(mainFrame, text="Votre nom").grid(column=1,  row=2)
ttk.Button(mainFrame, text="Validation", command=valid).grid(column=2, row=3, sticky=W)

for child in mainFrame.winfo_children():
    child.grid_configure(padx=5, pady=5)

nomEntry.focus()
#root.update_idletasks()
root.overrideredirect(1)

root.mainloop()
root.destroy()
我想使用tkinter窗口,通过OverrideDirect方法删除该窗口中的所有窗口管理器装饰

在这种情况下,我没有任何更多的装饰,但我不再能够访问输入字段,而验证按钮正在运行并退出窗口

如果我对root.overrideredirect1行进行注释,所有内容都正常工作,带有装饰

我尝试添加root.update_idletasks行,但这并没有改变我的问题:这没关系,但有装饰


如何获得没有装饰的运行窗口?

当我在3.6.4、tk8.6.6、Win 10上以空闲模式运行时,我看到一个未装饰的窗口,带有两个标签、一个带焦点的输入框和一个按钮。当我输入这是一个测试,并单击按钮时,我看到Dans valid这是一个打印在shell中的测试。我看没什么问题

文档声称需要.update_idletasks,但对于windows上tk 8.6的代码似乎不需要。它还说,这种方法在某些Unix和MacOS平台上可能不起作用。这适用于你吗?如果您使用的是MacOS,那么您可能运行的是8.5,也可能是一个有缺陷的旧版8.5,可以进行更新


该文档提供了更多的技术细节,还提到行为依赖于系统,尽管我不了解细节:一些平台(但不是所有平台)会在其他时间注意到。

我想我已经找到了一个解决方案,它在linux上无论如何都是有效的,可以在windows和OsX上测试

root = Tk()
root.wm_attributes('-type', 'splash')

在这种情况下,我没有更多的装饰,但我不再能够访问输入字段。你的意思是你不能使用输入字段nomEntry吗?虽然上面的代码很简单,但你可以进一步简化它,尝试缩小代码范围,更好地使用它来改进你的问题。如何获得一个没有装饰的操作窗口?您提供的代码中的窗口在多大程度上不可用?您是否在OSX上?您的意思是无法使用输入字段nomEntry?yestkinter.Tcl.eval'info patchlevel'给出了'8.6.6'和python 3.6.3,我的操作系统是Mint 18.3肉桂3.6.7