Update a widget value from another script? #1325
-
Hello, say I'm building an interface with a readonly MultilineTextInput. Now I want to add lines to the widget from another part of the application. Currently I do this: app.py:
and in another part of the app:
Is that the best practice way? I was unable to find any example in the docs that updated a widget from outside the app class. As the widgets can all have an |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
There will only ever be a single App instance in a running executable, and the app tracks that instance as
However, generally speaking, I'd advise against relying on |
Beta Was this translation helpful? Give feedback.
There will only ever be a single App instance in a running executable, and the app tracks that instance as
App.app
; so the following will do what you need:However, generally speaking, I'd advise against relying on
App.app
. It works (and needs to exist for a variety of reason); but as a general matter of code style, if there's "another part of your app" that needs to know about the app, then it should be constructed and configured with a reference to the app (or, preferably, with a reference to a common data source that, when updated, is reflected in the app's GUI).