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

22nd Jan 2020, 3:25 PM
Pattern
Pattern - avatar
7 Respostas
+ 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.
22nd Jan 2020, 3:56 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 4
Saja Ali can you post your code here ?
22nd Jan 2020, 3:32 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 4
Saja Ali do you know how to work with generators ?
22nd Jan 2020, 3:48 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 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.
22nd Jan 2020, 4:03 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 2
are you using scikit or sklearn ?
22nd Jan 2020, 3:31 PM
BroFar
BroFar - avatar
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)
22nd Jan 2020, 3:42 PM
Pattern
Pattern - avatar
0
No i don't understand generators
22nd Jan 2020, 3:50 PM
Pattern
Pattern - avatar