Python Forum
[Tkinter] Progressbar value update issue
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Progressbar value update issue
#1
Hi

i have one list .

I want to update Progressbar from list elements.

# this code works
self.prograssBar1["value"] = 12
#but this code does not works,
#updating value from list
self.prograssBar1["value"] = int(spData[1:2])
how to solve this issue ?
Reply
#2
What is progressBar1? What is spData?

My guess is progresBar1 is a tkinter.Progressbar and that spData is a list of floats?. To set the progress bar value equal to the number in spData[1], use:
self.prograssBar1["value"] = int(spData[1])
Next time include more surrounding code to provide context or give a more detailed explanation.
Reply
#3
progressbar is widget provided by tkinter.

spData[1:2] is element of list.
Reply
#4
spData[1:2] is a list containing spData[1]. spData[1:3] is a list containing spData[1] and spData[2]. I guess my question should have been "what is spData[1]? What do you have sored in your list?
Reply
#5
my list
['#', '336', '908', '120', '863', '789', '3', '\n']
but when i tried to print list like this, i got error

print(spData[2]) #print 2nd element of list
print(spData[3]) #print 3rd element of list
error is
IndexError: list index out of range


here is my actual code
i am receiving data from serial port.
received data is comma separated value followed by "\n"
myData = self.arduinoSerialData.readline()
        serData = myData.decode('ascii')
        # serData = myData.decode("utf-8")
        print(serData)
        if len(serData) > 1:
            spData = serData.split(',')
            print(spData)
            print(spData[2]) # this line generate error
Reply
#6
Your list is not ['#', '336', '908', '120', '863', '789', '3', '\n']. If it were, spData[2] would be '120'.

Maybe spData is a list of lists?

Please supply the code that creates spData.
Reply
#7
myData = self.arduinoSerialData.readline()
        serData = myData.decode('ascii')
        # serData = myData.decode("utf-8")
        print(serData)
        if len(serData) > 1:
            spData = serData.split(',')
            print(spData)
            print(spData[2]) # this line generate error
Reply
#8
What do you see printed when you call "print(spData)"
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] progressbar DPaul 9 2,851 Sep-01-2021, 12:50 PM
Last Post: deanhystad
  [PyGUI] ListBox Update Issue antonello 1 3,160 Feb-28-2021, 06:23 PM
Last Post: Larz60+
  Progressbar with start and stop jelo34 3 4,946 Nov-30-2020, 03:36 AM
Last Post: deanhystad
  [Tkinter] Can't get progressbar to update frednet 0 1,650 Feb-24-2020, 10:53 PM
Last Post: frednet
  Adding Progressbar to button aniyanetworks 9 9,984 Feb-07-2019, 11:12 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020