Example #1
0
 def updateList(self, frm: Frame, sbox: Spinbox, btn: bool = False) -> None:
     # get data
     start = frm.grid_info()['row']
     oldInfo = self.data.pop(zerofrmt(start))
     # get spinbox value
     moveToLbl = str(sbox.get())
     if moveToLbl == zerofrmt(start):
         return
     elif not moveToLbl:
         if start < self.lblRow:
             start = (self.lblRow + 1)
             moveToLbl = zerofrmt(self.lastRow)
             self.focus_set()
         else:
             return
     elif btn and int(moveToLbl) == self.lblRow:
         sbox.delete(0, 'end')
         start = (self.lblRow + 1)
         moveToLbl = zerofrmt(self.lastRow)
         self.after(0, self.focus_set)
     elif btn and abs(start - int(moveToLbl)) > 1:
         self.moveInterim(start, zerofrmt(self.lblRow + 1), True)
         start = 0
         moveToLbl = zerofrmt(self.maxRow)
         sbox.delete(0, 'end')
         sbox.insert(0, moveToLbl)
     elif not btn:
         if len(moveToLbl) != rndto:
             moveToLbl = zerofrmt(moveToLbl)
             sbox.delete(0, 'end')
             sbox.insert(0, moveToLbl)
         if start == self.lastRow:
             self.moveInterim(start, zerofrmt(self.lblRow + 1), True)
     sbox.selection_range(0, 'end')
     if moveToLbl == zerofrmt(start):
         return
     if moveToLbl in self.data:
         self.moveInterim(start, moveToLbl, False)
     moveToRow = int(moveToLbl)
     bg = self.litBg if (moveToRow % 2) else self.defBg
     frm.grid(row=moveToRow)
     frm.configure(bg=bg)
     sbox.configure(bg=bg)
     oldInfo['lbl'].configure(bg=bg)
     self.data[moveToLbl] = oldInfo
Example #2
0
 def cancelChange(self, frm: Frame, sbox: Spinbox) -> None:
     self.focus_set()
     oldRow = zerofrmt(frm.grid_info()['row'])
     if oldRow != sbox.get():
         sbox.delete(0, 'end')
         sbox.insert(0, oldRow)