Python gi.repository.Gtk.TreeStore() Examples

The following are 30 code examples of gi.repository.Gtk.TreeStore(). 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 gi.repository.Gtk , or try the search function .
Example #1
Source File: state_machine_tree.py    From RAFCON with Eclipse Public License 1.0 6 votes vote down vote up
def __init__(self, model, view):
        assert isinstance(model, StateMachineManagerModel)
        tree_store = Gtk.TreeStore(GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_PYOBJECT, GObject.TYPE_STRING)
        super(StateMachineTreeController, self).__init__(model, view, view, tree_store)

        self.add_controller("state_right_click_ctrl", StateMachineTreeRightClickMenuController(model, view))

        self.view_is_registered = False

        # view.set_hover_expand(True)
        self.state_row_iter_dict_by_state_path = {}
        self.__my_selected_sm_id = None
        self._selected_sm_model = None

        self.__expansion_state = {}

        self._ongoing_complex_actions = []

        self._state_which_is_updated = None

        self.register() 
Example #2
Source File: product.py    From amir with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self):
        productgroup.ProductGroup.__init__(self)

        self.qntyEntry = decimalentry.DecimalEntry()
        self.builder.get_object("qntyBox").add(self.qntyEntry)
        self.qntyEntry.show()

        self.qntyWrnEntry = decimalentry.DecimalEntry()
        self.builder.get_object("qntyWrnBox").add(self.qntyWrnEntry)
        self.qntyWrnEntry.show()

        self.purchPriceEntry = decimalentry.DecimalEntry()
        self.builder.get_object("purchPriceBox").add(self.purchPriceEntry)
        self.purchPriceEntry.show()

        self.sellPriceEntry = decimalentry.DecimalEntry()
        self.builder.get_object("sellPriceBox").add(self.sellPriceEntry)
        self.sellPriceEntry.show()

        self.treeview = self.builder.get_object("productsTreeView")
        self.treestore = Gtk.TreeStore(str, str, str, str, str, str, int) 
Example #3
Source File: modules.py    From gpt with GNU General Public License v3.0 6 votes vote down vote up
def get_tree_data(self, directory, parent=None):
        """Creates TreeStore table"""
        for dirs in sorted(os.listdir(directory)):
            path = os.path.join(directory, dirs)
            if os.path.isdir(path):
                os.chdir(dirs)
                # count media
                vidcount = len(glob.glob("*.MP4"))
                imgcount = len(glob.glob("*.JPG"))
                # size of directory, subdiretories exclued
                size = sum([os.path.getsize(f) for f in os.listdir(".") if os.path.isfile(f)])
                humansize = self.sizeof_fmt(size)
                try:
                    # 4th/5th position in file name of last element in sorted list of sequences
                    # (e.g. Seq_03_010.JPG)
                    seq = int(sorted(glob.glob("Seq_*_*.*"))[-1][4:6])
                except:
                    seq = 0
                # transmit row to treestore
                row = self.obj("treestore1").append(parent,
                                                    [dirs, vidcount, imgcount, humansize, path, seq, False, size]
                                                    )
                # read subdirs as child rows
                self.get_tree_data(path, row)
                os.chdir("..") 
Example #4
Source File: execution_history.py    From RAFCON with Eclipse Public License 1.0 6 votes vote down vote up
def __init__(self, model=None, view=None):
        assert isinstance(model, StateMachineManagerModel)
        assert isinstance(view, ExecutionHistoryView)

        super(ExecutionHistoryTreeController, self).__init__(model, view)
        self.history_tree_store = Gtk.TreeStore(GObject.TYPE_STRING, GObject.TYPE_PYOBJECT, GObject.TYPE_STRING)
        # a TreeView
        self.history_tree = view['history_tree']
        self.history_tree.set_model(self.history_tree_store)
        view['history_tree'].set_tooltip_column(self.TOOL_TIP_STORAGE_ID)

        self.observe_model(state_machine_execution_model)
        self._expansion_state = {}
        self._update_lock = RLock()

        self.update() 
