Replies: 3 comments 1 reply
-
There's two answers to your question. The first is the pragmatic, "works right now" answer. The sibling relationship between widgets in a layout doesn't matter. All that matters is that you can get a reference to another widget. So - you create the text input as You can slightly decouple things by using the widget registry - instead of assigning the Your comments about "shared data source" hint in the direction of the longer term solution - but that solution doesn't currently exist. Toga does contain a ValueSource, which is the "single value" equivalent of TreeSource/ListSource - but, at present, you can't use a ValueSource for anything. Ideally, you would be able to use a ValueSource as the data behind a TextInput - so then, whenever the ValueSource is changed, the TextInput would change, and vice versa. However, that won't change the underlying issue that made the "pragmatic" solution possible. You need a reference to something to represent the data- and that will mean either assigning something to the app, or using some other "registry" (be that the app/window widget registry, or something else). If you want an example of this - Toga Tutorial 1 (The Fahrenheit to Celsius converter) in the examples folder of the Toga folder demonstrates this - you press a button, and the value of one text input is used to update another text input. |
Beta Was this translation helpful? Give feedback.
-
Thanks again for your insight. Very Helpful. But a few more questions. The programmatic change to a text value would seem to have a solution. I will test the proposed methods to identify the widgets. My aim is to have a settings summary in a table with a data source then separate Input widgets that can update row items in the table source. (and trigger a display update unless that would be auto magical) Cheers |
Beta Was this translation helpful? Give feedback.
-
I am getting my head around this.
Now looking at ListSource updates so making progress. |
Beta Was this translation helpful? Give feedback.
-
It seems to be tricky (for me) to access and update values of widgets from different parts of an app.
#1325 suggests the way to update a value across a Toga app is:
"preferably, with a reference to a common data source that, when updated, is reflected in the app's GUI"
I have a 'feedback' Text box which is a child of the main_window and I would like to update it from actions in a separate class that defines a box in an option container which is also a child of the main_window.
In the example below I want to report the outcome of a file upload process - Success or Failure.
Is the treesource example the best starting point to create a shared datasource for a Text Box?
Or perhaps there a simple example to get started with?
I hope that this makes sense.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions