Python gtk.Image() Examples

The following are 14 code examples of gtk.Image(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gtk , or try the search function .
Example #1
Source File: notebook.py    From nightmare with GNU General Public License v2.0 6 votes vote down vote up
def createTabLabel(page, notebook):
    label = gtk.Label(page.vwGetDisplayName())

    if not page.vwIsClosable():
        return label

    box = gtk.HBox()
    image = gtk.Image()
    image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_SMALL_TOOLBAR)

    cbutton = gtk.Button()
    cbutton.connect("clicked", closeTabButton, page, notebook)
    cbutton.set_image(image)
    cbutton.set_relief(gtk.RELIEF_NONE)

    box.pack_start(label, True, True)
    box.pack_end(cbutton, False, False)
    box.show_all()
    return box 
Example #2
Source File: notebook.py    From NINJA-PingU with GNU General Public License v3.0 5 votes vote down vote up
def update_button(self):
        """Update the state of our close button"""
        if not self.config['close_button_on_tab']:
            if self.button:
                self.button.remove(self.icon)
                self.remove(self.button)
                del(self.button)
                del(self.icon)
                self.button = None
                self.icon = None
            return

        if not self.button:
            self.button = gtk.Button()
        if not self.icon:
            self.icon = gtk.Image()
            self.icon.set_from_stock(gtk.STOCK_CLOSE,
                                     gtk.ICON_SIZE_MENU)

        self.button.set_focus_on_click(False)
        self.button.set_relief(gtk.RELIEF_NONE)
        style = gtk.RcStyle()
        style.xthickness = 0
        style.ythickness = 0
        self.button.modify_style(style)
        self.button.add(self.icon)
        self.button.connect('clicked', self.on_close)
        self.button.set_name('terminator-tab-close-button')
        if hasattr(self.button, 'set_tooltip_text'):
            self.button.set_tooltip_text(_('Close Tab'))
        self.pack_start(self.button, False, False)
        self.show_all() 
Example #3
Source File: custom_commands.py    From NINJA-PingU with GNU General Public License v3.0 5 votes vote down vote up
def callback(self, menuitems, menu, terminal):
        """Add our menu items to the menu"""
        item = gtk.MenuItem(_('Custom Commands'))
        menuitems.append(item)

        submenu = gtk.Menu()
        item.set_submenu(submenu)

        menuitem = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
        menuitem.connect("activate", self.configure)
        submenu.append(menuitem)

        menuitem = gtk.SeparatorMenuItem()
        submenu.append(menuitem)

        theme = gtk.IconTheme()
        for command in self.cmd_list:
          if not command['enabled']:
            continue
          exe = command['command'].split(' ')[0]
          iconinfo = theme.choose_icon([exe], gtk.ICON_SIZE_MENU, gtk.ICON_LOOKUP_USE_BUILTIN)
          if iconinfo:
            image = gtk.Image()
            image.set_from_icon_name(exe, gtk.ICON_SIZE_MENU)
            menuitem = gtk.ImageMenuItem(command['name'])
            menuitem.set_image(image)
          else:
            menuitem = gtk.MenuItem(command["name"])
          menuitem.connect("activate", self._execute, {'terminal' : terminal, 'command' : command['command'] })
          submenu.append(menuitem) 
Example #4
Source File: status_icon_gtk2.py    From sun with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        self.dialog_title = ""
        self.daemon_STOCK = gtk.STOCK_YES
        self.sun_icon = "{0}{1}.png".format(icon_path, __all__)
        self.icon = gtk.status_icon_new_from_file(self.sun_icon)
        self.icon.connect("popup-menu", self.right_click)
        self.img = gtk.Image()
        self.img.set_from_file(self.sun_icon)
        self.icon.set_tooltip("Slackware Update Notifier")
        self.cmd = "{0}sun_daemon".format(bin_path)
        self.daemon_start()
        gtk.main() 
Example #5
Source File: window_tools.py    From openxenmanager with GNU General Public License v2.0 5 votes vote down vote up
def finish(self):
        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU) 
        self.widget2.set_image(image)
        self.widget2.set_label("Close") 