Example #5
Source File: semantic_data_editor.py    From RAFCON with Eclipse Public License 1.0 6 votes vote down vote up
def __init__(self, model, view):
        """Constructor
        """
        assert isinstance(model, AbstractStateModel)
        assert isinstance(view, SemanticDataEditorView)

        if isinstance(model.state, LibraryState):
            model_to_observe = model.state_copy
        else:
            model_to_observe = model

        # define tree store with the values in [key, value Is Dict]
        tree_store = Gtk.TreeStore(GObject.TYPE_STRING, GObject.TYPE_STRING, bool, GObject.TYPE_PYOBJECT)

        # unfortunately this cannot be down with super, as gtkmvc3 does not use super() consistently
        TreeViewController.__init__(self, model_to_observe, view,
                                    view["semantic_data_tree_view"], tree_store, logger)
        AbstractExternalEditor.__init__(self)

        self.semantic_data_counter = 0 
Example #6
Source File: cheatsheet_dialog.py    From bokken with GNU General Public License v2.0 6 votes vote down vote up
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 
Example #7
Source File: main_ui.py    From innstereo with GNU General Public License v2.0 6 votes vote down vote up
def parse_eigenvectors(self, treestore, subset=None):
        """
        Parses a eigenvector layer and returns a list of each column

        This method expect a TreeStore that stores the data of a layer. It
        iterates over the rows and adds each column to a list. It returns 3
        lists for line_dir, line_dip (the eigenvector) and values (the
        eigenvalue)
        """
        line_dir = []
        line_dip = []
        values = []
        for key, row in enumerate(treestore):
            if subset is not None and key not in subset:
                continue
            line_dir.append(float(row[0]))
            line_dip.append(float(row[1]))
            values.append(float(row[2]))
        return line_dir, line_dip, values 
Example #8
Source File: main_ui.py    From innstereo with GNU General Public License v2.0 6 votes vote down vote up
def on_toolbutton_cut_clicked(self, toolbutton):
        """
        Cuts the selected layer.

        The data is copied into the Gdk.Clipboard and then removed from the
        TreeStore.
        """
        selection = self.layer_view.get_selection()
        model, row_list = selection.get_selected_rows()

        if len(row_list) == 0:
            return

        data = self.copy_layer()
        self.clipboard.set_text(data, -1)

        self.delete_layer(model, row_list) 
Example #9
Source File: gui_utilities.py    From king-phisher with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def glib_idle_add_store_extend(store, things, clear=False, wait=False):
	"""
	Extend a GTK store object (either :py:class:`Gtk.ListStore` or
	:py:class:`Gtk.TreeStore`) object using :py:func:`GLib.idle_add`. This
	function is suitable for use in non-main GUI threads for synchronizing data.

	:param store: The GTK storage object to add *things* to.
	:type store: :py:class:`Gtk.ListStore`, :py:class:`Gtk.TreeStore`
	:param tuple things: The array of things to add to *store*.
	:param bool clear: Whether or not to clear the storage object before adding *things* to it.
	:param bool wait: Whether or not to wait for the operation to complete before returning.
	:return: Regardless of the *wait* parameter, ``None`` is returned.
	:rtype: None
	"""
	if not isinstance(store, Gtk.ListStore):
		raise TypeError('store must be a Gtk.ListStore instance')
	idle_add = glib_idle_add_wait if wait else glib_idle_add_once
	idle_add(_store_extend, store, things, clear) 
Example #10
Source File: widgets.py    From zim-desktop-wiki with GNU General Public License v2.0 5 votes vote down vote up
def do_initialize_popup(self, menu):
		'''Initialize the context menu.
		This method is called before the C{populate-popup} signal and
		can be used to put any standard items in the menu.
		@param menu: the C{Gtk.Menu} object for the popup
		@implementation: can be implemented by sub-classes. Default
		implementation calls L{populate_popup_expand_collapse()}
		if the model is a C{Gtk.TreeStore}. Otherwise it does nothing.
		'''
		model = self.get_model()
		if isinstance(model, Gtk.TreeStore):
			self.populate_popup_expand_collapse(menu) 
Example #11
Source File: templateeditordialog.py    From zim-desktop-wiki with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
		BrowserTreeView.__init__(self)
		model = Gtk.TreeStore(str, object, object)
			# BASENAME_COL, FILE_COL, DEFAULT_COL
		self.set_model(model)
		self.set_headers_visible(False)

		cell_renderer = Gtk.CellRendererText()
		column = Gtk.TreeViewColumn('_template_', cell_renderer, text=self.BASENAME_COL)
		self.append_column(column)

		self.refresh() 
