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

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

项目: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
项目:epoptes    作者:Epoptes    | 项目源码 | 文件源码
def __init__(self):
        gtk.DrawingArea.__init__(self)
        self.connect("expose-event", self.expose)
        self.connect("size-allocate", self.size_allocate)
        self._surface = None
        self._options = None
项目:driveboardapp    作者:nortd    | 项目源码 | 文件源码
def __init__(self):
        global args

        super(PyApp, self).__init__()

        self.set_title("Lasersaur")
        self.resize(1220, 610)
        self.set_position(gtk.WIN_POS_CENTER)

        self.connect("destroy", gtk.main_quit)
        # exit with ctr-q
        accel_group = gtk.AccelGroup()
        accel_group.connect_group(ord('q'), gtk.gdk.CONTROL_MASK,
        gtk.ACCEL_LOCKED, gtk.main_quit)
        self.add_accel_group(accel_group)

        self.darea = gtk.DrawingArea()
        self.darea.connect("expose-event", self.expose)
        self.add(self.darea)

        if args.animate:
            self.timer = True
            if args.fast:
                glib.timeout_add(10, self.on_timer)  #100fps
                self.inc = 8
            else:
                glib.timeout_add(40, self.on_timer)  #25fps
                self.inc = 4
            self.todraw = self.inc

        self.show_all()
项目:autoinjection    作者:ChengWiLL    | 项目源码 | 文件源码
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.last_mtime = None

        gobject.timeout_add(1000, self.update)

        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
项目: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)
项目:96board-mqtt-demo    作者:bfletcher    | 项目源码 | 文件源码
def _setup_widgets(self):
        self._window = gtk.Window()
        self._window.hide()
        self._window.connect("destroy", self._quit)
        widget = gtk.DrawingArea()
        self._window.add(widget)
        self.lcd_display = LCDWidget(widget, g_rows, g_cols)
项目:mgr.p2p.proxy    作者:tomusdrw    | 项目源码 | 文件源码
def __init__(self, node, *args, **kwargs):
        gtk.DrawingArea.__init__(self, *args, **kwargs)
        self.node = node
        self.timeoutID = gobject.timeout_add(5000, self.timeout)
        self.comms = {}
        self.incomingComms = {}
        # poison the node with our GUI hooks
        self.node._protocol.__gui = self
        self.node._protocol.__realSendRPC = self.node._protocol.sendRPC
        self.node._protocol.sendRPC = self.__guiSendRPC

        self.node._protocol.__realDatagramReceived = self.node._protocol.datagramReceived
        self.node._protocol.datagramReceived = self.__guiDatagramReceived
        self.msgCounter = 0
        self.printMsgCount = False
项目:landport    作者:land-pack    | 项目源码 | 文件源码
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.last_mtime = None

        gobject.timeout_add(1000, self.update)

        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
项目:Helix    作者:3lackrush    | 项目源码 | 文件源码
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.last_mtime = None

        gobject.timeout_add(1000, self.update)

        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
项目:wahcade    作者:sairuk    | 项目源码 | 文件源码
def __init__(self):
        """initialise video widget"""
        #print "VideoWidget.__init__"
        gtk.DrawingArea.__init__(self)
        self.connect('realize', self.on_realize)
项目:hls-player    作者:weimingtom    | 项目源码 | 文件源码
def __init__(self, display=True):
        import pygst
        import gst
        if display:
            self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
            self.window.set_title("Video-Player")
            self.window.set_default_size(500, 400)
            self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
            self.window.connect('delete-event', lambda _: reactor.stop())
            self.movie_window = gtk.DrawingArea()
            self.window.add(self.movie_window)
            self.window.show_all()

        self.player = gst.Pipeline("player")
        self.appsrc = gst.element_factory_make("appsrc", "source")
        self.appsrc.connect("enough-data", self.on_enough_data)
        self.appsrc.connect("need-data", self.on_need_data)
        self.appsrc.set_property("max-bytes", 10000)
        if display:
            self.decodebin = gst.element_factory_make("decodebin2", "decodebin")
            self.decodebin.connect("new-decoded-pad", self.on_decoded_pad)
            self.player.add(self.appsrc, self.decodebin)
            gst.element_link_many(self.appsrc, self.decodebin)
        else:
            sink = gst.element_factory_make("filesink", "filesink")
            sink.set_property("location", "/tmp/hls-player.ts")
            self.player.add(self.appsrc, sink)
            gst.element_link_many(self.appsrc, sink)
        bus = self.player.get_bus()
        bus.add_signal_watch()
        bus.enable_sync_message_emission()
        bus.connect("message", self.on_message)
        bus.connect("sync-message::element", self.on_sync_message)
        self._playing = False
        self._need_data = False
        self._cb = None
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def __init__(self):
        gtk.DrawingArea.__init__(self)
        self.set_double_buffered(False)
        self.add_events(
            gtk.gdk.BUTTON_PRESS_MASK| 
            gtk.gdk.BUTTON_RELEASE_MASK| 
            gtk.gdk.BUTTON1_MOTION_MASK| 
            gtk.gdk.BUTTON2_MOTION_MASK| 
            gtk.gdk.BUTTON3_MOTION_MASK| 
            gtk.gdk.SCROLL_MASK| 
            gtk.gdk.KEY_PRESS_MASK| 
            gtk.gdk.KEY_RELEASE_MASK)

        # foregorund, background
        self.fg = (0, 0, 0)
        self.bg = (0, 0, 0)

        # list of layers
        self.layers = []

        # visible are used for speedup as list
        self.visible = None

        # canvas bindings
        self.bindings = {}

        # last item which had some event
        self.current_item = None

        # cairo context
        self.cr = None

        # cached cairo image surfaces using filenames/images as keys
        self.cache_filenames = {}
        self.cache_images = {}

        # connect event callbacks
        gtk.DrawingArea.connect(self, 'configure-event', self.drawingarea_configure_event_cb)
        gtk.DrawingArea.connect(self, 'expose-event', self.drawingarea_expose_event_cb)
        gtk.DrawingArea.connect(self, 'button-press-event', self.drawingarea_button_press_event_cb)
        gtk.DrawingArea.connect(self, 'button-release-event', self.drawingarea_button_release_event_cb)
        gtk.DrawingArea.connect(self, 'motion-notify-event', self.drawingarea_motion_notify_event_cb)
        gtk.DrawingArea.connect(self, 'scroll-event', self.drawingarea_scroll_event_cb)