Python gi.repository.Gtk 模块,TreeView() 实例源码

我们从Python开源项目中,提取了以下49个代码示例,用于说明如何使用gi.repository.Gtk.TreeView()

项目:gedit-jshint    作者:Meseira    | 项目源码 | 文件源码
def __init__(self, window):
        Gtk.ScrolledWindow.__init__(self)

        # Parent window
        self._window = window

        # Tree view
        self._tree_view = Gtk.TreeView(Gtk.ListStore(int, int, str, str))
        self._tree_view.set_headers_visible(False)
        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Message", renderer, text=2, background=3)
        self._tree_view.append_column(column)
        self._tree_view.connect("row-activated", self.on_row_activated)
        self.add(self._tree_view)

        self.show_all()
项目:bcloud    作者:wangYanJava    | 项目源码 | 文件源码
def on_drag_data_received(self, widget, context, x, y, data, info, time):
        '''????'''
        if not data:
            return
        bx, by = self.iconview.convert_widget_to_bin_window_coords(x, y)
        selected = Gtk.TreeView.get_path_at_pos(self.iconview, bx, by)
        if not selected:
            return
        tree_path = selected[0]
        if tree_path is None:
            return
        target_path = self.liststore[tree_path][PATH_COL]
        is_dir = self.liststore[tree_path][ISDIR_COL]
        if not is_dir or info != TargetInfo.PLAIN_TEXT:
            return
        filelist_str = data.get_text()
        filelist = json.loads(filelist_str)
        for file_item in filelist:
            if file_item['path'] == target_path:
                self.app.toast(_('Error: Move folder to itself!'))
                return
        for file_item in filelist:
            file_item['dest'] = target_path
        gutil.async_call(pcs.move, self.app.cookie, self.app.tokens, filelist,
                         callback=self.parent.reload)
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def populate_tree(self, groups):
        """ Accepts an array of n rows made of 2 elements each, and returns a TreeView."""

        store = Gtk.TreeStore(GdkPixbuf.Pixbuf, str, str)

        for group in groups:
            #header = '<span background=\"#5a58ff\" foreground=\"white\"><b> ' + group.replace('_', ' ').capitalize() + '\t</b></span>'
            header = group.replace('_', ' ').capitalize()
            it = store.append(None, [self.pix, header, ''])
            for row in eval('self.' + group):
                store.append(it, [None, row[0], row[1]])

        tv = Gtk.TreeView(store)
        #tv.set_rules_hint(True)
        #tv.set_enable_tree_lines(True)
        tv.set_show_expanders(False)
        tv.set_level_indentation(10)
        tv.expand_all()

        return tv
项目:AncestryCitations    作者:tecknicaltom    | 项目源码 | 文件源码
def __create_gui(self):
        """
        Create and display the GUI components of the gramplet.
        """
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        self.model = Gtk.ListStore(object, str, int)
        view = Gtk.TreeView(self.model)
        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn(_("Person"), renderer, text=1)
        view.append_column(column)
        renderer = Gtk.CellRendererText()
        renderer.set_property('editable', True)
        renderer.connect('edited', self.__cell_edited)
        column = Gtk.TreeViewColumn(_("ID"), renderer, text=2)
        view.append_column(column)

        vbox.pack_start(view, expand=True, fill=True, padding=0)
        return vbox
项目:pycam    作者:SebKuzminsky    | 项目源码 | 文件源码
def __init__(self, choices, change_handler=None):
        self.model = gtk.ListStore(GObject.TYPE_STRING)
        self._values = []
        for label, value in choices:
            self.model.append((label,))
            self._values.append(value)
        renderer = gtk.CellRendererText()
        self.control = gtk.ScrolledWindow()
        self.control.show()
        self._treeview = gtk.TreeView(self.model)
        self._treeview.show()
        self.control.add(self._treeview)
        self.control.set_shadow_type(gtk.ShadowType.ETCHED_OUT)
        self.control.set_policy(gtk.PolicyType.AUTOMATIC, gtk.PolicyType.AUTOMATIC)
        # Sadly there seems to be no way to adjust the size of the ScrolledWindow to its content.
        # The default size of the ScrolledWindow is too small (making it hard to select the model).
        self.control.set_size_request(200, -1)
        column = gtk.TreeViewColumn()
        column.pack_start(renderer, expand=False)
        column.set_attributes(renderer, text=0)
        self._treeview.append_column(column)
        self._treeview.set_headers_visible(False)
        self._selection = self._treeview.get_selection()
        self._selection.set_mode(gtk.SelectionMode.MULTIPLE)
        self.connect("changed", change_handler, self._selection)
项目:google-tasks-indicator    作者:atareao    | 项目源码 | 文件源码
def create_window(self):
        self.dialog = Gtk.Dialog(None, None, Gtk.DialogFlags.MODAL) 
        self.dialog.set_decorated(False)
        #
        scrolledwindow = Gtk.ScrolledWindow()
        scrolledwindow.set_can_focus(False) 
        scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        scrolledwindow.set_shadow_type(Gtk.ShadowType.ETCHED_OUT)
        self.dialog.vbox.pack_start(scrolledwindow, Gtk.AttachOptions.SHRINK, Gtk.AttachOptions.SHRINK,0)
        #
        self.store = Gtk.ListStore(str)
        for value in self.values:
            self.store.append([value])
        self.tree = Gtk.TreeView(self.store)
        self.tree.set_headers_visible(False)
        self.tree.set_can_focus(False) 
        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn(title=None,cell_renderer=renderer, text=0)
        self.tree.append_column(column)
        #
        scrolledwindow.add(self.tree)
        self.tree.connect('focus-out-event',self.on_focus_out)
        self.dialog.connect('focus-out-event',self.on_focus_out)
        self.tree.connect('cursor-changed',self.on_cursor_changed)
        self.dialog.show_all()
项目:XFWM_theme_creator    作者:Sjc1000    | 项目源码 | 文件源码
def __init__(self):
        Gtk.ScrolledWindow.__init__(self)
        self.list = Gtk.ListStore(str, bool)
        self.view = Gtk.TreeView(self.list)
        self.view.set_hexpand(True)
        text_renderer = Gtk.CellRendererText()
        check_renderer = Gtk.CellRendererToggle()
        name_column = Gtk.TreeViewColumn('Gtk color list', text_renderer, text=0)
        check_column = Gtk.TreeViewColumn('', check_renderer, active=1)
        self.view.append_column(check_column)
        self.view.append_column(name_column)
        self.view.connect('row-activated', self.row_activated)
        self.add(self.view)

        names = ['active_text_color', 'inactive_text_color',
                 'active_text_shadow_color', 'inactive_text_shadow_color',
                 'active_border_color', 'inactive_border_color',
                 'active_color_1', 'active_color_2', 'active_highlight_1',
                 'active_highlight_2', 'active_mid_1', 'active_mid_2',
                 'active_shadow_1', 'active_shadow_2', 'inactive_color_1',
                 'inactive_color_2', 'inactive_highlight_1',
                 'inactive_highlight_2', 'inactive_mid_1', 'inactive_mid_2',
                 'inactive_shadow_1', 'inactive_shadow_2']
        for name in names:
            self.list.append([name, False])
项目:poseidon    作者:sidus-dev    | 项目源码 | 文件源码
def refresh_liststore(self, tp):

        for i in self.tabs[self.current_page][0]:
            if type(i) == Gtk.ScrolledWindow:
                for t in i:
                    if type(t) == Gtk.TreeView:

                        ls = t.get_model()
                        ls.clear()

                        if tp == 1: l = bookmarksview()
                        if tp == 2: l = cookiesview()
                        if tp == 3: l = historyview()

                        for a in l: ls.append(list(a))
                        t.set_model(ls)
