Python gtk 模块,gdk() 实例源码

我们从Python开源项目中,提取了以下45个代码示例,用于说明如何使用gtk.gdk()

项目:Eagle    作者:magerx    | 项目源码 | 文件源码
def __init__(self):
        gtk.DrawingArea.__init__(self)

        self.graph = Graph()
        self.openfilename = None

        self.set_flags(gtk.CAN_FOCUS)

        self.add_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK)
        self.connect("button-press-event", self.on_area_button_press)
        self.connect("button-release-event", self.on_area_button_release)
        self.add_events(gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.POINTER_MOTION_HINT_MASK | gtk.gdk.BUTTON_RELEASE_MASK)
        self.connect("motion-notify-event", self.on_area_motion_notify)
        self.connect("scroll-event", self.on_area_scroll_event)
        self.connect("size-allocate", self.on_area_size_allocate)

        self.connect('key-press-event', self.on_key_press_event)

        self.x, self.y = 0.0, 0.0
        self.zoom_ratio = 1.0
        self.zoom_to_fit_on_resize = False
        self.animation = NoAnimation(self)
        self.drag_action = NullAction(self)
        self.presstime = None
        self.highlight = None
项目:autoscan    作者:b01u    | 项目源码 | 文件源码
def __init__(self):
        gtk.DrawingArea.__init__(self)

        self.graph = Graph()
        self.openfilename = None

        self.set_flags(gtk.CAN_FOCUS)

        self.add_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK)
        self.connect("button-press-event", self.on_area_button_press)
        self.connect("button-release-event", self.on_area_button_release)
        self.add_events(gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.POINTER_MOTION_HINT_MASK | gtk.gdk.BUTTON_RELEASE_MASK)
        self.connect("motion-notify-event", self.on_area_motion_notify)
        self.connect("scroll-event", self.on_area_scroll_event)
        self.connect("size-allocate", self.on_area_size_allocate)

        self.connect('key-press-event', self.on_key_press_event)

        self.x, self.y = 0.0, 0.0
        self.zoom_ratio = 1.0
        self.zoom_to_fit_on_resize = False
        self.animation = NoAnimation(self)
        self.drag_action = NullAction(self)
        self.presstime = None
        self.highlight = None
项目:virtual-dressing-room    作者:akash0x53    | 项目源码 | 文件源码
def display_frame(self,a,b):
        self.drawing_area.window.draw_rectangle(self.drawing_area.get_style().white_gc,False,0,0,799,599)

        if self.isBanner_mode:
            self.canvas.draw_rgb_image(self.gc,1,1,798,598,gtk.gdk.RGB_DITHER_NORMAL,self.img.tostring(),2400)
            #self.final=self.getOutput_frames()
            #self.final=cv2.cvtColor(self.final,cv2.cv.CV_BGR2RGB)

        elif not self.isBanner_mode:

            if self.final==None:
                self.final=self.getOutput_frames()
                self.final=cv2.cvtColor(self.final,cv2.cv.CV_BGR2RGB)
                self.drawing_area.queue_draw()
                return 
            else:
                self.canvas.draw_rgb_image(self.gc,1,1,798,598,gtk.gdk.RGB_DITHER_NORMAL,self.final.tostring(),2400)
                self.final=self.getOutput_frames()
                self.final=cv2.cvtColor(self.final,cv2.cv.CV_BGR2RGB)
                self.drawing_area.queue_draw()

            #self.canvas.draw_rgb_image(self.gc,1,1,798,598,gtk.gdk.RGB_DITHER_NORMAL,self.final.tostring(),2400)
项目:autoinjection    作者:ChengWiLL    | 项目源码 | 文件源码
def draw(self, cr, highlight=False):
        cr2 = gtk.gdk.CairoContext(cr)
        pixbuf = gtk.gdk.pixbuf_new_from_file(self.path)
        sx = float(self.w)/float(pixbuf.get_width())
        sy = float(self.h)/float(pixbuf.get_height())
        cr.save()
        cr.translate(self.x0, self.y0 - self.h)
        cr.scale(sx, sy)
        cr2.set_source_pixbuf(pixbuf, 0, 0)
        cr2.paint()
        cr.restore()