Example #12
Source File: treeviews.py    From bokken with GNU General Public License v2.0 5 votes vote down vote up
def create_tree(self, imps):
        # Create the column
        imports = Gtk.TreeViewColumn()
        imports.set_title("Imports")
        imports.set_spacing(5)

        self.treestore = Gtk.TreeStore(GdkPixbuf.Pixbuf, str)

        self.imp_pix = GdkPixbuf.Pixbuf.new_from_file(datafile_path('import.png'))
        rendererPix = Gtk.CellRendererPixbuf()
        rendererText = Gtk.CellRendererText()
        imports.pack_start(rendererPix, False)
        imports.pack_start(rendererText, True)
        imports.set_attributes(rendererText, text=1)
        imports.set_attributes(rendererPix, pixbuf=0)

        # Iterate imports and add to the tree
        for element in imps.keys():
            it = self.treestore.append(None, [self.fcn_pix, element])
            for imp in imps[element]:
                self.treestore.append(it, [self.imp_pix, imp[0] + '\t' + imp[1]])

        # Add column to tree
        self.append_column(imports)
        self.set_model(self.treestore)
        self.expand_all() 
Example #13
Source File: preset_list.py    From oomox with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, preset_select_callback):
        super().__init__()
        self.set_size_request(width=UI_SETTINGS.preset_list_minimal_width, height=-1)

        self.preset_select_callback = preset_select_callback

        self.treestore = Gtk.TreeStore(str, str, str, bool)
        self.treeview = Gtk.TreeView(
            model=self.treestore, headers_visible=False
        )
        self.treeview.connect(
            "key-press-event", self._on_keypress
        )
        self.treeview.connect(
            "row-collapsed", self._on_row_collapsed
        )
        self.treeview.connect(
            "row-expanded", self._on_row_expanded
        )
        column = Gtk.TreeViewColumn(
            cell_renderer=Gtk.CellRendererText(), markup=self.DISPLAY_NAME
        )
        self.treeview.append_column(column)
        self.load_presets()

        self.add(self.treeview)

        GLib.idle_add(
            self.focus_first_available,
            priority=GLib.PRIORITY_HIGH
        )

    ###########################################################################
    # Public interface:
    ########################################################################### 
Example #14
Source File: tableofcontents.py    From zim-desktop-wiki with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
		Gtk.TreeStore.__init__(self, str) # TEXT_COL
		self.is_empty = True
		self.hidden_h1 = False 
Example #15
Source File: graph.py    From bokken with GNU General Public License v2.0 5 votes vote down vote up
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() 
Example #16
Source File: tableofcontents.py    From zim-desktop-wiki with GNU General Public License v2.0 5 votes vote down vote up
def clear(self):
		self.is_empty = True
		Gtk.TreeStore.clear(self) 
Example #17
Source File: configwindow.py    From autokey with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, folders):
        Gtk.TreeStore.__init__(self, str, str, str, str, object)

        for folder in folders:
            iterator = self.append(None, folder.get_tuple())
            self.populate_store(iterator, folder)

        self.folders = folders
        self.set_sort_func(1, self.compare)
        self.set_sort_column_id(1, Gtk.SortType.ASCENDING) 
Example #18
Source File: warehousing.py    From amir with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        """
        This class is created in order to have all the forms and view of
        products and groups together.
        Groups are viewed through the "viewGroup" method and added by "addNewGroup"
        method.
        Products are viewed by the "ViewProducts" method and added by "addNewProduct"
        method.
        """
        GObject.GObject.__init__(self)
        self.builder = get_builder("warehousing")
        self.session = config.db.session

        self.proListStore = Gtk.TreeStore(str, str, str, str, str)
        self.grpListStore = Gtk.TreeStore(str, str, str, str)
#        self.grpListStore   = Gtk.ListStore(str, str, str, str)

        self.groupsList = []
        self.productsList = []

        self.grpIterDict = {}
        self.proGrpDict = {}
        self.proProDict = {}

        self.builder.connect_signals(self)

    # --------------------------------------------------------------------
    #    viewProducts():
    # -------------------------------------------------------------------- 
