def saveas(self): # this will build the blank apparatus # not needed for template apparatus because it already has a structure if self.apptype == 'blank': for k in range(self.ui.treeWidget.topLevelItemCount()): parent = self.ui.treeWidget.topLevelItem(k) pathn = [] i = 0 if parent.child(0) is not None: while parent.child(0) is not None: child = parent.child(0) Parent = parent.text(0) # makes a list of the parents in reverse order # stops when it reaches the bottom item (no child) # inserts child at the end of the array pathn.insert(i, Parent) parent = child i = i + 1 pathn.insert(i, parent.text(0)) # sets Child equal to it's own value for setValue function Child = child.text(0) # updates the apparatus Apparatus.setValue(self.MyApparatus, pathn, Child) # needs to update the appa node # gets the filename from the textbox and sets the apparatus to that name filename = self.ui.fnamebox.text() filename = self.MyApparatus # logs the apparatus as a JSON Apparatus.logApparatus(filename)
def update(self): newvalue = self.ui.itable.currentItem() # this eliminates going through the process during start up # otherwise it will update every value in the qtreewidget which is not needed if newvalue is not None: row = self.ui.itable.currentRow() # gets pathname from left column newkey = self.ui.itable.item(row, 0) path = newkey.text() pathn = path.split(' ') # removes last item of the pathname pathn.pop() if newvalue is not None: # this has to be 1 because of how pathn is created key = pathn[len(pathn) - 1] # finds item in the qtreewidget with the same pathname listnewv = self.ui.treeWidget.findItems( key, Qt.MatchExactly | Qt.MatchRecursive) # from this list of pathnames inserts the new value into the apparatus for k in range(len(listnewv)): if listnewv[k].parent().text(0) == pathn[len(pathn) - 2]: text = newvalue.text() # places the new value into the correct place in the qtreewidget listnewv[k].child(0).setText(0, text) # sets the new value in the apparatus and appa node Apparatus.setValue(self.MyApparatus, pathn, text) self.apparatus.setValue(pathn, text)