Python gobject.TYPE_STRING Examples

The following are 11 code examples of gobject.TYPE_STRING(). 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 gobject , or try the search function .
Example #1
Source File: gnome_connection_manager.py    From gnome-connection-manager with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, path="gnome-connection-manager.glade",
                 root="wHost",
                 domain=domain_name, **kwargs):
        path = os.path.join(glade_dir, path)
        SimpleGladeApp.__init__(self, path, root, domain, **kwargs)
        
        self.treeModel = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING)
        self.treeTunel.set_model(self.treeModel)
        column = gtk.TreeViewColumn(_("Local"), gtk.CellRendererText(), text=0)
        self.treeTunel.append_column( column )        
        column = gtk.TreeViewColumn(_("Host"), gtk.CellRendererText(), text=1)
        self.treeTunel.append_column( column )        
        column = gtk.TreeViewColumn(_("Remoto"), gtk.CellRendererText(), text=2)
        self.treeTunel.append_column( column )        


    #-- Whost.new { 
Example #2
Source File: gnome_connection_manager.py    From gnome-connection-manager with GNU General Public License v3.0 6 votes vote down vote up
def new(self):        
        self.treeHosts = self.get_widget('treeHosts')
        self.treeStore = gtk.TreeStore( gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, gobject.TYPE_OBJECT )
        for x in self.terms:
            self.treeStore.append( None, (False, x[0], x[1]) )
        self.treeHosts.set_model( self.treeStore )               
        
        crt = gtk.CellRendererToggle()
        crt.set_property('activatable', True)
        crt.connect('toggled', self.on_active_toggled)        
        col = gtk.TreeViewColumn(_("Activar"), crt, active=0)               
        self.treeHosts.append_column( col )
        self.treeHosts.append_column(gtk.TreeViewColumn(_("Host"), gtk.CellRendererText(), text=1 ))
        self.get_widget("txtCommands").history = []
    #-- Wcluster.new }

    #-- Wcluster custom methods {
    #   Write your own methods here 
Example #3
Source File: paned.py    From NINJA-PingU with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        """Class initialiser"""
        self.terminator = Terminator()
        self.maker = Factory()
        Container.__init__(self)
        self.signals.append({'name': 'resize-term', 
                             'flags': gobject.SIGNAL_RUN_LAST,
                             'return_type': gobject.TYPE_NONE, 
                             'param_types': (gobject.TYPE_STRING,)})


    # pylint: disable-msg=W0613 
Example #4
Source File: gtktools.py    From pycopia with Apache License 2.0 5 votes vote down vote up
def __init__(self, items=()):
        gtk.Dialog.__init__(self)
        self.ret = None
        self._started = 0
        self.connect("destroy", self.quit)
        self.connect("delete_event", self.quit)
        self.set_geometry_hints(min_width=250, min_height=300)
        scrolled_win = gtk.ScrolledWindow()
        scrolled_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scrolled_win.show()
        self.vbox.pack_start(scrolled_win)
        #self.vbox.show()

        button = gtk.Button("Cancel")
        button.connect("clicked", self.cancel)
        button.set_flags(gtk.CAN_DEFAULT)
        self.action_area.pack_start(button)
        button.show()

        ls = gtk.ListStore(gobject.TYPE_STRING)
        for item in items:
            iter = ls.append()
            ls.set(iter, 0, item)

        lister = gtk.TreeView(ls)
        selection = lister.get_selection()
        selection.set_mode(gtk.SELECTION_BROWSE)
        selection.unselect_all()
        lister.set_search_column(0)
        scrolled_win.add_with_viewport(lister)

        column = gtk.TreeViewColumn('Keyword', gtk.CellRendererText(), text=0)
        lister.append_column(column)
        lister.set_headers_visible(False)
        lister.connect("row-activated", self.row_activated)
        lister.show() 
Example #5
Source File: gnome_connection_manager.py    From gnome-connection-manager with GNU General Public License v3.0 5 votes vote down vote up
def initLeftPane(self):
        global groups       

        self.treeModel = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT, gtk.gdk.Pixbuf)
        self.treeServers.set_model(self.treeModel)

        self.treeServers.set_level_indentation(5)
        #Force the alternating row colors, by default it's off with one column
        self.treeServers.set_property('rules-hint', True)
        gtk.rc_parse_string( """
                style "custom-treestyle"{
                    GtkTreeView::allow-rules = 1
                }
                widget "*treeServers*" style "custom-treestyle"
            """)
        column = gtk.TreeViewColumn()
        column.set_title('Servers')
        self.treeServers.append_column( column )

        renderer = gtk.CellRendererPixbuf()
        column.pack_start(renderer, expand=False)
        column.add_attribute(renderer, 'pixbuf', 2)

        renderer = gtk.CellRendererText()
        column.pack_start(renderer, expand=True)
        column.add_attribute(renderer, 'text', 0)
        
        self.treeServers.set_has_tooltip(True)
        self.treeServers.connect('query-tooltip', self.on_treeServers_tooltip)
        self.loadConfig()
        self.updateTree() 
