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

Updating __init__()

Let's start working through these with our __init__() method:

    def __init__(self, parent, fields,                  settings, callbacks, *args, **kwargs):
        self.callbacks = callbacks

We're adding a new argument, callbacks, and storing it as an instance property. This will give the controller a way to provide methods for the view to call.

Next, our __init__() method should set up a variable in which to store the current record:

        self.current_record = None

We'll use None to indicate that no record is loaded and the form is being used to create a new record. Otherwise, this value will be an integer referencing a row in the CSV data.

We could use a Tkinter variable here, but there's no real advantage in this case, and we wouldn't be able to ...

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