When running code the dialogues of the program do not show.
I Know this is probably a silly question, but being very new to python and having hunted for a decent IDE before finding PyCharm, which seems great by the way, I just cant get my forms to show when running the code through PyCharm. I receive no error messages etc, so am pretty sure the code is fine. Also when I run the code through IDLE the program works fine. I am sure it si simply my ignorance of PyCharm, but would appreciate being pointed in the right direction.
Thanks
here is the code by the way
The Diag class
from PySide import QtCore, QtGui
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(400, 300)
self.pushButton = QtGui.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(110, 80, 75, 23))
self.pushButton.setObjectName("pushButton")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton.setText(QtGui.QApplication.translate("Dialog", "testbtn", None, QtGui.QApplication.UnicodeUTF8))
and then the calling code:
import sys
from PySide.QtCore import *
from PySide.QtGui import *
import diagtest
class MainDialog(QDialog,diagtest.Ui_Dialog):
def __init(self,parent=None):
super(MainDialog,self).__init__(parent)
self.setupUi(self)
app = QApplication(sys.argv)
frm = MainDialog()
frm.show()
app.exec_()
Thanks
here is the code by the way
The Diag class
from PySide import QtCore, QtGui
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(400, 300)
self.pushButton = QtGui.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(110, 80, 75, 23))
self.pushButton.setObjectName("pushButton")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton.setText(QtGui.QApplication.translate("Dialog", "testbtn", None, QtGui.QApplication.UnicodeUTF8))
and then the calling code:
import sys
from PySide.QtCore import *
from PySide.QtGui import *
import diagtest
class MainDialog(QDialog,diagtest.Ui_Dialog):
def __init(self,parent=None):
super(MainDialog,self).__init__(parent)
self.setupUi(self)
app = QApplication(sys.argv)
frm = MainDialog()
frm.show()
app.exec_()
Please sign in to leave a comment.
I have also encountered it, it seems to be a "working directory".
this setting problem, how to change it requires you to study it yourself, everyone is different. The directory is usually set to your home directory, which is the directory where `main.py` is located.