Python gtk.image_new_from_stock() Examples

The following are 8 code examples of gtk.image_new_from_stock(). 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: operations.py    From gimp-plugin-export-layers with GNU General Public License v3.0 6 votes vote down vote up
def _init_gui(self):
    if self._add_operation_text is not None:
      self._button_add = gtk.Button()
      button_hbox = gtk.HBox()
      button_hbox.set_spacing(self._ADD_BUTTON_HBOX_SPACING)
      button_hbox.pack_start(
        gtk.image_new_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_MENU),
        expand=False,
        fill=False)
      
      label_add = gtk.Label(self._add_operation_text.encode(pg.GTK_CHARACTER_ENCODING))
      label_add.set_use_underline(True)
      button_hbox.pack_start(label_add, expand=False, fill=False)
      
      self._button_add.add(button_hbox)
    else:
      self._button_add = gtk.Button(stock=gtk.STOCK_ADD)
    
    self._button_add.set_relief(gtk.RELIEF_NONE)
    self._button_add.connect("clicked", self._on_button_add_clicked)
    
    self._vbox.pack_start(self._button_add, expand=False, fill=False)
    
    self._operations_menu = gtk.Menu()
    self._init_operations_menu_popup() 
Example #2
Source File: operations.py    From gimp-plugin-export-layers with GNU General Public License v3.0 6 votes vote down vote up
def _create_placeholder_widget(self):
    hbox = gtk.HBox()
    hbox.set_spacing(self._PLACEHOLDER_WIDGET_HORIZONTAL_SPACING_BETWEEN_ELEMENTS)
    
    hbox.pack_start(
      gtk.image_new_from_stock(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_BUTTON),
      expand=False,
      fill=False)
    
    label = gtk.Label()
    label.set_use_markup(True)
    label.set_markup(
      '<span font_size="small">{}</span>'.format(
        gobject.markup_escape_text(_("Cannot modify this parameter"))))
    
    hbox.pack_start(label, expand=False, fill=False)
    
    return hbox 
Example #3
Source File: gnome_connection_manager.py    From gnome-connection-manager with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, title, owner_, widget_, popup_):
        gtk.HBox.__init__(self, False, 0)
        
        self.title = title
        self.owner = owner_
        self.eb = gtk.EventBox()
        label = self.label = gtk.Label()
        self.eb.connect('button-press-event', self.popupmenu, label)
        label.set_alignment(0.0, 0.5)
        label.set_text(title)
        self.eb.add(label)        
        self.pack_start(self.eb)        
        label.show()        
        self.eb.show()                
        close_image = gtk.image_new_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)
        image_w, image_h = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU)
        self.widget=widget_
        self.popup = popup_        
        close_btn = gtk.Button()
        close_btn.set_relief(gtk.RELIEF_NONE)
        close_btn.connect('clicked', self.on_close_tab, owner_)
        close_btn.set_size_request(image_w+7, image_h+6)
        close_btn.add(close_image)
        style = close_btn.get_style();
        self.eb2 = gtk.EventBox()
        self.eb2.add(close_btn)        
        self.pack_start(self.eb2, False, False)
        self.eb2.show()
        close_btn.show_all()  
        self.is_active = True
        self.show() 
Example #4
Source File: container.py    From NINJA-PingU with GNU General Public License v3.0 4 votes vote down vote up
def construct_confirm_close(self, window, reqtype):
        """Create a confirmation dialog for closing things"""
        
        # skip this dialog if applicable
        if self.config['suppress_multiple_term_dialog']:
            return gtk.RESPONSE_ACCEPT
        
        dialog = gtk.Dialog(_('Close?'), window, gtk.DIALOG_MODAL)
        dialog.set_has_separator(False)
        dialog.set_resizable(False)
    
        dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT)
        c_all = dialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_ACCEPT)
        c_all.get_children()[0].get_children()[0].get_children()[1].set_label(
                _('Close _Terminals'))
    
        primary = gtk.Label(_('<big><b>Close multiple terminals?</b></big>'))
        primary.set_use_markup(True)
        primary.set_alignment(0, 0.5)
        secondary = gtk.Label(_('This %s has several terminals open. Closing \
the %s will also close all terminals within it.') % (reqtype, reqtype))
        secondary.set_line_wrap(True)
                    
        labels = gtk.VBox()
        labels.pack_start(primary, False, False, 6)
        labels.pack_start(secondary, False, False, 6)
    
        image = gtk.image_new_from_stock(gtk.STOCK_DIALOG_WARNING,
                                         gtk.ICON_SIZE_DIALOG)
        image.set_alignment(0.5, 0)
    
        box = gtk.HBox()
        box.pack_start(image, False, False, 6)
        box.pack_start(labels, False, False, 6)
        dialog.vbox.pack_start(box, False, False, 12)

        checkbox = gtk.CheckButton(_("Do not show this message next time"))
        dialog.vbox.pack_end(checkbox)
    
        dialog.show_all()

        result = dialog.run()
        
        # set configuration
        self.config['suppress_multiple_term_dialog'] = checkbox.get_active()
        self.config.save()

        dialog.destroy()
                
        return(result) 