项目:plotcommander    作者:FilipDominec    | 项目源码 | 文件源码
def __init__(self):
        super(CellRendererFadeWindow, self).__init__(title="CellRendererFade Example")

        self.set_default_size(200, 200)
        self.liststore = Gtk.ListStore(str, str)
        self.liststore.append(["New", Gtk.STOCK_NEW])
        self.liststore.append(["Open", Gtk.STOCK_OPEN])
        self.liststore.append(["Save", Gtk.STOCK_SAVE])

        treeview = Gtk.TreeView(model=self.liststore)
        renderer_text = Gtk.CellRendererText()
        column_text = Gtk.TreeViewColumn("Text", renderer_text, text=0)
        treeview.append_column(column_text)

        renderer_pixbuf = CellRenderFade(param=0.001)
        column_pixbuf = Gtk.TreeViewColumn("Image", renderer_pixbuf, stock_id=1)
        treeview.append_column(column_pixbuf)
        self.add(treeview)
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def populate_store(self, store):

        directory = '/home/anon/Documents'
        for filename in os.listdir(directory):
            size = os.path.getsize(os.path.join(directory, filename))
            # the second element is displayed in the second TreeView column
            # but that column is sorted by the third element
            # so the file sizes are sorted as numbers, not as strings
            store.append([filename, '{0:,}'.format(size), size])       

# The main part:
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __init__(self):

        Gtk.Window.__init__(self, title='My Window Title')
        self.connect('delete-event', Gtk.main_quit)        

        store = Gtk.ListStore(str, str, str, str)
        self.populate_store(store)

        self.treeview = Gtk.TreeView(model=store)

        renderer = Gtk.CellRendererText()

        column_catalog = Gtk.TreeViewColumn('Catalog Name', renderer, text=0)
        column_catalog.set_sort_column_id(0)        
        self.treeview.append_column(column_catalog)

        column_dbname = Gtk.TreeViewColumn('Database Name', renderer, text=1)
        column_dbname.set_sort_column_id(1)
        self.treeview.append_column(column_dbname)

        column_charset = Gtk.TreeViewColumn('Character Set', renderer, text=2)
        column_charset.set_sort_column_id(2)
        self.treeview.append_column(column_charset)

        column_collation = Gtk.TreeViewColumn('Collation', renderer, text=3)
        column_collation.set_sort_column_id(3)
        self.treeview.append_column(column_collation)

        scrolled_window = Gtk.ScrolledWindow()
        scrolled_window.set_policy(
            Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        scrolled_window.add(self.treeview)
        scrolled_window.set_min_content_height(200)

        self.add(scrolled_window)
        self.show_all()

    # Add data to ListStore
项目:sbrick-controller    作者:wintersandroid    | 项目源码 | 文件源码
def __init__(self):
        Gtk.Frame.__init__(self)
        self.sbrick = None
        self.set_label("SBrick Information")

        self.store = Gtk.ListStore(str, str)
        self.iterSBrickID = self.store.append(["SBrick BlueGiga ID", "--"])
        self.iterHardwareVersion = self.store.append(["Hardware Version", "--"])
        self.iterSoftwareVersion = self.store.append(["Software Version", "--"])
        self.iterNeedAuthentication = self.store.append(["Need Authentication", "--"])
        self.iterIsAuthenticated = self.store.append(["Is Authenticated", "--"])
        self.iterAuthenticationTimeout = self.store.append(["Authentication Timeout", "--"])
        self.iterInputVoltage = self.store.append(["Input Voltage", "--"])
        self.iterTemperature = self.store.append(["Temperature", "--"])
        self.iterPowerCycles = self.store.append(["Power Cycles", "--"])
        self.iterWatchdogTimeout = self.store.append(["Watchdog Timeout", "--"])
        self.iterUpTime = self.store.append(["Up Time", "--"])
        self.iterThermalLimit = self.store.append(["Thermal Limit", "--"])

        self.listView = Gtk.TreeView(self.store)

        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Item", renderer, text=0)
        self.listView.append_column(column)

        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Value", renderer, text=1)
        self.listView.append_column(column)

        self.scrollTree = Gtk.ScrolledWindow()
        self.scrollTree.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        self.scrollTree.add_with_viewport(self.listView)
        self.scrollTree.set_min_content_height(100)

        self.add(self.scrollTree)
        self.set_sensitive(False)
项目:gprime    作者:GenealogyCollective    | 项目源码 | 文件源码
def __init__(self):
        Gtk.TreeView.__init__(self)
        self.sections = {}
        titles = [(_('Key'), 1, 235),
                  (_('Value'), 2, 325)]
        self.model = ListModel(self, titles, list_mode="tree")
项目:isar    作者:ilbers    | 项目源码 | 文件源码
def __init__(self, model, dep_type, label):
        Gtk.TreeView.__init__(self)
        self.current = None
        self.dep_type = dep_type
        self.filter_model = model.filter_new()
        self.filter_model.set_visible_func(self._filter, data=None)
        self.set_model(self.filter_model)
        self.append_column(Gtk.TreeViewColumn(label, Gtk.CellRendererText(), text=COL_DEP_PACKAGE))
项目:isar    作者:ilbers    | 项目源码 | 文件源码
def __init__(self, model, label):
        Gtk.TreeView.__init__(self)
        self.current = None
        self.filter_model = model.filter_new()
        self.filter_model.set_visible_func(self._filter)
        self.set_model(self.filter_model)
        self.append_column(Gtk.TreeViewColumn(label, Gtk.CellRendererText(), text=COL_DEP_PARENT))
项目:MokaPlayer    作者:vedard    | 项目源码 | 文件源码
def on_grid_songs_focus_in_event(self, widget, event):
        """ We don't want 2 treeview with a selection,
            so we walk trougth the siblings and their children
            then call unselect_all() if it's a treeview
        """
        stack = [self.get_view().get_parent()]
        while any(stack):
            element = stack.pop()
            if isinstance(element, Gtk.TreeView) and element is not widget:
                element.get_selection().unselect_all()
            elif isinstance(element, Gtk.Container):
                stack.extend(element.get_children())
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def populate_treeview(self, rows):
        """ Accepts an array of n rows made of 2 elements each, and returns a ListView."""

        store = Gtk.ListStore(str, str)
        for row in rows:
            store.append([row[0], row[1]])

        tv = Gtk.TreeView(store)
        tv.set_rules_hint(True)

        return tv
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def create_tree(self):
        # Scrolled Window
        self.sw = Gtk.ScrolledWindow()
        self.sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
        self.sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)

        self.store = Gtk.ListStore(str, str)
        self.tree = Gtk.TreeView(self.store)

        self.sw.add(self.tree)

        self.tree.set_rules_hint(True)

        # Connect right click popup search menu
        self.popup_handler = self.tree.connect('button-press-event', self.popup_menu)

        # Create the column
        bblocks = Gtk.TreeViewColumn()
        bblocks.set_title("Basic Blocks")

        cell = Gtk.CellRendererText()
        bblocks.pack_start(cell, True)
        bblocks.add_attribute(cell, "text", 0)

        self.treestore = Gtk.TreeStore(str)

        # Add column to tree
        self.tree.append_column(bblocks)
        self.tree.set_model(self.treestore)
        self.tree.expand_all()
项目:ibus-typing-booster    作者:mike-fabian    | 项目源码 | 文件源码
def on_row_activated( # pylint: disable=no-self-use
            self, treeview, treepath, column):
        '''Signal handler for activating a row in the browsing treeview

        :param treeview: The browsing treeview
        :type treeview: Gtk.TreeView object
        :param treepath: The path of the activated row in the browsing treeview
        :type treepath: Gtk.TreePath object
        :param column: The column of the activated row in the browsing treeview
        :type column: Gtk.TreeViewColumn object
        '''
        if _ARGS.debug:
            sys.stdout.write(
                'on_row_activated() %s %s %s\n'
                %(repr(treeview), repr(treepath), repr(column)))
项目:PyFlowChart    作者:steelcowboy    | 项目源码 | 文件源码
def treeview_clicked(self, widget, event):
        """Responds to right click events on the TreeView."""
        if event.button == 3:
            store, course_iter = widget.get_selection().get_selected()
            course_id = store.get(course_iter, 4)[0] 
            self.selected_id = course_id  
            self.selected_course = self.course_manager.courses[course_id]

            self.edit_menu.popup(None, None, None, None, event.button, event.time)
