当前位置: 首页>>代码示例>>Python>>正文


Python gobject.GError方法代码示例

本文整理汇总了Python中gobject.GError方法的典型用法代码示例。如果您正苦于以下问题:Python gobject.GError方法的具体用法?Python gobject.GError怎么用?Python gobject.GError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gobject的用法示例。


在下文中一共展示了gobject.GError方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: apply_icon

# 需要导入模块: import gobject [as 别名]
# 或者: from gobject import GError [as 别名]
def apply_icon(self, requested_icon):
        """Set the window icon"""
        icon_theme = gtk.IconTheme()
        icon = None
        
        if requested_icon:
            try:
                self.set_icon_from_file(requested_icon)
                icon = self.get_icon()
            except (NameError, gobject.GError):
                dbg('Unable to load 48px %s icon as file' % (repr(requested_icon)))
        
        if requested_icon and icon is None:
            try:
                icon = icon_theme.load_icon(requested_icon, 48, 0)
            except (NameError, gobject.GError):
                dbg('Unable to load 48px %s icon' % (repr(requested_icon)))
        
        if icon is None:
            try:
                icon = icon_theme.load_icon(self.wmclass_name, 48, 0)
            except (NameError, gobject.GError):
                dbg('Unable to load 48px %s icon' % (self.wmclass_name))
        
        if icon is None:
            try:
                icon = icon_theme.load_icon(APP_NAME, 48, 0)
            except (NameError, gobject.GError):
                dbg('Unable to load 48px Terminator icon')
                icon = self.render_icon(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_BUTTON)

        self.set_icon(icon) 
开发者ID:OWASP,项目名称:NINJA-PingU,代码行数:34,代码来源:window.py

示例2: _print_image

# 需要导入模块: import gobject [as 别名]
# 或者: from gobject import GError [as 别名]
def _print_image(self, filename, format, *args, **kwargs):
        if self.flags() & gtk.REALIZED == 0:
            # for self.window(for pixmap) and has a side effect of altering
            # figure width,height (via configure-event?)
            gtk.DrawingArea.realize(self)

        width, height = self.get_width_height()
        pixmap = gdk.Pixmap (self.window, width, height)
        self._renderer.set_pixmap (pixmap)
        self._render_figure(pixmap, width, height)

        # jpg colors don't match the display very well, png colors match
        # better
        pixbuf = gdk.Pixbuf(gdk.COLORSPACE_RGB, 0, 8, width, height)
        pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(),
                                     0, 0, 0, 0, width, height)

        # set the default quality, if we are writing a JPEG.
        # http://www.pygtk.org/docs/pygtk/class-gdkpixbuf.html#method-gdkpixbuf--save
        options = {k: kwargs[k] for k in ['quality'] if k in kwargs}
        if format in ['jpg', 'jpeg']:
            options.setdefault('quality', rcParams['savefig.jpeg_quality'])
            options['quality'] = str(options['quality'])

        if isinstance(filename, six.string_types):
            try:
                pixbuf.save(filename, format, options=options)
            except gobject.GError as exc:
                error_msg_gtk('Save figure failure:\n%s' % (exc,), parent=self)
        elif is_writable_file_like(filename):
            if hasattr(pixbuf, 'save_to_callback'):
                def save_callback(buf, data=None):
                    data.write(buf)
                try:
                    pixbuf.save_to_callback(save_callback, format, user_data=filename, options=options)
                except gobject.GError as exc:
                    error_msg_gtk('Save figure failure:\n%s' % (exc,), parent=self)
            else:
                raise ValueError("Saving to a Python file-like object is only supported by PyGTK >= 2.8")
        else:
            raise ValueError("filename must be a path or a file-like object") 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:43,代码来源:backend_gtk.py

示例3: _print_image

