Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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")