Now Reading
Complete Tutorial on DearPyGui – GPU Accelerated Python GUI Framework

Complete Tutorial on DearPyGui – GPU Accelerated Python GUI Framework

DearpyGUI Framework

Graphical User Interface provides interaction between the user and the application. With the help of different widgets and functions, we can create a GUI of an application. Different indicators like buttons, text boxes, checkboxes can be used to build the GUI of an application.    

DearPyGUI is a powerful python GUI framework which is easy to use and is a wrapper for Dearlmgui. Dearpygui is not an ordinary python GUI framework as it does not use the native widgets but instead draws the widgets using the system’s GPU. It is an all-included GUI framework which means that it can perform and create each and every widget that is used to make GUI interfaces.

Register for our upcoming Masterclass>>

In this article, we will explore what are the different types of widgets that we can create using Dearpygui also we will see how we can leverage visualizations using Dearpygui.

Implementation:

Like any other python library, we will install Dearpygui using pip install dearpygui.

  1. Importing Required Libraries

We will start by importing dearpygui to look at the creation of the different widgets. We will import any other library required as and when required.

Looking for a job change? Let us help you.

from dearpygui.dearpygui import *

  1. Creating Different Widgets

As dearpygui supports a large variety of we will now explore some of the most used widgets and how we can create them. While creating an interface we need to end the python script with start_dearpygui() to launch the interface. 

  • Text Box and clickable Buttons

We can create different types of widgets using different parameters. Let us start by creating a text box and a button. We will also define and fix the Main Window Size.

set_main_window_size(400, 400)

add_text('DearPyGUI Generated This Text')

add_text('Below You Will See two buttons')

add_button("Button 1")

add_same_line(spacing=30) #Adding a space on the same line

add_button("Button 2")

start_dearpygui()

Main Window
  • Radio Button and CheckBox

Next, we will see how we can create radio buttons and checkboxes. We will add all the widgets in the same window.

add_spacing(count=4)

add_text("Below You will See a Check Box and a Radio Button")

add_checkbox("Checkbox")

start_dearpygui()

Radio Button and Check Box
  • Menu Bar and Menu Item

Dearpygui gives us the option of creating a menu bar and menu items to it. Let us see how we can create a menu bar. We will add this menu bar to the top of the window and some items to it.

add_menu_bar("Main Menu Bar")

add_menu("Format")

add_menu_item("form1")

add_menu_item("form2")

add_menu_item("form3")

add_spacing(count=5)

start_dearpygui()

See Also

Menu Bar, DearPyGui

Here we have created a dropdown menu that opens up as soon as we click it. Next, we will see how we can plot visualizations on our main window using Dearpygui.

  1. Creating Visualizations

We will create a new window with a new size and visualize different plots on it.

set_main_window_size(800, 800)

add_simple_plot("Lineplot", [1, 4, 2, 8, 12], height=180)

add_simple_plot("Histogram", [1,4,2,8,12], height=180, histogram=True)

start_dearpygui()

Visualization, DearPyGui

Visualizations created using Dearpygui are highly interactive and informative.

  1. Drawing/Canvas 

DearPyGui has a drawing API that is well suited for primitive drawing, custom widgets, or even dynamic drawings. Let’s see how we can use the drawing feature.

add_drawing("First_Drawing", width=300, height=300)

draw_circle("First_Drawing", [150, 150], radius=50, color=[255, 255, 255, 255], segments=0)

start_dearpygui()

Drawing Canvas, DearPyGui

Other than this dearpygui also allows you to select a theme of your own choice or even create your own theme.

This is an introduction to the basic functionalities of dearpygui, it contains a lot more functions that you can explore according to your requirements.

Conclusion:  

In this article, we saw how powerful and easy to use Dearpygui is when we created a variety of widgets and visualized them in the window. We saw how we can visualize highly interactive plots in just a single line of code, we also saw the drawing capabilities of dearpygui which makes it a lot different from other general GUI frameworks. We can say that dearpygui contains a vast number of functionalities that you can use and explore according to your requirements.

What Do You Think?

Join Our Discord Server. Be part of an engaging online community. Join Here.


Subscribe to our Newsletter

Get the latest updates and relevant offers by sharing your email.

Copyright Analytics India Magazine Pvt Ltd

Scroll To Top