Example #6
Source File: gtk-example.py    From SimpleCV2 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self):
        super(app, self).__init__()
        self.set_position(gtk.WIN_POS_CENTER)
        self.set_title("Edge Threshold Adjuster")
        self.set_decorated(True)
        self.set_has_frame(False)
        self.set_resizable(False)
        self.set_default_size(self.window_width,self.window_height)
        self.connect("destroy", gtk.main_quit)
        vbox = gtk.VBox(spacing=4)


        #Setup the slider bar
        scale = gtk.HScale()
        scale.set_range(self.min_threshold, self.max_threshold)
        scale.set_size_request(500, 25)
        scale.set_value((self.max_threshold + self.min_threshold) / 2)
        scale.connect("value-changed", self.update_threshold)
        vbox.add(scale)

        #Setup the information label
        info = gtk.Label()
        info.set_label("Move the slider to adjust the edge detection threshold")
        vbox.add(info)

        #Add the image to the display
        new_image = self.process_image()
        converted_image = gtk.gdk.pixbuf_new_from_array(new_image, gtk.gdk.COLORSPACE_RGB, 8)
        image = gtk.Image()
        image.set_from_pixbuf(converted_image)
        image.show()
        vbox.add(image)


        self.current_image = image
        self.add(vbox)
        self.show_all() 
Example #7
Source File: gtk-example.py    From SimpleCV2 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def process_image(self):
        #Start SimpleCV Code
        img = SimpleCV.Image('lenna').rotate90()
        edges = img.edges(self.edge_threshold)
        numpy_img = edges.getNumpy()
        #End SimpleCV Code
        return numpy_img


    #This function is called anything the slider is moved 
Example #8
Source File: gtk-example-camera.py    From SimpleCV2 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self):
        super(app, self).__init__()
        self.set_position(gtk.WIN_POS_CENTER)
        self.set_title("Edge Threshold Adjuster")
        self.set_decorated(True)
        self.set_has_frame(False)
        self.set_resizable(False)
        self.set_default_size(self.window_width,self.window_height)
        self.connect("destroy", gtk.main_quit)
        vbox = gtk.VBox(spacing=4)


        #Setup the slider bar
        scale = gtk.HScale()
        scale.set_range(self.min_threshold, self.max_threshold)
        scale.set_size_request(500, 25)
        scale.set_value((self.max_threshold + self.min_threshold) / 2)
        scale.connect("value-changed", self.update_threshold)
        vbox.add(scale)

        #Setup the information label
        info = gtk.Label()
        info.set_label("Move the slider to adjust the edge detection threshold")
        vbox.add(info)

        #Add the image to the display
        new_image = self.process_image()
        converted_image = gtk.gdk.pixbuf_new_from_array(new_image, gtk.gdk.COLORSPACE_RGB, 8)
        image = gtk.Image()
        image.set_from_pixbuf(converted_image)
        image.show()
        vbox.add(image)


        gobject.timeout_add(self.refresh_rate, self.refresh)
        self.current_image = image
        self.add(vbox)
        self.show_all() 
Example #9
Source File: gtkbase.py    From gui-o-matic with GNU Lesser General Public License v3.0 5 votes vote down vote up
def _main_window_indicator(self, menu_container, icon_container):
        if not self._HAVE_INDICATOR:
            menubar = gtk.MenuBar()
            im = gtk.MenuItem(self.config.get('app_name', 'GUI-o-Matic'))
            im.set_submenu(self.menu)
            menubar.append(im)
            menu_container.pack_start(menubar, False, True)

            icon = gtk.Image()
            icon_container.pack_start(icon, False, True)
            self.main_window['indicator_icon'] = icon 
Example #10
Source File: radmin.py    From rpy2 with GNU General Public License v2.0 5 votes vote down vote up
def get_splash():
    splash = gtk.Window(gtk.WINDOW_TOPLEVEL)
    splash.set_events(splash.get_events() | gtk.gdk.BUTTON_PRESS_MASK)
    def f(widget, data=None):
        splash.destroy()
    splash.connect('button_press_event', f)

    eb = gtk.EventBox()
    eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
    image = gtk.Image()
    image.show()
    image.set_from_file(os.path.join(rpy2.__path__[0], "images", "rpy2_logo.png"))
    splashVBox = gtk.VBox()

    splashVBox.pack_start(image, True, True, 0)
    splashVBox.pack_start(gtk.Label("A GTK+ toy user interface"), 
                          True, True, 0)
    eb.add(splashVBox)
    splash.add(eb)
    splash.realize()
    splash.window.set_type_hint (gtk.gdk.WINDOW_TYPE_HINT_SPLASHSCREEN)
    # needed on Win32
    splash.set_decorated (False)
    splash.set_position (gtk.WIN_POS_CENTER)
    return splash 
