我得到了一个配置对话框,其中预先填充了存储在cfg中的现有选项。当用户单击“保存”(或等效项)时,我需要从QLineEdit对象中获取新值。只是我搞不懂这一点。我从昨天晚上开始就一直在搜索和测试,直到我再次屈膝来到这里。下面是我的对话框代码(窗体来自Qt Designer,这就是为什么没有GUI代码):
class Config(QDialog):
def __init__(self):
super(Config, self).__init__()
popup = QDialog()
config_ui = configform()
config_ui.setupUi(popup)
config_ui.programver.setText(cfg['config']['programver'])
if cfg['config']['dummycopy']:
config_ui.democheck.setChecked(True)
config_ui.tmdbAPIkey.setText(cfg['config']['TMDB_KEY'])
config_ui.tvdbAPIkey.setText(cfg['config']['TVDB_KEY'])
config_ui.tvdbUserkey.setText(cfg['config']['TVDB_USERKEY'])
theme = cfg['config']['theme']
if theme == "blue":
config_ui.bluebutton.setChecked(True)
elif theme == "yellow":
config_ui.yellowbutton.setChecked(True)
elif theme == "light":
config_ui.lightmetalbutton.setChecked(True)
elif theme == "dark":
config_ui.darkmetalbutton.setChecked(True)
programversion = config_ui.programver.text()
config_ui.savebutton.clicked.connect(lambda: Config.save(self, programversion))
popup.exec_()
def save(self, programversion):
QDialog.close(self)
print(programversion)我需要一些伏都教才能到达改变过的地方。我现在所能得到的是对话框被赋予生命时的原始值。这有什么窍门吗?我不可能是第一个尝试预先填充对话框的人。我发誓我已经尝试了所有可用的button和buttonBox变体的组合。
我在想,也许有一些方法可以隐藏对话框,抓取数据,然后销毁对话框?不管怎样,这是一个可行的理论。
提前谢谢。
https://stackoverflow.com/questions/47699451
复制相似问题