Example #6
Source File: backend_gtk.py    From Computable with MIT License 4 votes vote down vote up
def __init__ (self,
                  title   = 'Save file',
                  parent  = None,
                  action  = gtk.FILE_CHOOSER_ACTION_SAVE,
                  buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                             gtk.STOCK_SAVE,   gtk.RESPONSE_OK),
                  path    = None,
                  filetypes = [],
                  default_filetype = None
                  ):
        super(FileChooserDialog, self).__init__ (title, parent, action,
                                                 buttons)
        super(FileChooserDialog, self).set_do_overwrite_confirmation(True)
        self.set_default_response (gtk.RESPONSE_OK)

        if not path: path = os.getcwd() + os.sep

        # create an extra widget to list supported image formats
        self.set_current_folder (path)
        self.set_current_name ('image.' + default_filetype)

        hbox = gtk.HBox (spacing=10)
        hbox.pack_start (gtk.Label ("File Format:"), expand=False)

        liststore = gtk.ListStore(gobject.TYPE_STRING)
        cbox = gtk.ComboBox(liststore)
        cell = gtk.CellRendererText()
        cbox.pack_start(cell, True)
        cbox.add_attribute(cell, 'text', 0)
        hbox.pack_start (cbox)

        self.filetypes = filetypes
        self.sorted_filetypes = filetypes.items()
        self.sorted_filetypes.sort()
        default = 0
        for i, (ext, name) in enumerate(self.sorted_filetypes):
            cbox.append_text ("%s (*.%s)" % (name, ext))
            if ext == default_filetype:
                default = i
        cbox.set_active(default)
        self.ext = default_filetype

        def cb_cbox_changed (cbox, data=None):
            """File extension changed"""
            head, filename = os.path.split(self.get_filename())
            root, ext = os.path.splitext(filename)
            ext = ext[1:]
            new_ext = self.sorted_filetypes[cbox.get_active()][0]
            self.ext = new_ext

            if ext in self.filetypes:
                filename = root + '.' + new_ext
            elif ext == '':
                filename = filename.rstrip('.') + '.' + new_ext

            self.set_current_name (filename)
        cbox.connect ("changed", cb_cbox_changed)

        hbox.show_all()
        self.set_extra_widget(hbox) 
Example #7
Source File: backend_gtk.py    From matplotlib-4-abaqus with MIT License 4 votes vote down vote up
def __init__ (self,
                  title   = 'Save file',
                  parent  = None,
                  action  = gtk.FILE_CHOOSER_ACTION_SAVE,
                  buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                             gtk.STOCK_SAVE,   gtk.RESPONSE_OK),
                  path    = None,
                  filetypes = [],
                  default_filetype = None
                  ):
        super(FileChooserDialog, self).__init__ (title, parent, action,
                                                 buttons)
        super(FileChooserDialog, self).set_do_overwrite_confirmation(True)
        self.set_default_response (gtk.RESPONSE_OK)

        if not path: path = os.getcwd() + os.sep

        # create an extra widget to list supported image formats
        self.set_current_folder (path)
        self.set_current_name ('image.' + default_filetype)

        hbox = gtk.HBox (spacing=10)
        hbox.pack_start (gtk.Label ("File Format:"), expand=False)

        liststore = gtk.ListStore(gobject.TYPE_STRING)
        cbox = gtk.ComboBox(liststore)
        cell = gtk.CellRendererText()
        cbox.pack_start(cell, True)
        cbox.add_attribute(cell, 'text', 0)
        hbox.pack_start (cbox)

        self.filetypes = filetypes
        self.sorted_filetypes = filetypes.items()
        self.sorted_filetypes.sort()
        default = 0
        for i, (ext, name) in enumerate(self.sorted_filetypes):
            cbox.append_text ("%s (*.%s)" % (name, ext))
            if ext == default_filetype:
                default = i
        cbox.set_active(default)
        self.ext = default_filetype

        def cb_cbox_changed (cbox, data=None):
            """File extension changed"""
            head, filename = os.path.split(self.get_filename())
            root, ext = os.path.splitext(filename)
            ext = ext[1:]
            new_ext = self.sorted_filetypes[cbox.get_active()][0]
            self.ext = new_ext

            if ext in self.filetypes:
                filename = root + '.' + new_ext
            elif ext == '':
                filename = filename.rstrip('.') + '.' + new_ext

            self.set_current_name (filename)
        cbox.connect ("changed", cb_cbox_changed)

        hbox.show_all()
        self.set_extra_widget(hbox) 
