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


Python Gtk.ComboBoxText方法代码示例

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


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

示例1: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ComboBoxText [as 别名]
def __init__(self, tviews, uicore):
        super(RightCombo,self).__init__(1, 7, False)

        self.tviews = tviews
        self.uicore = uicore

        # Theme Label
        self.theme_label = Gtk.Label(label='Color theme:')
        self.attach(self.theme_label, 0, 1, 0, 1)

        # Theme ComboBox
        self.theme_combo = Gtk.ComboBoxText()
        options = ['Classic', 'Cobalt', 'kate', 'Oblivion', 'Tango']
        for option in options:
            self.theme_combo.append_text(option)
        # Set first by default
        self.theme_combo.set_active(0)

        self.theme_combo.connect("changed", self.theme_combo_change)
        self.attach(self.theme_combo, 1, 2, 0, 1) 
开发者ID:inguma,项目名称:bokken,代码行数:22,代码来源:rightcombo.py

示例2: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ComboBoxText [as 别名]
def __init__(self, parent):
		Dialog.__init__(self, parent, _("Enable Version Control?")) # T: Question dialog
		self.add_text(
			_("Version control is currently not enabled for this notebook.\n"
			  "Do you want to enable it?") # T: Detailed question
		)

		self.combobox = Gtk.ComboBoxText()
		for option in (VCS.BZR, VCS.GIT, VCS.HG, VCS.FOSSIL):
			if VCS.check_dependencies(option):
				self.combobox.append_text(option)
		self.combobox.set_active(0)

		hbox = Gtk.Box(spacing=5)
		hbox.add(Gtk.Label(_('Backend') + ':'))
		hbox.add(self.combobox)
			# T: option to chose versioncontrol backend
		hbox.set_halign(Gtk.Align.CENTER)
		self.vbox.pack_start(hbox, False, False, 0)
		hbox.show_all() 
开发者ID:zim-desktop-wiki,项目名称:zim-desktop-wiki,代码行数:22,代码来源:__init__.py

示例3: get_widget

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ComboBoxText [as 别名]
def get_widget(self, _, value):
		widget = Gtk.ComboBoxText()
		widget.set_hexpand(True)
		for choice in self.choices:
			widget.append_text(choice)
		self.set_widget_value(widget, value)
		return widget 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:9,代码来源:plugins.py

示例4: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ComboBoxText [as 别名]
def __init__(self, option, dbstate, uistate, track, override=False):
        Gtk.HBox.__init__(self)
        self.__option = option
        value_str = self.__option.get_value()
        (incl, attr, attr_value) = value_str.split(', ',2)
        incl = int(incl.replace('L', ''))
        self.cbe_w = Gtk.ComboBoxText.new_with_entry()
        image_attributes = dbstate.db.get_media_attribute_types()
        image_attributes.insert(0,' ')
        for attrib in image_attributes:
            self.cbe_w.append_text(attrib)
        try:
            idx = image_attributes.index(attr)
            self.cbe_w.set_active(idx)
        except ValueError:
            pass
        self.cbe_w.connect('changed',self.__value_changed)
        self.l1_w = Gtk.Label(label=_("equal to"))
        self.e_w = Gtk.Entry()
        self.e_w.set_text(attr_value)
        self.e_w.connect('changed',self.__value_changed)
        self.l2_w = Gtk.Label(label=_("should be"))
        self.cb2_w = Gtk.ComboBoxText()
        self.cb2_w.append_text('Included')
        self.cb2_w.append_text('Excluded')
        self.cb2_w.set_active(incl)
        self.cb2_w.connect('changed',self.__value_changed)
        self.pack_start(self.cbe_w, False, True, 0)
        self.pack_start(self.l1_w, False, True, 5)
        self.pack_start(self.e_w, False, True, 0)
        self.pack_start(self.l2_w, False, True, 5)
        self.pack_start(self.cb2_w, False, True, 0) 
开发者ID:gramps-project,项目名称:addons-source,代码行数:34,代码来源:DenominoViso.py