Example #5
Source File: memview.py    From nightmare with GNU General Public License v2.0 4 votes vote down vote up
def __init__(self, canvas):
        self.canvas = canvas
        vw_layout.LayoutWindow.__init__(self)
        self.vbox = gtk.VBox()
        elabel = gtk.Label(" Memory Expression ")
        slabel = gtk.Label(" Memory Size ")

        self.eentry = gtk.Entry()
        self.sentry = gtk.Entry()
        self.sentry.set_text("256")

        self.nextbutton = gtk.Button()
        i = gtk.image_new_from_stock(gtk.STOCK_GO_FORWARD, gtk.ICON_SIZE_BUTTON)
        self.nextbutton.set_image(i)
        self.nextbutton.connect("clicked", self.goforward)

        self.backbutton = gtk.Button()
        i = gtk.image_new_from_stock(gtk.STOCK_GO_BACK, gtk.ICON_SIZE_BUTTON)
        self.backbutton.set_image(i)
        self.backbutton.connect("clicked", self.goback)

        self.downbutton = gtk.Button()
        i = gtk.image_new_from_stock(gtk.STOCK_GO_DOWN, gtk.ICON_SIZE_BUTTON)
        self.downbutton.set_image(i)
        self.downbutton.connect("clicked", self.godown)

        self.upbutton = gtk.Button()
        i = gtk.image_new_from_stock(gtk.STOCK_GO_UP, gtk.ICON_SIZE_BUTTON)
        self.upbutton.set_image(i)
        self.upbutton.connect("clicked", self.goup)

        hbox = gtk.HBox()

        hbox.pack_start(self.backbutton, expand=False)
        hbox.pack_start(self.nextbutton, expand=False)
        hbox.pack_start(self.upbutton, expand=False)
        hbox.pack_start(self.downbutton, expand=False)
        hbox.pack_start(elabel, expand=False)
        hbox.pack_start(self.eentry, expand=True)
        hbox.pack_start(slabel, expand=False)
        hbox.pack_start(self.sentry, expand=True)

        self.cbox = gtk.combo_box_new_text()
        for name in self.canvas.getRendererNames():
            self.canvas.addRenderer(name, self.canvas.getRenderer(name))
            self.cbox.append_text(name)
        self.cbox.set_active(0)
        hbox.pack_start(self.cbox, expand=False)

        self.vbox.pack_start(hbox, expand=False)
        self.vbox.pack_start(self.canvas, expand=True)
        self.add(self.vbox)

        self.eentry.connect("activate", self.entryActivated)
        self.sentry.connect("activate", self.entryActivated)
        self.cbox.connect("changed", self.updateMemoryView)

        self.canvas.memwin = self
        self.updateHistoryButtons() 
Example #6
Source File: status_icon_gtk2.py    From sun with GNU General Public License v3.0 4 votes vote down vote up
def sub_menu(self):
        """Create daemon submenu
        """
        submenu = gtk.Menu()
        self.start = gtk.ImageMenuItem("Start")
        self.stop = gtk.ImageMenuItem("Stop")
        self.restart = gtk.ImageMenuItem("Restart")
        self.status = gtk.ImageMenuItem("Status")

        self.start.show()
        self.stop.show()
        self.restart.show()
        self.status.show()

        img_Start = gtk.image_new_from_stock(gtk.STOCK_MEDIA_PLAY,
                                             gtk.ICON_SIZE_MENU)
        img_Start.show()
        self.start.set_image(img_Start)

        img_Stop = gtk.image_new_from_stock(gtk.STOCK_STOP,
                                            gtk.ICON_SIZE_MENU)
        img_Stop.show()
        self.stop.set_image(img_Stop)

        img_Restart = gtk.image_new_from_stock(gtk.STOCK_REFRESH,
                                               gtk.ICON_SIZE_MENU)
        img_Restart.show()
        self.restart.set_image(img_Restart)

        img_Status = gtk.image_new_from_stock(gtk.STOCK_DIALOG_QUESTION,
                                              gtk.ICON_SIZE_MENU)
        img_Status.show()
        self.status.set_image(img_Status)

        submenu.append(self.start)
        submenu.append(self.stop)
        submenu.append(self.restart)
        submenu.append(self.status)

        self.daemon = gtk.ImageMenuItem("Daemon")
        self.img_daemon = gtk.image_new_from_stock(self.daemon_STOCK,
                                                   gtk.ICON_SIZE_MENU)
        self.img_daemon.show()
        self.daemon.set_submenu(submenu) 