Example #19
Source File: cardexreport.py    From amir with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        self.builder = get_builder("cardex")
        self.window = self.builder.get_object("window1")

        self.treeview = self.builder.get_object("factorTreeView")
        self.treestore = Gtk.TreeStore(
            str, str, str, str, str, str, str, str, str)
        self.treeview.set_model(self.treestore)

        headers = (_("Date"), _("Type"), _("Quantity"), _("Unit Price"), _("Total Price"), _(
            "Remained"), _("Factor Code"), _("Customer Name"), _("Customer Code"))
        #headers = (_("Factor Code") ,_("Customer Code"), _("Customer Name"),_("Stock inventory"),_("Sell Quantity"),_("Buy Quantity") , _("Total Price"),_("Date") )
        i = 0
        for header in headers:
            column = Gtk.TreeViewColumn(header, Gtk.CellRendererText(), text=i)
            column.set_spacing(5)
            column.set_resizable(True)
            column.set_sort_column_id(i)
            column.set_sort_indicator(True)
            self.treeview.append_column(column)
            i += 1
        self.rows = []
        self.window.show_all()
        self.builder.connect_signals(self)
        self.session = share.config.db.session

        self.dateToEntry = self.builder.get_object("dateToEntry")
        self.dateFromEntry = self.builder.get_object("dateFromEntry")
        if share.config.datetypes[share.config.datetype] == "jalali":
            (year, month, day) = ("1397", "12", "20")
        else:
            (year, month, day) = ("2018", "12", "20")
        datelist = ["", "", ""]
        datelist[share.config.datefields["year"]] = year
        datelist[share.config.datefields["month"]] = month
        datelist[share.config.datefields["day"]] = day
        delimiter = share.config.datedelims[share.config.datedelim]
        placeH = datelist[0]+delimiter+datelist[1]+delimiter+datelist[2]
        self.dateToEntry.set_placeholder_text(placeH)
        self.dateFromEntry.set_placeholder_text(placeH)
        self.builder.get_object("typeComboBox").set_active(2) 
Example #20
Source File: user.py    From amir with GNU General Public License v3.0 5 votes vote down vote up
def selectGroup(self, sender=0, edit=None):
        self.session = share.config.db.session
        # self.Document = class_document.Document()

        query = self.session.query(Factors.Id).select_from(Factors)
        lastId = query.order_by(Factors.Id.desc()).first()
        if not lastId:
            lastId = 0
        else:
            lastId = lastId.Id
        self.Id = lastId + 1
        self.window1 = self.builder.get_object("viewPermissions")
        self.builder.connect_signals(self)
        self.groupTreeview = self.builder.get_object("groupsTreeView")
        self.groupTreestore = Gtk.TreeStore(int, str)
        column = Gtk.TreeViewColumn(_("ID"), Gtk.CellRendererText(), text=0)
        column.set_spacing(5)
        column.set_resizable(True)
        self.groupTreeview.append_column(column)
        column = Gtk.TreeViewColumn(_("Name"), Gtk.CellRendererText(), text=1)
        column.set_spacing(5)
        column.set_resizable(True)
        self.groupTreeview.append_column(column)

        result = share.config.db.session.query(
            Permissions.id, Permissions.name).all()
        for a in result:
            iter = self.groupTreestore.append(None, (int(a.id), str(a.name)))
        self.groupTreeview.set_model(self.groupTreestore)
        self.groupTreestore.set_sort_column_id(0, Gtk.SortType.ASCENDING)
        self.builder.connect_signals(self)

        self.window1.show_all()
        if checkPermission(2):
            self.builder.get_object("addPermissionButton").hide()
        if checkPermission(8):
            self.builder.get_object("editPermissionButton").hide()
        if checkPermission(16):
            self.builder.get_object("deletePermissionButton").hide() 
Example #21
Source File: sourceview.py    From zim-desktop-wiki with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, parent):
		Dialog.__init__(self, parent, _('Insert Code Block')) # T: dialog title
		self.result = (None, None)
		self.uistate.define(lang=String(None))
		self.uistate.define(line_numbers=Boolean(True))
		defaultlang = self.uistate['lang']

		menu = {}
		for l in sorted(LANGUAGES, key=lambda k: k.lower()):
			key = l[0].upper()
			if not key in menu:
				menu[key] = []
			menu[key].append(l)

		model = Gtk.TreeStore(str)
		defaultiter = None
		for key in sorted(menu):
			iter = model.append(None, [key])
			for lang in menu[key]:
				myiter = model.append(iter, [lang])
				if LANGUAGES[lang] == defaultlang:
					defaultiter = myiter

		hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
		hbox.set_spacing(5)
		label = Gtk.Label(_('Syntax') +':') # T: input label
		hbox.add(label)

		combobox = Gtk.ComboBox.new_with_model(model)
		renderer_text = Gtk.CellRendererText()
		combobox.pack_start(renderer_text, True)
		combobox.add_attribute(renderer_text, "text", 0)
		if defaultiter is not None:
			combobox.set_active_iter(defaultiter)
		hbox.add(combobox)
		self.combobox = combobox
		self.vbox.add(hbox)
		self.checkbox = Gtk.CheckButton(_('Display line numbers')) # T: input checkbox
		self.checkbox.set_active(self.uistate['line_numbers'])
		self.vbox.add(self.checkbox) 
