0
How to make a label that displays a different text every second?
Using after method how do i make a program that displays a different text every second say that I have a list of texts 'hello','text','car',...... I want the label to display texts from this list how do i do that
7 Antworten
+ 5
Saja Ali You don't need to pack the label every time, all you need is to change its value. So you can put everything else outside the function, and only keep the label change inside.
Here is how you change a text:
label.config(text="new text here")
I will write a working example, along with comments so you can understand.
+ 4
Saja Ali can you post your code here ?
+ 4
Saja Ali do you know how to work with generators ?
+ 3
Saja Ali here is a working example:
https://code.sololearn.com/c1mASnjIXJQJ/?ref=app
I had to use a global variable, because I think variables inside frameworks are handled differently. You don't need to worry about the "keyword", just ignore it.
If you have questions about other parts of the code feel free to ask, even tho I think it is explained in the comments.
+ 2
are you using scikit or sklearn ?
0
Aymane Boukrouh [INACTIVE]
I tried this but it didn't work
l =['its ' ,' some' ,'text ' ]
n=0
def func ():
L=Label (master,text=l [n])
L.pack ()
n+=1
Master.after (200,func)
0
No i don't understand generators