question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update Element with Thread

See original GitHub issue

I’ve this little examples that does not work… It’ doesn’t update the screen until I press a key.

Basically what I want is to run a thread that updates some element and update the screen Can you help me to understand why it is not completely working?

#!/usr/bin/env python3

import py_cui
import threading
import time
from datetime import datetime


class App:
    def __init__(self, master):
        self.master = master
        self.g1 = self.master.add_scroll_menu('PANEL',
                                              0, 0, row_span=6, column_span=6)
        thread = threading.Thread(target=self.thread_update, args=())
        thread.daemon = True
        thread.start()

    def thread_update(self):
        try:
            while True:
                d = "TIME:{}".format(datetime.now().strftime('%X'))
                self.g1.add_item(d)
                time.sleep(1)
        except Exception as e:
            print(e)


root = py_cui.PyCUI(9,6)
root.toggle_unicode_borders()
root.set_title('Test')
s = App(root)
root.start()

Is it a thread/curses limitation?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
jwlodekcommented, Mar 4, 2021

Yeah, for sure some of the documentation (like for this) needs to be overhauled eventually, I’ve just been busy with work lately, hopefully I have some extra free time in the coming months to dedicate to this.

1reaction
jwlodekcommented, Jun 18, 2020

Great! The new version will be uploaded on PyPi in the next few weeks with the fixes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to update a value of a variable in Thread class on some ...
The main thread should add() an element to the queue (e.g. the amount ... I want to update the variable countOfAdd //of the...
Read more >
Updating a UI Element from Multiple Threads - CodeProject
This article shows how to update a ToolStripProgressBar while multiple threads are running, and to stop updating it when all the threads are ......
Read more >
C# Quick Tip - Update UI Elements via Separate Thread
In this quick tip, we take a look at how to update a UI element from another thread using c# delegates.
Read more >
C# Update A GUI Element From Another Thread - C# Examples
This examples shows how to update a user interface element from another thread. To do this, we must update to the user interface...
Read more >
Solved Two threads update the integer array Buff[] first - Chegg
Each element in Buff[] is either processed by thread 1 (added 10) or by thread 2 (subtracted 10). For example, Buff[12] = 22...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found