Skip to content

Commit

Permalink
main : main : added window transparency example for WIndows
Browse files Browse the repository at this point in the history
  • Loading branch information
my1e5 committed Mar 16, 2023
1 parent e3a20fb commit ab06f3f
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
27 changes: 27 additions & 0 deletions buttons/combo_box_custom_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'''
If you are using a primary window, this will work. See combo_box_custom_2.py for a
version that works with floating windows.
'''

import dearpygui.dearpygui as dpg
dpg.create_context()

def show_options(sender):
x,y = dpg.get_item_pos(sender)
dpg.configure_item("options_window", pos=(x,y+20))
dpg.configure_item("options_window", show=True)

with dpg.window(popup=True, show=False, tag="options_window"):
dpg.add_checkbox(label="Option 1")
dpg.add_checkbox(label="Option 2")
dpg.add_checkbox(label="Option 3")

with dpg.window(width=500, height=300):
dpg.set_primary_window(dpg.last_item(), True)
dpg.add_button(label="Options V", width=100, callback=show_options)

dpg.create_viewport(width=800, height=600, title='Custom combo box with primary window')
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
27 changes: 27 additions & 0 deletions buttons/combo_box_custom_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'''
If you are not using a primary window, you need to check the position of the window
the button is in and add this on.
'''

import dearpygui.dearpygui as dpg
dpg.create_context()

def show_options(sender):
wx, wy = dpg.get_item_pos("window")
x,y = dpg.get_item_pos(sender)
dpg.configure_item("options_window", pos=(wx+x,wy+y+20))
dpg.configure_item("options_window", show=True)

with dpg.window(popup=True, show=False, tag="options_window"):
dpg.add_checkbox(label="Option 1")
dpg.add_checkbox(label="Option 2")
dpg.add_checkbox(label="Option 3")

with dpg.window(width=500, height=300, tag="window"):
dpg.add_button(label="Options V", width=100, callback=show_options)

dpg.create_viewport(width=800, height=600, title='Custom combo box with floating window')
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()

0 comments on commit ab06f3f

Please sign in to comment.