How to Connect Table View Methods to UI Builder (Storyboard)
GroundhogDayLoop last edited by
How would I go about connecting table view methods from the (.py) code file, for example, to the actual table view built in the UI Builder section (.pyui)? I would also like to set the rows text in the code instead of the storyboard section.
I set the delegate and data source but maybe I'm missing a detail in that regard. I thought maybe I could assign the class to a part of the UI (.pyui) but not sure.
Phuket2 last edited by
@GroundhogDayLoop, using the ui.View you assign to your .pyui file you can access the ui.Table by the name you give it in the builder.
v = ui.load_view('my_view.pyui') tbl = v['tbl_name'] # can access any of the elements this way
By default tbl load from a pyui file has a ListDataSource already attached correctly as the data_source. Of course you can change it. But it's work having a good look at the ui.ListDataSource before doing so as it's quite powerful and can save you some work as well you can extend it if you need to.
One thing to keep in mind. The code above works if your table is on the root/parent view in the builder. If you for example placed a CustomView then added the TableView to the CustomClass (so TableView is now a Subview of the CustomView) so then you would refer to your TableView like -
tbl = v['custom_class_name']['tbl_name']
I hope that last part is clear