2
我的问题是: 如何从包中更改标签(或其他图形元素)? 这个想法是减轻我的主要方案。 谢谢!PyQt:如何从包中更改标签文本
前主程序:
#../mainprogram.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from PyQt5 import QtWidgets
from ui import Ui_MainWindow
from package import update
class MainWindow(QtWidgets.QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
# label from .ui -> .py
self.ui.label_1.setText("need to change this")
def update_label(self):
self.update = update.label_update()
前包:
#../package/update.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def label_update():
self.ui.label_1.setText("no problem")
它很好用,谢谢! 在我的情况下,我需要存储上述过程,将像素图从绿色变为红色。 这是减轻主程序的最佳方式吗? – cheetOos