本文整理汇总了Python中sugar3.graphics.combobox.ComboBox类的典型用法代码示例。如果您正苦于以下问题:Python ComboBox类的具体用法?Python ComboBox怎么用?Python ComboBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ComboBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ToolComboBox
class ToolComboBox(Gtk.ToolItem):
'''
UI for ToolComboBox
A ToolComboBox is a widget that allows the user to choose
from a list of valid choices. The ToolComboBox displays
the selected choice. When activated, it displays a popup
which allows the user to make a new choice.
Functions:
ToolComboBox.new()
Returns a new tool combobox.
Keyword Args:
combo:
The combo attribute is like a Gtk.ComboBox.
There are two types: Either user passed or
automatic.
List of items in ToolComboBox
It can be also set to none.
'''
__gproperties__ = {
'label-text': (str, None, None, None, GObject.PARAM_WRITABLE),
}
'''
label-text
The text displayed on the label for ToolComboBox.
'''
def __init__(self, combo=None, **kwargs):
self.label = None
self._label_text = ''
GObject.GObject.__init__(self, **kwargs)
self.set_border_width(style.DEFAULT_PADDING)
hbox = Gtk.HBox(False, style.DEFAULT_SPACING)
self.label = Gtk.Label(label=self._label_text)
hbox.pack_start(self.label, False, False, 0)
self.label.show()
if combo:
self.combo = combo
else:
self.combo = ComboBox()
hbox.pack_start(self.combo, True, True, 0)
self.combo.show()
self.add(hbox)
hbox.show()
def do_set_property(self, pspec, value):
if pspec.name == 'label-text':
self._label_text = value
if self.label:
self.label.set_text(self._label_text)
示例2: __init__
def __init__(self, abi):
ComboBox.__init__(self)
self._abi_handler = abi.connect('font-size', self._font_size_cb)
self._font_sizes = ['8', '9', '10', '11', '12', '14', '16', '20', \
'22', '24', '26', '28', '36', '48', '72']
self._changed_id = self.connect('changed', self._font_size_changed_cb,
abi)
for i, s in enumerate(self._font_sizes):
self.append_item(i, s, None)
if s == '12':
self.set_active(i)
示例3: __init__
def __init__(self, face, **kwargs):
ComboBox.__init__(self, **kwargs)
self.face = face
voices = voice.allVoices()
voicenames = voices.keys()
voicenames.sort()
for name in voicenames:
self.append_item(voices[name], name)
self.select(voice.defaultVoice())
self.connect('changed', self._changed_cb)
示例4: __init__
def __init__(self, activity):
Gtk.Toolbar.__init__(self)
voicebar = Gtk.Toolbar()
self._activity = activity
if not speech.supported:
return
self.load_speech_parameters()
self.sorted_voices = [i for i in speech.voices()]
self.sorted_voices.sort(self.compare_voices)
default = 0
for voice in self.sorted_voices:
if voice[0] == speech.voice[0]:
break
default = default + 1
# Play button
self.play_btn = ToggleToolButton('media-playback-start')
self.play_btn.show()
self.play_btn.connect('toggled', self.play_cb)
self.insert(self.play_btn, -1)
self.play_btn.set_tooltip(_('Play / Pause'))
self.voice_combo = ComboBox()
for voice in self.sorted_voices:
self.voice_combo.append_item(voice, voice[0])
self.voice_combo.set_active(default)
self.voice_combo.connect('changed', self.voice_changed_cb)
combotool = ToolComboBox(self.voice_combo)
self.insert(combotool, -1)
combotool.show()
self.pitchadj = Gtk.Adjustment(0, -100, 100, 1, 10, 0)
pitchbar = Gtk.HScale(self.pitchadj)
pitchbar.set_draw_value(False)
pitchbar.set_update_policy(Gtk.UPDATE_DISCONTINUOUS)
pitchbar.set_size_request(150, 15)
self.pitchadj.set_value(speech.pitch)
pitchtool = Gtk.ToolItem()
pitchtool.add(pitchbar)
pitchtool.show()
self.insert(pitchtool, -1)
pitchbar.show()
self.rateadj = Gtk.Adjustment(0, -100, 100, 1, 10, 0)
ratebar = Gtk.HScale(self.rateadj)
ratebar.set_draw_value(False)
ratebar.set_update_policy(Gtk.UPDATE_DISCONTINUOUS)
ratebar.set_size_request(150, 15)
self.rateadj.set_value(speech.rate)
ratetool = Gtk.ToolItem()
ratetool.add(ratebar)
ratetool.show()
self.insert(ratetool, -1)
ratebar.show()
self.pitchadj.connect("value_changed", self.pitch_adjusted_cb)
self.rateadj.connect("value_changed", self.rate_adjusted_cb)
示例5: __init__
def __init__(self, icon_name, **kwargs):
Gtk.ToolItem.__init__(self, **kwargs)
self.icon_name = icon_name
self.set_border_width(style.DEFAULT_PADDING)
self.combo = ComboBox()
self.combo.set_focus_on_click(False)
self.combo.show()
self.add(self.combo)
示例6: __init__
def __init__(self):
ToolbarBox.__init__(self)
self._mount_point = None
self._filter_type = None
self._what_filter = None
self.search_entry = iconentry.IconEntry()
self.search_entry.set_icon_from_name(iconentry.ICON_ENTRY_PRIMARY,
'entry-search')
text = _('Search in %s') % _('Journal')
self.search_entry.set_placeholder_text(text)
self.search_entry.connect('activate', self._search_entry_activated_cb)
self.search_entry.connect('changed', self._search_entry_changed_cb)
self.search_entry.add_clear_button()
self._autosearch_timer = None
self._add_widget(self.search_entry, expand=True)
self._favorite_button = ToggleToolButton('emblem-favorite')
self._favorite_button.set_tooltip(_('Favorite entries'))
self._favorite_button.connect('toggled',
self.__favorite_button_toggled_cb)
self.toolbar.insert(self._favorite_button, -1)
self._favorite_button.show()
self._what_search_combo = ComboBox()
self._what_combo_changed_sid = self._what_search_combo.connect(
'changed', self._combo_changed_cb)
tool_item = ToolComboBox(self._what_search_combo)
self.toolbar.insert(tool_item, -1)
tool_item.show()
self._when_search_combo = self._get_when_search_combo()
tool_item = ToolComboBox(self._when_search_combo)
self.toolbar.insert(tool_item, -1)
tool_item.show()
self._sorting_button = SortingButton()
self.toolbar.insert(self._sorting_button, -1)
self._sorting_button.connect('sort-property-changed',
self.__sort_changed_cb)
self._sorting_button.show()
# TODO: enable it when the DS supports saving the buddies.
# self._with_search_combo = self._get_with_search_combo()
# tool_item = ToolComboBox(self._with_search_combo)
# self.insert(tool_item, -1)
# tool_item.show()
self._query = self._build_query()
self.refresh_filters()
示例7: create_new_toolbar
def create_new_toolbar(self):
toolbar_box = ToolbarBox()
book_search_item = Gtk.ToolItem()
self.search_entry = Gtk.Entry()
self.search_entry.connect('activate', self.search_entry_activate_cb)
width = int(Gdk.Screen.width() / 2.1)
self.search_entry.set_size_request(width, -1)
book_search_item.add(self.search_entry)
self.search_entry.show()
toolbar_box.toolbar.insert(book_search_item, -1)
book_search_item.show()
self._download = ToolButton('go-down')
self._download.set_tooltip(_('Get Book'))
self._download.props.sensitive = False
self._download.connect('clicked', self._get_book_cb)
toolbar_box.toolbar.insert(self._download, -1)
self._download.show()
self.format_combo = ComboBox()
self.format_combo.connect('changed', self.format_changed_cb)
self.format_combo.append_item('.djvu', 'Deja Vu')
self.format_combo.append_item('_bw.pdf', 'B/W PDF')
self.format_combo.append_item('.pdf', 'Color PDF')
self.format_combo.append_item('.epub', 'EPUB')
self.format_combo.set_active(0)
self.format_combo.props.sensitive = False
combotool = ToolComboBox(self.format_combo)
toolbar_box.toolbar.insert(combotool, -1)
combotool.show()
self.search_entry.grab_focus()
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
toolbar_box.toolbar.insert(separator, -1)
separator.show()
stop_button = StopButton(self)
stop_button.props.accelerator = '<Ctrl><Shift>Q'
toolbar_box.toolbar.insert(stop_button, -1)
stop_button.show()
self.set_toolbar_box(toolbar_box)
toolbar_box.show()
示例8: __init__
def __init__(self, owner):
GObject.GObject.__init__(self)
self.owner = owner
self.toolItem = {}
self.blockBeat = False
self.beatWheel = []
btn = RadioToolButton(group=None)
btn.set_icon_name('beats')
btn.connect('toggled', self.setBeat, 0)
btn.set_tooltip(_('Jump To Beat'))
self.insert(btn, -1)
self.beatWheel.append(btn)
for i in range(1, 12):
btn = RadioToolButton(group=self.beatWheel[0])
btn.set_icon_name('beats')
btn.connect('toggled', self.setBeat, i)
btn.set_tooltip(_('Jump To Beat'))
self.insert(btn, -1)
self.beatWheel.append(btn)
label = Gtk.Label(label=_("Synch to:"))
self.syncLabel = Gtk.ToolItem()
self.syncLabel.add(label)
self.insert(self.syncLabel, 0)
self.comboBox = ComboBox()
self.comboBox.append_item(1, _("1 Beat"))
self.comboBox.append_item(2, _("2 Beats"))
self.comboBox.append_item(3, _("3 Beats"))
self.comboBox.append_item(4, _("4 Beats"))
self.comboBox.append_item(5, _("5 Beats"))
self.comboBox.append_item(6, _("6 Beats"))
self.comboBox.append_item(7, _("7 Beats"))
self.comboBox.append_item(8, _("8 Beats"))
self.comboBox.append_item(9, _("9 Beats"))
self.comboBox.append_item(10, _("10 Beats"))
self.comboBox.append_item(11, _("11 Beats"))
self.comboBox.append_item(12, _("12 Beats"))
self.comboBox.set_active(4 - 1) # default 4 beats
self.comboBox.connect("changed", self.changeSync)
self.syncBox = ToolComboBox(self.comboBox)
self.insert(self.syncBox, 1)
self.show_all()
示例9: ToolComboBox
class ToolComboBox(Gtk.ToolItem):
__gproperties__ = {
'label-text': (str, None, None, None, GObject.ParamFlags.WRITABLE),
}
def __init__(self, combo=None, **kwargs):
self.label = None
self._label_text = ''
GObject.GObject.__init__(self, **kwargs)
self.set_border_width(style.DEFAULT_PADDING)
hbox = Gtk.HBox(False, style.DEFAULT_SPACING)
self.label = Gtk.Label(label=self._label_text)
hbox.pack_start(self.label, False, False, 0)
self.label.show()
if combo:
self.combo = combo
else:
self.combo = ComboBox()
hbox.pack_start(self.combo, True, True, 0)
self.combo.show()
self.add(hbox)
hbox.show()
def do_set_property(self, pspec, value):
if pspec.name == 'label-text':
self._label_text = value
if self.label:
self.label.set_text(self._label_text)
示例10: _combo_factory
def _combo_factory(combo_array, default, tooltip, toolbar):
'''Factory for making a toolbar combo box'''
my_combo = ComboBox()
if hasattr(my_combo, 'set_tooltip_text'):
my_combo.set_tooltip_text(tooltip)
for i, s in enumerate(combo_array):
my_combo.append_item(i, _(s), None)
toolbar.insert(ToolComboBox(my_combo), -1)
my_combo.set_active(default)
return my_combo
示例11: __init__
def __init__(self, activity):
GObject.GObject.__init__(self)
self._activity = activity
if not speech.supported:
return
self.is_paused = False
self._cnf_client = GConf.Client.get_default()
self.load_speech_parameters()
self.sorted_voices = [i for i in speech.voices()]
self.sorted_voices.sort(self.compare_voices)
default = 0
for voice in self.sorted_voices:
if voice[0] == speech.voice[0]:
break
default = default + 1
# Play button
self.play_btn = ToggleToolButton("media-playback-start")
self.play_btn.show()
self.play_toggled_handler = self.play_btn.connect("toggled", self.play_cb)
self.insert(self.play_btn, -1)
self.play_btn.set_tooltip(_("Play / Pause"))
# Stop button
self.stop_btn = ToolButton("media-playback-stop")
self.stop_btn.show()
self.stop_btn.connect("clicked", self.stop_cb)
self.stop_btn.set_sensitive(False)
self.insert(self.stop_btn, -1)
self.stop_btn.set_tooltip(_("Stop"))
self.voice_combo = ComboBox()
for voice in self.sorted_voices:
self.voice_combo.append_item(voice, voice[0])
self.voice_combo.set_active(default)
self.voice_combo.connect("changed", self.voice_changed_cb)
combotool = ToolComboBox(self.voice_combo)
self.insert(combotool, -1)
combotool.show()
speech.reset_cb = self.reset_buttons_cb
speech.end_text_cb = self.reset_buttons_cb
示例12: IconComboBox
class IconComboBox(Gtk.ToolItem):
def __init__(self, icon_name, **kwargs):
Gtk.ToolItem.__init__(self, **kwargs)
self.icon_name = icon_name
self.set_border_width(style.DEFAULT_PADDING)
self.combo = ComboBox()
self.combo.set_focus_on_click(False)
self.combo.show()
self.add(self.combo)
def append_item(self, i, text):
self.combo.append_item(i, text, icon_name=self.icon_name)
示例13: __init__
def __init__(self, combo=None, **kwargs):
self.label = None
self._label_text = ''
GObject.GObject.__init__(self, **kwargs)
self.set_border_width(style.DEFAULT_PADDING)
hbox = Gtk.HBox(False, style.DEFAULT_SPACING)
self.label = Gtk.Label(label=self._label_text)
hbox.pack_start(self.label, False, False, 0)
self.label.show()
if combo:
self.combo = combo
else:
self.combo = ComboBox()
hbox.pack_start(self.combo, True, True, 0)
self.combo.show()
self.add(hbox)
hbox.show()
示例14: __init__
def __init__(self):
Gtk.Toolbar.__init__(self)
book_search_item = Gtk.ToolItem()
self.search_entry = Gtk.Entry()
self.search_entry.connect('activate', self.search_entry_activate_cb)
width = int(Gdk.Screen.width() / 2)
self.search_entry.set_size_request(width, -1)
book_search_item.add(self.search_entry)
self.search_entry.show()
self.insert(book_search_item, -1)
book_search_item.show()
self._download = ToolButton('go-down')
self._download.set_tooltip(_('Get Book'))
self._download.props.sensitive = False
self._download.connect('clicked', self._get_book_cb)
self.insert(self._download, -1)
self._download.show()
self.format_combo = ComboBox()
self.format_combo.connect('changed', self.format_changed_cb)
self.format_combo.append_item('.djvu', 'Deja Vu')
self.format_combo.append_item('_bw.pdf', 'B/W PDF')
self.format_combo.append_item('.pdf', 'Color PDF')
self.format_combo.append_item('.epub', 'EPUB')
self.format_combo.set_active(0)
self.format_combo.props.sensitive = False
combotool = ToolComboBox(self.format_combo)
self.insert(combotool, -1)
combotool.show()
self.search_entry.grab_focus()
示例15: BooksToolbar
class BooksToolbar(Gtk.Toolbar):
__gtype_name__ = 'BooksToolbar'
def __init__(self):
Gtk.Toolbar.__init__(self)
book_search_item = Gtk.ToolItem()
self.search_entry = Gtk.Entry()
self.search_entry.connect('activate', self.search_entry_activate_cb)
width = int(Gdk.Screen.width() / 2)
self.search_entry.set_size_request(width, -1)
book_search_item.add(self.search_entry)
self.search_entry.show()
self.insert(book_search_item, -1)
book_search_item.show()
self._download = ToolButton('go-down')
self._download.set_tooltip(_('Get Book'))
self._download.props.sensitive = False
self._download.connect('clicked', self._get_book_cb)
self.insert(self._download, -1)
self._download.show()
self.format_combo = ComboBox()
self.format_combo.connect('changed', self.format_changed_cb)
self.format_combo.append_item('.djvu', 'Deja Vu')
self.format_combo.append_item('_bw.pdf', 'B/W PDF')
self.format_combo.append_item('.pdf', 'Color PDF')
self.format_combo.append_item('.epub', 'EPUB')
self.format_combo.set_active(0)
self.format_combo.props.sensitive = False
combotool = ToolComboBox(self.format_combo)
self.insert(combotool, -1)
combotool.show()
self.search_entry.grab_focus()
def set_activity(self, activity):
self.activity = activity
def format_changed_cb(self, combo):
if self.activity != None:
self.activity.show_book_data()
def search_entry_activate_cb(self, entry):
self.activity.find_books(entry.props.text)
def _get_book_cb(self, button):
self.activity.get_book()
def enable_button(self, state):
self._download.props.sensitive = state
self.format_combo.props.sensitive = state