我有这样的想法:
class Main(QWidget):
def __init__(self):
super().__init__()
def init_gui(self):
self.layout = QGridLayout()
self.setLayout(self.layout)
self.button_sett()
self.show()
def button_sett(self):
button = QPushButton()
menu = QMenu()
menu.addAction("Settings", self.switch_page)
menu.addAction("About", self.switch_page)
button.setMenu(menu)
我能告诉函数一个动作的textContent
吗
像这样:
def switch_page():
if textContent == "Settings":
.......
有更好的办法吗?我不想编写像switch_page_to_settings
和switch_page_to_about
这样的函数,因为我在按钮上有更多的操作
λ等于:
相关问题 更多 >
编程相关推荐