本文整理汇总了Python中sugar3.graphics.combobox.ComboBox类的典型用法代码示例。如果您正苦于以下问题:Python ComboBox类的具体用法?Python ComboBox怎么用?Python ComboBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ComboBox类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:Hrishi1999,项目名称:sugar-toolkit-gtk3,代码行数:57,代码来源:toolcombobox.py
示例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)
开发者ID:sugarlabs,项目名称:devtutor-activity,代码行数:14,代码来源:widgets.py
示例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)
开发者ID:godiard,项目名称:memorize-activity,代码行数:15,代码来源:widgets.py
示例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)
开发者ID:tanmoydeb07,项目名称:ebookreader,代码行数:59,代码来源:readtoolbar.py
示例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)
开发者ID:sugarlabs,项目名称:record-activity,代码行数:11,代码来源:iconcombobox.py
示例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()
开发者ID:hgarrereyn,项目名称:sugar,代码行数:52,代码来源:journaltoolbox.py
示例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()
开发者ID:leonardcj,项目名称:getiabooks,代码行数:51,代码来源:GetIABooksActivity.py
示例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()
开发者ID:leonardcj,项目名称:tamtam,代码行数:49,代码来源:Toolbars.py
示例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)
开发者ID:sugarlabs,项目名称:sugar-toolkit-gtk3,代码行数:36,代码来源:toolcombobox.py
示例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
开发者ID:sugarlabs,项目名称:distance-activity,代码行数:14,代码来源:smoot_toolbar.py
示例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
开发者ID:i5o,项目名称:write-activity,代码行数:43,代码来源:speechtoolbar.py
示例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)
开发者ID:sugarlabs,项目名称:record-activity,代码行数:15,代码来源:iconcombobox.py
示例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()
开发者ID:Hrishi1999,项目名称:sugar-toolkit-gtk3,代码行数:24,代码来源:toolcombobox.py
示例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()
开发者ID:leonardcj,项目名称:getiabooks,代码行数:36,代码来源:GetIABooksActivity.py
示例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
开发者ID:leonardcj,项目名称:getiabooks,代码行数:56,代码来源:GetIABooksActivity.py
示例16: create_dialog
#.........这里部分代码省略.........
self.text_entry = Gtk.Entry()
try:
self.text_entry.props.im_module = 'gtk-im-context-simple'
except AttributeError:
pass
self.text_entry.set_size_request(-1, 75)
self.text_entry.connect('key_press_event', self._parent.ignore_key_cb)
self.text_entry.modify_font(self.input_font)
self.text_entry.modify_bg(Gtk.StateType.INSENSITIVE, self.col_black)
eb = Gtk.EventBox()
eb.add(self.text_entry)
eb.modify_bg(Gtk.StateType.NORMAL, self.col_black)
eb.set_border_width(12)
eb2 = Gtk.EventBox()
eb2.add(eb)
eb2.modify_bg(Gtk.StateType.NORMAL, self.col_black)
vc1.pack_start(eb2, expand=True, fill=True, padding=0)
self.grid.attach(vc1, 0, 0, 7, 6)
# Left part: buttons
self.pad = Gtk.Grid()
self.pad.set_column_homogeneous(True)
self.pad.set_row_spacing(6)
self.pad.set_column_spacing(6)
self.create_button_data()
self.buttons = {}
for x, y, w, h, cap, bgcol, cb in self.button_data:
button = self.create_button(
_(cap), cb, self.col_white, bgcol, w, h)
self.buttons[cap] = button
self.pad.attach(button, x, y, w, h)
eb = Gtk.EventBox()
eb.add(self.pad)
eb.modify_bg(Gtk.StateType.NORMAL, self.col_black)
self.grid.attach(eb, 0, 6, 7, 20)
# Right part: container and equation button
hc2 = Gtk.HBox()
combo = ComboBox()
combo.append_item(0, _('All equations'))
combo.append_item(1, _('My equations'))
combo.append_item(2, _('Show variables'))
combo.set_active(0)
combo.connect('changed', self._history_filter_cb)
hc2.pack_start(combo, True, True, 0)
hc2.set_border_width(6)
self.grid.attach(hc2, 7, 0, 4, 2)
# Right part: last equation
self.last_eq = Gtk.TextView()
self.last_eq.set_editable(False)
self.last_eq.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
self.last_eq.connect('realize', self._textview_realize_cb)
self.last_eq.modify_base(Gtk.StateType.NORMAL, Gdk.color_parse(
sugar3.profile.get_color().get_fill_color()))
self.last_eq.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(
sugar3.profile.get_color().get_stroke_color()))
self.last_eq.set_border_window_size(Gtk.TextWindowType.LEFT, 4)
self.last_eq.set_border_window_size(Gtk.TextWindowType.RIGHT, 4)
self.last_eq.set_border_window_size(Gtk.TextWindowType.TOP, 4)
self.last_eq.set_border_window_size(Gtk.TextWindowType.BOTTOM, 4)
# TODO Fix for old Sugar 0.82 builds, red_float not available
xo_color = sugar3.profile.get_color()
bright = (
Gdk.color_parse(xo_color.get_fill_color()).red_float +
Gdk.color_parse(xo_color.get_fill_color()).green_float +
Gdk.color_parse(xo_color.get_fill_color()).blue_float) / 3.0
if bright < 0.5:
self.last_eq.modify_text(Gtk.StateType.NORMAL, self.col_white)
else:
self.last_eq.modify_text(Gtk.StateType.NORMAL, self.col_black)
self.grid.attach(self.last_eq, 7, 2, 4, 5)
# Right part: history
scrolled_window = Gtk.ScrolledWindow()
scrolled_window.set_policy(Gtk.PolicyType.NEVER,
Gtk.PolicyType.AUTOMATIC)
self.history_vbox = Gtk.VBox()
self.history_vbox.set_homogeneous(False)
self.history_vbox.set_border_width(0)
self.history_vbox.set_spacing(4)
self.variable_vbox = Gtk.VBox()
self.variable_vbox.set_homogeneous(False)
self.variable_vbox.set_border_width(0)
self.variable_vbox.set_spacing(4)
vbox = Gtk.VBox()
vbox.pack_start(self.history_vbox, True, True, 0)
vbox.pack_start(self.variable_vbox, True, True, 0)
scrolled_window.add_with_viewport(vbox)
self.grid.attach(scrolled_window, 7, 7, 4, 19)
Gdk.Screen.get_default().connect('size-changed',
self._configure_cb)
开发者ID:quozl,项目名称:sugarlabs-calculate,代码行数:101,代码来源:layout.py
示例17: GetIABooksActivity
#.........这里部分代码省略.........
self._books_toolbar = BooksToolbar()
toolbox.add_toolbar(_('Books'), self._books_toolbar)
self._books_toolbar.set_activity(self)
self._books_toolbar.show()
toolbox.show()
self.toolbox.set_current_toolbar(_TOOLBAR_BOOKS)
self._books_toolbar.search_entry.grab_focus()
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()
def format_changed_cb(self, combo):
self.show_book_data()
def search_entry_activate_cb(self, entry):
self.find_books(entry.props.text)
开发者ID:leonardcj,项目名称:getiabooks,代码行数:67,代码来源:GetIABooksActivity.py
示例18: MainToolbox
class MainToolbox(ToolbarBox):
__gsignals__ = {
'query-changed': (GObject.SignalFlags.RUN_FIRST, None,
([object])),
}
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()
def _get_when_search_combo(self):
when_search = ComboBox()
when_search.append_item(_ACTION_ANYTIME, _('Anytime'))
when_search.append_separator()
when_search.append_item(_ACTION_TODAY, _('Today'))
when_search.append_item(_ACTION_SINCE_YESTERDAY,
_('Since yesterday'))
# TRANS: Filter entries modified during the last 7 days.
when_search.append_item(_ACTION_PAST_WEEK, _('Past week'))
# TRANS: Filter entries modified during the last 30 days.
when_search.append_item(_ACTION_PAST_MONTH, _('Past month'))
# TRANS: Filter entries modified during the last 356 days.
when_search.append_item(_ACTION_PAST_YEAR, _('Past year'))
when_search.set_active(0)
when_search.connect('changed', self._combo_changed_cb)
return when_search
def _get_with_search_combo(self):
with_search = ComboBox()
with_search.append_item(_ACTION_EVERYBODY, _('Anyone'))
with_search.append_separator()
with_search.append_item(_ACTION_MY_FRIENDS, _('My friends'))
with_search.append_item(_ACTION_MY_CLASS, _('My class'))
with_search.append_separator()
# TODO: Ask the model for buddies.
with_search.append_item(3, 'Dan', 'theme:xo')
with_search.set_active(0)
with_search.connect('changed', self._combo_changed_cb)
return with_search
def _add_widget(self, widget, expand=False):
tool_item = Gtk.ToolItem()
tool_item.set_expand(expand)
tool_item.add(widget)
widget.show()
self.toolbar.insert(tool_item, -1)
#.........这里部分代码省略.........
开发者ID:hgarrereyn,项目名称:sugar,代码行数:101,代码来源:journaltoolbox.py
示例19: SpeechToolbar
class SpeechToolbar(Gtk.Toolbar):
def __init__(self, activity):
Gtk.Toolbar.__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_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_buttons_cb = self.reset_buttons_cb
def compare_voices(self, a, b):
if a[0].lower() == b[0].lower():
return 0
if a[0] .lower() < b[0].lower():
return -1
if a[0] .lower() > b[0].lower():
return 1
def voice_changed_cb(self, combo):
speech.voice = combo.props.value
speech.say(speech.voice[0])
self.save_speech_parameters()
def load_speech_parameters(self):
speech_parameters = {}
data_path = os.path.join(self._activity.get_activity_root(), 'data')
data_file_name = os.path.join(data_path, 'speech_params.json')
if os.path.exists(data_file_name):
f = open(data_file_name, 'r')
try:
speech_parameters = json.load(f)
speech.voice = speech_parameters['voice']
finally:
f.close()
self._cnf_client.add_dir('/desktop/sugar/speech',
GConf.ClientPreloadType.PRELOAD_NONE)
speech.pitch = self._cnf_client.get_int('/desktop/sugar/speech/pitch')
speech.rate = self._cnf_client.get_int('/desktop/sugar/speech/rate')
self._cnf_client.notify_add('/desktop/sugar/speech/pitch',
self.__conf_changed_cb, None)
self._cnf_client.notify_add('/desktop/sugar/speech/rate',
self.__conf_changed_cb, None)
def __conf_changed_cb(self, client, connection_id, entry, args):
key = entry.get_key()
value = client.get_int(key)
if key == '/desktop/sugar/speech/pitch':
speech.pitch = value
if key == '/desktop/sugar/speech/rate':
speech.rate = value
def save_speech_parameters(self):
speech_parameters = {}
speech_parameters['voice'] = speech.voice
data_path = os.path.join(self._activity.get_activity_root(), 'data')
data_file_name = os.path.join(data_path, 'speech_params.json')
f = open(data_file_name, 'w')
try:
json.dump(speech_parameters, f)
finally:
f.close()
def reset_buttons_cb(self):
#.........这里部分代码省略.........
开发者ID:icarito,项目名称:read-activity,代码行数:101,代码来源:speechtoolbar.py
示例20: __init__
def __init__(self):
Gtk.Toolbar.__init__(self)
voicebar = Gtk.Toolbar()
self.activity = None
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] == 'default':
break
default = default + 1
# Play button Image
play_img = Gtk.Image()
play_img.show()
play_img.set_from_icon_name('media-playback-start',
Gtk.IconSize.LARGE_TOOLBAR)
# Pause button Image
pause_img = Gtk.Image()
pause_img.show()
pause_img.set_from_icon_name('media-playback-pause',
Gtk.IconSize.LARGE_TOOLBAR)
# Play button
self.play_btn = ToggleToolButton('media-playback-start')
self.play_btn.show()
self.play_btn.connect('toggled', self.play_cb, [play_img, pause_img])
self.insert(self.play_btn, -1)
self.play_btn.set_tooltip(_('Play / Pause'))
self.voice_combo = ComboBox()
self.voice_combo.connect('changed', self.voice_changed_cb)
for voice in self.sorted_voices:
self.voice_combo.append_item(voice, voice[0])
self.voice_combo.set_active(default)
combotool = ToolComboBox(self.voice_combo)
self.insert(combotool, -1)
combotool.show()
self.pitchadj = Gtk.Adjustment(0, -100, 100, 1, 10, 0)
pitchbar = Gtk.HScale()
pitchbar.set_adjustment(self.pitchadj)
pitchbar.set_draw_value(False)
# pitchbar.set_update_policy(Gtk.UpdatePolicy.ALWAYS)
pitchbar.set_size_request(150,15)
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()
ratebar.set_adjustment(self.rateadj)
ratebar.set_draw_value(False)
#ratebar.set_update_policy(Gtk.UpdatePolicy.ALWAYS)
ratebar.set_size_request(150,15)
ratetool = Gtk.ToolItem()
ratetool.add(ratebar)
ratetool.show()
self.insert(ratetool, -1)
ratebar.show()
开发者ID:leonardcj,项目名称:readetexts,代码行数:63,代码来源:readtoolbar.py
注:本文中的sugar3.graphics.combobox.ComboBox类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论