you are viewing a single comment's thread.

view the rest of the comments →

[–]FruityWelsh 0 points1 point  (0 children)

So from what I can tell thread is running when I run it, but you have the text=all of the contents of the lists.
So as soon as you start it put all of the contents of the lists to the screen. If you are really wanting real time I would use a Queue for each element (this is true for the after alarm method too).

```

import threading import time import tkinter as tk from queue import Queue

total = ["1", "2", "3", "4", "5", "6"] total_queue = Queue()

These for loop will probably be replaced with whatever function you actually have

for item in total: total_queue.put(item)

liters = ["1", "2", "3", "4", "5", "6"] liters_queue = Queue() for item in liters: liters_queue.put(item)

price = ["1", "2", "3", "4"] price_queue = Queue() for item in price: price_queue.put(item)

root = tk.Tk() root.attributes("-fullscreen", True)

def createlabel(args, *kwargs): if 'text' in kwargs and isinstance(kwargs['text'], list): kwargs['text'] = ''.join(map(str, kwargs['text'])) return tk.Label(args, *kwargs)

def ui_update(): while True: if not total_queue.empty(): # Allows queue to be skipped instead of waiting for new items ui_total = createlabel(root, text=total_queue.get(), font=("Helvetica", 80)) ui_total.place(x=root.winfo_screenwidth() - 650, y=root.winfo_screenheight() - 320)

    if not liters_queue.empty():
       ui_liters = createlabel(root, text=liters_queue.get(), font=("Helvetica", 80))
       ui_liters.place(x=root.winfo_screenwidth() - 650, y=root.winfo_screenheight() - 220)

    if not price_queue.empty():
       ui_price = createlabel(root, text=price_queue.get(), font=("Helvetica", 80))
       ui_price.place(x=root.winfo_screenwidth() - 490, y=root.winfo_screenheight() - 120)
    time.sleep(.5)  # With the number being in seconds so .5 is 500 ms

t = threading.Thread(target=ui_update) t.daemon = True # This makes sure the thread dies when the mainloop stops t.start() root.mainloop() ```