项目:gnome-appfolders-manager    作者:muflone    | 项目源码 | 文件源码
def on_treeview_folders_cursor_changed(self, widget):
        selected_row = get_treeview_selected_row(self.ui.treeview_folders)
        if selected_row:
            folder_name = self.model_folders.get_key(selected_row)
            # Check if the folder still exists
            # (model erased while the cursor moves through the Gtk.TreeView)
            if folder_name in self.folders:
                folder_info = self.folders[folder_name]
                # Clear any previous application icon
                self.model_applications.clear()
                # Add new application icons
                applications = folder_info.get_applications()
                for application in applications:
                    desktop_file = applications[application]
                    if desktop_file or preferences.get(
                            preferences.PREFERENCES_SHOW_MISSING):
                        application_file = applications[application]
                        application_info = ApplicationInfo(
                            application,
                            application_file.getName()
                            if desktop_file else 'Missing desktop file',
                            application_file.getComment()
                            if desktop_file else application,
                            application_file.getIcon()
                            if desktop_file else None,
                            # Always show any application, also if hidden
                            True)
                        self.model_applications.add_data(application_info)
            # Disable folder content saving
            self.ui.action_files_save.set_sensitive(False)
项目:poseidon    作者:sidus-dev    | 项目源码 | 文件源码
def get_font_family_list():

    widget = Gtk.FontChooserWidget()
    treeview = get_descendant(widget, "family_face_list", level=0, doPrint=False)
    famlist = ["serif", "sans-serif", "monospace"]

    if type(treeview) == Gtk.TreeView:
        for i in treeview.get_model():
            fam = i[0].get_name()
            if fam not in famlist: famlist.append(fam)

    return famlist
项目:pytimetrack    作者:fhackerz    | 项目源码 | 文件源码
def __init__(self):
        Gtk.TreeView.__init__(self)
        self.task_store = Gtk.TreeStore(str, str)
        self.set_model(self.task_store)
        column = Gtk.TreeViewColumn(_('Tasks'), Gtk.CellRendererText(), text=0)
        self.append_column(column)
        self.connect('notify::tasks', self.tasks_changed)
项目:ssh-manager    作者:Doka-NT    | 项目源码 | 文件源码
def __setup_ui(self, win):
        btn_setting = Gtk.Button("Settings")
        btn_setting.set_margin_right(self.HORIZONTAL_MARGIN)
        btn_reload = Gtk.Button("Reload")
        btn_box = Gtk.HBox()
        btn_box.add(btn_setting)
        btn_box.add(btn_reload)
        self._listbox = Gtk.TreeView(self._list_store)
        self._listbox.set_headers_visible(False)
        self._listbox.connect("row-activated", self.__row_activated)
        self._scrollable = Gtk.ScrolledWindow()
        self._scrollable.add(self._listbox)
        self.__fill_listbox()
        self._frame = Gtk.Frame()
        self._frame.add(self._scrollable)
        self._frame.set_border_width(1)
        self._frame.set_margin_bottom(self.VERTICAL_MARGIN)
        vbox = Gtk.VBox()
        vbox.pack_start(self._frame, 1, 1, 1)
        vbox.pack_end(btn_box, 0, 0, 0)
        vbox.set_margin_top(self.VERTICAL_MARGIN)
        vbox.set_margin_bottom(self.VERTICAL_MARGIN)
        vbox.set_margin_left(self.VERTICAL_MARGIN)
        vbox.set_margin_right(self.VERTICAL_MARGIN)
        win.add(vbox)
        return btn_reload, btn_setting
