當前位置: 首頁>>代碼示例>>Python>>正文


Python Button.connect_object方法代碼示例

本文整理匯總了Python中gtk.Button.connect_object方法的典型用法代碼示例。如果您正苦於以下問題:Python Button.connect_object方法的具體用法?Python Button.connect_object怎麽用?Python Button.connect_object使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gtk.Button的用法示例。


在下文中一共展示了Button.connect_object方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from gtk import Button [as 別名]
# 或者: from gtk.Button import connect_object [as 別名]
    def __init__(self, title=TITLE, level=WINDOW_TOPLEVEL, on_exit=None):
        self.title = title
        self.grabbing = False
        self.events = []
        self.rgb = WHITE_RGB
        self.on_exit = on_exit

        self.window = Window(level)
        self.window.set_title(title)
        self.window.set_resizable(True)
        self.window.add_events(POINTER_MOTION_MASK)
        self.window.set_default_size(350, 150)
        self.colors = []

        grab_btn = Button('Grab')
        grab_btn.connect_object('clicked', self.toggle_grab, self.window)
        self.grab_btn = grab_btn

        exit_btn = Button('Exit')
        exit_btn.connect_object('clicked', self.destroy, self.window)

        drawing = DrawingArea()
        drawing.connect_object('expose_event', self.do_expose, self.window)
        self.drawing = drawing

        label = Label(rgb_to_string(WHITE_RGB))
        self.label = label

        table = Table(2, 2, True)
        table.attach(self.drawing, 0, 1, 0, 1)
        table.attach(label,   0, 1, 1, 2)
        table.attach(grab_btn, 1, 2, 0, 1)
        table.attach(exit_btn, 1, 2, 1, 2)
        self.window.add(table)
開發者ID:omab,項目名稱:PointAndPick,代碼行數:36,代碼來源:pp.py

示例2: life_cb

# 需要導入模塊: from gtk import Button [as 別名]
# 或者: from gtk.Button import connect_object [as 別名]
    def life_cb(widget, event):
        gtk.main_quit()

    def other_cb(widget, event):
        gtk.main_quit()

    window = Window(gtk.WINDOW_TOPLEVEL)
    window.connect("destroy", gtk.main_quit)

    box = gtk.VBox(False, 0)

    stamp = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S')

    btn_same = Button("SAME")
    btn_same.connect_object("button_press_event", same_cb, window)
    box.pack_start(btn_same, True, True, 0)

    btn_project = Button("project")
    btn_project.connect_object("button_press_event", project_cb, window)
    box.pack_start(btn_project, True, True, 0)

    btn_study = Button("study")
    btn_study.connect_object("button_press_event", study_cb, window)
    box.pack_start(btn_study, True, True, 0)

    btn_life = Button("life")
    btn_life.connect_object("button_press_event", life_cb, window)
    box.pack_start(btn_life, True, True, 0)

    btn_other = Button("other")
開發者ID:jmptable,項目名稱:timetracker900,代碼行數:32,代碼來源:timetracker.py


注:本文中的gtk.Button.connect_object方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。