这个是uitest.py文件的
if __name__ == "__main__":
global ui
import sys
app = QtGui.QApplication(sys.argv)
Dialog = QtGui.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
这个是另一个py文件,我想调用上面那个py文件的ui变量,然后报错'module' object has no attribute ‘ui'
uitest.ui.tableWidget.setColumnCount(9)
巴扎黑2017-04-18 10:12:08
I don’t quite understand why the questioner did this, but if you want to get the variables of another file, I suggest you write a function, which is better.
For example, if the variable ui you want to call is in the test1.py file, then you can write such a function in test1.py
class Test():
def __init__():
...
def getUi():
return ui
Then in test2.py code example:
test = Test()
ui = test.getUi()
That’s it
阿神2017-04-18 10:12:08
How did you import uitest?
Change it to this~
global ui
if __name__ == "__main__":
#…………