Example #22
Source File: selectform.py    From addons-source with GNU General Public License v2.0 5 votes vote down vote up
def _create_dialog(self):
        """
        Create a dialog box to select a form.
        """
        # pylint: disable-msg=E1101
        title = _("%(title)s - Gramps") % {'title': _("Select Form")}
        top = Gtk.Dialog(title)
        top.set_default_size(400, 350)
        top.set_modal(True)
        top.set_transient_for(self.uistate.window)
        top.vbox.set_spacing(5)
        label = Gtk.Label(label='<span size="larger" weight="bold">%s</span>'
                          % _("Select Form"))
        label.set_use_markup(True)
        top.vbox.pack_start(label, 0, 0, 5)
        box = Gtk.Box()
        top.vbox.pack_start(box, 1, 1, 5)

        self.model = Gtk.TreeStore(str, str)

        self.tree = Gtk.TreeView(model=self.model)
        self.tree.connect('button-press-event', self.__button_press)
        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Source", renderer, text=1)
        column.set_sort_column_id(1)
        self.tree.append_column(column)

        slist = Gtk.ScrolledWindow()
        slist.add(self.tree)
        slist.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        box.pack_start(slist, 1, 1, 5)
        top.add_button(_('_Cancel'), Gtk.ResponseType.CANCEL)
        top.add_button(_('_OK'), Gtk.ResponseType.OK)
        top.show_all()
        return top 
Example #23
Source File: PlaceCompletion.py    From addons-source with GNU General Public License v2.0 5 votes vote down vote up
def make_new_model(self):
        # model contains 4 colums: text to show, place handle, action, color
        self.model = Gtk.TreeStore(str, object, object, str)
        self.tree.set_model(self.model)
        self.populate_tree()
        self.tree.expand_all() 
Example #24
Source File: main_ui.py    From innstereo with GNU General Public License v2.0 5 votes vote down vote up
def create_layer(self, lyr_type):
        """
        Creates a layer according to the passed layer type.

        Depending on the layer-type a different TreeStore, TreeView and layer
        object is created. For folders all of them are None. Returns the new
        layer object, a TreeStore and a TreeView.
        """
        if lyr_type == "plane":
            store = Gtk.ListStore(float, float, str)
            view = PlaneDataView(store, self.redraw_plot, self.add_feature,
                                 self.settings)
            lyr_obj_new = PlaneLayer(store, view)
        elif lyr_type == "faultplane":
            store = Gtk.ListStore(float, float, float, float, str)
            view = FaultPlaneDataView(store, self.redraw_plot, self.add_feature,
                                      self.settings)
            lyr_obj_new = FaultPlaneLayer(store, view)
        elif lyr_type == "line":
            store = Gtk.ListStore(float, float, str)
            view = LineDataView(store, self.redraw_plot, self.add_feature,
                                self.settings)
            lyr_obj_new = LineLayer(store, view)
        elif lyr_type == "smallcircle":
            store = Gtk.ListStore(float, float, float)
            view = SmallCircleDataView(store, self.redraw_plot, self.add_feature,
                                       self.settings)
            lyr_obj_new = SmallCircleLayer(store, view)
        elif lyr_type == "eigenvector":
            store = Gtk.ListStore(float, float, float)
            view = EigenVectorView(store, self.redraw_plot, self.add_feature,
                                   self.settings)
            lyr_obj_new = EigenVectorLayer(store, view)
        elif lyr_type == "folder":
            store = None
            view = None
            lyr_obj_new = None

        return lyr_obj_new, store, view 