示例5: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ComboBoxText [as 别名]
def __init__(self):
        Gtk.Notebook.__init__(self, vexpand=True, vexpand_set=True, valign=1, expand=True)

        ###############
        ### Project ###
        ###############
        self.project_contents = Gtk.VBox(vexpand=True, valign=0, vexpand_set=True, expand=True)
        sw1 = Gtk.ScrolledWindow(vexpand=True, valign=0, vexpand_set=True, expand=True)
        sw1.add_with_viewport(self.project_contents)
        self.project_page_num = self.append_page(sw1, Gtk.Label("Project"))

        ################
        ### Selected ###
        ################
        self.selected_contents = Gtk.VBox()
        sw2 = Gtk.ScrolledWindow()
        sw2.add_with_viewport(self.selected_contents)
        self.selected_page_num = self.append_page(sw2, Gtk.Label("Selected"))

        ###############
        ### Options ###
        ###############
        self.options_contents_super = Gtk.VBox()
        sw3 = Gtk.ScrolledWindow()
        sw3.add_with_viewport(self.options_contents_super)
        self.options_page_num = self.append_page(sw3, Gtk.Label("Options"))

        hb = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        ico = Gtk.Image.new_from_file("share/gear32.png")
        hb.pack_start(ico, expand=False, fill=False, padding=0)
        self.combo_options = Gtk.ComboBoxText()
        hb.pack_start(self.combo_options, expand=True, fill=True, padding=0)
        self.options_contents_super.pack_start(hb, expand=False, fill=False, padding=0)
        self.options_contents = Gtk.VBox()
        self.options_contents_super.pack_start(self.options_contents, expand=False, fill=False, padding=0)

        ############
        ### Tool ###
        ############
        self.tool_contents = Gtk.VBox()
        self.tool_page_num = self.append_page(self.tool_contents, Gtk.Label("Tool")) 
开发者ID:Denvi,项目名称:FlatCAM,代码行数:43,代码来源:FCNoteBook.py

示例6: populate_objects_combo

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ComboBoxText [as 别名]
def populate_objects_combo(self, combo):
        """
        Populates a Gtk.Comboboxtext with the list of the object in the project.

        :param combo: Name or instance of the comboboxtext.
        :type combo: str or Gtk.ComboBoxText
        :return: None
        """
        App.log.debug("Populating combo!")
        if type(combo) == str:
            combo = self.builder.get_object(combo)

        combo.remove_all()
        for name in self.collection.get_names():
            combo.append_text(name) 
开发者ID:Denvi,项目名称:FlatCAM,代码行数:17,代码来源:FlatCAMApp.py

示例7: on_toggle_pointbox

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ComboBoxText [as 别名]
def on_toggle_pointbox(self, widget):
        """
        Callback for radio selection change between point and box in the
        Double-sided PCB tool. Updates the UI accordingly.

        :param widget: Ignored.
        :return: None
        """

        # Where the entry or combo go
        box = self.builder.get_object("box_pointbox")

        # Clear contents
        children = box.get_children()
        for child in children:
            box.remove(child)

        choice = self.get_radio_value({"rb_mirror_point": "point",
                                       "rb_mirror_box": "box"})

        if choice == "point":
            self.point_entry = Gtk.Entry()
            self.builder.get_object("box_pointbox").pack_start(self.point_entry,
                                                               False, False, 1)
            self.point_entry.show()
        else:
            self.box_combo = Gtk.ComboBoxText()
            self.builder.get_object("box_pointbox").pack_start(self.box_combo,
                                                               False, False, 1)
            self.populate_objects_combo(self.box_combo)
            self.box_combo.show() 
开发者ID:Denvi,项目名称:FlatCAM,代码行数:33,代码来源:FlatCAMApp.py

示例8: __init__

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ComboBoxText [as 别名]
def __init__(self, data_list=[], sort=False):
		Gtk.ComboBoxText.__init__(self)
		# set max chars width
		for renderer in self.get_cells():
			renderer.props.max_width_chars = 10
			renderer.props.ellipsize = Pango.EllipsizeMode.END
		# append data
		self.append_list(data_list, sort) 
开发者ID:AXeL-dev,项目名称:Dindo-Bot,代码行数:10,代码来源:custom.py