Example #8
Source File: backend_gtk.py    From neural-network-animation with MIT License 4 votes vote down vote up
def __init__ (self,
                  title   = 'Save file',
                  parent  = None,
                  action  = gtk.FILE_CHOOSER_ACTION_SAVE,
                  buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                             gtk.STOCK_SAVE,   gtk.RESPONSE_OK),
                  path    = None,
                  filetypes = [],
                  default_filetype = None
                  ):
        super(FileChooserDialog, self).__init__ (title, parent, action,
                                                 buttons)
        super(FileChooserDialog, self).set_do_overwrite_confirmation(True)
        self.set_default_response (gtk.RESPONSE_OK)

        if not path: path = os.getcwd() + os.sep

        # create an extra widget to list supported image formats
        self.set_current_folder (path)
        self.set_current_name ('image.' + default_filetype)

        hbox = gtk.HBox (spacing=10)
        hbox.pack_start (gtk.Label ("File Format:"), expand=False)

        liststore = gtk.ListStore(gobject.TYPE_STRING)
        cbox = gtk.ComboBox(liststore)
        cell = gtk.CellRendererText()
        cbox.pack_start(cell, True)
        cbox.add_attribute(cell, 'text', 0)
        hbox.pack_start (cbox)

        self.filetypes = filetypes
        self.sorted_filetypes = list(six.iteritems(filetypes))
        self.sorted_filetypes.sort()
        default = 0
        for i, (ext, name) in enumerate(self.sorted_filetypes):
            cbox.append_text ("%s (*.%s)" % (name, ext))
            if ext == default_filetype:
                default = i
        cbox.set_active(default)
        self.ext = default_filetype

        def cb_cbox_changed (cbox, data=None):
            """File extension changed"""
            head, filename = os.path.split(self.get_filename())
            root, ext = os.path.splitext(filename)
            ext = ext[1:]
            new_ext = self.sorted_filetypes[cbox.get_active()][0]
            self.ext = new_ext

            if ext in self.filetypes:
                filename = root + '.' + new_ext
            elif ext == '':
                filename = filename.rstrip('.') + '.' + new_ext

            self.set_current_name (filename)
        cbox.connect ("changed", cb_cbox_changed)

        hbox.show_all()
        self.set_extra_widget(hbox) 
Example #9
Source File: backend_gtk.py    From ImageFusion with MIT License 4 votes vote down vote up
def __init__ (self,
                  title   = 'Save file',
                  parent  = None,
                  action  = gtk.FILE_CHOOSER_ACTION_SAVE,
                  buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                             gtk.STOCK_SAVE,   gtk.RESPONSE_OK),
                  path    = None,
                  filetypes = [],
                  default_filetype = None
                  ):
        super(FileChooserDialog, self).__init__ (title, parent, action,
                                                 buttons)
        super(FileChooserDialog, self).set_do_overwrite_confirmation(True)
        self.set_default_response (gtk.RESPONSE_OK)

        if not path: path = os.getcwd() + os.sep

        # create an extra widget to list supported image formats
        self.set_current_folder (path)
        self.set_current_name ('image.' + default_filetype)

        hbox = gtk.HBox (spacing=10)
        hbox.pack_start (gtk.Label ("File Format:"), expand=False)

        liststore = gtk.ListStore(gobject.TYPE_STRING)
        cbox = gtk.ComboBox(liststore)
        cell = gtk.CellRendererText()
        cbox.pack_start(cell, True)
        cbox.add_attribute(cell, 'text', 0)
        hbox.pack_start (cbox)

        self.filetypes = filetypes
        self.sorted_filetypes = list(six.iteritems(filetypes))
        self.sorted_filetypes.sort()
        default = 0
        for i, (ext, name) in enumerate(self.sorted_filetypes):
            cbox.append_text ("%s (*.%s)" % (name, ext))
            if ext == default_filetype:
                default = i
        cbox.set_active(default)
        self.ext = default_filetype

        def cb_cbox_changed (cbox, data=None):
            """File extension changed"""
            head, filename = os.path.split(self.get_filename())
            root, ext = os.path.splitext(filename)
            ext = ext[1:]
            new_ext = self.sorted_filetypes[cbox.get_active()][0]
            self.ext = new_ext

            if ext in self.filetypes:
                filename = root + '.' + new_ext
            elif ext == '':
                filename = filename.rstrip('.') + '.' + new_ext

            self.set_current_name (filename)
        cbox.connect ("changed", cb_cbox_changed)

        hbox.show_all()
        self.set_extra_widget(hbox) 
