May 2019
Intermediate to advanced
542 pages
13h 37m
English
Now that our application has both the list and the form widgets, let's enable some navigation between them. First, create a toolbar button to switch from the coffee form to the list:
navigation = self.addToolBar("Navigation") navigation.addAction( "Back to list", lambda: self.stack.setCurrentWidget(self.coffee_list))
Next, we'll configure our list so that double-clicking an item will show the coffee form with that coffee record in it. Remember that our MainView.show_coffee() method expects the coffee's id value, but the list widget's itemDoubleClicked signal carries the model index of the click. Let's create a method on MainView to translate one to the other:
def get_id_for_row(self, index): index = index.siblingAtColumn(0) ...
Read now
Unlock full access