Replies: 1 comment
-
I found the problem. I creted handler inside child MyLog(RichLog).init, so each instance of screen creted new handler |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First, i tried to make base class for screens like this:
The, i created some child screens. When i run app and push the first screen, everything works fine. But when i switche two the second screen, everything is duplicated: when i press l, m, in logs i see 2 messages, instead 1. When screen was switched, i also got 2 log messages. In on_mount I log messages, they also duplicated. When i switch to the thied screen, now i see 3 copies of each log message.
I thought, maybe propblem is because all child screen catches events, so I moved code to main app file:
But the problem is the same. Everything from on_mount, actions and events repeats as many times, as many screen was created.
PS: i store logs in global variable, custom function refresh_logs clear all content of RichLog and load content from global variable. I tested that part of code (custom handler, which add new log messages to global variable) outside textual, there is no duplication.
I located the problem. Here is the modifed code of custom handler for debugging.
I got result:
[2025-06-30 15:43:46] INFO | Screen 'dash' COUNT [36]
[2025-06-30 15:43:46] INFO | Screen 'dash' COUNT [35]
[2025-06-30 15:43:46] INFO | Screen 'dash' COUNT [30]
So, something calls emit several times. Directly modifying _globallog right before and after log.info(...) in code doesn't cause repetition
Beta Was this translation helpful? Give feedback.
All reactions