hoffstadt / DearPyGui

Dear PyGui: A fast and powerful Graphical User Interface Toolkit for Python with minimal dependencies
https://dearpygui.readthedocs.io/en/latest/
MIT License
12.94k stars 676 forks source link

Ability to hide viewport #2377

Open Vazgen005 opened 1 month ago

Vazgen005 commented 1 month ago

Is your feature request related to a problem? Please describe. I want my application to be able to minimize to the system tray using pystray library.

Describe the solution you'd like To do this, I need to hide the viewport in some way. It would be nice to have a function dpg.set_viewport_visible(bool)

Describe alternatives you've considered PySide6 has a .hide() method.

KyleTheScientist commented 3 weeks ago

The application I was making a few weeks ago had a dependency on the AutoHotKey Python library, and that library has a window.hide() method that can hide arbitrary windows if you're looking for a workaround. There are probably simpler solutions, but since I already had the package imported it was easy to include. Something like this:

from ahk import AHK
from ahk.directives import NoTrayIcon

ahk = AHK(directives=[NoTrayIcon()])

... # Set up your window and such

# Fetch the window
title = dpg.get_viewport_title()
window = ahk.find_window_by_class(title)

# Hiding completely hides the window and the taskbar item, but it is still running.
dpg.add_button(label="Hide", callback=window.hide)
dpg.add_button(label="Show", callback=window.show)
Vazgen005 commented 3 weeks ago

The application I was making a few weeks ago had a dependency on the AutoHotKey Python library, and that library has a window.hide() method that can hide arbitrary windows if you're looking for a workaround. There are probably simpler solutions, but since I already had the package imported it was easy to include. Something like this:

Thanks, I'll look into it. It's a pretty interesting solution, by the way 😁