#!/usr/bin/env python import gtk class MyButton(gtk.Button): def __init__(self, label=None): # chain up to parent __init__ gtk.Button.__init__(self, label) def set_label(self, label): gtk.Button.set_label(self, label + " dork!") def buttonPressed(button): button.set_label("I've been pressed!") win = gtk.Window() button = MyButton('Hello, world. Press me') win.add(button) button.connect('pressed', buttonPressed) win.show_all() win.connect('destroy', lambda w: gtk.main_quit()) gtk.main()