项目:autoinjection    作者:ChengWiLL    | 项目源码 | 文件源码
def lookup_color(self, c):
        try:
            color = gtk.gdk.color_parse(c)
        except ValueError:
            pass
        else:
            s = 1.0/65535.0
            r = color.red*s
            g = color.green*s
            b = color.blue*s
            a = 1.0
            return r, g, b, a

        try:
            dummy, scheme, index = c.split('/')
            r, g, b = brewer_colors[scheme][int(index)]
        except (ValueError, KeyError):
            pass
        else:
            s = 1.0/255.0
            r = r*s
            g = g*s
            b = b*s
            a = 1.0
            return r, g, b, a

        sys.stderr.write("warning: unknown color '%s'\n" % c)
        return None
项目:autoinjection    作者:ChengWiLL    | 项目源码 | 文件源码
def on_motion_notify(self, event):
        if event.is_hint:
            x, y, state = event.window.get_pointer()
        else:
            x, y, state = event.x, event.y, event.state
        dot_widget = self.dot_widget
        item = dot_widget.get_url(x, y)
        if item is None:
            item = dot_widget.get_jump(x, y)
        if item is not None:
            dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))
            dot_widget.set_highlight(item.highlight)
        else:
            dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.ARROW))
            dot_widget.set_highlight(None)
项目:autoinjection    作者:ChengWiLL    | 项目源码 | 文件源码
def start(self):
        self.dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.FLEUR))
项目:autoinjection    作者:ChengWiLL    | 项目源码 | 文件源码
def stop(self):
        self.dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.ARROW))
项目:autoinjection    作者:ChengWiLL    | 项目源码 | 文件源码
def get_drag_action(self, event):
        state = event.state
        if event.button in (1, 2): # left or middle button
            if state & gtk.gdk.CONTROL_MASK:
                return ZoomAction
            elif state & gtk.gdk.SHIFT_MASK:
                return ZoomAreaAction
            else:
                return PanAction
        return NullAction
项目:autoinjection    作者:ChengWiLL    | 项目源码 | 文件源码
def is_click(self, event, click_fuzz=4, click_timeout=1.0):
        assert event.type == gtk.gdk.BUTTON_RELEASE
        if self.presstime is None:
            # got a button release without seeing the press?
            return False
        # XXX instead of doing this complicated logic, shouldn't we listen
        # for gtk's clicked event instead?
        deltax = self.pressx - event.x
        deltay = self.pressy - event.y
        return (time.time() < self.presstime + click_timeout
                and math.hypot(deltax, deltay) < click_fuzz)
项目:autoinjection    作者:ChengWiLL    | 项目源码 | 文件源码
def on_area_scroll_event(self, area, event):
        if event.direction == gtk.gdk.SCROLL_UP:
            self.zoom_image(self.zoom_ratio * self.ZOOM_INCREMENT,
                            pos=(event.x, event.y))
            return True
        if event.direction == gtk.gdk.SCROLL_DOWN:
            self.zoom_image(self.zoom_ratio / self.ZOOM_INCREMENT,
                            pos=(event.x, event.y))
            return True
        return False
项目:vivisect-py3    作者:bat-serjo    | 项目源码 | 文件源码
def __init__(self, graph, layout, scrollwin=None, ):
        gtk.DrawingArea.__init__(self)
        self._vg_graph = graph
        self._vg_layout = layout
        self._vg_scrollwin = scrollwin

        self.connect('expose-event', self.expose_event_cb)
        self.connect('button_press_event', self.button_press_event)
        self.set_events( self.get_events() | gtk.gdk.BUTTON_PRESS_MASK)

        self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color())
        self.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(green=65535))

        if scrollwin != None:
            scrollwin.connect('destroy', self.scroll_destroy_cb)
