def __init__(self, config=None): QtGui.QDialog.__init__(self) self.ui = Ui_Dialog() self.ui.setupUi(self) self.accepted.connect(self.saveFromUI) if config: self.config = config self.populateUI() self.ui.emailLine.setFocus()
class ConfigUI(QtGui.QDialog): def __init__(self, config=None): QtGui.QDialog.__init__(self) self.ui = Ui_Dialog() self.ui.setupUi(self) self.accepted.connect(self.saveFromUI) if config: self.config = config self.populateUI() self.ui.emailLine.setFocus() def populateUI(self): # account tab self.ui.emailLine.setText(self.config['user']['email']) self.ui.emailLine.setToolTip(format_comment(config['user'].comments['email'])) self.ui.passwdLine.setText(self.config['user']['password']) self.ui.passwdLine.setToolTip(format_comment(config['user'].comments['password'])) self.ui.connectBox.setChecked(self.config['user'].as_bool('auto_connect')) self.ui.connectBox.setToolTip(format_comment(config['user'].comments['auto_connect'])) # data tab self.ui.saveCsvBox.setChecked(self.config['data'].as_bool('save_csv')) self.ui.saveCsvBox.setToolTip(format_comment(config['data'].comments['save_csv'])) self.ui.csvPathLine.setText(self.config['data']['csv_path']) self.ui.csvPathLine.setToolTip(format_comment(config['data'].comments['csv_path'])) self.ui.csvFormatLine.setText(self.config['data']['csv_format']) self.ui.csvFormatLine.setToolTip(format_comment(config['data'].comments['csv_format'])) self.ui.saveXmlBox.setChecked(self.config['data'].as_bool('save_xml')) self.ui.saveXmlBox.setToolTip(format_comment(config['data'].comments['save_xml'])) self.ui.xmlPathLine.setText(self.config['data']['xml_path']) self.ui.xmlPathLine.setToolTip(format_comment(config['data'].comments['xml_path'])) self.ui.saveTcxBox.setChecked(self.config['data'].as_bool('save_tcx')) self.ui.saveTcxBox.setToolTip(format_comment(config['data'].comments['save_tcx'])) self.ui.tcxPathLine.setText(self.config['data']['tcx_path']) self.ui.tcxPathLine.setToolTip(format_comment(config['data'].comments['tcx_path'])) def saveFromUI(self): # account tab self.config['user']['email'] = self.ui.emailLine.text() self.config['user']['password'] = self.ui.passwdLine.text() self.config['user']['auto_connect'] = self.ui.connectBox.isChecked() # data tab self.config['data']['save_csv'] = self.ui.saveCsvBox.isChecked() self.config['data']['csv_path'] = self.ui.csvPathLine.text() self.config['data']['csv_format'] = self.ui.csvFormatLine.text() self.config['data']['save_xml'] = self.ui.saveXmlBox.isChecked() self.config['data']['xml_path'] = self.ui.xmlPathLine.text() self.config['data']['save_tcx'] = self.ui.saveTcxBox.isChecked() self.config['data']['tcx_path'] = self.ui.tcxPathLine.text() self.config.write() self.config.reload()
class ConfigUI(QtGui.QDialog): def __init__(self, config=None): QtGui.QDialog.__init__(self) self.ui = Ui_Dialog() self.ui.setupUi(self) self.accepted.connect(self.saveFromUI) if config: self.config = config self.populateUI() self.ui.emailLine.setFocus() def populateUI(self): # account tab self.ui.emailLine.setText(self.config['user']['email']) self.ui.emailLine.setToolTip( format_comment(config['user'].comments['email'])) self.ui.passwdLine.setText(self.config['user']['password']) self.ui.passwdLine.setToolTip( format_comment(config['user'].comments['password'])) self.ui.connectBox.setChecked( self.config['user'].as_bool('auto_connect')) self.ui.connectBox.setToolTip( format_comment(config['user'].comments['auto_connect'])) # data tab self.ui.saveCsvBox.setChecked(self.config['data'].as_bool('save_csv')) self.ui.saveCsvBox.setToolTip( format_comment(config['data'].comments['save_csv'])) self.ui.csvPathLine.setText(self.config['data']['csv_path']) self.ui.csvPathLine.setToolTip( format_comment(config['data'].comments['csv_path'])) self.ui.csvFormatLine.setText(self.config['data']['csv_format']) self.ui.csvFormatLine.setToolTip( format_comment(config['data'].comments['csv_format'])) self.ui.saveXmlBox.setChecked(self.config['data'].as_bool('save_xml')) self.ui.saveXmlBox.setToolTip( format_comment(config['data'].comments['save_xml'])) self.ui.xmlPathLine.setText(self.config['data']['xml_path']) self.ui.xmlPathLine.setToolTip( format_comment(config['data'].comments['xml_path'])) self.ui.saveTcxBox.setChecked(self.config['data'].as_bool('save_tcx')) self.ui.saveTcxBox.setToolTip( format_comment(config['data'].comments['save_tcx'])) self.ui.tcxPathLine.setText(self.config['data']['tcx_path']) self.ui.tcxPathLine.setToolTip( format_comment(config['data'].comments['tcx_path'])) def saveFromUI(self): # account tab self.config['user']['email'] = self.ui.emailLine.text() self.config['user']['password'] = self.ui.passwdLine.text() self.config['user']['auto_connect'] = self.ui.connectBox.isChecked() # data tab self.config['data']['save_csv'] = self.ui.saveCsvBox.isChecked() self.config['data']['csv_path'] = self.ui.csvPathLine.text() self.config['data']['csv_format'] = self.ui.csvFormatLine.text() self.config['data']['save_xml'] = self.ui.saveXmlBox.isChecked() self.config['data']['xml_path'] = self.ui.xmlPathLine.text() self.config['data']['save_tcx'] = self.ui.saveTcxBox.isChecked() self.config['data']['tcx_path'] = self.ui.tcxPathLine.text() self.config.write() self.config.reload()