我在python3.3中使用PyQt4,制作了一个GUI并有多个类,其中一些类在单击某个按钮之前不想运行。如何连接这样一个类,使其仅在单击按钮时运行,而不在程序启动时运行。 下面是我当前如何将这个类连接到另一个类中的按钮。你知道吗
btns.clicked.connect(self.tableshow2)
def tableshow2(self):
table5.show()
这是第一个有按钮的班级。你知道吗
class CustTableSearch(QtGui.QDialog):
def __init__(self, parent=None):
super(CustTableSearch, self).__init__(parent)
with sqlite3.connect('database.db') as db:
cursor=db.cursor()
num = QtGui.QInputDialog.getText(self, 'Insert TelephoneNumber',
'Enter TeleNum:')
table5 = CustTableSearch()
这是按钮激活的类的一部分,在pythonshell启动时运行。我试着用按钮把它放到类中的函数中,但是我不能用.show()显示它(这是一个带表的屏幕)。你知道吗
一种方法是只按需创建对话框,而不是在加载模块时立即创建对话框。你知道吗
假设两个类在同一个模块中,您可以在
tableshow2(self)
方法中创建CustomTableSearch
的实例。你知道吗相关问题 更多 >
编程相关推荐