项目:vivisect-py3    作者:bat-serjo    | 项目源码 | 文件源码
def expose_event_cb(self, layout, event):

        style = self.get_style()
        gc = style.fg_gc[gtk.STATE_NORMAL]

        rect = self.get_allocation()

        owidth = rect.width
        oheight = rect.height

        lwidth, lheight = self._vg_layout.getLayoutSize()

        for nid, ninfo in self._vg_graph.getNodes():

            nwidth, nheight = ninfo.get('size', zero_zero)
            if nwidth == 0:
                continue

            xpos, ypos = ninfo.get('position', zero_zero)

            drawx = ((xpos * owidth) / lwidth)
            drawy = (ypos * oheight) / lheight

            sizex = owidth * nwidth / lwidth
            sizey = oheight * nheight / lheight

            colorstr = ninfo.get('color')
            if colorstr == None:
                colorstr = '#0f0'

            color = gtk.gdk.color_parse(colorstr)

            #self.modify_fg(gtk.STATE_NORMAL, color)
            self.window.draw_rectangle(gc, False, drawx, drawy, sizex, sizey)

            #c = self.window.cairo_create()
            #c.set_source_rgb(color.red / float(65535), color.green / float(65535), color.blue / float(65535))
            #c.rectangle(drawx, drawy, sizex, sizey)# event.area.x, event.area.y, event.area.width, event.area.height)
            #c.set_line_width(0.5)
            #c.stroke()
项目:vivisect-py3    作者:bat-serjo    | 项目源码 | 文件源码
def __init__(self, graph):
        gtk.Layout.__init__(self)
        vg_render.GraphRenderer.__init__(self, graph)

        self._vg_lines = []

        self.connect('expose-event', self.expose_event_cb)
        self.connect('button_press_event', self.button_press_event)

        self.set_events( self.get_events() | gtk.gdk.BUTTON_PRESS_MASK)

        self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color())
        self.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(green=65535))
项目:vivisect-py3    作者:bat-serjo    | 项目源码 | 文件源码
def setNodeSizes(self, graph):

        for nid, ninfo in graph.getNodes():

            # Skip "ghost" nodes...
            if ninfo.get('ghost'):
                continue

            widget = ninfo.get('widget')
            if widget == None:
                widget = gtk.Label(str(nid))
                widget.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color())
                widget.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(green=65535))
                ninfo['widget'] = widget

            # Put them all at 0,0 for now...
            self.put(widget, 0, 0)

        # Get them all to render...
        self.show_all()
        vw_main.doiterations()

        # Now that we have rendered them...
        for nid, ninfo in graph.getNodes():
            widget = ninfo.get('widget')
            if widget == None:
                continue

            size = widget.size_request()
            ninfo['size'] = size
项目:Eagle    作者:magerx    | 项目源码 | 文件源码
def lookup_color(self, c):
        try:
            color = gtk.gdk.color_parse(c)
        except ValueError:
            pass
        else:
            s = 1.0/65535.0
            r = color.red*s
            g = color.green*s
            b = color.blue*s
            a = 1.0
            return r, g, b, a

        try:
            dummy, scheme, index = c.split('/')
            r, g, b = brewer_colors[scheme][int(index)]
        except (ValueError, KeyError):
            pass
        else:
            s = 1.0/255.0
            r = r*s
            g = g*s
            b = b*s
            a = 1.0
            return r, g, b, a

        sys.stderr.write("unknown color '%s'\n" % c)
        return None
项目:Eagle    作者:magerx    | 项目源码 | 文件源码
def on_motion_notify(self, event):
        if event.is_hint:
            x, y, state = event.window.get_pointer()
        else:
            x, y, state = event.x, event.y, event.state
        dot_widget = self.dot_widget
        item = dot_widget.get_url(x, y)
        if item is None:
            item = dot_widget.get_jump(x, y)
        if item is not None:
            dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))
            dot_widget.set_highlight(item.highlight)
        else:
            dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.ARROW))
            dot_widget.set_highlight(None)
项目:Eagle    作者:magerx    | 项目源码 | 文件源码
def start(self):
        self.dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.FLEUR))
