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.
Sign up for your weekly dose of what's up in emerging technology.
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.
Like any other python library, we will install Dearpygui using pip install dearpygui.
- 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.
from dearpygui.dearpygui import *
- 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.
add_text('DearPyGUI Generated This Text')
add_text('Below You Will See two buttons')
add_same_line(spacing=30) #Adding a space on the same line
- 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_text("Below You will See a Check Box and a Radio Button")
- 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")
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.
- Creating Visualizations
We will create a new window with a new size and visualize different plots on it.
add_simple_plot("Lineplot", [1, 4, 2, 8, 12], height=180)
add_simple_plot("Histogram", [1,4,2,8,12], height=180, histogram=True)
Visualizations created using Dearpygui are highly interactive and informative.
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)
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.
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.