0

I'm trying to make a leaderboard using tkinter and pandastable however, on the last column the pandastable incorrectly places the values

enter image description here

this happens in every rows last column. I have tried to manually put in the numbers but the value is still stuck there

here is the dictionary (without any data):

self.places = {"Name":[], "Time":[], "Best Lap": []}

Here is the code where I'm getting the data:

    def serialReading(self):   
        while(self.terminate == True):
                if(serialPort.in_waiting > 0):
                    self.serialString = serialPort.readline()
                    self.string = self.serialString.decode('Ascii')

                    self.numbers = 0
                        
                    try:
                        for self.i in range(len(self.frameIdentities)):
                            self.i+=1
                            if self.i == int(self.string.split(' ')[1]):
                                try:   
                                    self.lapRemainingPeople['serialTime'+str(self.i-1)] -=1

                                    self.BestLap = tk.CTkLabel(self.frameIdentities[self.i-1], text = str(self.string.split(' ')[7]))
                                    self.laps = tk.CTkLabel(self.frameIdentities[self.i-1], text = str(self.string.split(' ')[4]))
                                    self.lapsRem = tk.CTkLabel(self.frameIdentities[self.i-1], text=str(self.lapRemainingPeople['serialTime' + str(self.i-1)]), text_font=("Arial", 36))
                                    
                                    self.time[self.i-1] += int(self.string.split(' ')[4])
                                    self.best[self.i-1] = self.string.split(' ')[7]

                                    y = self.yCoordinates[self.i-1] + 30
                                    self.lapsRem.place(x=65, y=y)
                                    self.BestLap.place(x=0, y=140, width=65)
                                    self.laps.place(x=0, y=80, width=65)

                                    if self.lapRemainingPeople['serialTime'+str(self.i-1)] <= 0:
                                        if (str(self.names[self.i-1]) not in self.places['Name']): 
                                            self.time[self.i-1] /= 1000                    
                                            self.lapsRem.configure(text='0')
                                            self.places["Name"].append(self.names[self.i-1])
                                            self.places["Time"].append(self.time[self.i-1])
                                            self.places["Best Lap"].append(self.best[self.i-1])
                                            threading.Thread(target=self.LeaderBoard()).start()
                                        else:
                                            self.lapsRem.configure(text='0')

                                except:
                                    pass

                    except:
                        pass

here is the part of the code where I am showing the pandastable:

    def LeaderBoard(self):
        if self.Truth == False:
            self.leaderboard = tk.CTkToplevel(window)
            self.statsFrame = tk.CTkFrame(self.leaderboard)
            self.statsFrame.pack()
            self.Truth = True
        self.leaderboard.update()
        self.stats = pd.DataFrame.from_dict(self.places)
        print(self.stats)
        self.table = Table(self.statsFrame, dataframe=self.stats)
        self.table.show()
Noah Robb
  • 59
  • 1
  • 7

0 Answers0