Example #25
Source File: modification_history.py    From RAFCON with Eclipse Public License 1.0 5 votes vote down vote up
def __init__(self, model, view):
        """Constructor
        :param model StateMachineModel should be exchangeable
        """
        assert isinstance(model, StateMachineManagerModel)

        ExtendedController.__init__(self, model, view)
        self.view_is_registered = False

        self._mode = 'branch'
        self.with_tree = True
        self.tree_folded = False

        assert self._mode in ['trail', 'branch']
        self.history_tree_store = Gtk.TreeStore(GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_PYOBJECT, GObject.TYPE_STRING, GObject.TYPE_STRING)
        if view is not None:
            view['history_tree'].set_model(self.history_tree_store)
        view['history_tree'].set_tooltip_column(8)

        # view.set_hover_expand(True)

        self.__my_selected_sm_id = None
        self._selected_sm_model = None

        self.doing_update = False
        self.no_cursor_observation = False
        self.next_activity_focus_self = True
        self.on_toggle_mode_check_gaphas_view_is_meta_data_consistent = True

        self.register() 
Example #26
Source File: tree_view_controller.py    From RAFCON with Eclipse Public License 1.0 5 votes vote down vote up
def __init__(self, model, view, tree_view, tree_store, logger=None):
        assert isinstance(tree_store, Gtk.TreeStore)
        super(TreeViewController, self).__init__(model, view, tree_view, tree_store, logger)
        self.tree_store = tree_store
        self._changed_id_to = {} 
Example #27
Source File: library_tree.py    From RAFCON with Eclipse Public License 1.0 5 votes vote down vote up
def __init__(self, model, view):
        assert isinstance(model, LibraryManagerModel)
        assert isinstance(view, Gtk.TreeView)
        ExtendedController.__init__(self, model, view)
        self.tree_store = Gtk.TreeStore(GObject.TYPE_STRING, GObject.TYPE_PYOBJECT, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING)
        view.set_model(self.tree_store)
        view.set_tooltip_column(3)

        # Gtk TODO: solve via Gtk.TargetList? https://python-gtk-3-tutorial.readthedocs.io/en/latest/drag_and_drop.html
        view.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, [Gtk.TargetEntry.new('STRING', 0, 0)], Gdk.DragAction.COPY)

        self.library_row_iter_dict_by_library_path = {}
        self.__expansion_state = None

        self.update() 
Example #28
Source File: categories.py    From rednotebook with GNU General Public License v2.0 4 votes vote down vote up
def __init__(self, tree_view, main_window):
        self.tree_view = tree_view

        self.main_window = main_window

        # Maintain a list of all entered categories. Initialized by rn.__init__()
        self.categories = []
        self.last_category = ""

        self.statusbar = self.main_window.statusbar

        # create a TreeStore with one string column to use as the model
        self.tree_store = Gtk.TreeStore(str)

        # create the TreeView using tree_store
        self.tree_view.set_model(self.tree_store)

        # create the TreeViewColumn to display the data
        self.tvcolumn = Gtk.TreeViewColumn()
        label = Gtk.Label()
        label.set_markup("<b>" + _("Tags") + "</b>")
        label.show()
        self.tvcolumn.set_widget(label)

        # add tvcolumn to tree_view
        self.tree_view.append_column(self.tvcolumn)

        # create a CellRendererText to render the data
        self.cell = Gtk.CellRendererText()

        self.cell.set_property("editable", True)
        self.cell.connect("edited", self.edited_cb, self.tree_store)
        self.cell.connect("editing-started", self.on_editing_started)

        # add the cell to the tvcolumn and allow it to expand
        self.tvcolumn.pack_start(self.cell, True)

        """ set the cell "text" attribute to column 0 - retrieve text
            from that column in tree_store"""
        self.tvcolumn.add_attribute(self.cell, "markup", 0)

        # make it searchable
        self.tree_view.set_search_column(0)

        # Allow sorting on the column
        self.tvcolumn.set_sort_column_id(0)

        # Enable a context menu
        self.context_menu = self._get_context_menu()
        self.context_menu.attach_to_widget(self.tree_view, lambda x, y: None)

        self.tree_view.connect("button-press-event", self.on_button_press_event)
        self.tree_view.connect("key-press-event", self.on_key_press_event)

        # Wrap lines
        self.cell.props.wrap_mode = Pango.WrapMode.WORD
        self.cell.props.wrap_width = 200
        self.tree_view.connect_after(
            "size-allocate", self.on_size_allocate, self.tvcolumn, self.cell
        ) 
