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

Fixing the on_save() method

The error handling portion of on_save() is fine, but after the if errors: block, we'll start changing things:

        data = self.recordform.get()
        try:
            self.data_model.save_record(data)

We no longer need to extract the row number or pass it into save_record(), and we can delete the handling of IndexError since SQLModel will not raise that exception. We also need to rewrite the updating of inserted_rows and updated_rows.

Remove all the code in this method after the call to self.status.set(), and replace it with this:

 key = (data['Date'], data['Time'], data['Lab'], data['Plot']) if self.data_model.last_write == 'update': self.updated_rows.append(key) else: self.inserted_rows.append(key) self.populate_recordlist() if self.data_model.last_write ...
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