-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import dearpygui.dearpygui as dpg | ||
dpg.create_context() | ||
|
||
def print_item_sizes(sender): | ||
print(f"On {sender} the window size is: {dpg.get_item_rect_size('window')}") | ||
print(f"On {sender} the text size is: {dpg.get_item_rect_size('text')}") | ||
|
||
with dpg.window(autosize=True, tag='window'): | ||
dpg.add_input_text(width=400, height=200, multiline=True, tag='text') | ||
print_item_sizes('startup') | ||
|
||
dpg.set_frame_callback(1, print_item_sizes) | ||
dpg.set_frame_callback(2, print_item_sizes) | ||
dpg.create_viewport(width=800, height=600, title="Get item size on startup") | ||
dpg.setup_dearpygui() | ||
dpg.show_viewport() | ||
dpg.start_dearpygui() | ||
dpg.destroy_context() | ||
|
||
""" | ||
$ python get_item_size_on_startup.py | ||
On startup the window size is: [0, 0] | ||
On startup the text size is: [0, 0] | ||
On 1 the window size is: [100, 100] | ||
On 1 the text size is: [400, 200] | ||
On 2 the window size is: [416, 235] | ||
On 2 the text size is: [400, 200] | ||
""" |