简体   繁体   中英

Using Qt designer and python in ubuntu

I am a new Ubuntu user and want to do my coding using Python and incorporating Qt designer for my forms (interface). I open the designer and put up some controls on the forms or widgets but I get problems on how to include the form I made in my Python codes. I try using the Import style for my .ui but to no avail. Please help on how I should go about this issue. Here is what I have: Mwakenya is the .ui file I created on Qt designer.

from pyQt import *
from mwakenya.ui import *

class at(mwakenya):
    def __init__(self, parent=None, name=None, fl=0):
        mwakenya.__init__(self,parent,name,fl)

if __name__ == "__main__":
    import sys
    a = QApplication(sys.argv)
    QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
    w = at()
    a.setMainWidget(w)
    w.show()
    a.exec_loop()

You need to compile your .ui files, into python code.

You can do this with the pyuic command.

eg.

pyuic mwakenya.ui -o mwakenya_ui.py

You then import mwakenya_ui.py

See here for more information:

http://manpages.ubuntu.com/manpages/hardy/man1/pyuic4.1.html

Users of KDE should look for pykdeuic , which performs the same job.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM