Reputation: 1845
I made a gui using Pyqt earlier. I did all the coding on the terminal in Linux. Now I am going to make a big project in Pyqt.
Is there any sdk which will help me to overcome the coding part, so I can just drag and drop the items? I know about qt designer, but I don't know how I should write and integrate it with Python.
Do you have suggestions on what program to use for this?
Upvotes: 0
Views: 1050
Reputation: 92559
Qt Designer when coupled with PyQt4 is usually used only for the layout process, as opposed to defining signals, buddies, etc. You perform the visual layout of your widgets, and save the .ui
file.
Using pyuic4
, you can then compile the .ui
-> .py
, and import that into your coded project.
Though there are probably 3 different approaches to using the UI at this point, what I typically do is multiple inheritance. If class MyMainWindow
is meant to be a QMainWindow, then I inherit my class from QMainWindow, and the UI class.
Something like this...
pyuic4 myMainWindow.ui -o myMainWindowUI.py
main.py
from PyQt4 import QtGui
from myMainWindowUI import Ui_MainWindow
class MyMainWindow(QtGui.QMainWindow, Ui_MainWindow):
def __init__(self, *args, **kwargs)
super(MyMainWindow, self).__init__(*args, **kwargs)
self.setupUi(self)
The setupUi
method applies your entire UI design to the class and you can now access all of the widgets you designed by their object names.
win = MyMainWindow()
print win.listWidget
print win.button1
win.show()
Upvotes: 3
Reputation: 5877
See Creating interfaces visually with designer
if using pyqt4 use pyuic4
if using pyside use pyside-uic
These compile the output from QTDesigner into a python file.
You can google you way to usage of these command line tools but Riverbank is usually a good reference
Upvotes: 1