Example #11
Source File: titlebar.py    From NINJA-PingU with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, terminal):
        """Class initialiser"""
        gtk.EventBox.__init__(self)
        self.__gobject_init__()

        self.terminator = Terminator()
        self.terminal = terminal
        self.config = self.terminal.config

        self.label = EditableLabel()
        self.label.connect('edit-done', self.on_edit_done)
        self.ebox = gtk.EventBox()
        grouphbox = gtk.HBox()
        self.grouplabel = gtk.Label()
        self.groupicon = gtk.Image()
        self.bellicon = gtk.Image()
        self.bellicon.set_no_show_all(True)

        self.groupentry = gtk.Entry()
        self.groupentry.set_no_show_all(True)
        self.groupentry.connect('focus-out-event', self.groupentry_cancel)
        self.groupentry.connect('activate', self.groupentry_activate)
        self.groupentry.connect('key-press-event', self.groupentry_keypress)

        groupsend_type = self.terminator.groupsend_type
        if self.terminator.groupsend == groupsend_type['all']:
            icon_name = 'all'
        elif self.terminator.groupsend == groupsend_type['group']:
            icon_name = 'group'
        elif self.terminator.groupsend == groupsend_type['off']:
            icon_name = 'off'
        self.set_from_icon_name('_active_broadcast_%s' % icon_name, 
                gtk.ICON_SIZE_MENU)

        grouphbox.pack_start(self.groupicon, False, True, 2)
        grouphbox.pack_start(self.grouplabel, False, True, 2)
        grouphbox.pack_start(self.groupentry, False, True, 2)

        self.ebox.add(grouphbox)
        self.ebox.show_all()

        self.bellicon.set_from_icon_name('terminal-bell', gtk.ICON_SIZE_MENU)
        hbox = gtk.HBox()
        hbox.pack_start(self.ebox, False, True, 0)
        hbox.pack_start(gtk.VSeparator(), False, True, 0)
        hbox.pack_start(self.label, True, True)
        hbox.pack_end(self.bellicon, False, False, 2)

        self.add(hbox)
        hbox.show_all()
        self.set_no_show_all(True)
        self.show()

        self.connect('button-press-event', self.on_clicked) 
Example #12
Source File: searchbar.py    From NINJA-PingU with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self):
        """Class initialiser"""
        gtk.HBox.__init__(self)
        self.__gobject_init__()

        self.config = Config()

        # Search text
        self.entry = gtk.Entry()
        self.entry.set_activates_default(True)
        self.entry.show()
        self.entry.connect('activate', self.do_search)
        self.entry.connect('key-press-event', self.search_keypress)

        # Label
        label = gtk.Label(_('Search:'))
        label.show()

        # Result label
        self.reslabel = gtk.Label('')
        self.reslabel.show()

        # Close Button
        close = gtk.Button()
        close.set_relief(gtk.RELIEF_NONE)
        close.set_focus_on_click(False)
        icon = gtk.Image()
        icon.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)
        close.add(icon)
        close.set_name('terminator-search-close-button')
        if hasattr(close, 'set_tooltip_text'):
            close.set_tooltip_text(_('Close Search bar'))
        close.connect('clicked', self.end_search)
        close.show_all()

        # Next Button
        self.next = gtk.Button(_('Next'))
        self.next.show()
        self.next.set_sensitive(False)
        self.next.connect('clicked', self.next_search)

        # Previous Button
        self.prev = gtk.Button(_('Prev'))
        self.prev.show()
        self.prev.set_sensitive(False)
        self.prev.connect('clicked', self.prev_search)

        self.pack_start(label, False)
        self.pack_start(self.entry)
        self.pack_start(self.reslabel, False)
        self.pack_start(self.prev, False, False)
        self.pack_start(self.next, False, False)
        self.pack_end(close, False, False)

        self.hide()
        self.set_no_show_all(True) 
