![]() ![]() Print('Favorite language: '.format(language)) Self.line = (QLineEdit, 'lineEdit')ītn = (QPushButton, 'pushButton') So I looked up some other examples on other websites and eventually put the following together:įrom PySide2.QtWidgets import QApplication, QPushButton, QLineEditįrom PySide2.QtCore import QFile, QObjectĭef _init_(self, ui_file, parent=None): Frankly, I thought this was kind of a dumb example. While this works, it doesn't really show you how to hook up events or get anything useful out of the user interface. The first is taken pretty much wholesale from Qt for Python's wiki:įrom PySide2.QtWidgets import QApplication There are a couple of different ways that I discovered I could use to load the UI file in Qt for Python (PySide2). Now we just need to learn how to load this file in Qt for Python. When I saved the file, I got the following in my UI file: MainWindow 0 0 400 300 MainWindow 160 210 80 25 OK 130 30 113 25 20 30 111 17 Favorite Language: 0 0 400 22 Test TopToolBarArea false You can just double-click it or click on the Design button that should be on the left-hand side of the program. Then I opened up the mainwindow.ui that Qt Creator made for me. Then I chose the "Qt Widgets Application" choice. Creating the User Interfaceįor this example, I opened up Qt Creator and went to File -> "New File or Project". Qt Creator / Designer will generate an XML file with a *.ui extension that you can then load inside of your PySide2 application (or PyQt). This is actually very similar to the way you would create an interface using Visual Studio. If you don't know, PyQt and PySide / PySide2 can use the Qt Creator application to create user interfaces using a drag-and-drop interface. PySide2) was announced recently and got me interested in trying to use it to load up a UI file.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |