Search code examples
pythonwindowswinapipygtkwin32gui

hide window from MS windows taskbar


Using pyGtk I created a window without decoration. The Window is hidden from task bar and top of all windows. On linux it works fine, but on MS Windows window sometimes it hides under some other window and always has "python.exe" the taskbar in windows.

Image representing my problem:

enter image description here

How can I hide this "python.exe" window from taskbar?

My code:

class Infowindow(gtk.Window):
'''
Klasa okienka informacyjnego
'''
def __init__(self, json, index, destroy_cb, device):
    gtk.Window.__init__(self)
    self.size_x = 260+48
    self.size_y = 85
    self.separator_size = 10
    self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_SPLASHSCREEN)
    self.set_decorated(False)
    self.set_property('skip-taskbar-hint', True)
    self.set_opacity(1)
    self.set_keep_above(True)
    self.add_events(gtk.gdk.BUTTON_PRESS_MASK)
    self.connect("enter-notify-event", self.__on_hover)
    self.connect("leave-notify-event", self.__on_leave)
    self.connect("button_press_event", self.__on_click)
    self.set_size_request(self.size_x, self.size_y)
    color = gtk.gdk.color_parse('#f3f3f3')
    self.modify_bg(gtk.STATE_NORMAL, color)

    self.expanded = False
    self.index = index
    self.destroy_cb = destroy_cb
    self.json = json['data']
    self.system_info = False if 'system' not in self.json or not self.json['system'] else True
    self.device = device
    f = gtk.Frame()
    self.move_window(index) #move window to specified place
    self.box_area = gtk.VBox()
    self.box_area.set_spacing(10)
    f.add(self.box_area)
    self.add(f)
    self.show_all()

Solution

  • You have two options to remove a window from the taskbar:

    1. Add the WS_EX_TOOLWINDOW extended window style. But this has other consequences and I cannot say whether or not they are serious.
    2. Give the window an owner that is not visible. This allows you freedom to use whatever window styles and extended styles you wish, but does involve more work.

    It's natural that your window will go beneath other windows. That's how windows works. If you want to make your window appear on top, show it with HWND_TOPMOST.

    I've no idea how any of this is (or is not) implemented under PyGtk. I've just given you the Win32 answer!