示例9: __populate_preferences

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ComboBoxText [as 别名]
def __populate_preferences(self):
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        hbox_theme = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50)
        themes = ["Day (light)", "Night (dark)"]
        self.themes_combo = Gtk.ComboBoxText()
        self.themes_combo.set_entry_text_column(0)
        self.themes_combo.connect("changed", self.__on_themes_combo_changed)
        for theme in themes:
            self.themes_combo.append_text(theme)
        if self.window.config_provider.config["Application"]["stylesheet"] == "Day":
            self.themes_combo.set_active(0)
        else:
            self.themes_combo.set_active(1)
        hbox_theme.pack_end(self.themes_combo, False, True, 0)
        theme_label = Gtk.Label(_("Application theme") ,xalign=0)
        hbox_theme.pack_start(theme_label, False, True, 0)
        vbox.pack_start(hbox_theme, False, True, 0)
        try:
            vbox.set_margin_start(20)
            vbox.set_margin_end(20)
        except AttributeError:
            print("Gtk-WARNING **: GTK+ ver. below 3.12 will cause application interface to misbehave")
            vbox.set_margin_left(20)
            vbox.set_margin_right(20)
        vbox.set_margin_top(20)
        self.add(vbox) 
开发者ID:michaldaniel,项目名称:ebook-viewer,代码行数:28,代码来源:preferences_dialog.py

示例10: _ask_overwrite_alpha

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ComboBoxText [as 别名]
def _ask_overwrite_alpha(window, can_save_as):
	"""Warn the user about the replacement of the alpha channel for JPG or BMP
	files, but it will quickly annoy users to see a dialog so it's an option."""
	dialog = DrMessageDialog(window)
	cancel_id = dialog.set_action(_("Cancel"), None, False)
	if can_save_as:
		save_as_id = dialog.set_action(_("Save as…"), None, False)
	replace_id = dialog.set_action(_("Replace"), None, True)

	dialog.add_string(_("This file format doesn't support transparent colors."))
	if can_save_as:
		dialog.add_string(_("You can save the image as a PNG file, or " \
		                                          "replace transparency with:"))
	else:
		dialog.add_string(_("Replace transparency with:"))

	alpha_combobox = Gtk.ComboBoxText(halign=Gtk.Align.CENTER)
	alpha_combobox.append('white', _("White"))
	alpha_combobox.append('black', _("Black"))
	alpha_combobox.append('checkboard', _("Checkboard"))
	alpha_combobox.append('nothing', _("Nothing"))
	alpha_combobox.set_active_id('white') # If we run the dialog, it means the
	# active preference is 'ask', so there is no way we can set the default
	# value to something pertinent.
	dialog.add_widget(alpha_combobox)

	result = dialog.run()
	repl = alpha_combobox.get_active_id()
	dialog.destroy()
	if result != replace_id:
		raise Exception(result)
	return repl

################################################################################ 
开发者ID:maoschanz,项目名称:drawing,代码行数:36,代码来源:utilities.py

示例11: get_object_data

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ComboBoxText [as 别名]
def get_object_data(obj, *args):
    if isinstance(obj, Gtk.ComboBoxText):
        return obj.get_active_id() if obj.get_active_id() != 'none' else ''
    elif isinstance(obj, Gtk.Switch):
        return obj.get_active()
    elif isinstance(obj, Gtk.SpinButton):
        return obj.get_value_as_int()
    elif isinstance(obj, Gtk.Entry):
        text = obj.get_text()
        if obj.get_name() == 'float_only' and isfloat(text):
            return float(text)
        else:
            return text 
开发者ID:C2N14,项目名称:AutomaThemely,代码行数:15,代码来源:settsmanager.py

示例12: scan_comboboxtext_descendants

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ComboBoxText [as 别名]
def scan_comboboxtext_descendants(obj, match):
    try:
        children = obj.get_children()
    except AttributeError:
        return
    else:
        if children:
            comboboxtexts = []
            for child in children:
                scan = scan_comboboxtext_descendants(child, match)
                if scan:
                    comboboxtexts.extend(scan)
            return comboboxtexts
        elif isinstance(obj, Gtk.ComboBoxText) and match in Gtk.Buildable.get_name(obj):
            return [obj] 
开发者ID:C2N14,项目名称:AutomaThemely,代码行数:17,代码来源:settsmanager.py

示例13: _init_view

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ComboBoxText [as 别名]
def _init_view(self):
		self.buffer.object_attrib.connect('changed', self.on_attrib_changed)

		self.view = GtkSource.View()
		self.view.set_buffer(self.buffer)
		self.view.modify_font(Pango.FontDescription('monospace'))
		self.view.set_auto_indent(True)
		self.view.set_smart_home_end(True)
		self.view.set_highlight_current_line(True)
		self.view.set_right_margin_position(80)
		self.view.set_show_right_margin(True)
		self.view.set_tab_width(4)
		self.view.set_show_line_numbers(self.buffer.object_attrib['linenumbers'])
		self.view.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)

		self.WRAP_MODE = {
			WRAP_NONE: Gtk.WrapMode.NONE,
			WRAP_WORD_CHAR: Gtk.WrapMode.WORD_CHAR,
			WRAP_CHAR: Gtk.WrapMode.CHAR,
			WRAP_WORD: Gtk.WrapMode.WORD,
		}

		# simple toolbar
		#~ bar = Gtk.HBox() # FIXME: use Gtk.Toolbar stuff
		#~ lang_selector = Gtk.ComboBoxText()
		#~ lang_selector.append_text('(None)')
		#~ for l in lang_names: lang_selector.append_text(l)
		#~ try:
			#~ lang_selector.set_active(lang_ids.index(self._attrib['lang'])+1)
			#~ self.set_language(self._attrib['lang'] or None, False)
		#~ except (ValueError, KeyError):
			#~ lang_selector.set_active(0)
			#~ self.set_language(None, False)
		#~ lang_selector.connect('changed', self.on_lang_changed)
		#~ bar.pack_start(lang_selector, False, False)

		#~ line_numbers = Gtk.ToggleButton('Line numbers')
		#~ try:
			#~ line_numbers.set_active(self._attrib['linenumbers']=='true')
			#~ self.show_line_numbers(self._attrib['linenumbers'], False)
		#~ except (ValueError, KeyError):
			#~ line_numbers.set_active(True)
			#~ self.show_line_numbers(True, False)
		#~ line_numbers.connect('toggled', self.on_line_numbers_toggled)
		#~ bar.pack_start(line_numbers, False, False)
		#~ self.add_header(bar)

		# TODO: other toolbar options
		# TODO: autohide toolbar if textbuffer is not active

		win = ScrolledWindow(self.view, Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER, Gtk.ShadowType.NONE)
		self.add(win)

		self.view.connect('populate-popup', self.on_populate_popup) 
开发者ID:zim-desktop-wiki,项目名称:zim-desktop-wiki,代码行数:56,代码来源:sourceview.py

示例14: populate_themes_cboxt

# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import ComboBoxText [as 别名]
def populate_themes_cboxt(self, cboxt):
        # If ComboBoxText has an active id it has already been populated
        if cboxt.get_active_id():
            return

        cboxt_id = Gtk.Buildable.get_name(cboxt)
        cboxt_path = split_id_delimiter(cboxt_id)[0]
        cboxt_attr = cboxt.get_name()

        val = read_dict(self.us_se, cboxt_path.split('.'))
        themes = []

        if cboxt_id.startswith('*themes'):
            theme_type = cboxt_attr.split('-')[2]

            if not self.system_themes or theme_type not in self.system_themes:
                tmp = cboxt.get_children()
                cboxt.set_sensitive(False)
                return
            else:
                themes = self.system_themes[theme_type]

        elif cboxt_id.startswith('*extras'):
            cboxt_split = cboxt_attr.split('-')
            theme_type = cboxt_split[1]
            extra_type = cboxt_split[2]

            if theme_type not in self.extras[extra_type]:
                cboxt.set_sensitive(False)
            else:
                themes = self.extras[extra_type][theme_type]

        for theme in themes:
            t_id = theme[0]
            if len(theme) > 1:
                t_name = theme[1]
            else:
                t_name = t_id[0].upper() + t_id[1:]
            cboxt.append(t_id, t_name)

        active_id = try_or_default_type(val, str)
        if active_id:
            cboxt.set_active_id(active_id)
        else:
            # So it doesn't continue populating repeated options on non-set CBoxTs
            cboxt.set_active_id('none')

    #       HANDLERS
    # noinspection PyAttributeOutsideInit 
开发者ID:C2N14,项目名称:AutomaThemely,代码行数:51,代码来源:settsmanager.py


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