Tkinter, tkMessagebox and overrideredirect

Eric Brunel see.signature at no.spam
Thu Jun 7 06:01:06 EDT 2007


On Thu, 07 Jun 2007 09:04:24 +0200, <marcoberi at gmail.com> wrote:
[snip]
> I can't believe there isn't an easier way to make a kiosk application
> without titlebar.

That's not the problem: there *is* an easy way, and you found it:  
overrideredirect(1). But now you're trying to mix windows ignored by the  
window manager - as you've told it to - and windows that *are* managed by  
the window manager. This is where the problem is.

> Perhaps to create a normal window bigger than screen with title bar
> outside it?

This won't work on some platforms and/or with some window managers... And  
there's no portable way to do that, as sometimes, the dimensions you give  
for the window includes the window decorations, and sometimes they don't.

> And after how can I ignore titlebar menu command or "x" and "-"
> button?

For the 'X' button, it's quite simple:  
myToplevel.protocol('WM_DELETE_WINDOW', lambda: None)

For the '-' button, I don't know any way.

> Or is it possible to create a main Toplevel without "x" and "-"?

Apart from overrideredirect(1), I don't think there's any.


BTW, what are you trying to do here? Will your application run on a  
"normal" desktop computer? Or will it run on special devices such as  
vending machines or similar? If in the first case, my advice would be to  
give up this design (which many people hate, BTW) and use normal windows.  
You'll have far less trouble and will probably make your users happier. If  
in the second case, you shouldn't rely on an existing window manager, and  
try to design your GUI so that doing things "manually" will be easier. For  
example, instead of displaying a dialog for a message, maybe you should  
just reserve a screen zone to display the message, optionally displaying  
it in a special color or making it blink so that the user can't miss it.  
You may also consider using the "place" layout method to display things at  
random coordinates in your application window. For example:

--------------------------------------------------------
 from Tkinter import *

class App:
     def __init__(self):
         self.root = Tk()
         self.root.overrideredirect(1)
         frm = Frame(self.root, width=320, height=200,
                            borderwidth=5, relief=RAISED)
         frm.pack_propagate(0)
         frm.pack()
         Button(frm, text="Quit", command=self.root.quit).pack(pady=20)
         Button(frm, text="Hello", command=self.hello).pack(pady=20)

     def hello(self):
         self.dialogWdw = Frame(self.root, borderwidth=2, relief=RAISED)
         Label(self.dialogWdw, text='Hello!').pack(side=TOP, padx=20,  
pady=4)
         Button(self.dialogWdw, text='OK',  
command=self.destroyDialog).pack(side=TOP, padx=20, pady=4)
         self.dialogWdw.place(x=170, y=100, anchor='center')

     def destroyDialog(self):
         self.dialogWdw.place_forget()
         self.dialogWdw.destroy()


app = App()
app.root.mainloop()
--------------------------------------------------------

HTH
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"



More information about the Python-list mailing list