项目:ssh-manager    作者:Doka-NT    | 项目源码 | 文件源码
def __row_activated(self, target: Gtk.TreeView, path: Gtk.TreePath, column: Gtk.TreeViewColumn):
        i = path.get_indices()[0]
        connection = self._manager.get_connection(i)
        self.__command_ssh.run(connection, connection.args)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def set_model(self, model):
        # the set_cell_data_func() calls here are a workaround for bug
        # LP: #986186 - once that is fixed upstream we can revert this
        # and remove the entire "set_model" again
        self._column.set_cell_data_func(self._renderer, None)
        Gtk.TreeView.set_model(self, model)
        self._column.set_cell_data_func(
            self._renderer, self._cell_data_func_cb)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def _on_realize(self, widget, tr):
        # connect to backend events once self is realized so handlers
        # have access to the TreeView's initialised Gdk.Window
        if self._transactions_connected:
            return
        self.backend.connect("transaction-started",
            self._on_transaction_started, tr)
        self.backend.connect("transaction-finished",
            self._on_transaction_finished, tr)
        self.backend.connect("transaction-stopped",
            self._on_transaction_stopped, tr)
        self._transactions_connected = True
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, navhistory):
        Gtk.TreeView.__init__(self)
        self.navhistory = navhistory
        model = Gtk.ListStore()
        model.set_column_types(self._COLUMN_TYPES)
        self._build_tree_view(model)
        self.connect("button-press-event", self.on_press_event)
        return
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def set_model(self, model):
        # the set_cell_data_func() calls here are a workaround for bug
        # LP: #986186 - once that is fixed upstream we can revert this
        # and remove the entire "set_model" again
        self._column.set_cell_data_func(self._renderer, None)
        Gtk.TreeView.set_model(self, model)
        self._column.set_cell_data_func(
            self._renderer, self._cell_data_func_cb)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, navhistory):
        Gtk.TreeView.__init__(self)
        self.navhistory = navhistory
        model = Gtk.ListStore()
        model.set_column_types(self._COLUMN_TYPES)
        self._build_tree_view(model)
        self.connect("button-press-event", self.on_press_event)
        return
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __init__(self):

        Gtk.Window.__init__(self, title='My Window Title')
        self.connect('delete-event', Gtk.main_quit)        

        # Gtk.ListStore will hold data for the TreeView
        # Only the first two columns will be displayed
        # The third one is for sorting file sizes as numbers
        store = Gtk.ListStore(str, str, long)
        # Get the data - see below
        self.populate_store(store)

        treeview = Gtk.TreeView(model=store)

        # The first TreeView column displays the data from
        # the first ListStore column (text=0), which contains
        # file names
        renderer_1 = Gtk.CellRendererText()        
        column_1 = Gtk.TreeViewColumn('File Name', renderer_1, text=0)
        # Calling set_sort_column_id makes the treeViewColumn sortable
        # by clicking on its header. The column is sorted by
        # the ListStore column index passed to it 
        # (in this case 0 - the first ListStore column) 
        column_1.set_sort_column_id(0)        
        treeview.append_column(column_1)

        # xalign=1 right-aligns the file sizes in the second column
        renderer_2 = Gtk.CellRendererText(xalign=1)
        # text=1 pulls the data from the second ListStore column
        # which contains filesizes in bytes formatted as strings
        # with thousand separators
        column_2 = Gtk.TreeViewColumn('Size in bytes', renderer_2, text=1)
        # Mak the Treeview column sortable by the third ListStore column
        # which contains the actual file sizes
        column_2.set_sort_column_id(2)
        treeview.append_column(column_2)

        # Use ScrolledWindow to make the TreeView scrollable
        # Otherwise the TreeView would expand to show all items
        # Only allow vertical scrollbar
        scrolled_window = Gtk.ScrolledWindow()
        scrolled_window.set_policy(
            Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        scrolled_window.add(treeview)
        scrolled_window.set_min_content_height(200)

        self.add(scrolled_window)
        self.show_all()
项目:jcchess    作者:johncheetham    | 项目源码 | 文件源码
def __init__(self):
        glade_dir = gv.jcchess.get_glade_dir()
        self.glade_file = os.path.join(glade_dir, "move_list.glade")
        Move_List.move_list_ref = self
        self.comments = comments.get_ref()

        self.saved_move_list = []

        # create move list window
        self.builder = Gtk.Builder()
        self.builder.set_translation_domain(gv.domain)
        self.builder.add_from_file(self.glade_file)
        self.builder.connect_signals(self)

        self.window = self.builder.get_object("move_list_window")
        self.vbox = self.builder.get_object("vbox1") #man
        self.treeview = Gtk.TreeView()  #man
        self.liststore = self.builder.get_object("liststore1")

        self.scrolled_window = Gtk.ScrolledWindow()
        #self.scrolled_window.set_size_request(150,300)
        self.treeview.set_model(self.liststore)
        self.scrolled_window.add(self.treeview)           
        self.vbox.add(self.scrolled_window)        
        self.comments_button = self.builder.get_object("comments_button")
        #self.builder.connect("button_press_event",self.comments_button_clicked_cb)

        cell0 = Gtk.CellRendererText()
        # cell0.set_property("cell-background", Gdk.color_parse("#F8F8FF"))
        tvcolumn0 = Gtk.TreeViewColumn("#")
        self.treeview.append_column(tvcolumn0)
        tvcolumn0.pack_start(cell0, True)
        tvcolumn0.set_min_width(50)
        tvcolumn0.set_attributes(cell0, text=0)

        cell1 = Gtk.CellRendererText()
        # cell1.set_property("cell-background", Gdk.color_parse("#F8F8FF"))
        tvcolumn1 = Gtk.TreeViewColumn(_("Move"))
        self.treeview.append_column(tvcolumn1)
        tvcolumn1.pack_start(cell1, True)
        tvcolumn1.set_min_width(100)
        tvcolumn1.set_attributes(cell1, text=1)

        cell2 = Gtk.CellRendererText()
        # cell1.set_property("cell-background", Gdk.color_parse("#F8F8FF"))
        tvcolumn2 = Gtk.TreeViewColumn(_("Cmt"))
        self.treeview.append_column(tvcolumn2)
        tvcolumn2.pack_start(cell2, True)
        tvcolumn2.set_min_width(20)
        tvcolumn2.set_attributes(cell2, text=2)


        self.tree_selection = self.treeview.get_selection()
        self.treeview.connect("button_press_event", self.treeview_button_press)
        self.treeview.connect("key_press_event", self.treeview_key_press)
        self.update()

    # user has closed the window
    # just hide it
项目:btcwidget    作者:rafalh    | 项目源码 | 文件源码
def __init__(self, parent):
        Gtk.Dialog.__init__(self, "Alarms", parent, 0,
                            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                             Gtk.STOCK_OK, Gtk.ResponseType.OK))

        self._store = Gtk.ListStore(str, str, str, object)
        for i, alarm in enumerate(config['alarms']):
            row = self._build_row(alarm)
            self._store.append(row)

        self._tree = Gtk.TreeView(self._store)
        self._selection = self._tree.get_selection()
        self._selection.connect("changed", self._on_tree_selection_changed)
        self._tree.set_size_request(300, 150)

        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Exchange", renderer, text=self._EXCHANGE_COL)
        self._tree.append_column(column)

        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Market", renderer, text=self._MARKET_COL)
        self._tree.append_column(column)

        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Alarm Trigger", renderer, text=self._TRIGGER_COL)
        self._tree.append_column(column)

        vbox = Gtk.Box(spacing=6, orientation=Gtk.Orientation.VERTICAL)

        new_button = Gtk.Button.new_with_label("New Alarm")
        new_button.connect("clicked", self._on_new_button_clicked)
        vbox.pack_start(new_button, False, False, 0)

        self._remove_button = Gtk.Button.new_with_label("Remove Alarm")
        self._remove_button.connect("clicked", self._on_remove_button_clicked)
        vbox.pack_start(self._remove_button, False, False, 0)

        self._market_combo, self._market_store = self._create_market_combo()
        self._market_combo.connect("changed", self._on_market_changed)
        vbox.pack_start(self._market_combo, False, False, 0)

        self._above_radio = Gtk.RadioButton.new_with_label_from_widget(None, "Above")
        self._above_radio.connect("clicked", self._on_type_radio_clicked)
        self._below_radio = Gtk.RadioButton.new_with_label_from_widget(self._above_radio, "Below")
        self._below_radio.connect("clicked", self._on_type_radio_clicked)
        type_hbox = Gtk.Box(spacing=6, orientation=Gtk.Orientation.HORIZONTAL)
        type_hbox.pack_start(self._above_radio, True, True, 0)
        type_hbox.pack_start(self._below_radio, True, True, 0)
        vbox.pack_start(type_hbox, False, False, 0)

        self._price_entry = Gtk.Entry()
        self._price_entry.connect("changed", self._on_price_changed)
        _add_label_and_widget(vbox, "Price:", self._price_entry)

        hbox = Gtk.Box(spacing=6)
        hbox.pack_start(self._tree, True, True, 0)
        hbox.pack_start(vbox, False, False, 0)

        self.get_content_area().add(hbox)
        self._set_inputs_sensitive(False)
        self.show_all()
项目:isar    作者:ilbers    | 项目源码 | 文件源码
def __init__(self):
        Gtk.Window.__init__(self)
        self.set_title("Dependency Explorer")
        self.set_default_size(500, 500)
        self.connect("delete-event", Gtk.main_quit)

        # Create the data models
        self.pkg_model = Gtk.ListStore(GObject.TYPE_STRING)
        self.pkg_model.set_sort_column_id(COL_PKG_NAME, Gtk.SortType.ASCENDING)
        self.depends_model = Gtk.ListStore(GObject.TYPE_INT, GObject.TYPE_STRING, GObject.TYPE_STRING)
        self.depends_model.set_sort_column_id(COL_DEP_PACKAGE, Gtk.SortType.ASCENDING)

        pane = Gtk.HPaned()
        pane.set_position(250)
        self.add(pane)

        # The master list of packages
        scrolled = Gtk.ScrolledWindow()
        scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        scrolled.set_shadow_type(Gtk.ShadowType.IN)

        self.pkg_treeview = Gtk.TreeView(self.pkg_model)
        self.pkg_treeview.get_selection().connect("changed", self.on_cursor_changed)
        column = Gtk.TreeViewColumn("Package", Gtk.CellRendererText(), text=COL_PKG_NAME)
        self.pkg_treeview.append_column(column)
        pane.add1(scrolled)
        scrolled.add(self.pkg_treeview)

        box = Gtk.VBox(homogeneous=True, spacing=4)

        # Runtime Depends
        scrolled = Gtk.ScrolledWindow()
        scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        scrolled.set_shadow_type(Gtk.ShadowType.IN)
        self.rdep_treeview = PackageDepView(self.depends_model, TYPE_RDEP, "Runtime Depends")
        self.rdep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PACKAGE)
        scrolled.add(self.rdep_treeview)
        box.add(scrolled)

        # Build Depends
        scrolled = Gtk.ScrolledWindow()
        scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        scrolled.set_shadow_type(Gtk.ShadowType.IN)
        self.dep_treeview = PackageDepView(self.depends_model, TYPE_DEP, "Build Depends")
        self.dep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PACKAGE)
        scrolled.add(self.dep_treeview)
        box.add(scrolled)
        pane.add2(box)

        # Reverse Depends
        scrolled = Gtk.ScrolledWindow()
        scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        scrolled.set_shadow_type(Gtk.ShadowType.IN)
        self.revdep_treeview = PackageReverseDepView(self.depends_model, "Reverse Depends")
        self.revdep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PARENT)
        scrolled.add(self.revdep_treeview)
        box.add(scrolled)
        pane.add2(box)

        self.show_all()