Example #7
Source File: status_icon_gtk2.py    From sun with GNU General Public License v3.0 4 votes vote down vote up
def menu(self, event_button, event_time, data=None):
        """Create popup menu
        """
        self.sub_menu()
        menu = gtk.Menu()
        menu.append(self.daemon)

        separator = gtk.SeparatorMenuItem()

        menu_Check = gtk.ImageMenuItem("Check updates")
        img_Check = gtk.image_new_from_stock(gtk.STOCK_OK,
                                             gtk.ICON_SIZE_MENU)
        img_Check.show()

        menu_Info = gtk.ImageMenuItem("OS Info")
        img_Info = gtk.image_new_from_stock(gtk.STOCK_INFO,
                                            gtk.ICON_SIZE_MENU)
        img_Info.show()

        menu_About = gtk.ImageMenuItem("About")
        img_About = gtk.image_new_from_stock(gtk.STOCK_ABOUT,
                                             gtk.ICON_SIZE_MENU)
        img_About.show()

        self.daemon.set_image(self.img_daemon)
        menu.append(self.daemon)
        self.daemon.show()

        menu_Quit = gtk.ImageMenuItem("Quit")
        img_Quit = gtk.image_new_from_stock(gtk.STOCK_QUIT, gtk.ICON_SIZE_MENU)
        img_Quit.show()

        menu_Check.set_image(img_Check)
        menu_Info.set_image(img_Info)
        menu_About.set_image(img_About)
        menu_Quit.set_image(img_Quit)

        menu.append(menu_Check)
        menu.append(menu_Info)
        menu.append(separator)
        menu.append(menu_About)
        menu.append(menu_Quit)

        separator.show()
        menu_Check.show()
        menu_Info.show()
        menu_About.show()
        menu_Quit.show()

        menu_Check.connect_object("activate", self._Check, " ")
        menu_Info.connect_object("activate", self._Info, "OS Info")
        menu_About.connect_object("activate", self._About, "SUN")
        self.start.connect_object("activate", self._start, "Start daemon   ")
        self.stop.connect_object("activate", self._stop, "Stop daemon   ")
        self.restart.connect_object("activate", self._restart,
                                    "Restart daemon   ")
        self.status.connect_object("activate", self._status, daemon_status())
        menu_Quit.connect_object("activate", self._Quit, "stop")

        menu.popup(None, None, None, event_button, event_time, data) 
Example #8
Source File: gnome_connection_manager.py    From gnome-connection-manager with GNU General Public License v3.0 4 votes vote down vote up
def updateTree(self):
        for grupo in dict(groups):
            if len(groups[grupo])==0:
                del groups[grupo]
        
        if conf.COLLAPSED_FOLDERS == None:
            conf.COLLAPSED_FOLDERS = ','.join(self.get_collapsed_nodes())
        
        self.menuServers.foreach(self.menuServers.remove)
        self.treeModel.clear()
        
        iconHost = self.treeServers.render_icon("gtk-network", size=gtk.ICON_SIZE_BUTTON, detail=None)
        iconDir = self.treeServers.render_icon("gtk-directory", size=gtk.ICON_SIZE_BUTTON, detail=None)             
        
        grupos = groups.keys()
        grupos.sort(lambda x,y: cmp(y,x))
        
        for grupo in grupos:
            group = None
            path = ""
            menuNode = self.menuServers
                  
            for folder in grupo.split("/"):
                path = path + '/' + folder
                row = self.get_folder(self.treeModel, '', path)
                if row == None:
                    group = self.treeModel.prepend(group, [folder, None, iconDir])
                else:
                    group = row.iter
                
                menu = self.get_folder_menu(self.menuServers, '', path)
                if menu == None:
                    menu = gtk.ImageMenuItem(folder)
                    #menu.set_image(gtk.image_new_from_stock(gtk.STOCK_DIRECTORY, gtk.ICON_SIZE_MENU))
                    menuNode.prepend(menu)
                    menuNode = gtk.Menu()
                    menu.set_submenu(menuNode)
                    menu.show()
                else:
                    menuNode = menu
                
            groups[grupo].sort(key=operator.attrgetter('name'))
            for host in groups[grupo]:
                self.treeModel.append(group, [host.name, host, iconHost])
                mnuItem = gtk.ImageMenuItem(host.name)
                mnuItem.set_image(gtk.image_new_from_stock(gtk.STOCK_NETWORK, gtk.ICON_SIZE_MENU))
                mnuItem.show()
                mnuItem.connect("activate", lambda arg, nb, h: self.addTab(nb, h), self.nbConsole, host) 
                menuNode.append(mnuItem)
                
        self.set_collapsed_nodes()
        conf.COLLAPSED_FOLDERS = None