项目:Eagle    作者:magerx    | 项目源码 | 文件源码
def stop(self):
        self.dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.ARROW))
项目:Eagle    作者:magerx    | 项目源码 | 文件源码
def is_click(self, event, click_fuzz=4, click_timeout=1.0):
        assert event.type == gtk.gdk.BUTTON_RELEASE
        if self.presstime is None:
            # got a button release without seeing the press?
            return False
        # XXX instead of doing this complicated logic, shouldn't we listen
        # for gtk's clicked event instead?
        deltax = self.pressx - event.x
        deltay = self.pressy - event.y
        return (time.time() < self.presstime + click_timeout
                and math.hypot(deltax, deltay) < click_fuzz)
项目:Eagle    作者:magerx    | 项目源码 | 文件源码
def on_area_scroll_event(self, area, event):
        if event.direction == gtk.gdk.SCROLL_UP:
            self.zoom_image(self.zoom_ratio * self.ZOOM_INCREMENT,
                            pos=(event.x, event.y))
            return True
        if event.direction == gtk.gdk.SCROLL_DOWN:
            self.zoom_image(self.zoom_ratio / self.ZOOM_INCREMENT,
                            pos=(event.x, event.y))
            return True
        return False
项目:landport    作者:land-pack    | 项目源码 | 文件源码
def draw(self, cr, highlight=False):
        cr2 = gtk.gdk.CairoContext(cr)
        pixbuf = gtk.gdk.pixbuf_new_from_file(self.path)
        sx = float(self.w)/float(pixbuf.get_width())
        sy = float(self.h)/float(pixbuf.get_height())
        cr.save()
        cr.translate(self.x0, self.y0 - self.h)
        cr.scale(sx, sy)
        cr2.set_source_pixbuf(pixbuf, 0, 0)
        cr2.paint()
        cr.restore()
项目:landport    作者:land-pack    | 项目源码 | 文件源码
def lookup_color(self, c):
        try:
            color = gtk.gdk.color_parse(c)
        except ValueError:
            pass
        else:
            s = 1.0/65535.0
            r = color.red*s
            g = color.green*s
            b = color.blue*s
            a = 1.0
            return r, g, b, a

        try:
            dummy, scheme, index = c.split('/')
            r, g, b = brewer_colors[scheme][int(index)]
        except (ValueError, KeyError):
            pass
        else:
            s = 1.0/255.0
            r = r*s
            g = g*s
            b = b*s
            a = 1.0
            return r, g, b, a

        sys.stderr.write("warning: unknown color '%s'\n" % c)
        return None
项目:landport    作者:land-pack    | 项目源码 | 文件源码
def on_motion_notify(self, event):
        if event.is_hint:
            x, y, state = event.window.get_pointer()
        else:
            x, y, state = event.x, event.y, event.state
        dot_widget = self.dot_widget
        item = dot_widget.get_url(x, y)
        if item is None:
            item = dot_widget.get_jump(x, y)
        if item is not None:
            dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))
            dot_widget.set_highlight(item.highlight)
        else:
            dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.ARROW))
            dot_widget.set_highlight(None)
项目:landport    作者:land-pack    | 项目源码 | 文件源码
def start(self):
        self.dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.FLEUR))
项目:landport    作者:land-pack    | 项目源码 | 文件源码
def stop(self):
        self.dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.ARROW))
项目:landport    作者:land-pack    | 项目源码 | 文件源码
def get_drag_action(self, event):
        state = event.state
        if event.button in (1, 2): # left or middle button
            if state & gtk.gdk.CONTROL_MASK:
                return ZoomAction
            elif state & gtk.gdk.SHIFT_MASK:
                return ZoomAreaAction
            else:
                return PanAction
        return NullAction
