-
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.
main : refactor repo structure so examples are organised into folders
- Loading branch information
Showing
27 changed files
with
145 additions
and
7 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
wip | ||
.vscode | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
|
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 |
---|---|---|
@@ -1,19 +1,70 @@ | ||
# DearPyGui examples | ||
A collection of example scripts which demonstrate various features/functionality in DearPyGui | ||
A collection of example scripts which demonstrate various features/functionality in DearPyGui. | ||
|
||
## Examples | ||
|
||
- [Progress bar](#progress-bar) | ||
- [Simple paint](#simple-paint) | ||
- [Data binding](#data-binding) | ||
- [Drawing]() | ||
- [Simple paint](#simple-paint) | ||
- [Listbox] | ||
- [Misc] | ||
- [Persistance] | ||
- [Plots] | ||
- [Sizing] | ||
- [Spacing] | ||
- [Threading] | ||
- [Progress bar](#progress-bar) | ||
- [Window] | ||
|
||
### Progress bar | ||
|
||
A basic progress bar with a start button. Once running, the start button changes to a pause button. The task can then be paused, upon which the pause button changes to a resume button and a reset button appears. | ||
## Data binding | ||
|
||
![Progress bar](assets/gifs/progress_bar.gif) | ||
Examples of how to link a data structure to GUI items so that changes made using the GUI are reflected in the underlying data structure. | ||
|
||
## Drawing | ||
|
||
Examples of how to use the drawing API. | ||
|
||
### Simple paint | ||
|
||
A very simple implementation of a paint app. It demonstrates how you can click and drag the mouse on a `dpg.add_drawlist` and draw basic free-form lines using `dpg.draw_line`. | ||
|
||
![Simple paint](assets/gifs/simple_paint.gif) | ||
![Simple paint](assets/gifs/simple_paint.gif) | ||
|
||
## Listbox | ||
|
||
Examples of custom listbox widgets which extend the functionality of the default listbox. Includes how to implement a listbox which is unselected by default and how to respond to key presses. | ||
|
||
## Misc | ||
|
||
Miscellaneous examples. | ||
|
||
## Persistance | ||
|
||
Examples of how to save and load the state of a GUI. This includes the values of GUI items, the position of windows, etc. A simple example using `dict` is shown as well as a more advanced example using `dataclasses`. | ||
|
||
## Plots | ||
|
||
Examples of how to implement various features in plots. Such as enforcing axes limits and updating colours and marker styles. | ||
|
||
## Sizing | ||
|
||
Examples of how to size/re-size GUI items. There are some quirks with sizing - mainly to do with getting the correct size of an item on startup. | ||
|
||
## Spacing | ||
|
||
Examples of how to space GUI items using different methods. This includes automatic spacing, spacing using a grid of child windows and spacing using tables. | ||
|
||
## Threading | ||
|
||
Examples of how to use threading in DearPyGui. Includes a start/stop button which can be used to start/stop a thread and a progress bar to show the progress of a task. | ||
|
||
### Progress bar | ||
|
||
A basic progress bar with a start button. Once running, the start button changes to a pause button. The task can then be paused, upon which the pause button changes to a resume button and a reset button appears. | ||
|
||
![Progress bar](assets/gifs/progress_bar.gif) | ||
|
||
## Window | ||
|
||
Examples of how to manage windows. This includes how to create a window which is always on top and how to drag the viewport when `decorated=False`. Also includes restricting the position of a window and how to implement a clicked handler for child windows. |
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,49 @@ | ||
import dearpygui.dearpygui as dpg | ||
dpg.create_context() | ||
|
||
numbers = { | ||
dpg.generate_uuid(): 0, | ||
dpg.generate_uuid(): 0, | ||
dpg.generate_uuid(): 0, | ||
dpg.generate_uuid(): 0, | ||
} | ||
|
||
|
||
def update(_, app_data, user_data): | ||
numbers[user_data] = app_data | ||
|
||
def remove(_, app_data, user_data): | ||
if len(numbers) > 1: | ||
del numbers[user_data] | ||
dpg.delete_item(user_data) | ||
|
||
def add(_, app_data, user_data): | ||
if user_data is None: | ||
number = 0 | ||
tag = dpg.generate_uuid() | ||
numbers[tag] = number | ||
else: | ||
tag, number = user_data | ||
with dpg.group(horizontal=True, tag=tag, parent="input_group"): | ||
dpg.add_input_int(default_value=number, callback=update, user_data=tag) | ||
dpg.add_button(label=" X ", callback=remove, user_data=tag) | ||
with dpg.tooltip(parent=dpg.last_item()): | ||
dpg.add_text("Remove this input") | ||
|
||
|
||
with dpg.window() as primary_window: | ||
with dpg.group(horizontal=True): | ||
dpg.add_button(label="Add number", callback=add) | ||
dpg.add_button(label="Print numbers", callback=lambda: print(numbers.values())) | ||
|
||
with dpg.group(tag="input_group"): | ||
for tag, number in numbers.items(): | ||
add(None, None, (tag, number)) | ||
|
||
|
||
dpg.set_primary_window(primary_window, True) | ||
dpg.create_viewport(width=400, height=100, title="Data binding with dict") | ||
dpg.setup_dearpygui() | ||
dpg.show_viewport() | ||
dpg.start_dearpygui() | ||
dpg.destroy_context() |
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,37 @@ | ||
import dearpygui.dearpygui as dpg | ||
dpg.create_context() | ||
|
||
numbers = [0, 0, 0, 0] | ||
|
||
def update(_, app_data, user_data): | ||
numbers[user_data] = app_data | ||
|
||
def remove(): | ||
if len(numbers) > 1: | ||
numbers.pop() | ||
last_input = dpg.get_item_children('input_group',1)[-1] | ||
dpg.delete_item(last_input) | ||
|
||
def add(): | ||
numbers.append(0) | ||
dpg.add_input_int(parent='input_group', callback=update, user_data=len(numbers)-1) | ||
|
||
|
||
with dpg.window() as primary_window: | ||
|
||
with dpg.group(horizontal=True): | ||
dpg.add_button(label='Add number', callback=add) | ||
dpg.add_button(label='Remove last number', callback=remove) | ||
dpg.add_button(label="Print numbers", callback=lambda: print(numbers)) | ||
|
||
with dpg.group(tag='input_group'): | ||
for idx, number in enumerate(numbers): | ||
dpg.add_input_int(default_value=number, callback=update, user_data=idx) | ||
|
||
|
||
dpg.set_primary_window(primary_window, True) | ||
dpg.create_viewport(width=400, height=100, title="Data binding with list") | ||
dpg.setup_dearpygui() | ||
dpg.show_viewport() | ||
dpg.start_dearpygui() | ||
dpg.destroy_context() |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.