Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/hoffstadt/DearPyGui
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffstadt committed Oct 13, 2021
2 parents 231fad3 + e536cc8 commit 0ba779a
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 37 deletions.
2 changes: 1 addition & 1 deletion docs/source/documentation/io-handlers-state.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Handlers can be activated or deactivated by showing or hiding them.
Handlers are required to be added to a handler registry.

Item Handlers
----------------
-------------

Item handlers listen for states related to a specific item.

Expand Down
6 changes: 3 additions & 3 deletions docs/source/documentation/item-callbacks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ app_data:
print(f"app_data is: {app_data}")
with dpg.window(label="Tutorial"):
dpg.add_button(label="Apply", callback=button_callback)
dpg.add_button(label="Print to Terminal", callback=button_callback)
dpg.create_viewport(title='Custom Title', width=800, height=600)
dpg.setup_dearpygui()
Expand Down Expand Up @@ -75,10 +75,10 @@ User data can be any python object.
with dpg.window(label="Tutorial"):
# user data set when button is created
dpg.add_button(label="Apply", callback=button_callback, user_data="Some Data")
dpg.add_button(label="Print to Terminal", callback=button_callback, user_data="Some Data")
# user data and callback set any time after button has been created
dpg.add_button(label="Apply 2", tag="btn")
dpg.add_button(label="Print to Terminal 2", tag="btn")
dpg.set_item_callback("btn", button_callback)
dpg.set_item_user_data("btn", "Some Extra User Data")
Expand Down
2 changes: 1 addition & 1 deletion docs/source/documentation/item-id-system.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ be done at run time, is anonymous or sometimes just for convenience.
with dpg.window(label="Example"):
with dpg.group():
dpg.add_button(label="Press me")
dpg.add_button(label="View the Terminal for item tags")
print(dpg.last_item())
print(dpg.last_container())
print(dpg.last_root())
Expand Down
1 change: 1 addition & 0 deletions docs/source/documentation/popups.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Normally when used, a popup will be shown until you click away from it.
By default, a right click activates the popup.

**Code**

.. code-block:: python
import dearpygui.dearpygui as dpg
Expand Down
19 changes: 9 additions & 10 deletions docs/source/documentation/tables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,11 @@ You can also set the sizing policy
keyword, `policy`, using the following options


| Policy |
| ---- |
| mvTable_SizingFixedFit |
| mvTable_SizingFixedSame |
| mvTable_SizingStretchProp |
| mvTable_SizingStretchSame |
Policy:
| mvTable_SizingFixedFit
| mvTable_SizingFixedSame
| mvTable_SizingStretchProp
| mvTable_SizingStretchSame
Stretch
-------
Expand Down Expand Up @@ -405,10 +404,10 @@ the effect on the framerate listed in metrics.
for i in range(5):
dpg.add_table_column()
for i in range(7000):
with dpg.table_row():
for j in range(5):
dpg.add_text(f"Row{i} Column{j}")
for i in range(30000):
with dpg.table_row():
for j in range(5):
dpg.add_text(f"Row{i} Column{j}")
dpg.show_metrics()
Expand Down
27 changes: 19 additions & 8 deletions docs/source/tutorials/dpg-structure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,19 @@ All DPG apps must do 3 things:
* Create & Show Viewport
* Setup & Start DearPyGui

The Context
-----------

To access any DPG commands the context must be created with :py:func:`create_context <dearpygui.dearpygui.create_context>`
This should be the first DPG command and it's typical to perform this with an import.

Proper clean up of DPG can be done using :py:func:`destroy_context <dearpygui.dearpygui.destroy_context>`.

Creating and destroying the context and also setup and start dearpygui
are useful when the DPG needs to be started and stopped multiple times in one python session.

.. warning:: Creating the context must be the first call to DPG or DPG will not start (and will probably crash).
.. warning:: If :py:func:`create_context <dearpygui.dearpygui.create_context>`
is not first DPG will not start (and will probably crash).

The Viewport
------------
Expand Down Expand Up @@ -65,7 +74,8 @@ The render loop is completely handled
by the :py:func:`start_dearpygui <dearpygui.dearpygui.start_dearpygui>` command.

In some cases it's necessary to explicitly create
the render loop so you can call python commands that may need to run every frame.
the render loop so you can call python commands that may need to run every frame.
Such as per-frame ticker or counter update functions.

**Code:**

