Add a button to frame : Button « GUI Tk « Python

Home
Python
1.2D
2.Application
3.Buildin Function
4.Class
5.Data Structure
6.Data Type
7.Database
8.Development
9.Dictionary
10.Event
11.Exception
12.File
13.Function
14.GUI Pmw
15.GUI Tk
16.Language Basics
17.List
18.Math
19.Network
20.String
21.System
22.Thread
23.Tuple
24.Utility
25.XML
Perl
Ruby
PHP
Python Tutorial
Python Open Source
Python » GUI Tk » Button 
Add a button to frame


from Tkinter import *                   

class Hello(Frame):                     
    def __init__(self, parent=None):    
        Frame.__init__(self, parent)
        self.pack()
        self.make_widgets()

    def make_widgets(self):             
        widget = Button(self, text='Hello world', command=self.quit)
        widget.pack(side=LEFT)

if __name__ == '__main__':  Hello().mainloop()

           
       
Related examples in the same category
1.Simple Button Action
2.Disable a button
3.Enable a button
4.Set Button to get focus
5.Button Border styles
6.Button action to set Button background
7.Button event binding: without passing the event as an argument
8.Button focus
9.create a button, and put it into a Container
10.Set Button background by property name
11.Specify the button's properties
12.Button action inside a class
13.Button width
14.Buttons on a toolbar
15.Button foreground color
16.Creating buttons
17.Button single click and double click
18.Use lambda to generate a call back function for a button
19.adds user-defined callbacks as button action
20.Subclasses button
21.Subclass HelloButton: redefine press-handler method
22.Sub class button: add callback method and pack myself
23.Sub class button: add callback method and use a dictionary
24.Button Border
25.Button border size
26.Button border effects: RAISED
27.Button background, foreground and font
28.Button width and height
29.Config button properties
30.Add gif image to a button
31.Bind mouse single click and double click to a button
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.