项目:efibootmgr-gui    作者:Elinvention    | 项目源码 | 文件源码
def __init__(self):
        Gtk.Window.__init__(self, title="EFI boot manager")
        self.set_border_width(10)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
        self.add(vbox)

        self.store = EFIStore(self)
        self.tree = Gtk.TreeView(self.store, vexpand=True)
        vbox.add(self.tree)

        renderer_text = Gtk.CellRendererText()
        renderer_check = Gtk.CellRendererToggle(radio=False)
        renderer_radio = Gtk.CellRendererToggle(radio=True)
        renderer_check.connect("toggled", self.store.change_active)
        renderer_radio.connect("toggled", self.store.change_boot_next)
        self.tree.append_column(Gtk.TreeViewColumn("BootNum", renderer_text, text=0))
        self.tree.append_column(Gtk.TreeViewColumn("Name", renderer_text, text=1))
        self.tree.append_column(Gtk.TreeViewColumn("Loader", renderer_text, text=2))
        self.tree.append_column(Gtk.TreeViewColumn("Active", renderer_check, active=3))
        self.tree.append_column(Gtk.TreeViewColumn("NextBoot", renderer_radio, active=4))
        for column in self.tree.get_columns():
            column.set_resizable(True)
            column.set_min_width(75)

        hb = Gtk.HeaderBar()
        hb.set_show_close_button(True)
        hb.props.title = "EFI boot manager"
        self.set_titlebar(hb)

        clear_btn = btn_with_icon("edit-clear-all-symbolic")
        clear_btn.connect("button-press-event", self.discard_changes)
        hb.pack_end(clear_btn)

        write_btn = btn_with_icon("document-save-symbolic")
        write_btn.connect("button-press-event", self.apply_changes)
        hb.pack_end(write_btn)

        hbox = Gtk.HButtonBox()
        hbox.set_layout(Gtk.ButtonBoxStyle.EXPAND)
        vbox.add(hbox)
        up = btn_with_icon("go-up-symbolic")
        down = btn_with_icon("go-down-symbolic")
        new = btn_with_icon("list-add-symbolic")
        delete = btn_with_icon("list-remove-symbolic")
        hbox.add(up)
        hbox.add(down)
        hbox.add(new)
        hbox.add(delete)
        up.connect("button-press-event", self.up)
        down.connect("button-press-event", self.down)
        new.connect("button-press-event", self.new)
        delete.connect("button-press-event", self.delete)

        self.connect("delete-event", self.quit)
        self.set_default_size(300, 260)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def __init__(self):
        Gtk.Dialog.__init__(self, _("GNU Solfege Preferences"),
             solfege.win, 0,
             (Gtk.STOCK_HELP, Gtk.ResponseType.HELP, Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE))
        cfg.ConfigUtils.__init__(self, 'configwindow')
        self.connect('response', self.apply_and_close)
        # We do this so that the window is only hidden when the
        # user click on the close button provided by the window manager.
        self.connect('delete-event', self.on_destroy)#lambda w, e: True)

        hbox = Gtk.HBox()
        hbox.set_spacing(gu.hig.SPACE_LARGE)
        hbox.set_border_width(gu.hig.SPACE_SMALL)
        self.vbox.pack_start(hbox, True, True, 0)

        frame = Gtk.Frame()
        self.g_pages = Gtk.TreeStore(str)
        self.g_pview = Gtk.TreeView(self.g_pages)
        self.g_pview.set_headers_visible(False)
        hbox.pack_start(frame, False, False, 0)
        frame.add(self.g_pview)

        self.g_page_box = Gtk.HBox()
        hbox.pack_start(self.g_page_box, True, True, 0)
        self.m_page_mapping = {}

        def cursor_changed(treeview):
            path, col = treeview.get_cursor()
            if not path:
                return
            path = tuple(path)
            for key, page in self.m_page_mapping.items():

                if key == path:
                    page.show()

                else:
                    page.hide()
            self.m_page_mapping[path].show_all()
        tvcol = Gtk.TreeViewColumn("Col 0")
        self.g_pview.append_column(tvcol)
        cell = Gtk.CellRendererText()
        tvcol.pack_start(cell, True)
        tvcol.add_attribute(cell, 'text', 0)
        hbox.show_all()

        self.create_midi_config()
        self.create_user_config()
        self.create_external_programs_config()
        self.create_gui_config()
        self.create_practise_config()
        self.create_sound_config()
        self.create_statistics_config()
        self.g_pview.connect('cursor-changed', cursor_changed)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def create_idtone_accels_config(self, parent):
        it, page_vbox = self.new_page_box(parent, _("Identify tone keyboard accelerators"))
        self.g_idtone_accels = Gtk.ListStore(GObject.TYPE_STRING,
            GObject.TYPE_STRING)
        notenames = ('c', 'cis', 'd', 'dis', 'e', 'f', 'fis',
                     'g', 'gis', 'a', 'ais', 'b')
        for notename in notenames:
            self.g_idtone_accels.append((
                solfege.mpd.MusicalPitch.new_from_notename(notename).get_user_notename(),
                cfg.get_string('idtone/tone_%s_ak' % notename)))
        self.g_treeview = Gtk.TreeView(self.g_idtone_accels)
        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn(_("Note name"), renderer, text=0)
        self.g_treeview.append_column(column)
        renderer = Gtk.CellRendererAccel()
        renderer.set_property('editable', True)

        def acc_ff(renderer, path, accel_key, accel_mods, hw_key):
            is_unique = True
            for notename in notenames:
                if (notename != notenames[int(path)]
                    and cfg.get_string('idtone/tone_%s_ak' % notename) == unichr(accel_key)):
                    is_unique = False
                    break

            if not is_unique:
                gu.dialog_ok(_(u"The accelerator in use for the tone “%s”. You have to choose another key.") % solfege.mpd.MusicalPitch.new_from_notename(notename).get_user_notename(), parent=self, msgtype=Gtk.MessageType.ERROR)
                return
            it = self.g_idtone_accels.get_iter(path)
            cfg.set_string('idtone/tone_%s_ak' % notenames[int(path)], unichr(accel_key))
            self.g_idtone_accels.set(it, 1, unichr(accel_key))
            return True
        renderer.connect('accel-edited', acc_ff)
        column = Gtk.TreeViewColumn(_i("keyboard|Key"), renderer, text=1)
        self.g_treeview.append_column(column)
        page_vbox.pack_start(self.g_treeview, True, True, 0)
        layouts = {'ascii': (_('ASCII'), u'awsedfujikol'),
                   'dvorak': (_('Dvorak'), u'a,o.eughctrn'),
        }
        hbox = Gtk.HBox()
        page_vbox.pack_start(hbox, False, False, 0)

        def set_buttons(widget, layout):
            v = layouts[layout][1]
            idx = 0
            it = self.g_idtone_accels.get_iter_first()
            while True:
                self.g_idtone_accels.set_value(it, 1, v[idx])
                cfg.set_string('idtone/tone_%s_ak' % notenames[idx], v[idx])
                it = self.g_idtone_accels.iter_next(it)
                idx += 1
                if not it:
                    break
        for key in layouts:
            btn = Gtk.Button(layouts[key][0])
            btn.connect('clicked', set_buttons, key)
            hbox.pack_start(btn, True, True, 0)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def create_interval_accels_config(self, parent):
        it, page_vbox = self.new_page_box(parent, _("Interval keyboard accelerators"))
        self.g_interval_accels = Gtk.ListStore(GObject.TYPE_STRING,
            GObject.TYPE_STRING)
        intervals = ['minor2', 'major2', 'minor3', 'major3',
                     'perfect4', 'diminished5', 'perfect5', 'minor6',
                     'major6', 'minor7', 'major7', 'perfect8',
                     'minor9', 'major9', 'minor10', 'major10']
        for interval in intervals:
            self.g_interval_accels.append((
                mpd.Interval.new_from_int(intervals.index(interval)).get_name(),
                cfg.get_string('interval_input/%s' % interval)))
        self.g_intervals_treeview = Gtk.TreeView(self.g_interval_accels)
        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn(_("Interval"), renderer, text=0)
        self.g_intervals_treeview.append_column(column)
        renderer = Gtk.CellRendererAccel()
        renderer.set_property('editable', True)

        def acc_ff(renderer, path, accel_key, accel_mods, hw_key):
            is_unique = True
            for interval in intervals:
                if (interval != intervals[int(path)]
                    and cfg.get_string('interval_input/%s' % interval) == unichr(accel_key)):
                    is_unique = False
                    break

            if not is_unique:
                gu.dialog_ok(_(u"The accelerator in use for “%s”. You have to choose another key.") % mpd.Interval.new_from_int(intervals.index(interval)).get_name(), parent=self, msgtype=Gtk.MessageType.ERROR)
                return
            it = self.g_interval_accels.get_iter(path)
            cfg.set_string('interval_input/%s' % intervals[int(path)], unichr(accel_key))
            self.g_interval_accels.set(it, 1, unichr(accel_key))
            return True
        renderer.connect('accel-edited', acc_ff)
        column = Gtk.TreeViewColumn(_i("keyboard|Key"), renderer, text=1)
        self.g_intervals_treeview.append_column(column)
        page_vbox.pack_start(self.g_intervals_treeview, True, True, 0)
        hbox = Gtk.HBox()
        page_vbox.pack_start(hbox, False, False, 0)
        layouts = {'ascii': (_('ASCII'), u'1qaz2wsx3edc4rfv'),
                   'dvorak': (_('Dvorak'), u"1'a;2,oq3.ej4puk"),
        }

        def set_buttons(widget, layout):
            v = layouts[layout][1]
            idx = 0
            it = self.g_interval_accels.get_iter_first()
            while True:
                self.g_interval_accels.set_value(it, 1, v[idx])
                cfg.set_string('interval_input/%s' % intervals[idx], v[idx])
                it = self.g_interval_accels.iter_next(it)
                idx += 1

                if not it:
                    break
        for key in layouts:
            btn = Gtk.Button(layouts[key][0])
            btn.connect('clicked', set_buttons, key)
            hbox.pack_start(btn, True, True, 0)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def __init__(self, default_profile):
        Gtk.Dialog.__init__(self, _("GNU Solfege - Choose User Profile"))
        # We save the initially selected profile, because we need to keep
        # track of it if the user renames it and then presses cancel.
        self.m_default_profile = default_profile
        vbox = gu.hig_dlg_vbox()
        self.vbox.pack_start(vbox, False, False, 0)
        l = Gtk.Label(_("Solfege will save your statistics and test results in the user profile. By adding additional user profiles to Solfege, multiple users can share a user account on the operating system."))
        l.set_alignment(0.0, 0.5)
        l.set_line_wrap(True)
        vbox.pack_start(l, True, True, 0)

        hbox = Gtk.HBox()
        hbox.set_spacing(gu.hig.SPACE_MEDIUM)
        vbox.pack_start(hbox, True, True, 0)
        button_box = Gtk.VBox()

        self.g_create_profile = Gtk.Button.new_with_mnemonic(_(u"_Create profile\u2026"))
        self.g_create_profile.connect('clicked', self.on_create_profile)
        button_box.pack_start(self.g_create_profile, False, False, 0)

        self.g_rename_profile = Gtk.Button.new_with_mnemonic(_(u"_Rename profile\u2026"))
        self.g_rename_profile.connect('clicked', self.on_rename_profile)
        button_box.pack_start(self.g_rename_profile, False, False, 0)

        self.g_delete_profile = Gtk.Button.new_with_mnemonic(_(u"_Delete profile\u2026"))
        self.g_delete_profile.connect('clicked', self.on_delete_profile)
        button_box.pack_start(self.g_delete_profile, False, False, 0)

        hbox.pack_start(button_box, False, False, 0)
        self.g_liststore = liststore = Gtk.ListStore(GObject.TYPE_STRING)
        liststore.append((_("Standard profile"),))
        if os.path.exists(os.path.join(filesystem.app_data(), 'profiles')):
            for subdir in os.listdir(os.path.join(filesystem.app_data(),
                'profiles')):
                liststore.append((subdir,))
        #
        self.g_tw = tw = Gtk.TreeView(liststore)
        tw.connect('row-activated', lambda a, b, c: self.response(Gtk.ResponseType.ACCEPT))
        tw.set_headers_visible(False)
        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn(None, renderer, text=0)
        tw.append_column(column)
        hbox.pack_start(tw, False, False, 0)
        tw.show()
        tw.connect('cursor-changed', self.on_cursor_changed)
        tw.set_cursor((0,))
        for idx, s in enumerate(self.g_liststore):

            if s[0].decode("utf-8") == default_profile:
                tw.set_cursor((idx, ))
        #
        chk = gu.nCheckButton("app", "noprofilemanager", _("D_on't ask at startup"))
        vbox.pack_start(chk, False, False, 0)
        self.show_all()
