Skip to content

Commit

Permalink
Merge pull request #5 from bknox95/patch-2
Browse files Browse the repository at this point in the history
Updated 19.01
  • Loading branch information
epequeno authored Dec 5, 2016
2 parents 89c6ebd + f7f3a8b commit a818e4b
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion ch19/19.01.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,41 @@
# What happens if you press the buttons more than once? You can see my
# solution at thinkpython.com/code/button_demo.py

# Current Status: Incomplete
# Current Status: Complete
#note: Written in Python 3.5
#Author: bknox95

from tkinter import messagebox
import tkinter as tk
class Window1:
def __init__(self, master):
self.master = master
self.frame = tk.Frame(self.master)
self.button1 = tk.Button(self.frame, text = 'Press Me', width = 25, command = self.new_window)
self.button1.pack()
self.frame.pack()
def new_window(self):
self.newWindow = tk.Toplevel(self.master)
self.app = Window2(self.newWindow)


#Creates Window2 with button2 that displays a "Nice Job" message
class Window2:
def __init__(self, master):
self.master = master
self.frame = tk.Frame(self.master)
self.button2 = tk.Button(self.frame, text = 'Now Press Me', width = 25, command = self.new_window)
self.button2.pack()
self.frame.pack()
def new_window(self):
msg=messagebox.showinfo(message="Nice Job!")
self.master.destroy()


def main():
root = tk.Tk()
app = Window1(root)
root.mainloop()

if __name__ == '__main__':
main()

0 comments on commit a818e4b

Please sign in to comment.