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.92k stars 672 forks source link

Viewport Transparency #1142

Open Mstpyt opened 3 years ago

Mstpyt commented 3 years ago

feature request It would be wonderfull and great for DPG if we have the possibility to hide the VP so the possibilities for applications are way higher.

Describe the solution you'd like --> Transparency option on VP --> Option to "hide" the VP completly

Describe alternatives you've considered 3rdparty libraries can do it as well, but it is always the same, you have to install and outsource a lot of code you don't want.

ElCuboNegro commented 2 years ago

The idea here can allow the user to have dynamic SVG components and floating windows?

nlapinski commented 2 years ago

I had this same issue - there was a resolution on the discord that used the win32con.LWA_COLORKEY windows attributes for windows, but it provides edge alias artifacts on bad keys, this seemed the better solution windows only unfortunately

image

I think the margin -1 thing is a hold over from DX9 and windows 7? I tried it first in the C++ code

    MARGINS margins = { -1 }; 
    DwmExtendFrameIntoClientArea(viewportData->handle, &margins);

but it works in python too

example, ctypes + win32gui are required:

import win32gui
import win32con
import dearpygui.dearpygui as dpg

import ctypes
from ctypes import c_int
dwm = ctypes.windll.dwmapi

dpg.create_context()

p1 = [0,0]
p2 = [10,0]
p3 = [10,10]
p4 = [0,10]
p5 = [0,0]

class MARGINS(ctypes.Structure):
  _fields_ = [("cxLeftWidth", c_int),
              ("cxRightWidth", c_int),
              ("cyTopHeight", c_int),
              ("cyBottomHeight", c_int)
             ]

dpg.create_viewport(title='overlay',always_on_top=True,decorated=False,clear_color=[0.0,0.0,0.0,0.0])

dpg.set_viewport_always_top(True)
dpg.create_context()
dpg.setup_dearpygui()

with dpg.window(label="About2",no_background=True, tag='bg_win'):
    with dpg.draw_node() as root :
        dpg.draw_polygon([p1,p2,p3,p4,p5], color=[0,255,0,255],fill=[0,0,255,255])
        dpg.apply_transform(root,dpg.create_scale_matrix([6,6])*dpg.create_translation_matrix([5,5]))

with dpg.window(label="About3",no_background=False, tag='bg_wi2'):
    with dpg.draw_node() as root :
        dpg.draw_polygon([p1,p2,p3,p4,p5], color=[0,255,0,255],fill=[0,0,255,255])
        dpg.apply_transform(root,dpg.create_scale_matrix([6,6])*dpg.create_translation_matrix([5,5]))

dpg.show_viewport()
dpg.toggle_viewport_fullscreen()

hwnd = win32gui.FindWindow(None, "overlay")
margins = MARGINS(-1, -1,-1, -1)
dwm.DwmExtendFrameIntoClientArea(hwnd, margins)

#enable this for click through otherwise always overtop
#win32gui.SetWindowLong(hwnd, win32con.GWL_EXSTYLE, win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE) | win32con.WS_EX_LAYERED | win32con.WS_EX_TRANSPARENT )

dpg.start_dearpygui()
dpg.destroy_context()
OpsecGuy commented 2 years ago

bump!

JCMSimon commented 1 year ago

This would be really useful tbh

AndreyArhimed commented 1 year ago

Is it possible to change the title color, answers or old or no information at all? I apologize if this is not the right place to ask a question.

title_color dpg.create_viewport(title='Custom Title', decorated=True, clear_color=[115.0,114.0,115.0,116.0], width=600, height=200, small_icon='a.ico', large_icon='c:\PT11\LABS\a.ico')

Umbrella167 commented 1 week ago

Is there any solution now? in linux