项目:bcloud    作者:wangYanJava    | 项目源码 | 文件源码
def __init__(self, parent, app, title, source_url, save_path):
        '''???BT???????.

        source_url - ???BT????, ?????????.
                      ???????, ???magent:???????.
        '''
        super().__init__(title, app.window, Gtk.DialogFlags.MODAL,
                         (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                         Gtk.STOCK_OK, Gtk.ResponseType.OK))

        self.app = app
        self.source_url = source_url
        self.save_path = save_path

        self.set_default_response(Gtk.ResponseType.OK)
        self.set_default_size(520, 480)
        self.set_border_width(10)
        box = self.get_content_area()

        select_all_button = Gtk.ToggleButton.new_with_label(_('Select All'))
        select_all_button.props.halign = Gtk.Align.START
        select_all_button.props.margin_bottom = 5
        select_all_button.connect('toggled', self.on_select_all_toggled)
        box.pack_start(select_all_button, False, False, 0)

        scrolled_win = Gtk.ScrolledWindow()
        box.pack_start(scrolled_win, True, True, 0)

        # check, name, size, humansize
        self.liststore = Gtk.ListStore(bool, str, GObject.TYPE_INT64, str)
        self.treeview = Gtk.TreeView(model=self.liststore)
        self.treeview.set_tooltip_column(NAME_COL)
        scrolled_win.add(self.treeview)
        check_cell = Gtk.CellRendererToggle()
        check_cell.connect('toggled', self.on_check_cell_toggled)
        check_col = Gtk.TreeViewColumn('', check_cell, active=CHECK_COL)
        self.treeview.append_column(check_col)
        name_cell = Gtk.CellRendererText(ellipsize=Pango.EllipsizeMode.END,
                                         ellipsize_set=True)
        name_col = Gtk.TreeViewColumn(_('Name'), name_cell, text=NAME_COL)
        name_col.set_expand(True)
        self.treeview.append_column(name_col)
        size_cell = Gtk.CellRendererText()
        size_col = Gtk.TreeViewColumn(_('Size'), size_cell, text=HUMANSIZE_COL)
        self.treeview.append_column(size_col)

        box.show_all()
        self.request_data()