Example #29
Source File: productgroup.py    From amir with GNU General Public License v3.0 4 votes vote down vote up
def viewProductGroups(self):
        self.window = self.builder.get_object("viewProGroupsWindow")

        self.treeview = self.builder.get_object("GroupsTreeView")
        self.treestore = Gtk.TreeStore(str, str, str, str)
        self.treestore.clear()
        self.treeview.set_model(self.treestore)

        column = Gtk.TreeViewColumn(_("Code"), Gtk.CellRendererText(), text=0)
        column.set_spacing(5)
        column.set_resizable(True)
        column.set_sort_column_id(0)
        column.set_sort_indicator(True)
        self.treeview.append_column(column)

        column = Gtk.TreeViewColumn(_("Name"), Gtk.CellRendererText(), text=1)
        column.set_spacing(5)
        column.set_resizable(True)
        column.set_sort_column_id(1)
        column.set_sort_indicator(True)
        self.treeview.append_column(column)

        column = Gtk.TreeViewColumn(
            _("Buy ID"), Gtk.CellRendererText(), text=2)
        column.set_spacing(5)
        column.set_resizable(True)
        self.treeview.append_column(column)

        column = Gtk.TreeViewColumn(
            _("Sell ID"), Gtk.CellRendererText(), text=3)
        column.set_spacing(5)
        column.set_resizable(True)
        self.treeview.append_column(column)

        self.treeview.get_selection().set_mode(Gtk.SelectionMode.SINGLE)
        self.treestore.set_sort_column_id(0, Gtk.SortType.ASCENDING)

        # Fill groups treeview
        query = share.config.db.session.query(
            ProductGroups).select_from(ProductGroups)
        result = query.all()

        for group in result:
            code = group.code
            buyId = group.buyId
            sellId = group.sellId
            if share.config.digittype == 1:
                #code = utility.convertToPersian(code)
                buyId = utility.convertToPersian(buyId)
                sellId = utility.convertToPersian(sellId)
            self.treestore.append(None, (utility.readNumber(code), str(group.name),
                utility.readNumber(buyId), utility.readNumber(sellId)))

        self.window.show_all()
        self.window.grab_focus() 
Example #30
Source File: main_ui.py    From innstereo with GNU General Public License v2.0 4 votes vote down vote up
def copy_layer(self):
        """
        Copies the contents of a layer and all its children.

        This method is called by the drag-and-drop and copy-paste functions.
        It returns the data as JSON.
        """
        tree_selection = self.layer_view.get_selection()
        store, itr = tree_selection.get_selected_rows()
        model = self.layer_view.get_model()
        path = itr[0]
        path_str = str(path)
        itr = store.get_iter(path)

        copy = {}
        copy["filetype"] = "InnStereo layer 1.0"
        copy["layers"] = []

        def append_layer(lyr_obj, path_str, label):
            """
            Appends a layer to the serialization dictionary.

            Receives a store, iter and path_str. Appends the path, properties
            and data to the 'layers' list of the dictionary. For folders it
            appends the path, the folder-properties and an empty list (So that
            the destination can use iterators also for folders).
            """
            #The layer includes the layer and children as
            #[[path, properties, data],...]
            if lyr_obj is None:
                #No lyr_obj means that this is a folder
                folder_props = {"type": "folder", "label": label}
                folder_props = OrderedDict(sorted(folder_props.items()))
                copy["layers"].append([path_str, folder_props, []])
            else:
                properties = lyr_obj.get_properties()
                data = lyr_obj.return_data()
                copy["layers"].append([path_str, properties, data])

        def iterate_over_store(model, path, itr, start_path):
            """
            Iterates over the whole TreeStore and appends all draged layers.

            The function iterates over the whole TreeStore, but uses the
            path to identify the dragged layer and its children. Calls the
            append function on each these layers.
            """
            path_str = str(path)
            lyr_obj = store[itr][3]
            label = store[itr][2]
            if path_str.startswith(start_path) == True:
                append_layer(lyr_obj, path_str, label)

        self.layer_store.foreach(iterate_over_store, path_str)
        copy = OrderedDict(sorted(copy.items()))
        data = json.dumps(copy)
        return data