Loading src/gui.py +46 −29 Original line number Diff line number Diff line Loading @@ -75,9 +75,9 @@ class Ui(QtWidgets.QMainWindow): # Instances to widget saves self.rbg = {} # buttongroups self.rb = {} # radiobuttons self.rbTypes, self.rbNames = [], [] # self.rbTypes, self.rbNames = [], [] self.cb = {} # checkboxs self.cbColumns, self.cbNames = [], [] # self.cbColumns, self.cbNames = [], [] self.tb = {} # textbox # Add dynamic widgets for tconf in config: Loading Loading @@ -116,6 +116,8 @@ class Ui(QtWidgets.QMainWindow): gb = newGroupBox(id, name, QtWidgets.QSizePolicy(policy.Minimum, policy.Maximum)) if 'elements' in tconf and len(tconf['elements']) > 0: self.cb[id] = {} for element in tconf['elements']: try: eid = element['id'] Loading @@ -130,9 +132,9 @@ class Ui(QtWidgets.QMainWindow): gb.layout().addWidget(widget, count//cols, count%cols) count += 1 # save widget self.cb[eid] = widget self.cbColumns.append(eid) self.cbNames.append(wid) self.cb[id][eid] = widget # self.cbColumns.append(eid) # self.cbNames.append(wid) except KeyError as e: print(f"KeyError: {e}") Loading @@ -146,6 +148,8 @@ class Ui(QtWidgets.QMainWindow): gbb = QtWidgets.QButtonGroup() gbb.setObjectName(f"gbb_{id}") if 'elements' in tconf and len(tconf['elements']) > 0: self.rb[id] = {} for element in tconf['elements']: element:dict try: Loading @@ -162,9 +166,9 @@ class Ui(QtWidgets.QMainWindow): gb.layout().addWidget(widget, count//cols, count%cols) count += 1 # save widget self.rb[eid] = widget self.rbTypes.append(eid) self.rbNames.append(wid) self.rb[id][eid] = widget # self.rbTypes.append(eid) # self.rbNames.append(wid) # shortcut label if 'shortcut' in element.keys(): Loading Loading @@ -196,12 +200,17 @@ class Ui(QtWidgets.QMainWindow): except: raise # Dynamic COLUMNS utils.IDS['FILE'] = list(df.columns) utils.IDS['TB'] = list(self.tb.keys()) utils.IDS['CB'] = self.cbColumns utils.IDS['RB'] = list(self.rb.keys()) + [""] for _, cb in self.cb.items(): utils.IDS['CB'].extend(list(cb.keys())) utils.IDS['RBG'] = list(self.rbg.keys()) for _, rb in self.rb.items(): utils.IDS['RB'].extend(list(rb.keys())) utils.IDS['RB'].extend([""]) utils.COLUMNS = utils.IDS['FILE'] + utils.IDS['RBG'] + utils.IDS['CB'] + utils.IDS['TB'] for v in ['ra', 'dec']: Loading @@ -216,11 +225,10 @@ class Ui(QtWidgets.QMainWindow): # DONE 1 - utils COLUMNS and MORPHO need to be dinamic # DONE 2 - aboid finding cb and rb maybe safe them in creation # DONE 3 - get radio button ischecked from ButtonGroup # DONE 4 - dinamic input file, independent form group. # also, HEADER created from this file # DONE 5 - output file keys have to be dinamic (related to input file and COLUMNS) # also, newEntry func # 6 - what if multiple same named widgets? add groupid to widgetid? # DONE 4 - dinamic input file, independent form group. also, HEADER created from this file # DONE 5 - output file keys have to be dinamic (related to input file and COLUMNS). also, newEntry func # DONE 6 - what if multiple same named widgets? add groupid to widgetid? # 6.5 - what if multiple same named widgets? outputfile names should include widgetgroup id? # 7 - multiple commentBox not supported (yes, but events need to be solved) # 8 - If filename not in input file, detect images (currently fails) # DONE 9 - Shortcuts not working Loading Loading @@ -364,11 +372,11 @@ class Ui(QtWidgets.QMainWindow): for id, bg in self.rbg.items(): selected = '' if bg.checkedButton() is not None: idChecked = bg.checkedButton().objectName() idChecked:str = bg.checkedButton().objectName() selected = idChecked.split('_',1)[-1] # refactor rbTypes and rbNames? selected = self.rbTypes[self.rbNames.index(idChecked)] #selected = self.rbTypes[self.rbNames.index(idChecked)] self.df.loc[item_index, id] = selected # for radio in self.rbTypes: # if(self.rb[radio].isChecked()): # self.df.loc[item_index, 'morphology'] = radio Loading @@ -376,8 +384,11 @@ class Ui(QtWidgets.QMainWindow): # else: # self.df.loc[item_index, 'morphology'] = utils.getMorphology()[-1] for column in self.cbColumns: self.df.loc[item_index, column] = self.cb[column].isChecked() for id, cb in self.cb.items(): for eid, wcb in cb.items(): self.df.loc[item_index, eid] = wcb.isChecked() # for column in self.cbColumns: # self.df.loc[item_index, column] = self.cb[column].isChecked() for id, tb in self.tb.items(): self.df.loc[item_index, id] = tb.toPlainText().replace('\n', '') Loading Loading @@ -423,17 +434,20 @@ class Ui(QtWidgets.QMainWindow): for id, bg in self.rbg.items(): self.clear_ButtonGroup(bg) selected = item[id].item() if selected in self.rbTypes: idChecked = self.rbNames[self.rbTypes.index(selected)] # refactor rbTypes and rbNames? self.rb[selected].setChecked(True) if selected in self.rb[id].keys(): # idChecked = self.rbNames[self.rbTypes.index(selected)] # refactor rbTypes and rbNames? self.rb[id][selected].setChecked(True) # for radio in self.rbTypes: # if(item['morphology'].item() == radio): # self.rb[radio].setChecked(True) # checkboxes for cb in self.cbColumns: self.cb[cb].setChecked(item[cb].item()) for id, cb in self.cb.items(): for eid, wcb in cb.items(): wcb.setChecked(item[eid].item()) # for cb in self.cbColumns: # self.cb[cb].setChecked(item[cb].item()) # textboxes for id, tb in self.tb.items(): Loading @@ -452,8 +466,11 @@ class Ui(QtWidgets.QMainWindow): print(f"WARNING:\tEmpty item. [{e}]") self.imgPath = self.defaultImgPath self.setWindowTitle(self.title) for cb in self.cbColumns: self.cb[cb].setChecked(False) for _, cb in self.cb.items(): for _, wcb in cb.items(): wcb.setChecked(False) # for cb in self.cbColumns: # self.cb[cb].setChecked(False) self.showImage(self.imgPath) Loading src/utils.py +1 −1 Original line number Diff line number Diff line Loading @@ -196,7 +196,7 @@ def getRadioButtonGroups(): return IDS['RBG'] def getRadioButtonsNames(): return IDS['RB'][:-1] return IDS['RB'] def getCheckBoxesColumns(): return IDS['CB'] Loading Loading
src/gui.py +46 −29 Original line number Diff line number Diff line Loading @@ -75,9 +75,9 @@ class Ui(QtWidgets.QMainWindow): # Instances to widget saves self.rbg = {} # buttongroups self.rb = {} # radiobuttons self.rbTypes, self.rbNames = [], [] # self.rbTypes, self.rbNames = [], [] self.cb = {} # checkboxs self.cbColumns, self.cbNames = [], [] # self.cbColumns, self.cbNames = [], [] self.tb = {} # textbox # Add dynamic widgets for tconf in config: Loading Loading @@ -116,6 +116,8 @@ class Ui(QtWidgets.QMainWindow): gb = newGroupBox(id, name, QtWidgets.QSizePolicy(policy.Minimum, policy.Maximum)) if 'elements' in tconf and len(tconf['elements']) > 0: self.cb[id] = {} for element in tconf['elements']: try: eid = element['id'] Loading @@ -130,9 +132,9 @@ class Ui(QtWidgets.QMainWindow): gb.layout().addWidget(widget, count//cols, count%cols) count += 1 # save widget self.cb[eid] = widget self.cbColumns.append(eid) self.cbNames.append(wid) self.cb[id][eid] = widget # self.cbColumns.append(eid) # self.cbNames.append(wid) except KeyError as e: print(f"KeyError: {e}") Loading @@ -146,6 +148,8 @@ class Ui(QtWidgets.QMainWindow): gbb = QtWidgets.QButtonGroup() gbb.setObjectName(f"gbb_{id}") if 'elements' in tconf and len(tconf['elements']) > 0: self.rb[id] = {} for element in tconf['elements']: element:dict try: Loading @@ -162,9 +166,9 @@ class Ui(QtWidgets.QMainWindow): gb.layout().addWidget(widget, count//cols, count%cols) count += 1 # save widget self.rb[eid] = widget self.rbTypes.append(eid) self.rbNames.append(wid) self.rb[id][eid] = widget # self.rbTypes.append(eid) # self.rbNames.append(wid) # shortcut label if 'shortcut' in element.keys(): Loading Loading @@ -196,12 +200,17 @@ class Ui(QtWidgets.QMainWindow): except: raise # Dynamic COLUMNS utils.IDS['FILE'] = list(df.columns) utils.IDS['TB'] = list(self.tb.keys()) utils.IDS['CB'] = self.cbColumns utils.IDS['RB'] = list(self.rb.keys()) + [""] for _, cb in self.cb.items(): utils.IDS['CB'].extend(list(cb.keys())) utils.IDS['RBG'] = list(self.rbg.keys()) for _, rb in self.rb.items(): utils.IDS['RB'].extend(list(rb.keys())) utils.IDS['RB'].extend([""]) utils.COLUMNS = utils.IDS['FILE'] + utils.IDS['RBG'] + utils.IDS['CB'] + utils.IDS['TB'] for v in ['ra', 'dec']: Loading @@ -216,11 +225,10 @@ class Ui(QtWidgets.QMainWindow): # DONE 1 - utils COLUMNS and MORPHO need to be dinamic # DONE 2 - aboid finding cb and rb maybe safe them in creation # DONE 3 - get radio button ischecked from ButtonGroup # DONE 4 - dinamic input file, independent form group. # also, HEADER created from this file # DONE 5 - output file keys have to be dinamic (related to input file and COLUMNS) # also, newEntry func # 6 - what if multiple same named widgets? add groupid to widgetid? # DONE 4 - dinamic input file, independent form group. also, HEADER created from this file # DONE 5 - output file keys have to be dinamic (related to input file and COLUMNS). also, newEntry func # DONE 6 - what if multiple same named widgets? add groupid to widgetid? # 6.5 - what if multiple same named widgets? outputfile names should include widgetgroup id? # 7 - multiple commentBox not supported (yes, but events need to be solved) # 8 - If filename not in input file, detect images (currently fails) # DONE 9 - Shortcuts not working Loading Loading @@ -364,11 +372,11 @@ class Ui(QtWidgets.QMainWindow): for id, bg in self.rbg.items(): selected = '' if bg.checkedButton() is not None: idChecked = bg.checkedButton().objectName() idChecked:str = bg.checkedButton().objectName() selected = idChecked.split('_',1)[-1] # refactor rbTypes and rbNames? selected = self.rbTypes[self.rbNames.index(idChecked)] #selected = self.rbTypes[self.rbNames.index(idChecked)] self.df.loc[item_index, id] = selected # for radio in self.rbTypes: # if(self.rb[radio].isChecked()): # self.df.loc[item_index, 'morphology'] = radio Loading @@ -376,8 +384,11 @@ class Ui(QtWidgets.QMainWindow): # else: # self.df.loc[item_index, 'morphology'] = utils.getMorphology()[-1] for column in self.cbColumns: self.df.loc[item_index, column] = self.cb[column].isChecked() for id, cb in self.cb.items(): for eid, wcb in cb.items(): self.df.loc[item_index, eid] = wcb.isChecked() # for column in self.cbColumns: # self.df.loc[item_index, column] = self.cb[column].isChecked() for id, tb in self.tb.items(): self.df.loc[item_index, id] = tb.toPlainText().replace('\n', '') Loading Loading @@ -423,17 +434,20 @@ class Ui(QtWidgets.QMainWindow): for id, bg in self.rbg.items(): self.clear_ButtonGroup(bg) selected = item[id].item() if selected in self.rbTypes: idChecked = self.rbNames[self.rbTypes.index(selected)] # refactor rbTypes and rbNames? self.rb[selected].setChecked(True) if selected in self.rb[id].keys(): # idChecked = self.rbNames[self.rbTypes.index(selected)] # refactor rbTypes and rbNames? self.rb[id][selected].setChecked(True) # for radio in self.rbTypes: # if(item['morphology'].item() == radio): # self.rb[radio].setChecked(True) # checkboxes for cb in self.cbColumns: self.cb[cb].setChecked(item[cb].item()) for id, cb in self.cb.items(): for eid, wcb in cb.items(): wcb.setChecked(item[eid].item()) # for cb in self.cbColumns: # self.cb[cb].setChecked(item[cb].item()) # textboxes for id, tb in self.tb.items(): Loading @@ -452,8 +466,11 @@ class Ui(QtWidgets.QMainWindow): print(f"WARNING:\tEmpty item. [{e}]") self.imgPath = self.defaultImgPath self.setWindowTitle(self.title) for cb in self.cbColumns: self.cb[cb].setChecked(False) for _, cb in self.cb.items(): for _, wcb in cb.items(): wcb.setChecked(False) # for cb in self.cbColumns: # self.cb[cb].setChecked(False) self.showImage(self.imgPath) Loading
src/utils.py +1 −1 Original line number Diff line number Diff line Loading @@ -196,7 +196,7 @@ def getRadioButtonGroups(): return IDS['RBG'] def getRadioButtonsNames(): return IDS['RB'][:-1] return IDS['RB'] def getCheckBoxesColumns(): return IDS['CB'] Loading