# 需要导入模块: import gobject [as 别名]
# 或者: from gobject import GError [as 别名]
def _print_image(self, filename, format, *args, **kwargs):
        if self.flags() & gtk.REALIZED == 0:
            # for self.window(for pixmap) and has a side effect of altering
            # figure width,height (via configure-event?)
            gtk.DrawingArea.realize(self)

        width, height = self.get_width_height()
        pixmap = gdk.Pixmap (self.window, width, height)
        self._renderer.set_pixmap (pixmap)
        self._render_figure(pixmap, width, height)

        # jpg colors don't match the display very well, png colors match
        # better
        pixbuf = gdk.Pixbuf(gdk.COLORSPACE_RGB, 0, 8, width, height)
        pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(),
                                     0, 0, 0, 0, width, height)

        # set the default quality, if we are writing a JPEG.
        # http://www.pygtk.org/docs/pygtk/class-gdkpixbuf.html#method-gdkpixbuf--save
        options = cbook.restrict_dict(kwargs, ['quality'])
        if format in ['jpg','jpeg']:
           if 'quality' not in options:
              options['quality'] = rcParams['savefig.jpeg_quality']

           options['quality'] = str(options['quality'])

        if is_string_like(filename):
            try:
                pixbuf.save(filename, format, options=options)
            except gobject.GError as exc:
                error_msg_gtk('Save figure failure:\n%s' % (exc,), parent=self)
        elif is_writable_file_like(filename):
            if hasattr(pixbuf, 'save_to_callback'):
                def save_callback(buf, data=None):
                    data.write(buf)
                try:
                    pixbuf.save_to_callback(save_callback, format, user_data=filename, options=options)
                except gobject.GError as exc:
                    error_msg_gtk('Save figure failure:\n%s' % (exc,), parent=self)
            else:
                raise ValueError("Saving to a Python file-like object is only supported by PyGTK >= 2.8")
        else:
            raise ValueError("filename must be a path or a file-like object") 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:45,代码来源:backend_gtk.py

示例4: __init__

# 需要导入模块: import gobject [as 别名]
# 或者: from gobject import GError [as 别名]
def __init__(self, canvas, num):
        if _debug: print('FigureManagerGTK.%s' % fn_name())
        FigureManagerBase.__init__(self, canvas, num)

        self.window = gtk.Window()
        self.set_window_title("Figure %d" % num)
        if (window_icon):
            try:
                self.window.set_icon_from_file(window_icon)
            except:
                # some versions of gtk throw a glib.GError but not
                # all, so I am not sure how to catch it.  I am unhappy
                # diong a blanket catch here, but an not sure what a
                # better way is - JDH
                verbose.report('Could not load matplotlib icon: %s' % sys.exc_info()[1])

        self.vbox = gtk.VBox()
        self.window.add(self.vbox)
        self.vbox.show()

        self.canvas.show()

        self.vbox.pack_start(self.canvas, True, True)

        self.toolbar = self._get_toolbar(canvas)

        # calculate size for window
        w = int (self.canvas.figure.bbox.width)
        h = int (self.canvas.figure.bbox.height)

        if self.toolbar is not None:
            self.toolbar.show()
            self.vbox.pack_end(self.toolbar, False, False)

            tb_w, tb_h = self.toolbar.size_request()
            h += tb_h
        self.window.set_default_size (w, h)

        def destroy(*args):
            Gcf.destroy(num)
        self.window.connect("destroy", destroy)
        self.window.connect("delete_event", destroy)
        if matplotlib.is_interactive():
            self.window.show()

        def notify_axes_change(fig):
            'this will be called whenever the current axes is changed'
            if self.toolbar is not None: self.toolbar.update()
        self.canvas.figure.add_axobserver(notify_axes_change)

        self.canvas.grab_focus() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:53,代码来源:backend_gtk.py

示例5: __init__

# 需要导入模块: import gobject [as 别名]
# 或者: from gobject import GError [as 别名]
def __init__(self, canvas, num):
        FigureManagerBase.__init__(self, canvas, num)

        self.window = gtk.Window()
        self.window.set_wmclass("matplotlib", "Matplotlib")
        self.set_window_title("Figure %d" % num)
        if window_icon:
            try:
                self.window.set_icon_from_file(window_icon)
            except:
                # some versions of gtk throw a glib.GError but not
                # all, so I am not sure how to catch it.  I am unhappy
                # diong a blanket catch here, but an not sure what a
                # better way is - JDH
                _log.info('Could not load matplotlib '
                         'icon: %s', sys.exc_info()[1])

        self.vbox = gtk.VBox()
        self.window.add(self.vbox)
        self.vbox.show()

        self.canvas.show()

        self.vbox.pack_start(self.canvas, True, True)

        self.toolbar = self._get_toolbar(canvas)

        # calculate size for window
        w = int (self.canvas.figure.bbox.width)
        h = int (self.canvas.figure.bbox.height)

        if self.toolbar is not None:
            self.toolbar.show()
            self.vbox.pack_end(self.toolbar, False, False)

            tb_w, tb_h = self.toolbar.size_request()
            h += tb_h
        self.window.set_default_size (w, h)

        def destroy(*args):
            Gcf.destroy(num)
        self.window.connect("destroy", destroy)
        self.window.connect("delete_event", destroy)
        if matplotlib.is_interactive():
            self.window.show()
            self.canvas.draw_idle()

        def notify_axes_change(fig):
            'this will be called whenever the current axes is changed'
            if self.toolbar is not None: self.toolbar.update()
        self.canvas.figure.add_axobserver(notify_axes_change)

        self.canvas.grab_focus() 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:55,代码来源:backend_gtk.py


注:本文中的gobject.GError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。