def SLOT_comboChanged(self,text,source_d=None): ext = DEDict[str(text)].extension filepath = str(self.lineedit_path.text()) filepath,tmp = os.path.splitext(filepath) filepath += '.' + ext self.lineedit_path.setText(filepath) # TODO: problem when delete self.widget_options.hide() # replace the same filed of the new doc_opt by the old ones doc_opt = DEDict[str(text)].doc_opt.copy() if isinstance(self.widget_options,CMWidget): d = self.widget_options.getValueDict() for k, v in list(d.items()): if k in list(doc_opt.keys()): doc_opt[k] = doc_opt[k] if source_d!=None: for k, v in list(source_d.items()): if k in list(doc_opt.keys()): doc_opt[k] = v cm = CMConstantsManager.new_from_defaults(doc_opt,keys_list=self.keys_list) self.widget_options = CMWidget(cm()) self.main_layout.insertRow(self.rowWidgetOption,self.widget_options)
def SLOT_comboChanged(self,text): ext = DEDict[unicode(text)].extension filepath = unicode(self.lineedit_path.text()) filepath,tmp = os.path.splitext(filepath) filepath += '.' + ext self.lineedit_path.setText(filepath) # TODO: problem when delete self.widget_options.hide() # replace the same filed of the new doc_opt_dft by the old ones doc_opt_dft = DEDict[unicode(text)].doc_opt_dft.copy() if isinstance(self.widget_options,CMWidget): d = self.widget_options.getValueDict() for k, v in d.items(): if k in doc_opt_dft.keys(): doc_opt_dft[k] = (doc_opt_dft[k][0],v, doc_opt_dft[k][2]) cm = CMConstantsManager.new_from_defaults(doc_opt_dft,keys_list=self.keys_list) self.widget_options = CMWidget(cm()) self.main_layout.insertRow(self.rowWidgetOption,self.widget_options)
def __init__(self,dft_opening_saving_site=None, default_path='./Untitled.txt',source_d=None,*args,**kargs): """ A dialog window to deal with the exportations. source_d: the default arguments """ if dft_opening_saving_site==None: dft_opening_saving_site="" self.dft_opening_saving_site = dft_opening_saving_site QtWidgets.QDialog.__init__(self,*args) self.combo_format = QtWidgets.QComboBox ( self ) self.lineedit_path = QtWidgets.QLineEdit () self.widget_options = QtWidgets.QWidget() self.check_typo = QtWidgets.QCheckBox() self.check_typo.setToolTip('Recheck typo before export') # self.lineedit_title = QtWidgets.QLineEdit () # self.lineedit_author = QtWidgets.QLineEdit () # self.lineedit_version = QtWidgets.QLineEdit () button_export = QtWidgets.QPushButton("&Export") button_cancel = QtWidgets.QPushButton("&Cancel") button_browse = QtWidgets.QPushButton("&Browse") layout_path = QtWidgets.QHBoxLayout() layout_path .addWidget(self.lineedit_path ) layout_path .addWidget(button_browse ) layout_button = QtWidgets.QHBoxLayout() layout_button.addWidget( button_export ) layout_button.addWidget( button_cancel ) self.main_layout=QtWidgets.QFormLayout() self.main_layout.addRow('Format',self.combo_format) self.main_layout.addRow('Path' ,layout_path) self.main_layout.addRow(self.widget_options) self.main_layout.addRow('Recheck Typo',self.check_typo) self.rowWidgetOption = self.main_layout.rowCount()-1 self.main_layout.addRow(layout_button) self.setLayout ( self.main_layout ) # def if source_d==None: source_d={} self.source_d = CMConstantsManager.new_from_defaults( source_d,keys_list=self.keys_list)() # # fill the fileds list_extension = list(DEDict.keys()) self.combo_format.addItems(list_extension) self.lineedit_path.setText(default_path) # Connections: button_export.clicked.connect(self.accept) button_cancel.clicked.connect(self.reject) button_browse.clicked.connect(self.SLOT_browse) self.combo_format.activated[str] .connect( self.SLOT_comboChanged ) # to put filepath to the correct extension : self.SLOT_comboChanged(self.combo_format.currentText(), source_d=source_d)
def __init__(self,a=None): if type(a)==list or type(a)==unicode: a = CMConstantsManager.str_to_dict(a,{unicode:unicode}) COContrainedDict.__init__(self,a)