【发布时间】:2015-02-28 01:10:08
【问题描述】:
我有 2 个使用 qt-designer 创建的 GUI,并将其转换为 python - anmUi.py 和 anmInfoUI.py
虽然我可以通过运行以下命令导入并打开anmUi:
import sys
sys.path.insert(0, '/user_data/test/anm/versions')
import anmTool_v01a
reload(anmTool_v01a)
win = anmTool_v01a.anmUi()
win.show()
但是,我在打开第二个 gui - anmInfoUI 时遇到了问题,这是由第一个 gui 中的按钮启动的。
我尝试使用与第一个 gui 类似的格式进行编写,但是当我尝试使用 .exec 运行它时,出现了诸如 # AttributeError: 'module' object has no attribute 'exec_' 之类的错误。
class anmUi(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self, parent = None, modal = False)
self.ui = anmUi.Ui_Migration()
self.ui.setupUi(self)
self.createConnections()
def createConnections(self):
self.connect(self.ui.pushButton_editSelected, QtCore.SIGNAL('clicked()'), self.editSelected)
def editSelected(self):
selected_item = self.ui.treeWidget_migrateAnmg.selectedItems()
if selected_item:
anmInfoUI.exec_()
class anmInfoUI(QtGui.QDialog):
def __init__(self, parent = None, modal = False):
QtGui.QWidget.__init__(self, parent, modal = modal)
self.ui = anmInfoUI.Ui_EditInfo()
self.ui.setupUi(self)
如何让它运行?
【问题讨论】:
-
请提供您调用
exec_的代码,它不起作用(所有相关代码)。在任何人可以帮助您之前,有必要知道您在做什么 -
@three_pineapples 我已经编辑了我帖子中的代码,如上所示
标签: python user-interface pyqt