# Graphics --- CS 65 // 2021-02-16 ## Extra Credit Activities - [Lunch & Learn: Diversity in Service](https://www.eventbrite.com/e/lunch-learn-diversity-in-service-tickets-140108780133) + Thursday, 2/18 from noon to 1:00pm - [Career Conference](https://calendar.drake.edu/event/be_unstoppable_flexible_fearless_career_conference?utm_source=newsletter&utm_medium=email&utm_content=DETAILS&utm_campaign=Faculty-Feb-9#.YCLmlHdKhTY) + Friday, 2/19 from 9:00am to 4:00pm - [Songs for A New World](https://calendar.drake.edu/event/songs_for_a_new_world?utm_campaign=widget&utm_medium=widget&utm_source=Drake+University+Calendar) Livestream Performance + Thursday, 2/25 from 8:00 to 10:00am - [Global Citizen Forum](https://www.drake.edu/diversity/initiatives/globalcitizenforum2021/) + Conference on equity and inclusion in higher ed + March 3-5 # Assignment 3 - Due Thursday before class # Questions ## .. about anything? # "Objects" in Python ## Object-Oriented Programming - Python is an **object-oriented language** and all basic values are implemented as "objects" - An **object** consists of the following: + A collection of related **information** + A set of **methods** (i.e. operations) to manipulate that information - For example, consider the string: `s = "abc"` + Its basic information includes three characters ## Object-Oriented Programming - Python also lets you create your own types of objects---called **classes** - When writing a class, you tell Python what **information** each object has and also what **methods** can be performed on it - We'll cover creating our own classes during week 11 # Graphics Library ## The graphics.py Library - We are going to learn the **Zelle graphics library** that can be used to easily create simple, cross-platform, programs that include graphics + It is written using a larger library called **Tkinter** - The library comes with many **classes** that help facilitate various graphics tasks - When using the graphics library, you must have access to the **graphics.py** file that is provided on the **Resources** page of the course website ## The graphics.py Library - To import the graphics classes, use: + `from graphics import *` - Once the library is loaded, a **GraphWin** object can be created to display a graphical window to the user + You can also **draw** shapes and interact with the window via **mouse movements** and **click events** - You can create a GraphWin object calling its **constructor** + `win = GraphWin()` - You can also create various **graphics objects** # DEMO # Graphics Classes ## Summary of Classes - **GraphWin** + A "window" that acts like a canvas and can be shown to the user. + Has a width / height, background color, and ways to get input from the user ## Summary of Classes - **GraphicsObject** + Any object that can be drawn to a GraphWin canvas has all the GraphicsObject methods + They have a position, fill color, etc. + The list of all GraphicsObject types are below: + Point, Line, Circle, Rectangle, Oval, Polygon, Text, Entry, and Image # Lab Time