~ubuntu-branches/ubuntu/maverick/python3.1/maverick

« back to all changes in this revision

Viewing changes to Demo/tkinter/matt/window-creation-simple.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-03-23 00:01:27 UTC
  • Revision ID: james.westby@ubuntu.com-20090323000127-5fstfxju4ufrhthq
Tags: upstream-3.1~a1+20090322
ImportĀ upstreamĀ versionĀ 3.1~a1+20090322

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from tkinter import *
 
2
 
 
3
# this shows how to spawn off new windows at a button press
 
4
 
 
5
class Test(Frame):
 
6
    def printit(self):
 
7
        print("hi")
 
8
 
 
9
    def makeWindow(self):
 
10
        fred = Toplevel()
 
11
        fred.label = Label(fred, text="Here's a new window")
 
12
        fred.label.pack()
 
13
 
 
14
    def createWidgets(self):
 
15
        self.QUIT = Button(self, text='QUIT', foreground='red',
 
16
                           command=self.quit)
 
17
 
 
18
        self.QUIT.pack(side=LEFT, fill=BOTH)
 
19
 
 
20
        # a hello button
 
21
        self.hi_there = Button(self, text='Make a New Window',
 
22
                               command=self.makeWindow)
 
23
        self.hi_there.pack(side=LEFT)
 
24
 
 
25
    def __init__(self, master=None):
 
26
        Frame.__init__(self, master)
 
27
        Pack.config(self)
 
28
        self.createWidgets()
 
29
 
 
30
test = Test()
 
31
test.mainloop()