Example #10
Source File: bluezchat.py    From python-for-android with Apache License 2.0 4 votes vote down vote up
def __init__(self):
        self.main_window_xml = gtk.glade.XML(GLADEFILE, "bluezchat_window")

        # connect our signal handlers
        dic = { "on_quit_button_clicked" : self.quit_button_clicked,
                "on_send_button_clicked" : self.send_button_clicked,
                "on_chat_button_clicked" : self.chat_button_clicked,
                "on_scan_button_clicked" : self.scan_button_clicked,
                "on_devices_tv_cursor_changed" : self.devices_tv_cursor_changed
                }

        self.main_window_xml.signal_autoconnect(dic)

        # prepare the floor listbox
        self.devices_tv = self.main_window_xml.get_widget("devices_tv")
        self.discovered = gtk.ListStore(gobject.TYPE_STRING, 
                gobject.TYPE_STRING)
        self.devices_tv.set_model(self.discovered)
        renderer = gtk.CellRendererText()
        column1=gtk.TreeViewColumn("addr", renderer, text=0)
        column2=gtk.TreeViewColumn("name", renderer, text=1)
        self.devices_tv.append_column(column1)
        self.devices_tv.append_column(column2)

        self.quit_button = self.main_window_xml.get_widget("quit_button")
        self.scan_button = self.main_window_xml.get_widget("scan_button")
        self.chat_button = self.main_window_xml.get_widget("chat_button")
        self.send_button = self.main_window_xml.get_widget("send_button")
        self.main_text = self.main_window_xml.get_widget("main_text")
        self.text_buffer = self.main_text.get_buffer()

        self.input_tb = self.main_window_xml.get_widget("input_tb")

        self.listed_devs = []

        self.chat_button.set_sensitive(False)

        self.peers = {}
        self.sources = {}
        self.addresses = {}

        # the listening sockets
        self.server_sock = None

# --- gui signal handlers 
Example #11
Source File: backend_gtk.py    From twitter-stock-recommendation with MIT License 4 votes vote down vote up
def __init__ (self,
                  title   = 'Save file',
                  parent  = None,
                  action  = gtk.FILE_CHOOSER_ACTION_SAVE,
                  buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                             gtk.STOCK_SAVE,   gtk.RESPONSE_OK),
                  path    = None,
                  filetypes = [],
                  default_filetype = None
                  ):
        super(FileChooserDialog, self).__init__(title, parent, action, buttons)
        super(FileChooserDialog, self).set_do_overwrite_confirmation(True)
        self.set_default_response(gtk.RESPONSE_OK)

        if not path:
            path = os.getcwd() + os.sep

        # create an extra widget to list supported image formats
        self.set_current_folder (path)
        self.set_current_name ('image.' + default_filetype)

        hbox = gtk.HBox(spacing=10)
        hbox.pack_start(gtk.Label ("File Format:"), expand=False)

        liststore = gtk.ListStore(gobject.TYPE_STRING)
        cbox = gtk.ComboBox(liststore)
        cell = gtk.CellRendererText()
        cbox.pack_start(cell, True)
        cbox.add_attribute(cell, 'text', 0)
        hbox.pack_start(cbox)

        self.filetypes = filetypes
        self.sorted_filetypes = sorted(six.iteritems(filetypes))
        default = 0
        for i, (ext, name) in enumerate(self.sorted_filetypes):
            cbox.append_text("%s (*.%s)" % (name, ext))
            if ext == default_filetype:
                default = i
        cbox.set_active(default)
        self.ext = default_filetype

        def cb_cbox_changed (cbox, data=None):
            """File extension changed"""
            head, filename = os.path.split(self.get_filename())
            root, ext = os.path.splitext(filename)
            ext = ext[1:]
            new_ext = self.sorted_filetypes[cbox.get_active()][0]
            self.ext = new_ext

            if ext in self.filetypes:
                filename = root + '.' + new_ext
            elif ext == '':
                filename = filename.rstrip('.') + '.' + new_ext

            self.set_current_name(filename)
        cbox.connect("changed", cb_cbox_changed)

        hbox.show_all()
        self.set_extra_widget(hbox)