开发者

Setting window styles with Tkinter/Tcl: no exit button

I know that Tkinter is just a thin layer over Tcl/Tk. Tkinter you can do a few things to change the windows styling. One examp开发者_StackOverflow中文版le would be root.attributes('-toolwindow', True). This would change the window style, to that of a tool window. However, I'm looking to go a little bit lower level.

I suspect at some point Tcl/Tk refrences Windows window styles. I'm pretty sure it would have to do this in order to set the window style and by extension the Tkinter window styling. I'm trying to give a Tkinter window what I'm pretty sure is the WS_DLGFRAME style. However, I'm unsure how to approach this.

I'm wondering where in the Tcl/Tk part of Tkinter does it assign windows styles, and what I'd have to add to get this style.

The end goal is to get a Tkinter window border style that looks like the one below (note how it lacks an exit button):

Setting window styles with Tkinter/Tcl: no exit button

This is in Windows 7, BTW.


The following option instructs the window manager not to decorate the window (i.e no title bar and window buttons, plus no borders)

root.overrideredirect(True)

A false argument restores the decorations.


If you are familiar with C, download Tk source code.

I've looked quickly, and in this file: ./win/tkWinWm.c at line 3072 (tk859-src.zip), you have the function static int WmAttributesCmd(), dealing with -toolwindow as you've said, later updated by UpdateWrapper().

So no easy way to change it, unless you change Tk source code.

Alternatively you might be able to use FindWindow and look for Tk's window class TK_WIN_CHILD_CLASS_NAME defined to be TkChild, and then use SetWindowLongPtr( GWLP_STYLE, ...) to change the style (but this requires some ffi call to C or other means).

I myself I'm not familiar with neither Tcl/Tk, so take it with a grain of salt. Why not try the Tcl/Tk community?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