Ejemplo 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)