Chapter 17: Windows Programming

Message Box, Page number: 563

In [ ]:
from tkinter import *


#creating window
root = Tk()
root.title("Press Me")
button1 = Button(root, text="Press Me") #creating button
button1.pack()
import ctypes #creating message box
MessageBox = ctypes.windll.user32.MessageBoxW
MessageBox(None, 'Hi!', 'Waiting', 0)
root.mainloop()

More Windows, Page number: 566

In [ ]:
from tkinter import *
root = []
#creating windows
for x in range(0,10):
    root.append(Tk())
    root[x].title("Press Me")
    button1 = Button(root[x], text="Press Me") #creating button
    button1.pack()
    
import ctypes #creating message box
MessageBox = ctypes.windll.user32.MessageBoxW
MessageBox(None, 'Hi!', 'Waiting', 0)

A Real World Window, Page number: 568

In [ ]:
from tkinter import *


class Example(Frame):
        def __init__(self, parent):
            Frame.__init__(self, parent)

            self.display = Canvas(self, width=700, height=200)
            self.display.pack(side="top", fill="both", expand=True)
            
if __name__ == "__main__":
    root = Tk()
    root.title("Title")
    Frame = Example(parent=root)
    Frame.pack(side="top", fill="both", expand=True)
    root.mainloop()