![]() ![]() So if you need to access the widget from your main code, you need to know that name and it’s a good idea to give these widgets intuitive names. This name is important because when turning a GUI form into Python code, the object name will become the name of the variable containing that widget. The “Object” column lists the object name for each widget in the hierarchy. You can also drag and drop widgets onto entries in the hierarchy to add new child widgets to these entries, which can sometimes be easier than dropping them on widgets in the form, e.g., when the parent widget is rather small. You can pretty much perform the same set of operations that are available when interacting with a widget in the form (like changing its layout) with the corresponding entry in the “Object Inspector” hierarchy. This currently should show you that you have a QMainWindow widget with a QWidget for its central area, which in turn has several child widgets, namely the widgets you added to it. The one at the top called “Object Inspector” shows you the hierarchy of all the widgets of the current form. On the right side of QT Designer, there are three different panes. You can change the layout of any widget that contains other widgets in this way. See what happens if you instead change to a grid or vertical layout. Do this and pick “Lay out horizontally” which should result in all the widgets you added being arranged in a single row. When you do a right-click in an empty part of the central area of the main window form, you can pick “Lay out” in the context menu that pops up to set the layout that should be used to arrange the child widgets. Go ahead and place a few different widgets like push buttons, labels, and line edits somewhere on the main window form. ![]() Adding a widget to the current form can be done by simply dragging the widget from the pane and dropping it somewhere on the form. On the left side, you see the “Widget Box” pane that lists all the widgets available including layout widgets and spacers. Let’s quickly go through the main windows of QT Designer. After starting, QT Designer will greet you as shown in the figure below:įigure 2.22 Empty form for a new QMainWindow exe file on your desktop for the duration of the course, allowing you to directly start the application. It might be good idea to create a shortcut to this. Since you already installed PyQt5 from the ArcGIS Pro package manager, the QT Designer executable will be in your ArcGIS Pro default Python environment folder, either under "C:\Users\\AppData\Local\ESRI\conda\envs\arcgispro-p圓-clone\Library\bin\designer.exe" or under “C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-p圓\Library\bin\designer.exe”. In the following, we will take a quick look at how the QT Designer works. However, you will see an example of reading in the content of the. ui file from Python code in PyQT5 and then generating the GUI from its content, but we here will use the approach of creating the Python code with pyui5 because it is faster and allows us to see and inspect the Python code for our application. There is also support for directly reading the. ui file can then be translated into Python code with the pyuic5 GUI compiler tool that also comes with PyQT5. ui file with an xml description of the QT-based GUI. Instead of producing code from a particular programming language, it creates a. The tool itself is platform and programming language independent. QT Designer is included in the PyQT5 Python package. The GUI building tool for QT that we are going to use in this lesson is called QT Designer. ![]() The typical approach is that first the GUI is created within the graphical GUI building tool and then the tool translates the graphical design into code of the respective programming language that is then included into the main code of the new software application. So together with the advent of early GUI frameworks, people also started to look into more visual approaches in which the GUI of a new software application is clicked and dragged together from predefined building blocks. While it’s good and useful to understand how to write Python code to create a GUI directly, it’s obviously a very laborious and time consuming approach that requires writing a lot of code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |