Atheer
Atheer

Reputation: 921

Tkinter StringVar() concatenation

I am using Tkinter lib for Python gui, and I'd like to display text from excel sheet using a loop, and a label inside a frame, however, since StringVar has only set function, I can not insert new values, or concatenate the string

print('Matched Tweets')
        for i, element in enumerate(ranked_tweets):
            for j in range(1, 8):
             result.set(worksheet._get_cell((element + 1), j).value+"\n")
        #result.set("\n")

in which, result is stringVar and it is shown inside lable in the gui

Label1= ttk.Label(frame1, textvariable=result)

and when I ran the application, it only shows one result given that it overwrites the variable with set method each iteration.

My question is, how to list all the texts using the stringVar

Upvotes: 1

Views: 7193

Answers (1)

Novel
Novel

Reputation: 13729

StringVar has a get() method too:

new_data = worksheet._get_cell((element + 1), j).value+"\n"
result.set(result.get() + new_data)

Upvotes: 6

Related Questions