2

I have a little Tkinter application here, as well as a handle to the Tkinter window. What I'm trying to do is remove the window from the taskbar using some combination of Windows API calls. Basically I don't want the window to show up in the task bar.

import Tkinter as tk
import string

import win32ui
import win32con

root = tk.Tk()

handle = string.atoi(root.wm_frame(), 0)
winhandle = win32ui.CreateWindowFromHandle(handle)

root.mainloop()
rectangletangle
  • 50,393
  • 94
  • 205
  • 275
  • There is an example doing the reverse at https://stackoverflow.com/a/30819099/291641 which may help. If you use `overrideredirect` the windows is ignored by the taskbar but in the linked answer someone wanted such a window to be shown on the taskbar. Overrideredirect stops the application window from being decorated by the window manager so you might not want to use that and so fiddle with the window styles might be appropriate. – patthoyts Feb 15 '18 at 21:27

1 Answers1

4

I hope this helps, or at least guides you somehow. I'm not sure how to do this in python, but speaking for the winapi part, this has to do with the window ex style. This is what MSDN says:

The Shell creates a button on the taskbar whenever an application creates a window that isn't owned. To ensure that the window button is placed on the taskbar, create an unowned window with the WS_EX_APPWINDOW extended style. To prevent the window button from being placed on the taskbar, create the unowned window with the WS_EX_TOOLWINDOW extended style. As an alternative, you can create a hidden window and make this hidden window the owner of your visible window.

Complete reference here|

In C or C++ you specify the ex style when you create the window with CreateWindowEx. You can also modify the style after a window is created with SetWindowLongPtr.

Edit: I found this very promising python method: PyCWnd.ModifyStyleEx

alf
  • 18,372
  • 10
  • 61
  • 92