I am working on a user interface in PyQt and am having problems using QDialog. Essentially, I have a main widget and a sub-widget stored in separate .py files; I would like the sub-widget to open when I click on a specific button in the main widget. This seems to be normal.
The problem is with return and closing. I have a send button in my subviewer - when the user clicks on this button, I would like to return the value (the dictionary made from their input) to the main widget and close the sub-widget. I cannot do any of this with the code that I have now.
Applicable code bits in the main widget (you can add more to make it standalone if the problem is not obvious):
import SGROIWidget_ui def retranslateUi(self, ROIGUI):
It seems I never got into the code after the if-statement.
The applicable code from my sub-widget (there will be a bit more here):
try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: def _fromUtf8(s): return s try: _encoding = QtGui.QApplication.UnicodeUTF8 def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig, _encoding) except AttributeError: def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig) class Ui_ShowGroupWidget(QtGui.QWidget): def __init__(self): QtGui.QWidget.__init__(self) self.setupUi(self) def setupUi(self, ShowGroupWidget):
* I also tried ex.close (), but ex is not recognized when this widget starts as a dialog. It seems that it should not fall into this line due to the return statement, but I do not know how else to close this widget after the user clicks "send". Or should the .accept () dialog in my main widget handle this?
Last: do I need this in my sub-widget at all, because it launches through my main widget?
if __name__=='__main__': app=QtGui.QApplication(sys.argv) ex=Ui_ShowGroupWidget() ex.show() sys.exit(app.exec_())
Thanks in advance! I'm new to PyQt, so hopefully this is somewhat legible.
python user-interface qt pyqt qdialog
Emily c
source share