2

I want to make a window without the top taskbar (that is movable), so there is only thin outline around the GUI box. I also want to add my own 'X' to the box.

import Tkinter

class Application(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.parent = master
............
def main():
    root = Tk()
    root.attributes('-fullscreen', True)
    root.geometry('500x250+500+200')
    app = Application(root)
    app.parent.configure(background = 'gray32')
    root.resizable(width=FALSE, height=FALSE)
    app.mainloop()

main()

I tried forcing the box to resize after going into fullscreen to remove the taskbar, though box is no longer movable. Any suggestions?

[I have seen this thread: Removing or disabling a resizable Tkinter window maximise button under Windows

The -toolwindow attribute didn't work for me, maybe because I use linux...]

Community
  • 1
  • 1
user1435947
  • 139
  • 2
  • 4
  • 12
  • Perhaps try invoking the maximize of the window? however, that would require it to be resizable, but you can always turn off resizing after it is maximized :) – IT Ninja Jun 24 '12 at 17:49
  • That is what I did in the code given above... I don't want it fully maximized, just a medium box with no taskbar on top. – user1435947 Jun 24 '12 at 18:06

1 Answers1

3

I replaced the fullscreen command (you said you don't want it fully maximized) with root.overrideredirect(1), which gives a window without title bar (not a taskbar, that is something else).

def main():
    root = Tk()
    root.overrideredirect(1)
    root.geometry('500x250+500+200')
    app = Application(root)
    app.parent.configure(background = 'gray32')
    root.resizable(width=FALSE, height=FALSE)
    app.mainloop()
Junuxx
  • 14,011
  • 5
  • 41
  • 71
  • @user1435947: Just add binds for clicking and dragging, as described in the answer to [this question](http://stackoverflow.com/questions/4055267/python-tkinter-mouse-drag-a-window-without-borders-eg-overridedirect1) – Junuxx Jun 24 '12 at 21:36
  • 1
    @user1435947: it's movable, but you removed the way the OS allows you to move it. You need to add your own bindings to the border, or provide some other way for the user to move it. It's pretty simple to bind to ``, `` and `` and allow the user to move the window – Bryan Oakley Jun 24 '12 at 21:36
  • Thank you! I had to create 3 functions to use all three events, is that necessary? – user1435947 Jun 24 '12 at 23:00
  • The window hasn't "smooth shade" borders like all other Windows 7 apps @Junuxx, even those which don't have standard borders : for example iTunes (which doesn't have standard borders) still has smooth shade borders. Any idea ? – Basj Dec 19 '13 at 23:06