← Back to Book Detail

3 Object Oriented Programming (I) (3/2) -- Building Apps with Tkinter

Browse
150%

3 Object Oriented Programming (I)

3 Object Oriented Programming (I) Overview Object Oriented Programming (OOP) is a programming style in python that focuses creating objects that contains both data (attributes) and methods that can operate on the data. TEKS Computer Science 1 (3): To foster students’ creativity and innovation by presenting opportunities to design, implement, and present meaningful programs through a variety of media Content Objective - Students will create a simple graphical user interface using basic Tkinter widgets, including windows, frames, labels, buttons, entry fields, and textbox areas. - Students will learn how Tkinter variables work and methods for input validation. - Keywords (Phrases): Graphical User Interface, Widgets Language Objective (read, write, speak): - Students will be able to read and interpret Python code for GUI programming. - Students will be able to write descriptive code comments explaining the purpose any logic used in their project - Students will verbally explain the purpose of GUI components and their implementation in Python to their peers. Key terms to take note of (Click here for link to code) - Classes: A blueprint / template for creating objects. which have properties (attributes) and behaviors (methods/functions) - Attributes: Attributes also known as properties are variables that belongs to a class and defines its characteristics for example age, name etc., There are two types of attributes. - Class attributes– These variables are defined at the class level and are shared amongst all instances of the class, thus can be accessed from any instance or from the class itself. - Instance attributes– These variables are defined within the constructor (__init__) method and its values are unique to each instance of a class - Methods: Also known as behaviors are the functions within a class that defines some action or operations that an object can perform on the instance variable, and they help us to encapsulate the behavior or functionality of an object. For example, in tkinter these behaviors may be commands to make a button or widget to perform some action when clicked. In python we have 3 kinds of Methods - Instance Methods– These functions operate on the instances of a class and its capable of accessing instance variables. It takes self as its first argument. - Class Methods– These functions operate on the class itself including the class variables. It takes cls as its first argument - Static Methods– These functions operate independently of the instance of class itself, and used as an utility functions or helper methods. It has no specific requirement for “self” or “cls” as first argument - Objects: This refers to an instance of a class, with each instance containing the data and behavior defined by the class, as well as a unique identity. - Inheritance: Inheritance allows a programmer to create a new class based on an existing class, thus inheriting the instance attributes and instance methods of the parent class - Encapsulation:
← Previous Chapter Next Chapter →