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


Python Gtk.TreeModelSort方法代码示例

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


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

示例1: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeModelSort [as 别名]
def __init__(self, *args, **kwargs):
		super(CampaignSelectionDialog, self).__init__(*args, **kwargs)
		treeview = self.gobjects['treeview_campaigns']
		self.treeview_manager = managers.TreeViewManager(treeview, cb_delete=self._prompt_to_delete_row, cb_refresh=self.load_campaigns)
		self.treeview_manager.set_column_titles(
			tuple(column.title for column in self.view_columns),
			column_offset=4,
			renderers=tuple(column.cell_renderer() for column in self.view_columns)
		)
		treeview.set_tooltip_column(1)
		self.treeview_manager.set_column_color(background=2, foreground=3)
		self.popup_menu = self.treeview_manager.get_popup_menu()
		self._creation_assistant = None

		view_column_types = tuple(column.g_type for column in self.view_columns)
		self._tv_model = Gtk.ListStore(str, str, Gdk.RGBA, Gdk.RGBA, *view_column_types)

		# create and set the filter for expired campaigns
		self._tv_model_filter = self._tv_model.filter_new()
		self._tv_model_filter.set_visible_func(self._filter_campaigns)
		tree_model_sort = Gtk.TreeModelSort(model=self._tv_model_filter)
		for idx, column in enumerate(self.view_columns, 4):
			if column.sort_function is not None:
				tree_model_sort.set_sort_func(idx, column.sort_function, idx)
		# default sort is descending by campaign creation date
		tree_model_sort.set_sort_column_id(9, Gtk.SortType.DESCENDING)
		treeview.set_model(tree_model_sort)

		self.destroyed = False
		self.dialog.connect('destroy', self.signal_dialog_destroy)
		# setup menus for filtering campaigns and load campaigns
		self.get_popup_filter_menu()
		self.load_campaigns() 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:35,代码来源:campaign_selection.py

示例2: _reload_data_port_list_store

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeModelSort [as 别名]
def _reload_data_port_list_store(self):
        """Reloads the input data port list store from the data port models"""

        tmp = self._get_new_list_store()
        for data_port_m in self.data_port_model_list:
            data_port_id = data_port_m.data_port.data_port_id
            data_type = data_port_m.data_port.data_type
            # get name of type (e.g. ndarray)
            data_type_name = data_type.__name__
            # get module of type, e.g. numpy
            data_type_module = data_type.__module__
            # if the type is not a builtin type, also show the module
            if data_type_module not in ['__builtin__', 'builtins']:
                data_type_name = data_type_module + '.' + data_type_name
            if data_port_m.data_port.default_value is None:
                default_value = "None"
            else:
                default_value = data_port_m.data_port.default_value

            if not isinstance(self.model.state, LibraryState):
                tmp.append([data_port_m.data_port.name, data_type_name, str(default_value), data_port_id,
                            None, None, data_port_m])
            else:
                use_runtime_value, runtime_value = self.get_data_port_runtime_configuration(data_port_id)
                tmp.append([data_port_m.data_port.name,
                            data_type_name,
                            str(default_value),
                            data_port_id,
                            bool(use_runtime_value),
                            str(runtime_value),
                            data_port_m,
                            ])

        tms = Gtk.TreeModelSort(model=tmp)
        tms.set_sort_column_id(0, Gtk.SortType.ASCENDING)
        tms.set_sort_func(0, compare_variables)
        tms.sort_column_changed()
        tmp = tms
        self.list_store.clear()
        for elem in tmp:
            self.list_store.append(elem[:]) 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:43,代码来源:io_data_port_list.py

示例3: reload_scoped_variables_list_store

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeModelSort [as 别名]
def reload_scoped_variables_list_store(self):
        """Reloads the scoped variable list store from the data port models"""

        if isinstance(self.model, ContainerStateModel):
            tmp = self.get_new_list_store()
            for sv_model in self.model.scoped_variables:
                data_type = sv_model.scoped_variable.data_type
                # get name of type (e.g. ndarray)
                data_type_name = data_type.__name__
                # get module of type, e.g. numpy
                data_type_module = data_type.__module__
                # if the type is not a builtin type, also show the module
                if data_type_module not in ['__builtin__', 'builtins']:
                    data_type_name = data_type_module + '.' + data_type_name
                tmp.append([sv_model.scoped_variable.name, data_type_name,
                            str(sv_model.scoped_variable.default_value), sv_model.scoped_variable.data_port_id,
                                sv_model])
            tms = Gtk.TreeModelSort(model=tmp)
            tms.set_sort_column_id(0, Gtk.SortType.ASCENDING)
            tms.set_sort_func(0, compare_variables)
            tms.sort_column_changed()
            tmp = tms
            self.list_store.clear()
            for elem in tmp:
                self.list_store.append(elem[:])
        else:
            raise RuntimeError("The reload_scoped_variables_list_store function should be never called for "
                               "a non Container State Model") 