Example #13
Source File: preview_image.py    From gimp-plugin-export-layers with GNU General Public License v3.0 4 votes vote down vote up
def _init_gui(self):
    self._button_menu = gtk.Button()
    self._button_menu.set_relief(gtk.RELIEF_NONE)
    self._button_menu.add(gtk.Arrow(gtk.ARROW_DOWN, gtk.SHADOW_IN))
    
    self._menu_item_update_automatically = gtk.CheckMenuItem(
      _("Update Preview Automatically"))
    self._menu_item_update_automatically.set_active(True)
    
    self._menu_settings = gtk.Menu()
    self._menu_settings.append(self._menu_item_update_automatically)
    self._menu_settings.show_all()
    
    self._button_refresh = gtk.Button()
    self._button_refresh.set_tooltip_text(_("Update Preview"))
    self._button_refresh.set_relief(gtk.RELIEF_NONE)
    self._button_refresh.add(gtk.image_new_from_pixbuf(
      self._button_refresh.render_icon(gtk.STOCK_REFRESH, gtk.ICON_SIZE_MENU)))
    self._button_refresh.show_all()
    self._button_refresh.hide()
    self._button_refresh.set_no_show_all(True)
    
    self._hbox_buttons = gtk.HBox()
    self._hbox_buttons.pack_start(self._button_menu, expand=False, fill=False)
    self._hbox_buttons.pack_start(self._button_refresh, expand=False, fill=False)
    
    self._preview_image = gtk.Image()
    self._preview_image.set_no_show_all(True)
    
    self._placeholder_image = gtk.Image()
    self._placeholder_image.set_from_stock(
      gtk.STOCK_DIALOG_QUESTION, gtk.ICON_SIZE_DIALOG)
    self._placeholder_image.set_no_show_all(True)
    
    self._label_layer_name = gtk.Label()
    self._label_layer_name.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
    
    self.set_spacing(self._WIDGET_SPACING)
    self.set_border_width(self._BORDER_WIDTH)
    
    self.pack_start(self._hbox_buttons, expand=False, fill=False)
    self.pack_start(self._preview_image, expand=True, fill=True)
    self.pack_start(self._placeholder_image, expand=True, fill=True)
    self.pack_start(self._label_layer_name, expand=False, fill=False)
        
    self._show_placeholder_image() 
Example #14
Source File: overwritechooser.py    From gimp-plugin-export-layers with GNU General Public License v3.0 4 votes vote down vote up
def _init_gui(self):
    self._dialog = gimpui.Dialog(
      title="",
      role=None,
      parent=self._parent,
      flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
    self._dialog.set_transient_for(self._parent)
    self._dialog.set_title(self._title)
    self._dialog.set_border_width(self._DIALOG_BORDER_WIDTH)
    self._dialog.set_resizable(False)
    
    self._dialog_icon = gtk.Image()
    self._dialog_icon.set_from_stock(gtk.STOCK_DIALOG_QUESTION, gtk.ICON_SIZE_DIALOG)
    
    self._dialog_text = gtk.Label("")
    self._dialog_text.set_line_wrap(True)
    self._dialog_text.set_use_markup(True)
    
    self._dialog_text_event_box = gtk.EventBox()
    self._dialog_text_event_box.add(self._dialog_text)
    
    self._hbox_dialog_contents = gtk.HBox(homogeneous=False)
    self._hbox_dialog_contents.set_spacing(self._DIALOG_HBOX_CONTENTS_SPACING)
    self._hbox_dialog_contents.pack_start(self._dialog_icon, expand=False, fill=False)
    self._hbox_dialog_contents.pack_start(
      self._dialog_text_event_box, expand=False, fill=False)
    
    self._checkbutton_apply_to_all = gtk.CheckButton(
      label=_("_Apply action to all files"))
    self._checkbutton_apply_to_all.set_use_underline(True)
    
    self._dialog.vbox.set_spacing(self._DIALOG_VBOX_SPACING)
    self._dialog.vbox.pack_start(self._hbox_dialog_contents, expand=False, fill=False)
    self._dialog.vbox.pack_start(self._checkbutton_apply_to_all, expand=False, fill=False)
    
    self._buttons = {}
    for value, display_name in self.values_and_display_names:
      self._buttons[value] = self._dialog.add_button(display_name, value)
    
    self._dialog.action_area.set_spacing(self._DIALOG_ACTION_AREA_SPACING)
    
    self._checkbutton_apply_to_all.connect(
      "toggled", self._on_checkbutton_apply_to_all_toggled)
    
    self._is_dialog_text_allocated_size = False
    self._dialog_text_event_box.connect(
      "size-allocate", self._on_dialog_text_event_box_size_allocate)
    
    self._dialog.set_focus(self._buttons[self.default_value])