项目:landport    作者:land-pack    | 项目源码 | 文件源码
def is_click(self, event, click_fuzz=4, click_timeout=1.0):
        assert event.type == gtk.gdk.BUTTON_RELEASE
        if self.presstime is None:
            # got a button release without seeing the press?
            return False
        # XXX instead of doing this complicated logic, shouldn't we listen
        # for gtk's clicked event instead?
        deltax = self.pressx - event.x
        deltay = self.pressy - event.y
        return (time.time() < self.presstime + click_timeout
                and math.hypot(deltax, deltay) < click_fuzz)
项目:landport    作者:land-pack    | 项目源码 | 文件源码
def on_area_scroll_event(self, area, event):
        if event.direction == gtk.gdk.SCROLL_UP:
            self.zoom_image(self.zoom_ratio * self.ZOOM_INCREMENT,
                            pos=(event.x, event.y))
            return True
        if event.direction == gtk.gdk.SCROLL_DOWN:
            self.zoom_image(self.zoom_ratio / self.ZOOM_INCREMENT,
                            pos=(event.x, event.y))
            return True
        return False
项目:hazzy    作者:KurtJacobson    | 项目源码 | 文件源码
def pressed(self, widget, event):
        if not self.use_default_controls:return
        button1 = event.button == 1
        button2 = event.button == 2
        button3 = event.button == 3
        if button1:
            self.select_prime(event.x, event.y) # select G-Code element
        if button3 and (event.type == gtk.gdk._2BUTTON_PRESS):
            self.clear_live_plotter()
        elif button1 or button2 or button3:
            self.startZoom(event.y)
            self.recordMouse(event.x, event.y)
项目:hazzy    作者:KurtJacobson    | 项目源码 | 文件源码
def scroll(self, widget, event):
        if not self.use_default_controls:return
        if event.direction == gtk.gdk.SCROLL_UP: self.zoomin()
        elif event.direction == gtk.gdk.SCROLL_DOWN: self.zoomout()
项目:Helix    作者:3lackrush    | 项目源码 | 文件源码
def draw(self, cr, highlight=False):
        cr2 = gtk.gdk.CairoContext(cr)
        pixbuf = gtk.gdk.pixbuf_new_from_file(self.path)
        sx = float(self.w)/float(pixbuf.get_width())
        sy = float(self.h)/float(pixbuf.get_height())
        cr.save()
        cr.translate(self.x0, self.y0 - self.h)
        cr.scale(sx, sy)
        cr2.set_source_pixbuf(pixbuf, 0, 0)
        cr2.paint()
        cr.restore()
项目:Helix    作者:3lackrush    | 项目源码 | 文件源码
def lookup_color(self, c):
        try:
            color = gtk.gdk.color_parse(c)
        except ValueError:
            pass
        else:
            s = 1.0/65535.0
            r = color.red*s
            g = color.green*s
            b = color.blue*s
            a = 1.0
            return r, g, b, a

        try:
            dummy, scheme, index = c.split('/')
            r, g, b = brewer_colors[scheme][int(index)]
        except (ValueError, KeyError):
            pass
        else:
            s = 1.0/255.0
            r = r*s
            g = g*s
            b = b*s
            a = 1.0
            return r, g, b, a

        sys.stderr.write("warning: unknown color '%s'\n" % c)
        return None
项目:Helix    作者:3lackrush    | 项目源码 | 文件源码
def on_motion_notify(self, event):
        if event.is_hint:
            x, y, state = event.window.get_pointer()
        else:
            x, y, state = event.x, event.y, event.state
        dot_widget = self.dot_widget
        item = dot_widget.get_url(x, y)
        if item is None:
            item = dot_widget.get_jump(x, y)
        if item is not None:
            dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))
            dot_widget.set_highlight(item.highlight)
        else:
            dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.ARROW))
            dot_widget.set_highlight(None)
项目:Helix    作者:3lackrush    | 项目源码 | 文件源码
def start(self):
        self.dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.FLEUR))
项目:Helix    作者:3lackrush    | 项目源码 | 文件源码
def stop(self):
        self.dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.ARROW))