开发者ID:DLR-RM,项目名称:RAFCON,代码行数:30,代码来源:scoped_variable_list.py

示例4: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeModelSort [as 别名]
def __init__(self, icon):
        GObject.GObject.__init__(self)
        self.id2iter = {}

        pm = Gtk.ListStore(str, str, int, str)
        self.sort_model = Gtk.TreeModelSort(model=pm)
        self.set_model(self.sort_model)
        self.idSet = set()

        self.set_headers_visible(False)
        self.set_tooltip_column(3)
        self.set_search_column(1)
        self.sort_model.set_sort_column_id(1, Gtk.SortType.ASCENDING)
        self.sort_model.set_sort_func(1, self.compareFunction, 1)

        # First column
        crp = Gtk.CellRendererPixbuf()
        crp.props.pixbuf = icon
        self.rightcol = Gtk.TreeViewColumn("", crp)
        self.append_column(self.rightcol)

        # Second column
        crt = Gtk.CellRendererText()
        crt.props.ellipsize = Pango.EllipsizeMode.END
        self.leftcol = Gtk.TreeViewColumn("", crt, text=1)
        self.leftcol.set_expand(True)
        self.append_column(self.leftcol)

        # Mouse
        self.pressed = None
        self.stdcursor = Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR)
        self.linkcursor = Gdk.Cursor.new(Gdk.CursorType.HAND2)
        self.connect("button_press_event", self.button_press)
        self.connect("button_release_event", self.button_release)
        self.connect("motion_notify_event", self.motion_notify)
        self.connect("leave_notify_event", self.leave_notify)

        # Selection
        self.get_selection().connect("changed", self.selection_changed) 
开发者ID:pychess,项目名称:pychess,代码行数:41,代码来源:ChannelsPanel.py

示例5: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeModelSort [as 别名]
def __init__(self, application, config, wd_history):
		self.application = application
		self.config = config
		self.treeview = sftp_utilities.get_object('SFTPClient.notebook.page_stfp.' + self.treeview_name)
		self.notebook = sftp_utilities.get_object('SFTPClient.notebook')
		self.wd_history = collections.deque(wd_history, maxlen=3)
		self.cwd = None
		self.col_name = Gtk.CellRendererText()
		self.col_name.connect('edited', self.signal_text_edited)
		col_bytes = extras.CellRendererBytes()
		col_datetime = extras.CellRendererDatetime()
		col_img = Gtk.CellRendererPixbuf()

		col = Gtk.TreeViewColumn('Files')
		col.pack_start(col_img, False)
		col.pack_start(self.col_name, True)
		col.add_attribute(self.col_name, 'text', 0)
		col.add_attribute(col_img, 'pixbuf', 1)
		col.set_property('resizable', True)
		col.set_sort_column_id(0)

		self.treeview.append_column(col)
		gui_utilities.gtk_treeview_set_column_titles(
			self.treeview,
			('Permissions', 'Size', 'Date Modified'),
			column_offset=3,
			renderers=(_CellRendererPermissions(), col_bytes, col_datetime)
		)

		self.treeview.connect('button_press_event', self.signal_tv_button_press)
		self.treeview.connect('key-press-event', self.signal_tv_key_press)
		self.treeview.connect('row-expanded', self.signal_tv_expand_row)
		self.treeview.connect('row-collapsed', self.signal_tv_collapse_row)
		self._tv_model = Gtk.TreeStore(
			str,               # 0 base name
			GdkPixbuf.Pixbuf,  # 1 icon
			str,               # 2 full path
			int,               # 3 st_mode
			GTYPE_ULONG,       # 4 size in bytes
			object             # 5 modified timestamp
		)
		self._tv_model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
		self._tv_model_filter = self._tv_model.filter_new()
		self._tv_model_filter.set_visible_func(self._filter_entries)
		self.refilter = self._tv_model_filter.refilter
		self._tv_model_sort = Gtk.TreeModelSort(model=self._tv_model_filter)
		self._tv_model_sort.set_sort_func(
			_ModelNamedRow._fields.index('ts_modified'),
			gui_utilities.gtk_treesortable_sort_func,
			_ModelNamedRow._fields.index('ts_modified')
		)
		self.treeview.set_model(self._tv_model_sort)

		self._wdcb_model = Gtk.ListStore(str)  # working directory combobox
		self.wdcb_dropdown = sftp_utilities.get_object(self.working_directory_combobox_name)
		self.wdcb_dropdown.set_model(self._wdcb_model)
		self.wdcb_dropdown.set_entry_text_column(0)
		self.wdcb_dropdown.connect('changed', sftp_utilities.DelayedChangedSignal(self.signal_combo_changed))

		self.show_hidden = False
		self._get_popup_menu() 
