2

I have previously use the following steps to load PyQt ui into python.
1.Use designer to create the ui file
2.Go to dos and use pyuic4 to convert the ui files into python(MyQtUI.py)
3.Import in the python files

from MyQtUI import UI_Mainwindow

Class MyUi(QtGui.QMainWindow):
    def __init__(self,parent=none): 
        QtGui.Qwidget.__init__(self,parent)
        self = Ui_MainWindow()
        self.setupUi(self)
        self.ui.comboBox_Title.addItems("a","b","c")
        .
        .
        .
    def check_radioButtonStatus(self):
        print self.ui.radioBtnGrp_confirmed.checkedButton().objectName()

I have no problem running the above code but when i tried the other method which is using uic.loadUi, my button group could not be recognized.

Class MyUi(QtGui.QMainWindow):
    def __init__(self,parent=none): 
        QtGui.Qwidget.__init__(self,parent)
        uic.loadUi('MyQtUi.ui',self)
        self.comboBox_Title.addItems("a","b","c") <--- no problem here
        .
        .
        .
    def check_radioButtonStatus(self):
        print self.radioBtnGrp_confirmed.checkedButton().objectName() <--- object has no attribute 'radioBtnGrp_confirmed'

Thanks for any help

Reinhart
  • 31
  • 3
  • Some possibilities: 1) You redefined self (same as you did in the first example), 2) You need to call setupUi() – Radio- Aug 13 '13 at 07:35
  • 1
    Thanks for the suggestions. self is already define in the loadUi function as the 2nd parameter and setupUi() is a function from the python file. As I'm trying to load the ui file directly without importing the python file, I wont have setupUi() to use. – Reinhart Aug 14 '13 at 03:40
  • Did you mean `self.ui = Ui_MainWindow()` and `self.ui.setupUi(self)` in the 1st example ? – Frodon Aug 21 '13 at 21:03
  • Concerning the 2nd example, either you deleted the object somewhere, either it is not in the ui file. – Frodon Aug 21 '13 at 21:07

0 Answers0