[Python] How do I update text in toga?

Discussão em 'Python' iniciado por Stack, Abril 7, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to create a simple clock app, for that I am using time. I want to update the time label

    Imports

    import toga
    from toga.style import Pack
    from toga.style.pack import COLUMN, ROW
    import time


    code

    self.time_label=toga.Label("00:00:00",style=Pack(padding=10,font_size=50))


    I directly call the update_time() function in the startup method

    self.Update_time()


    self.time_label is needed to change to the current time the text will change inside the Update_time() function

    def Update_time(self):
    current_time= time.strftime('%I:%M:%S')
    self.time_label.text=current_time


    now I encounter that it only displays the time and does not change to the current time

    eg: if i run the program at 9:22:56 it displays 9:22:56 but when it becomes 9:22:57 (or) 9:23:00 it still show 9:22:56

    Continue reading...

Compartilhe esta Página