user1435947
user1435947

Reputation: 139

Python/Tkinter make a custom window

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...]

Upvotes: 2

Views: 7155

Answers (1)

Junuxx
Junuxx

Reputation: 14251

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()

Upvotes: 3

Related Questions