Skip to Content
Python GUI Programming with Tkinter
book

Python GUI Programming with Tkinter

by Alan D. Moore
May 2018
Beginner to intermediate content levelBeginner to intermediate
452 pages
11h 26m
English
Packt Publishing
Content preview from Python GUI Programming with Tkinter

Adding a load_record() method

The last thing to add in our view is a method for loading in a new record. This method will need to set up our form with a given row number and data dictionary from the controller.

Let's call it load_record() as follows:

    def load_record(self, rownum, data=None):

The first thing we should do is set the form's current_record value from the rownum provided:

        self.current_record = rownum

Recall that rownum could be None, indicating that this is a new record.

Let's check for that by executing the following code:

        if rownum is None:
            self.reset()
            self.record_label.config(text='New Record')

If we're going to be inserting a new record, we simply want to reset the form, then set the label to indicate that this is a new ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python GUI Programming with Tkinter - Second Edition

Python GUI Programming with Tkinter - Second Edition

Alan D. Moore

Publisher Resources

ISBN: 9781788835886Supplemental Content