项目:bcloud    作者:wangYanJava    | 项目源码 | 文件源码
def __init__(self, parent, app, title=_('Save to..')):
        self.parent = parent
        self.app = app
        super().__init__(title, app.window, Gtk.DialogFlags.MODAL,
                         (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                         Gtk.STOCK_OK, Gtk.ResponseType.OK))
        self.set_default_size(440, 480)
        self.set_border_width(10)
        self.set_default_response(Gtk.ResponseType.OK)

        box = self.get_content_area()

        control_box = Gtk.Box()
        box.pack_start(control_box, False, False, 0)

        mkdir_button = Gtk.Button.new_with_label(_('Create Folder'))
        control_box.pack_end(mkdir_button, False, False, 0)
        mkdir_button.connect('clicked', self.on_mkdir_clicked)

        reload_button = Gtk.Button.new_with_label(_('Reload'))
        control_box.pack_end(reload_button, False, False, 5)
        reload_button.connect('clicked', self.on_reload_clicked)

        scrolled_win = Gtk.ScrolledWindow()
        box.pack_start(scrolled_win, True, True, 5)

        # disname, path, empty, loaded
        self.treestore = Gtk.TreeStore(str, str, bool, bool)
        self.treeview = Gtk.TreeView(model=self.treestore)
        self.selection = self.treeview.get_selection()
        scrolled_win.add(self.treeview)
        icon_cell = Gtk.CellRendererPixbuf(icon_name='folder')
        name_cell = Gtk.CellRendererText()
        name_col = Gtk.TreeViewColumn(_('Folder'))
        name_col.pack_start(icon_cell, False)
        name_col.pack_start(name_cell, True)
        if Config.GTK_LE_36:
            name_col.add_attribute(name_cell, 'text', NAME_COL)
        else:
            name_col.set_attributes(name_cell, text=NAME_COL)
        self.treeview.append_column(name_col)
        self.treeview.connect('row-expanded', self.on_row_expanded)

        box.show_all()

        self.reset()
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def __init__(self):
        GObject.GObject.__init__(self)
        self.set_position (500)
        # Graph viewers
        hbox = Gtk.HBox(True, 5)
        dw = self.dw = DiffView()
        dw2 = self.dw2 = DiffView()
        hbox.pack_start(dw, True, True, 0)
        hbox.pack_start(dw2, True, True, 0)
        self.add(hbox)
        # Function list
        scrolledwin = Gtk.ScrolledWindow()
        scrolledwin.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        liststore = self.liststore = Gtk.ListStore(str, str, str, str, str)
        treeview = Gtk.TreeView(liststore)
        # Column Address L
        tvcolumn0 = Gtk.TreeViewColumn('Function L')
        treeview.append_column(tvcolumn0)
        cell0 = Gtk.CellRendererText()
        tvcolumn0.pack_start(cell0, True)
        tvcolumn0.add_attribute(cell0, 'text', 0)
        tvcolumn0.set_sort_column_id(0)
        # Column Function L
        tvcolumn1 = Gtk.TreeViewColumn('Address L')
        treeview.append_column(tvcolumn1)
        cell1 = Gtk.CellRendererText()
        tvcolumn1.pack_start(cell1, True)
        tvcolumn1.add_attribute(cell1, 'text', 1)
        tvcolumn1.set_sort_column_id(1)
        # Column Address R
        tvcolumn2 = Gtk.TreeViewColumn('Function R')
        treeview.append_column(tvcolumn2)
        cell2 = Gtk.CellRendererText()
        tvcolumn2.pack_start(cell2, True)
        tvcolumn2.add_attribute(cell2, 'text', 2)
        tvcolumn2.set_sort_column_id(2)
        # Column Function R
        tvcolumn3 = Gtk.TreeViewColumn('Address R')
        treeview.append_column(tvcolumn3)
        cell3 = Gtk.CellRendererText()
        tvcolumn3.pack_start(cell3, True)
        tvcolumn3.add_attribute(cell3, 'text', 3)
        tvcolumn3.set_sort_column_id(3)
        # Column Diff
        tvcolumn4 = Gtk.TreeViewColumn('Diff')
        treeview.append_column(tvcolumn4)
        cell4 = Gtk.CellRendererText()
        tvcolumn4.pack_start(cell4, True)
        tvcolumn4.add_attribute(cell4, 'text', 4)
        tvcolumn4.set_sort_column_id(4)
        # Set treeview options and add it to scrolledwin
        treeview.set_reorderable(True)
        scrolledwin.add(treeview)
        self.add2(scrolledwin)
        treeview.connect('row-activated', self.on_row_activated)
项目:PyFlowChart    作者:steelcowboy    | 项目源码 | 文件源码
def setup_builder(self):
        """
        Setup the layout for the window and containers.
        """
        grid = Gtk.Grid()
        grid.set_column_homogeneous(True)

        scroll_window = Gtk.ScrolledWindow()
        scroll_window.set_vexpand(True)
        grid.attach(scroll_window, 0, 0, 1, 1)

        self.builder_grid = ModifyGrid() 

        add_button = Gtk.Button.new_with_label("Add")
        add_button.connect('clicked', self.add_entry)
        add_button.set_margin_top(5)
        self.builder_grid.attach(add_button, 1, 9, 2, 1)

        grid.attach(self.builder_grid, 1, 0, 1, 1)

        self.course_manager.store = Gtk.ListStore(str, str, int, str, int)

        self.added_tree = Gtk.TreeView(self.course_manager.store)

        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Course", renderer, text=0)
        self.added_tree.append_column(column)

        column = Gtk.TreeViewColumn("Year/Quarter", renderer, text=1)
        self.added_tree.append_column(column)

        column = Gtk.TreeViewColumn("Units", renderer, text=2)
        self.added_tree.append_column(column)

        column = Gtk.TreeViewColumn("Type", renderer, text=3)
        self.added_tree.append_column(column)

        self.added_tree.connect('button-press-event', self.treeview_clicked)

        scroll_window.add(self.added_tree)

        self.interface_switcher.insert_page(grid, None, 1)
项目:draobpilc    作者:awamper    | 项目源码 | 文件源码
def __init__(self, keybindings):
        super().__init__()

        self.set_orientation(Gtk.Orientation.VERTICAL)

        self._keybindings = keybindings

        scrolled_window = Gtk.ScrolledWindow()
        scrolled_window.set_policy(
            Gtk.PolicyType.AUTOMATIC,
            Gtk.PolicyType.AUTOMATIC
        )

        self._store = Gtk.ListStore(str, str, int, int)
        self._tree_view = Gtk.TreeView()
        self._tree_view.set_model(self._store)
        self._tree_view.set_vexpand(True)
        self._tree_view.set_hexpand(True)
        self._tree_view.get_selection().set_mode(Gtk.SelectionMode.SINGLE)

        action_renderer = Gtk.CellRendererText()
        action_column = Gtk.TreeViewColumn()
        action_column.props.title = _('Action')
        action_column.props.expand = True
        action_column.pack_start(action_renderer, True)
        action_column.add_attribute(action_renderer, 'text', 1)
        self._tree_view.append_column(action_column)

        keybinding_renderer = Gtk.CellRendererAccel()
        keybinding_renderer.props.editable = True
        keybinding_renderer.connect('accel-edited', self._on_accel_edited)
        keybinding_column = Gtk.TreeViewColumn()
        keybinding_column.props.title = _('Modify')
        keybinding_column.pack_end(keybinding_renderer, False)
        keybinding_column.add_attribute(
            keybinding_renderer,
            'accel-mods',
            KeybindingsWidget.Columns.MODS
        )
        keybinding_column.add_attribute(
            keybinding_renderer,
            'accel-key',
            KeybindingsWidget.Columns.KEY
        )
        self._tree_view.append_column(keybinding_column)

        scrolled_window.add(self._tree_view)
        self.add(scrolled_window)

        self._refresh()
项目:ukui-menu    作者:ukui    | 项目源码 | 文件源码
def __init__(self, desktopFile):
        self.desktopFile = desktopFile
        (status, output) = subprocess.getstatusoutput("dpkg -S " + self.desktopFile)
        package = output[:output.find(":")]
        if status != 0:
            warnDlg = Gtk.MessageDialog(None, 0, Gtk.MessageType.WARNING, Gtk.ButtonsType.YES_NO, _("This application has been removed. Are you sure remove the menu form the startup menu?"))
            warnDlg.vbox.set_spacing(10)
            response = warnDlg.run()
            if response == Gtk.ResponseType.YES :
                print (("removing '%s'" % self.desktopFile))
                os.system("rm -f '%s'" % self.desktopFile)
                os.system("rm -f '%s.desktop'" % self.desktopFile)
            warnDlg.destroy()
            sys.exit(0)

        warnDlg = Gtk.MessageDialog(None, 0, Gtk.MessageType.WARNING, Gtk.ButtonsType.OK_CANCEL, _("The following packages will be removed:"))
        warnDlg.vbox.set_spacing(10)

        treeview = Gtk.TreeView()
        column1 = Gtk.TreeViewColumn(_("Packages will be removed"))
        renderer = Gtk.CellRendererText()
        column1.pack_start(renderer, False)
        column1.add_attribute(renderer, "text", 0)
        treeview.append_column(column1)

        model = Gtk.ListStore(str)
        dependenciesString = subprocess.getoutput("apt-get -s -q remove " + package + " | grep Remv")
        dependencies = string.split(dependenciesString, "\n")
        for dependency in dependencies:
            dependency = dependency.replace("Remv ", "")
            model.append([dependency])
        treeview.set_model(model)
        treeview.show()

        scrolledwindow = Gtk.ScrolledWindow()
        scrolledwindow.set_shadow_type(Gtk.ShadowType.ETCHED_OUT)
        scrolledwindow.set_size_request(300, 150)
        scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        scrolledwindow.add(treeview)
        scrolledwindow.show()

        warnDlg.get_content_area().add(scrolledwindow)

        response = warnDlg.run()
        if response == Gtk.ResponseType.OK :
            executer = RemoveExecuter(package)
            executer.start()
        elif response == Gtk.ResponseType.CANCEL :
            sys.exit(0)
        warnDlg.destroy()

        Gtk.main()
