Сlickthrough and Transparent background viewport
Feature Request: Clickthrough Viewport Background with Transparency and Mouse Support
Is your feature request related to a problem? Please describe.
I'm often frustrated when I need to create a Dear PyGui application with a transparent viewport background that allows interaction with underlying applications (clickthrough) while still enabling mouse interactions with Dear PyGui windows. Currently, setting the viewport background to transparent (e.g., dpg.set_viewport_clear_color([0, 0, 0, 0])) results in a black background instead of true transparency, and there’s no built-in support for clickthrough behavior, forcing me to choose between a fully interactive viewport or a completely non-interactive one. This limits the ability to create overlay-like interfaces where the viewport background is invisible and clickthrough, but Dear PyGui windows remain fully interactive.
Describe the solution you'd like
I’d like the ability to:
- Set the viewport background to be fully transparent (alpha channel = 0) so it blends seamlessly with the desktop or applications behind it.
- Enable clickthrough behavior for the transparent viewport background, allowing mouse clicks to pass through to underlying applications.
- Retain full mouse interaction (clicks, hovers, etc.) for Dear PyGui windows within the viewport, ensuring they function normally.
This could be implemented via new viewport configuration options, such as:
dpg.set_viewport_transparency(True)to enable true transparency.dpg.set_viewport_clickthrough(True)to allow clicks to pass through the transparent background but not the Dear PyGui windows.
For example:
import dearpygui.dearpygui as dpg
dpg.create_context()
dpg.create_viewport(title="Transparent App", width=800, height=600)
dpg.set_viewport_transparency(True) # Make viewport background fully transparent
dpg.set_viewport_clickthrough(True) # Clicks pass through transparent areas
with dpg.window(label="Interactive Window", width=200, height=200):
dpg.add_button(label="Click Me") # Window remains interactive
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
Describe alternatives you've considered
- Using C# ImGui with Clickable Transparent Overlay: In C# ImGui, a package like "clickable transparent overlay" achieves this behavior by creating an invisible viewport while keeping ImGui windows interactive. However, this requires switching to C#, which I’d prefer to avoid as I’m more comfortable with Python and Dear PyGui.
- Custom Window Styling: I tried setting the viewport’s clear color to
[0, 0, 0, 0]and adjusting window themes to minimize the background, but this doesn’t achieve true transparency or clickthrough behavior. It also doesn’t allow mouse events to pass through the viewport. - No Title Bar and Custom Windows: I considered using
no_title_bar=Trueandno_background=Truefor windows to simulate a floating interface, but this doesn’t address viewport transparency or clickthrough for the background, and managing multiple windows this way is cumbersome. - External Libraries: I explored using other Python GUI frameworks like PyQt or Tkinter, but they either lack the GPU-accelerated performance of Dear PyGui or have more complex APIs for achieving transparency and clickthrough, making Dear PyGui a better fit if this feature is added.
Additional context
This feature would be highly valuable for creating overlay applications, such as desktop widgets, annotation tools, or HUD-like interfaces, where the viewport background needs to be invisible and non-blocking, but the Dear PyGui windows remain fully functional. Similar functionality exists in C# ImGui, suggesting it’s feasible to implement in Dear PyGui, possibly by leveraging the underlying Dear ImGui or OS-specific windowing APIs (e.g., Win32, Metal, or Vulkan). Existing GitHub issues ( #1142 ) indicate community interest in viewport transparency, but they don’t fully address clickthrough or mouse interaction with windows, so this request extends those ideas. A potential challenge might be OS-specific behavior (e.g., Windows vs. macOS), but a unified API with fallbacks (e.g., partial transparency if full clickthrough isn’t supported) would still be useful.