cfg
에 저장되어있는 기존 옵션으로 미리 채우는 구성 대화 상자가 있습니다. 사용자가 "저장"(또는 이에 상응하는)을 클릭하면 QLineEdit 객체에서 새 값을 가져와야합니다. 내가 그걸 알아낼 수 없다는 걸 제외하고. 나는 어제 저녁부터 인터넷 검색 및 테스트를 해왔다. 내가 다시 구부린 무릎에 오기 전에.PyQt5에서 변경된 데이터 얻기 QDialog
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)
나는 변경 필드에서 얻을 일부 부두가 필요합니다 : 여기 내 대화 코드 (양식에는 GUI 코드가 없습니다 왜 Qt는 디자이너 출신)이다. 지금 내가 얻을 수있는 것은 대화가 현실화되었을 때의 원래 값입니다. 이 트릭이 있습니까? 대화 상자를 미리 채울 수있는 첫 번째 사람이 될 수 없습니다. 나는 button과 buttonBox 변형의 모든 조합을 시도해 봤다.
대화 상자를 숨기고 데이터를 가져온 다음 대화 상자를 파괴 할 수있는 방법이 있을지 모릅니다. 그것은 어쨌든 하나의 작동 이론입니다.
미리 감사드립니다.
당신을 도울 cfg 이외에 Qt 디자이너의 디자인을 공유하십시오. – eyllanesc
config 파일의 개요 (ConfigParser 모듈에서 읽음), config.ui의 XML 및 생성 된 Python 파일 ... https://gist.github.com/bundito/e6656928dedc61fa45fa2e1b90b18b12 – Dito
내 대답보기. – eyllanesc