DearPyGui
DearPyGui copied to clipboard
getWidgetWidth() / getWidgetHeight
I would be very helpful if you could get the px width and height for most widgets. This would be helpful in making a GUI scalable, as you could define a position based on the width of the widget you're working with. For example, say I wanted to center a text widget in a viewport you could set position to (dpg.getViewportWidth - dpg.getWidgetWidth, SomeYValue), or with more complex equations you could make adjustable widget locations that would be the same relatively regardless of window scale.
Try use: dpg.get_item_rect_size()
Test code:
import dearpygui.dearpygui as dpg
dpg.create_context()
with dpg.window():
dpg.add_button(label='test', callback=lambda item: print(dpg.get_item_rect_size(item)))
dpg.add_button(label='test22222', callback=lambda item: print(dpg.get_item_rect_size(item)))
dpg.create_viewport()
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
Solution provided, closing issue.