项目:Helix    作者:3lackrush    | 项目源码 | 文件源码
def get_drag_action(self, event):
        state = event.state
        if event.button in (1, 2): # left or middle button
            if state & gtk.gdk.CONTROL_MASK:
                return ZoomAction
            elif state & gtk.gdk.SHIFT_MASK:
                return ZoomAreaAction
            else:
                return PanAction
        return NullAction
项目:Helix    作者:3lackrush    | 项目源码 | 文件源码
def is_click(self, event, click_fuzz=4, click_timeout=1.0):
        assert event.type == gtk.gdk.BUTTON_RELEASE
        if self.presstime is None:
            # got a button release without seeing the press?
            return False
        # XXX instead of doing this complicated logic, shouldn't we listen
        # for gtk's clicked event instead?
        deltax = self.pressx - event.x
        deltay = self.pressy - event.y
        return (time.time() < self.presstime + click_timeout
                and math.hypot(deltax, deltay) < click_fuzz)
项目:Helix    作者:3lackrush    | 项目源码 | 文件源码
def on_area_scroll_event(self, area, event):
        if event.direction == gtk.gdk.SCROLL_UP:
            self.zoom_image(self.zoom_ratio * self.ZOOM_INCREMENT,
                            pos=(event.x, event.y))
            return True
        if event.direction == gtk.gdk.SCROLL_DOWN:
            self.zoom_image(self.zoom_ratio / self.ZOOM_INCREMENT,
                            pos=(event.x, event.y))
            return True
        return False
项目:autoscan    作者:b01u    | 项目源码 | 文件源码
def lookup_color(self, c):
        try:
            color = gtk.gdk.color_parse(c)
        except ValueError:
            pass
        else:
            s = 1.0/65535.0
            r = color.red*s
            g = color.green*s
            b = color.blue*s
            a = 1.0
            return r, g, b, a

        try:
            dummy, scheme, index = c.split('/')
            r, g, b = brewer_colors[scheme][int(index)]
        except (ValueError, KeyError):
            pass
        else:
            s = 1.0/255.0
            r = r*s
            g = g*s
            b = b*s
            a = 1.0
            return r, g, b, a

        sys.stderr.write("unknown color '%s'\n" % c)
        return None
项目:autoscan    作者:b01u    | 项目源码 | 文件源码
def on_motion_notify(self, event):
        if event.is_hint:
            x, y, state = event.window.get_pointer()
        else:
            x, y, state = event.x, event.y, event.state
        dot_widget = self.dot_widget
        item = dot_widget.get_url(x, y)
        if item is None:
            item = dot_widget.get_jump(x, y)
        if item is not None:
            dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))
            dot_widget.set_highlight(item.highlight)
        else:
            dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.ARROW))
            dot_widget.set_highlight(None)
项目:autoscan    作者:b01u    | 项目源码 | 文件源码
def start(self):
        self.dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.FLEUR))
项目:autoscan    作者:b01u    | 项目源码 | 文件源码
def stop(self):
        self.dot_widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.ARROW))
项目:autoscan    作者:b01u    | 项目源码 | 文件源码
def is_click(self, event, click_fuzz=4, click_timeout=1.0):
        assert event.type == gtk.gdk.BUTTON_RELEASE
        if self.presstime is None:
            # got a button release without seeing the press?
            return False
        # XXX instead of doing this complicated logic, shouldn't we listen
        # for gtk's clicked event instead?
        deltax = self.pressx - event.x
        deltay = self.pressy - event.y
        return (time.time() < self.presstime + click_timeout
                and math.hypot(deltax, deltay) < click_fuzz)
项目:autoscan    作者:b01u    | 项目源码 | 文件源码
def on_area_scroll_event(self, area, event):
        if event.direction == gtk.gdk.SCROLL_UP:
            self.zoom_image(self.zoom_ratio * self.ZOOM_INCREMENT,
                            pos=(event.x, event.y))
            return True
        if event.direction == gtk.gdk.SCROLL_DOWN:
            self.zoom_image(self.zoom_ratio / self.ZOOM_INCREMENT,
                            pos=(event.x, event.y))
            return True
        return False