The final exam will be held on Thursday, December 19th from 3 to 6 PM.
The exam will be given in this room.
If for some reason you are not able to take the Final at the time it will be offered, you MUST send an email to me before the exam so we can make alternative arrangements.
The final will consist of questions taken from the Weekly Graded Quizzes, along with questions asking you to write short segments of Python code.
There is a link to the answers to the graded quizze on the class web page.
60% of the points on this exam will consist of questions from the Graded Quizzes.
You do not need to study a Graded Quiz question if the topic is not mentioned in either the Midterm or Final review.
The remaining 40% will come from 4 questions that ask you to write some code.
To study for the code questions you should know
A good way to study for the code questions is to review the Class Exercises, homework solutions and Class Notes.
The last class on Thursday, December 10th, will be a review session.
You will only be responsible for the material in that review session, which you will find here, and the review for the Midterm, which you will find here.
Although the time alloted for the exam is 3 hours, I would expect that most of you would not need that much time.
The final is a closed book exam.
To prevent cheating, certain rules will be enforced during the exam.
At the end of each semester we offer you the opportunity to say what you think about this course.
What have I done right?
What have I done wrong?
What can I do better?
You are not asked for you name.
So the submissions are anonymous.
I will not see your responses until after I have submitted grades for this course.
We collect this feedback through Course Evaluations.
I will use what you say to make this course better.
To complete the course evaluation, use the following link .
You have until Friday, December 20th, to submit the evaluation.
I have posted a solution to homework 11 here.
Let's take a look.
Quiz 10 was the last graded quiz.
Let's review the answers to Quiz 10.
The new IT Club will hold it's first event, this coming Thursday, December 5th at 3 PM in the Integrated Sciences Complex, Room 3300.
Jason Agress wil speak about his experiences in the IT industry.
This is a great chance to meet other IT students and expand your network.
Holiday food will be served.
You will find a poster for the event here.
Are there any questions before I begin?
#! /usr/bin/python3 import tkinter class EmptyWindow: def __init__(self): # Create the main window widget. self.main_window = tkinter.Tk() # Enter the tkinter main loop. tkinter.mainloop() root = EmptyWindow()
#! /usr/bin/python3
import tkinter
class EmptyWindow:
def __init__(self):
self.main_window = tkinter.Tk()
self.main_window.title("Empty Window")
tkinter.mainloop()
root = EmptyWindow()
WIDTHxHEIGHT
#! /usr/bin/python3
import tkinter
class EmptyWindow:
def __init__(self):
self.main_window = tkinter.Tk()
self.main_window.title("Empty Window")
self.main_window.geometry("400x200")
tkinter.mainloop()
root = EmptyWindow()
WIDTHxHEIGHT+X_COORDINATE+Y_COORDINATE
Widget | Description |
---|---|
Button | A button that can cause an action to occur when it is clicked |
Canvas | A rectangular area that can be used to display graphics |
Checkbutton | A button that may be in either the "on" or "off" position |
Entry | An area in which the user may type a single line of input from the keyboard |
Frame | A container that can hold other widgets |
Label | An area that displays one line of text or an image |
Listbox | A list from which the user may select an item |
Menu | A list of menu choices that are displayed when the user clicks a Menu widget |
Menubutton | A menu that is displayed on the screen and may be clicked by the user |
Message | Displays multiple lines of text |
Radiobutton | A widget that can be either selected or deselected. Radiobutton widgets usually appear in groups and allow the user to select one of several options |
Scale | A widget that allows the user to select a value by moving a slider along a track |
Scrollbar | Can be used with some other types of widgets to provide scrolling ability |
Text | A widget that allows the user to enter multiple lines of text input |
Toplevel | A container, like a Frame, but displayed in its own window |
print(1,2,3,4,5, sep=",")
import tkinter class HelloWindow: def __init__(self): self.main_window = tkinter.Tk() self.main_window.title("Hello") self.main_window.geometry("400x200") self.label = tkinter.Label(self.main_window, text="Hello, world!") self.label.pack() tkinter.mainloop() root = HelloWindow()
self.label = tkinter.Label(self.main_window, text="Hello, world!", \ font="times 24 bold")
import tkinter
self.main_window = tkinter.Tk() ... self.label = tkinter.Label(self.main_window, text="Hello, world!", font="times 24 bold") ... tkinter.mainloop()
from tkinter import *
self.main_window = Tk() ... self.label = Label(self.main_window, text="Hello, world!", \ font="times 24 bold") ... mainloop()
self.label = Label(self.main_window, text="Hello, world!", \
font="times 24 bold", fg="blue")
from tkinter import * class ColorWindow: def __init__(self): self.main_window = Tk() self.main_window.title("Colors") self.main_window.geometry("400x200") self.red_label = Label(self.main_window, text="Red text", fg="red") self.red_label.pack() self.orange_label = Label(self.main_window, text="Orange text", fg="orange") self.orange_label.pack() self.yellow_label = Label(self.main_window, text="Yellow text", fg="yellow") self.yellow_label.pack() self.green_label = Label(self.main_window, text="Green text", fg="green") self.green_label.pack() self.blue_label = Label(self.main_window, text="Blue text", fg="blue") self.green_label.pack() self.violet_label = Label(self.main_window, text="Violet text", fg="violet") self.violet_label.pack() self.cyan_label = Label(self.main_window, text="Cyan text", fg="cyan") self.cyan_label.pack() self.magenta_label = Label(self.main_window, text="Magenta text", fg="magenta") self.magenta_label.pack() self.brown_label = Label(self.main_window, text="Brown text", fg="brown") self.brown_label.pack() mainloop() root = ColorWindow()
self.red_label = Label(self.main_window, text="Red text", fg="red") self.red_label.pack() self.orange_label = Label(self.main_window, text="Orange text", fg="orange") self.orange_label.pack() self.yellow_label = Label(self.main_window, text="Yellow text", fg="yellow") self.yellow_label.pack() ...
from tkinter import * class ColorWindow: def __init__(self): self.main_window = Tk() self.main_window.title("Colors") self.main_window.geometry("400x200") for color in ["red", "orange", "yellow", "green", "blue", "violet", "magenta", "cyan", "brown"]: self.colored_label(color) mainloop() def colored_label(self, color): label_text = color.capitalize() + " text" self.label = Label(self.main_window, text=label_text, fg=color) self.label.pack() root = ColorWindow()
WIDTHxHEIGHT+X_COORDINATE+Y_COORDINATE
from tkinter import * class CenteredWindow: def __init__(self): self.main_window = Tk() self.main_window.title("Centered") self.main_window.geometry("400x200") screen_width = self.main_window.winfo_screenwidth() screen_height = self.main_window.winfo_screenheight() self.l1 = Label(self.main_window, text=screen_width) self.l1.pack() self.l2 = Label(self.main_window, text=screen_height) self.l2.pack() mainloop() root = CenteredWindow()
x = screen_width // 2 - width // 2
y = screen_height // 2 - height // 2
from tkinter import * class CenteredWindow: def __init__(self): self.main_window = Tk() self.main_window.title("Centered") self.window_position(400,200) self.label = Label(self.main_window, text="A centered window") self.label.pack() mainloop() def window_position(self, width, height): screen_height = self.main_window.winfo_screenheight() screen_width = self.main_window.winfo_screenwidth() x = screen_width // 2 - width // 2 y = screen_height // 2 - height // 2 self.main_window.geometry(str(width) + "x" + str(height) + "+" + str(x) + "+" + str(y)) root = CenteredWindow()
from tkinter import * class PackTestWindow: def __init__(self): self.root= Tk() self.root.title("Pack Test") mainloop() root = PackTestWindow()
from tkinter import *
class PackTestWindow:
def __init__(self):
self.root= Tk()
self.root.title("Pack Test")
self.l1 = Label(self.root, text="First label", fg="red")
self.l1.pack()
mainloop()
root = PackTestWindow()
self.l2 = Label(self.root, text="Second label", fg="green") self.l2.pack()
self.l3 = Label(self.root, text="Third label", fg="blue") self.l3.pack()
self.l1 = Label(self.root, text="First label", fg="red") self.l1.pack(side="left") self.l2 = Label(self.root, text="Second label", fg="green") self.l2.pack(side="left") self.l3 = Label(self.root, text="Third label", fg="blue") self.l3.pack(side="left")
from tkinter import * class FrameWindow: def __init__(self): self.root= Tk() self.root.title("Frame Test") self.top_frame = Frame(self.root) self.bottom_frame = Frame(self.root)
self.l1 = Label(self.top_frame, text="Red label", fg="red") self.l1.pack(side="top") self.l2 = Label(self.top_frame, text="Green label", fg="green") self.l2.pack(side="top") self.l3 = Label(self.top_frame, text="Blue label", fg="blue") self.l3.pack(side="top") self.l4 = Label(self.bottom_frame, text="Magenta label", fg="magenta") self.l4.pack(side="left") self.l5 = Label(self.bottom_frame, text="Cyan label", fg="cyan") self.l5.pack(side="left")
self.top_frame.pack() self.bottom_frame.pack() root = FrameWindow()
from tkinter import * class GridWindow: def __init__(self): self.root= Tk() self.root.title("Grid Test") self.l1 = Label(self.root, text="Red", fg="red") self.l1.grid(row=0, column=0) self.l2 = Label(self.root, text="Green", fg="green") self.l2.grid(row=0, column=1) self.l3 = Label(self.root, text="Blue", fg="blue") self.l3.grid(row=1, column=0) self.l4 = Label(self.root, text="Magenta", fg="magenta") self.l4.grid(row=1, column=1) mainloop() root = GridWindow()
from tkinter import *
class ButtonWindow:
def __init__(self):
self.root= Tk()
self.root.title("Button Test")
self.button = Button(self.root, text="Quit", command=quit)
self.button.pack()
mainloop()
root = ButtonWindow()
from tkinter import * import tkinter.messagebox class ButtonWindow: def __init__(self): self.root= Tk() self.root.title("Button Test") self.button = Button(self.root, \ text="Click for showinfo box", \ command=self.action) self.button.pack() mainloop() def action(self): tkinter.messagebox.showinfo("Show Info", \ "This is a message box created by showinfo") root = ButtonWindow()
def action(self): tkinter.messagebox.showwarning("Show Warning", "This is a message box created by showwarning")
def action(self): tkinter.messagebox.showerror("Show Error", "This is a message box created by showerror")
def action(self):
reply = tkinter.messagebox.askquestion("Ask Question", "This is a message box created by askquestion")
tkinter.messagebox.showerror("Result", "You clicked " + reply)