有用。
import sys,os
import pygtk, gtk, gobject
class GTK_Main:
def __init__(self):
""" Window """
button_rc = """
style "deButton" {
# Default - Yellow
bg[NORMAL] = "yellow"
fg[NORMAL] = "#000000"
# Mouse-Over - Blue
fg[PRELIGHT] = "blue"
bg[PRELIGHT] = "#000000"
# Click - RED
bg[ACTIVE] = "red"
fg[ACTIVE] = "#000000"
}
widget "*.deButton" style "deButton"
"""
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_title("Test")
window.set_default_size(100, 100)
window.connect("destroy", gtk.main_quit, "WM destroy")
gtk.rc_parse_string(button_rc)
hbox_eq = gtk.HBox()
buttonlist = []
for i in [1,2,3,4,5,6,7,8,9]:
b = gtk.Button( str(i) )
b.set_name("deButton")
buttonlist.append(b)
hbox_eq.pack_start(b, True, True, 0)
for button in buttonlist:
print button.get_label()
window.add(hbox_eq)
window.show_all()
def exit(self, widget, data=None):
gtk.main_quit()
GTK_Main()
gtk.gdk.threads_init()
gtk.main()