开发者ID:rsmusllp,项目名称:king-phisher-plugins,代码行数:63,代码来源:directory.py

示例6: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import TreeModelSort [as 别名]
def __init__(self, parent, title='Silaty'):
		Gtk.Dialog.__init__(self, modal=True, transient_for=parent, title=_(title), flags=Gtk.DialogFlags.DESTROY_WITH_PARENT)
		self.parent = parent
		self.set_border_width(10)
		self.set_resizable(False)
		self.connect('delete-event', self.hide_dialog)
		self.connect('response', self.hide_dialog)
		self.locations = []
		self.locations_count = 0
		# Location
		content_area = self.get_content_area()
		content_area.set_spacing(5)
		scrolledwindow = Gtk.ScrolledWindow()
		scrolledwindow.set_size_request(150, 250)
		content_area.add(scrolledwindow)
		self.treestore = Gtk.TreeStore(str, int)
		self.parse_locations()
		treemodelsort = Gtk.TreeModelSort(self.treestore)
		treemodelsort.set_sort_column_id(0, Gtk.SortType.ASCENDING)
		self.treeview = Gtk.TreeView()
		self.treeview.set_model(treemodelsort)
		scrolledwindow.add(self.treeview)
		cellrenderertext = Gtk.CellRendererText()
		treeviewcolumn = Gtk.TreeViewColumn(_('Location'), cellrenderertext, text=0)
		self.treeview.append_column(treeviewcolumn)
		#self.treeview.set_headers_visible(False)
		treeselection = self.treeview.get_selection()
		treeselection.set_mode(Gtk.SelectionMode.SINGLE)
		treeselection.connect('changed', self.on_selection_changed)
		# Search
		searchbox   = Gtk.Box(halign=Gtk.Align.FILL, spacing=10)
		searchlabel = Gtk.Label(_('Search:'), halign=Gtk.Align.START)
		searchbox.pack_start(searchlabel, False, False, 0)
		searchentry = Gtk.Entry(halign=Gtk.Align.FILL)
		searchentry.connect('changed', self.on_search_entry_changed)
		self.treeview.set_search_entry(searchentry)
		self.treeview.set_search_equal_func(self.search_function)
		self.treeview.set_search_column(0)
		searchbox.pack_start(searchentry, True, True, 0)
		content_area.add(searchbox)
		# Help
		helpbox   = Gtk.Box(halign=Gtk.Align.FILL, spacing=3, margin=10)
		helpimage = Gtk.Image(icon_name='system-help')
		helpbox.pack_start(helpimage, False, False, 0)
		helplabel = Gtk.Label(_('Check your location on %s') % '<a href="https://www.islamicfinder.org/">www.islamicfinder.org</a>', use_markup=True)
		helpbox.pack_start(helplabel, True, True, 0)
		content_area.add(helpbox)
		# Buttons
		self.action_area.set_layout(Gtk.ButtonBoxStyle.END)
		self.apply_button = Gtk.Button(_('Apply'))
		self.apply_button.set_sensitive(False)
		self.apply_button.connect('clicked', self.on_apply_button_clicked)
		cancel_button = Gtk.Button(_('Cancel'))
		cancel_button.connect('clicked', self.on_cancel_button_clicked)
		self.add_action_widget(self.apply_button, Gtk.ResponseType.OK)
		self.add_action_widget(cancel_button, Gtk.ResponseType.CANCEL)
		self.show_all() 
开发者ID:Jessewb786,项目名称:Silaty,代码行数:59,代码来源:location.py


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