Expand Down Expand Up @@ -96,26 +106,27 @@ the render loop so you can call python commands that may need to run every frame
.. warning:: The manual render loop must be created after :py:func:`start_dearpygui <dearpygui.dearpygui.start_dearpygui>`

.. seealso:: for more information on the render loop :doc:`../documentation/render-loop`
.. seealso:: For more information on the render loop :doc:`../documentation/render-loop`

Items
---------
Item Overview
-------------

DPG can be broken down into **Items**, **UI Items**, **Containers**

Items:
Items are anything in the library (i.e. button, registries, windows, ect).

UI Items:
Any item in dpg that has a visual component (i.e. button, listbox, window, ect).
Any item in DPG that has a visual component (i.e. button, listbox, window, ect).

Containers:
Items that can hold other items. A root container is a container that has no parent container.
Items that can hold other items. (i.e. window, groups, registries, ect).

The Primary Window
------------------

DPG can assign one window to be the *primary window*, which will fill the
DPG can assign one window to be the *primary window*.
The primary window will fill the
viewport and always be drawn behind other windows.

**Code:**
Expand Down
4 changes: 2 additions & 2 deletions docs/source/tutorials/first-steps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Confirm the pip install by runing the code block below.
import dearpygui.dearpygui as dpg
dpg.create_context()
dpg.create_viewport(title='Custom Title', width=600, height=200)
dpg.create_viewport(title='Custom Title', width=600, height=300)
with dpg.window(label="Example Window"):
dpg.add_text("Hello, world")
Expand Down Expand Up @@ -60,7 +60,7 @@ The code for this can be found in the repo in the `demo.py`_ file
import dearpygui.demo as demo
dpg.create_context()
dpg.create_viewport(title='Custom Title', width=600, height=200)
dpg.create_viewport(title='Custom Title', width=600, height=600)
demo.show_demo()
Expand Down
25 changes: 13 additions & 12 deletions docs/source/tutorials/item-usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ Creating Items

Items are created using their *add_\*\*\** commands.

All items must have a unique tag which can either be specified by the keyword argument *tag*
or are automatically generated by DPG.
All items must have a tag which can either be specified or are automatically generated by DPG.

The *tags* can be either integers or strings and are
*Tags* can be either integers or strings and are
used to refer to the item after it has been created.

All items return their tag when they are created.
Items return their tag when they are created.

.. warning::
Item tags shall be unique if specified using the *tag* keyword.
Item tags must be unique if specified using the *tag* keyword.
Integers 0-10 are reserved for DPG internal items.

.. code-block:: python
Expand Down Expand Up @@ -102,7 +101,7 @@ Each of these can be accessed by their corresponding function
:py:func:`get_item_info <dearpygui.dearpygui.get_item_info>`
keywords that reflect its information (item type, children, theme, ect)

.. note:: configuration, state and info have been broken into
.. note:: configuration, state and info are been broken into
separate commands that access each individual keyword,
instead of returning the entire dictionary.

Expand Down Expand Up @@ -157,10 +156,6 @@ an item is created or at a later runtime using

Callbacks may have up to 3 arguments in the following order.

.. note:: Because they are optional positional arguments you
must use the *sender* and *app_data* if you want to use *user_data*
standard keyword arguments:

sender:
the *id* of the UI item that submitted the callback

Expand All @@ -170,6 +165,10 @@ app_data:
user_data:
any python object you want to send to the function

.. note:: Because they are optional positional arguments you
must use the *sender* and *app_data* if you want to use *user_data*
standard keyword arguments

**Code:**

.. code-block:: python
Expand Down Expand Up @@ -258,6 +257,7 @@ setting a callback to the items and printing their values.
.. image:: https://raw.githubusercontent.com/Atlamillias/DearPyGui-Stuff/main/wiki%20images/dpg_using_widgets_ex1.png


An input item's value is changed by interacting with it.
In the above example, moving slider_float1 slider to 30.55 sets its' value to 30.55.

Expand Down Expand Up @@ -287,14 +287,15 @@ We can set the position of the slider by changing items' value at runtime using
.. image:: https://raw.githubusercontent.com/Atlamillias/DearPyGui-Stuff/main/wiki%20images/dpg_using_widgets_ex2.png


.. note::
The values' type depends on the widget. (ex.) input_int default value needs to be an integer.

.. seealso::
For more information on item values :doc:`../documentation/item-value`

Item Handlers
-------------
Using Item Handlers
-------------------

UI item handlers listen for events (changes in state) related to a UI item then submit a callback.

Expand Down

0 comments on commit 0ba779a

Please sign in to comment.