How to run a python tkinter app without appearing in unity panel or alt-tab
To move a window without borders you can take a look at this question for a simple example of how to implement what you want and just keep building on top of it.
For the hiding, you could use .iconify()
, theoretically minimizing the app to the tray thus hiding it, and .deiconify()
, for example:
root = tk.Tk()root.iconify()
ps. If it don't work on Ubuntu/Unity you may have to use other GUI framework with support for this behavior on Ubuntu, like GTK.
import tkinter root = tkinter.Tk()root.withdraw()root.mainloop()
Will hide the window.
Make your own titlebar
, like so:
import sysimport tkinter as tkimport tkinter.ttk as ttkroot = tk.Tk() #create the windowtitlebar = tk.Label(root,height=2, bg='cyan', fg='navyblue', text=sys.argv[0]) #create the titlebarresizable = ttk.Sizegrip(root) #make the window resizabletitlebar.pack(fill='both') # display the titlebarroot.overrideredirect(1) #make the window run without appearing in alt tab#root.withdraw() #root.deiconify()root.geometry('200x200') #set the window size to 200x200resizable.pack(fill='y',side='right')def ontitlebarclicked(event): global lastposition lastposition=[event.x,event.y] def ontitlebardragged(event): global lastposition windowposition=[int(i) for i in root.geometry().split('+')[1:]] # get the window position diffposition=[event.x-lastposition[0],event.y-lastposition[1]] widthheight=root.geometry().split('+')[0] root.geometry(widthheight+'+'+str(windowposition[0]+diffposition[0])+'+'+str(windowposition[1]+diffposition[1]))titlebar.bind('<Button-1>',ontitlebarclicked)titlebar.bind('<Button1-Motion>',ontitlebardragged)titlebar.focus_force()