项目:Vulnerabilities-spider    作者:muhammad-bouabid    | 项目源码 | 文件源码
def __init__(self, parent):
      Gtk.Dialog.__init__(self, "History Scanne Tables", parent,
          Gtk.DialogFlags.MODAL, buttons=(
          Gtk.STOCK_OK, Gtk.ResponseType.OK,
          Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))

      self.set_default_size(500, 400)

      box = self.get_content_area()

      self.HoriBox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
      box.add(self.HoriBox)

      self.scrolledwindow = Gtk.ScrolledWindow()
      self.scrolledwindow.set_hexpand(True)
      self.scrolledwindow.set_vexpand(True)

      self.HoriBox.pack_start(self.scrolledwindow, True, True, 0)

      self.people_lst = []

      #convert data to listStore Now (lists that TreeView can Display)
      peoples_list_store = Gtk.ListStore(str, str, str, str)
      for item in self.people_lst:
        peoples_list_store.append(list(item))
      #Make treeView for those item will display
      people_tree_view = Gtk.TreeView(peoples_list_store)

      for i, col_title in enumerate(["Website", "Point", "Faille","Payload"]):
        #Render means how to draw the data
        renderer = Gtk.CellRendererText()
        #create columns
        column = Gtk.TreeViewColumn(col_title, renderer, text=i)
        column.set_sort_column_id(i) # Make the Columns Sortable just bech ywali bsort (option)
        people_tree_view.append_column(column) # Add column to treeView

      #Handel data
      selected_row = people_tree_view.get_selection()
      selected_row.connect("changed", self.the_item_selected)

      # Add TreeView to main layout now
      self.scrolledwindow.add(people_tree_view)
      self.show_all()

  #user selectred row method
项目:poseidon    作者:sidus-dev    | 项目源码 | 文件源码
def user_agent(self):

    if self.tabs[self.current_page][0]\
    .scrolled_window.get_name() != "webview": return True

    window = build_window(self, 0, 0)
    window.set_titlebar(build_headerbar("User Agent", None, 1))

    scrolled_window = Gtk.ScrolledWindow()
    scrolled_window.set_size_request(400, 300)

    tree = Gtk.TreeView()
    tree.connect('row-activated', self.new_user_agent)
    column = Gtk.TreeViewColumn()
    column.set_title(_("Double click item to switch"))

    cell = Gtk.CellRendererText()
    column.pack_start(cell, True)
    column.add_attribute(cell, "text", 0)

    treestore = Gtk.TreeStore(str, str)

    ua_browsers_list = []
    ua_mobile_list = []
    ua_crawlers_list = []

    treestore.append(None, ["Default", ""])

    browsers = treestore.append(None, ["Browsers", None])
    for c, i in enumerate(ua_browsers_dsc): ua_browsers_list.append([i, ua_browsers_val[c]])
    ua_browsers_list.sort()
    for c, i in enumerate(ua_browsers_list): treestore.append(browsers, [ua_browsers_list[c][0], ua_browsers_list[c][1]])

    mobile = treestore.append(None, ["Mobile Browsers", None])
    for c, i in enumerate(ua_mobile_dsc): ua_mobile_list.append([i, ua_mobile_val[c]])
    ua_mobile_list.sort()
    for c, i in enumerate(ua_mobile_list): treestore.append(mobile, [ua_mobile_list[c][0], ua_mobile_list[c][1]])

    crawlers = treestore.append(None, ["Crawlers", None])
    for c, i in enumerate(ua_crawlers_dsc): ua_crawlers_list.append([i, ua_crawlers_val[c]])
    ua_crawlers_list.sort()
    for c, i in enumerate(ua_crawlers_list): treestore.append(crawlers, [ua_crawlers_list[c][0], ua_crawlers_list[c][1]])

    tree.append_column(column)
    tree.set_model(treestore)
    scrolled_window.add(tree)

    window.add(scrolled_window)
    window.show_all()
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, icons):
        Gtk.ScrolledWindow.__init__(self)
        BasePane.__init__(self)
        self.state = DisplayState()
        self.pane_name = _("Progress")

        self.tv = Gtk.TreeView()
        # customization
        self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        self.add(self.tv)
        self.tv.set_headers_visible(False)
        self.tv.connect("button-press-event", self._on_button_pressed)
        # icon
        self.icons = icons
        tp = Gtk.CellRendererPixbuf()
        tp.set_property("xpad", self.CANCEL_XPAD)
        tp.set_property("ypad", self.CANCEL_YPAD)
        column = Gtk.TreeViewColumn("Icon", tp, pixbuf=PendingStore.COL_ICON)
        self.tv.append_column(column)
        # name
        tr = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Name", tr, markup=PendingStore.COL_STATUS)
        column.set_min_width(200)
        column.set_expand(True)
        self.tv.append_column(column)
        # progress
        tp = Gtk.CellRendererProgress()
        tp.set_property("xpad", self.CANCEL_XPAD)
        tp.set_property("ypad", self.CANCEL_YPAD)
        tp.set_property("text", "")
        column = Gtk.TreeViewColumn("Progress", tp,
                                    value=PendingStore.COL_PROGRESS,
                                    pulse=PendingStore.COL_PULSE)
        column.set_min_width(200)
        self.tv.append_column(column)
        # cancel icon
        tpix = Gtk.CellRendererPixbuf()
        column = Gtk.TreeViewColumn("Cancel", tpix,
                                    stock_id=PendingStore.COL_CANCEL)
        self.tv.append_column(column)
        # fake columns that eats the extra space at the end
        tt = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Cancel", tt)
        self.tv.append_column(column)
        # add it
        store = PendingStore(icons)
        self.tv.set_model(store)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, icons):
        Gtk.ScrolledWindow.__init__(self)
        BasePane.__init__(self)
        self.state = DisplayState()
        self.pane_name = _("Progress")

        self.tv = Gtk.TreeView()
        # customization
        self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        self.add(self.tv)
        self.tv.set_headers_visible(False)
        self.tv.connect("button-press-event", self._on_button_pressed)
        # icon
        self.icons = icons
        tp = Gtk.CellRendererPixbuf()
        tp.set_property("xpad", self.CANCEL_XPAD)
        tp.set_property("ypad", self.CANCEL_YPAD)
        column = Gtk.TreeViewColumn("Icon", tp, pixbuf=PendingStore.COL_ICON)
        self.tv.append_column(column)
        # name
        tr = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Name", tr, markup=PendingStore.COL_STATUS)
        column.set_min_width(200)
        column.set_expand(True)
        self.tv.append_column(column)
        # progress
        tp = Gtk.CellRendererProgress()
        tp.set_property("xpad", self.CANCEL_XPAD)
        tp.set_property("ypad", self.CANCEL_YPAD)
        tp.set_property("text", "")
        column = Gtk.TreeViewColumn("Progress", tp,
                                    value=PendingStore.COL_PROGRESS,
                                    pulse=PendingStore.COL_PULSE)
        column.set_min_width(200)
        self.tv.append_column(column)
        # cancel icon
        tpix = Gtk.CellRendererPixbuf()
        column = Gtk.TreeViewColumn("Cancel", tpix,
                                    stock_id=PendingStore.COL_CANCEL)
        self.tv.append_column(column)
        # fake columns that eats the extra space at the end
        tt = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Cancel", tt)
        self.tv.append_column(column)
        # add it
        store = PendingStore(icons)
        self.tv.set_model(store)