class TitleBox(VolumesToolbar): __gtype_name__ = 'TitleBox' def __init__(self): VolumesToolbar.__init__(self) label = gtk.Label() label.set_markup('<b>%s</b>' % _('Choose an object')) label.set_alignment(0, 0.5) self._add_widget(label, expand=True) self.close_button = ToolButton(icon_name='dialog-cancel') self.close_button.set_tooltip(_('Close')) self.insert(self.close_button, -1) self.close_button.show() def _add_widget(self, widget, expand=False): tool_item = gtk.ToolItem() tool_item.set_expand(expand) tool_item.add(widget) widget.show() self.insert(tool_item, -1) tool_item.show()
def build_toolbar(self): toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) toolbar_box.show() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, -1) activity_button.show() self.blocklist = [] self.radioList = {} for c in tools.allTools: button = ToolButton(c.icon) button.set_tooltip(_(c.toolTip)) button.connect('clicked',self.radioClicked) toolbar_box.toolbar.insert(button, -1) button.show() self.radioList[button] = c.name separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.show_all()
def build_toolbar(self): toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) toolbar_box.show() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, -1) activity_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(False) toolbar_box.toolbar.insert(separator, -1) separator.show() button = ToolButton('speaker-muted-100') button.set_tooltip(_('Sound')) button.connect('clicked', self.sound_control) toolbar_box.toolbar.insert(button, -1) separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.show_all()
def __init__(self, **kwargs): gtk.ToolItem.__init__(self) help_button = ToolButton('help-icon') help_button.set_tooltip(_('Help')) self.add(help_button) self._palette = help_button.get_palette() sw = gtk.ScrolledWindow() sw.set_size_request(int(gtk.gdk.screen_width() / 2.8), gtk.gdk.screen_height() - style.GRID_CELL_SIZE * 3) sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self._max_text_width = int(gtk.gdk.screen_width() / 3) - 20 self._vbox = gtk.VBox() self._vbox.set_homogeneous(False) hbox = gtk.HBox() hbox.pack_start(self._vbox, False, True, 0) sw.add_with_viewport(hbox) self._palette.set_content(sw) sw.show_all() help_button.connect('clicked', self.__help_button_clicked_cb)
def __init__(self, activity, **kwargs): gtk.ToolItem.__init__(self) description_button = ToolButton('edit-description') description_button.show() description_button.set_tooltip(_('Description')) self._palette = description_button.get_palette() description_box = gtk.HBox() sw = gtk.ScrolledWindow() sw.set_size_request(int(gtk.gdk.screen_width() / 2), 2 * style.GRID_CELL_SIZE) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self._text_view = gtk.TextView() self._text_view.set_left_margin(style.DEFAULT_PADDING) self._text_view.set_right_margin(style.DEFAULT_PADDING) self._text_view.set_wrap_mode(gtk.WRAP_WORD_CHAR) text_buffer = gtk.TextBuffer() if 'description' in activity.metadata: text_buffer.set_text(activity.metadata['description']) self._text_view.set_buffer(text_buffer) self._text_view.connect('focus-out-event', self.__description_changed_cb, activity) sw.add(self._text_view) description_box.pack_start(sw, False, True, 0) self._palette.set_content(description_box) description_box.show_all() self.add(description_button) description_button.connect('clicked', self.__description_button_clicked_cb) activity.metadata.connect('updated', self.__jobject_updated_cb)
def __init__(self, activity, **kwargs): gtk.ToolItem.__init__(self) description_button = ToolButton('edit-description') description_button.show() description_button.set_tooltip(_('Description')) self._palette = description_button.get_palette() description_box = gtk.HBox() sw = gtk.ScrolledWindow() sw.set_size_request(int(gtk.gdk.screen_width() / 2), 2 * style.GRID_CELL_SIZE) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self._text_view = gtk.TextView() self._text_view.set_left_margin(style.DEFAULT_PADDING) self._text_view.set_right_margin(style.DEFAULT_PADDING) text_buffer = gtk.TextBuffer() if 'description' in activity.metadata: text_buffer.set_text(activity.metadata['description']) self._text_view.set_buffer(text_buffer) self._text_view.connect('focus-out-event', self.__description_changed_cb, activity) sw.add(self._text_view) description_box.pack_start(sw, False, True, 0) self._palette.set_content(description_box) description_box.show_all() self.add(description_button) description_button.connect('clicked', self.__description_button_clicked_cb) activity.metadata.connect('updated', self.__jobject_updated_cb)
def __init__(self, web_view): gobject.GObject.__init__(self) self._web_view = web_view self._back = ToolButton('go-previous-paired') self._back.set_tooltip(_('Back')) self._back.props.sensitive = False self._back.connect('clicked', self._go_back_cb) self.insert(self._back, -1) self._back.show() self._forward = ToolButton('go-next-paired') self._forward.set_tooltip(_('Forward')) self._forward.props.sensitive = False self._forward.connect('clicked', self._go_forward_cb) self.insert(self._forward, -1) self._forward.show() home = ToolButton('zoom-home') home.set_tooltip(_('Home')) home.connect('clicked', self._go_home_cb) self.insert(home, -1) home.show() self._listener = xpcom.server.WrapObject( ProgressListener(self), interfaces.nsIWebProgressListener) weak_ref = xpcom.client.WeakReference(self._listener) mask = interfaces.nsIWebProgress.NOTIFY_STATE_NETWORK | \ interfaces.nsIWebProgress.NOTIFY_LOCATION self._web_view.web_progress.addProgressListener(self._listener, mask)
def __init__(self, web_view): gobject.GObject.__init__(self) self._web_view = web_view self._back = ToolButton('go-previous-paired') self._back.set_tooltip(_('Back')) self._back.props.sensitive = False self._back.connect('clicked', self._go_back_cb) self.insert(self._back, -1) self._back.show() self._forward = ToolButton('go-next-paired') self._forward.set_tooltip(_('Forward')) self._forward.props.sensitive = False self._forward.connect('clicked', self._go_forward_cb) self.insert(self._forward, -1) self._forward.show() home = ToolButton('zoom-home') home.set_tooltip(_('Home')) home.connect('clicked', self._go_home_cb) self.insert(home, -1) home.show() progress_listener = self._web_view.progress progress_listener.connect('location-changed', self._location_changed_cb) progress_listener.connect('loading-stop', self._loading_stop_cb)
class ViewToolbar(gtk.Toolbar): __gtype_name__ = 'ViewToolbar' def __init__(self): gtk.Toolbar.__init__(self) self._zoom_out = ToolButton('zoom-out') self._zoom_out.set_tooltip(_('Zoom out')) self._zoom_out.connect('clicked', self._zoom_out_cb) self.insert(self._zoom_out, -1) self._zoom_out.show() self._zoom_in = ToolButton('zoom-in') self._zoom_in.set_tooltip(_('Zoom in')) self._zoom_in.connect('clicked', self._zoom_in_cb) self.insert(self._zoom_in, -1) self._zoom_in.show() def _zoom_in_cb(self, button): self.activity.font_increase() def _zoom_out_cb(self, button): self.activity.font_decrease() def set_activity(self, activity): self.activity = activity
class InstrumentToolbar(gtk.Toolbar): ''' The toolbar for adding new instruments ''' def __init__(self, activity): gtk.Toolbar.__init__(self) self.activity = activity self.new_instruments = [] self._name_entry = gtk.Entry() self._name_entry.set_text(_('my instrument')) self._name_entry_changed_id = self._name_entry.connect( 'changed', self.update_name_entry) if hasattr(self._name_entry, 'set_tooltip_text'): self._name_entry.set_tooltip_text(_('Enter instrument name.')) self._name_entry.set_width_chars(24) self._name_entry.show() toolitem = gtk.ToolItem() toolitem.add(self._name_entry) self.insert(toolitem, -1) toolitem.show() self._notes_combo = ComboBox() n = 0 for octave in range(9): for i in range(len(NOTES)): if octave == 0 and i < 9: # Start with A0 continue self._notes_combo.append_item(n, note_octave(i, octave), None) n += 1 self._notes_combo.set_active(48) # A4 if hasattr(self._notes_combo, 'set_tooltip_text'): self._notes_combo.set_tooltip_text(_('Notes')) self._notes_tool = ToolComboBox(self._notes_combo) self.insert(self._notes_tool, -1) self._notes_tool.show() self._new_note = ToolButton('list-add') self._new_note.show() self.insert(self._new_note, -1) self._new_note.set_tooltip(_('Add a new note.')) self._new_note.connect('clicked', self.new_note_cb) def update_name_entry(self, *args): ''' Add name to INSTRUMENT_DICT and combo box ''' # Wait until a note has been added... return def new_note_cb(self, *args): ''' Add a new note to instrument tuning list ''' name = self._name_entry.get_text() if name not in INSTRUMENT_DICT: INSTRUMENT_DICT[name] = [] self.activity.tuning_toolbar.instrument.append(name) i = len(self.activity.tuning_toolbar.instrument) self.activity.tuning_toolbar.instrument_combo.append_item( i, name, None) self.new_instruments.append(name) i = self._notes_combo.get_active() freq = A0 * pow(TWELTHROOT2, i) if freq not in INSTRUMENT_DICT[name]: INSTRUMENT_DICT[name].append(freq)
class TitleBox(VolumesToolbar): __gtype_name__ = 'TitleBox' def __init__(self): VolumesToolbar.__init__(self) label = gtk.Label() label.set_markup('<b>%s</b>' % _('Choose an object')) label.set_alignment(0, 0.5) self._add_widget(label, expand=True) self.close_button = ToolButton(icon_name='dialog-cancel') self.close_button.set_tooltip(_('Close')) self.insert(self.close_button, -1) self.close_button.show() def _add_widget(self, widget, expand=False): tool_item = gtk.ToolItem() tool_item.set_expand(expand) tool_item.add(widget) widget.show() self.insert(tool_item, -1) tool_item.show()
def __init__(self, calc): gtk.Toolbar.__init__(self) copy_tool = ToolButton('edit-copy') copy_tool.set_tooltip(_('Copy')) copy_tool.set_accelerator(_('<ctrl>c')) copy_tool.connect('clicked', lambda x: calc.text_copy()) self.insert(copy_tool, -1) menu_item = MenuItem(_('Cut')) try: menu_item.set_accelerator(_('<ctrl>x')) except AttributeError: pass menu_item.connect('activate', lambda x: calc.text_cut()) menu_item.show() copy_tool.get_palette().menu.append(menu_item) self.insert(IconToolButton('edit-paste', _('Paste'), lambda x: calc.text_paste(), alt_html='Paste'), -1) self.show_all()
def __init__(self, handle): gtk.Toolbar.__init__(self) self.handle = handle #Tytuł pola tekstowego self.add_widget(gtk.Label("Id testu: ")) #Pole tekstowe self.test_entry = gtk.Entry() self.test_entry.set_size_request(200,25) self.test_entry.set_text('709rqd') self.add_widget(self.test_entry) #Separator separator = gtk.SeparatorToolItem() separator.set_draw(True) separator.set_size_request(50,25) self.add_widget(separator) #Tytuł pola tekstowego self.add_widget(gtk.Label("Hasło: ")) #Pole tekstowe self.pass_entry = gtk.Entry() self.pass_entry.set_size_request(300,25) # self.pass_entry.set_text('123123') self.add_widget(self.pass_entry) #Przycisk pobierania download_button = ToolButton("download") download_button.set_tooltip("Pobierz test") download_button.connect("clicked", handle.get_test_bt) self.add_widget(download_button)
def __init__(self, **kwargs): gtk.ToolItem.__init__(self) help_button = ToolButton('help-icon') help_button.set_tooltip(_('Help')) self.add(help_button) self._palette = help_button.get_palette() sw = gtk.ScrolledWindow() sw.set_size_request(int(gtk.gdk.screen_width() / 2.8), gtk.gdk.screen_height() - style.GRID_CELL_SIZE * 3) sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self._max_text_width = int(gtk.gdk.screen_width() / 3) - 20 self._vbox = gtk.VBox() self._vbox.set_homogeneous(False) hbox = gtk.HBox() hbox.pack_start(self._vbox, False, True, 0) sw.add_with_viewport(hbox) self._palette.set_content(sw) sw.show_all() help_button.connect('clicked', self.__help_button_clicked_cb)
def build_toolbar(self): toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) toolbar_box.show() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, -1) activity_button.show() # Pause/Play button: stop_play = ToolButton('media-playback-stop') stop_play.set_tooltip(_("Stop")) stop_play.set_accelerator(_('<ctrl>space')) stop_play.connect('clicked', self._stop_play_cb) stop_play.show() toolbar_box.toolbar.insert(stop_play, -1) # Blank space (separator) and Stop button at the end: separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show()
class EditToolbar(activity.EditToolbar): __gtype_name__ = 'EditToolbar' def __init__(self): activity.EditToolbar.__init__(self) separator = gtk.SeparatorToolItem() separator.set_draw(False) separator.set_expand(True) self.insert(separator, -1) separator.show() search_item = gtk.ToolItem() self._search_entry = gtk.Entry() self._search_entry.connect('activate', self._search_entry_activate_cb) width = int(gtk.gdk.screen_width() / 3) self._search_entry.set_size_request(width, -1) search_item.add(self._search_entry) self._search_entry.show() self.insert(search_item, -1) search_item.show() self._prev = ToolButton('go-previous-paired') self._prev.set_tooltip(_('Previous')) self._prev.props.sensitive = False self._prev.connect('clicked', self._find_prev_cb) self.insert(self._prev, -1) self._prev.show() self._next = ToolButton('go-next-paired') self._next.set_tooltip(_('Next')) self._next.props.sensitive = False self._next.connect('clicked', self._find_next_cb) self.insert(self._next, -1) self._next.show() def set_activity(self, activity): self.activity = activity def _search_entry_activate_cb(self, entry): current_page = self.activity.get_current_page() self.activity.find_begin(entry.props.text) self._update_find_buttons() def _find_changed_cb(self, page, spec): self._update_find_buttons() def _find_prev_cb(self, button): self.activity.find_previous() def _find_next_cb(self, button): self.activity.find_next() def _update_find_buttons(self): self._prev.props.sensitive = self.activity.can_find_previous() self._next.props.sensitive = self.activity.can_find_next()
def build_toolbar(self): toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) toolbar_box.show() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, -1) activity_button.show() separator1 = gtk.SeparatorToolItem() separator1.props.draw = True separator1.set_expand(False) toolbar_box.toolbar.insert(separator1, -1) separator1.show() item1 = gtk.ToolItem() label1 = gtk.Label() label1.set_text(_('Levels') + ' ') item1.add(label1) toolbar_box.toolbar.insert(item1, -1) item2 = gtk.ToolItem() levels = (_('Cross'), _('Cross 2'), #TRANS:'chimney' - the place where you make fire _('Hearth'), _('Arrow'), _('Pyramid'), _('Diamond'), _('Solitaire')) combo = Combo(levels) item2.add(combo) combo.connect('changed', self.change_combo) toolbar_box.toolbar.insert(item2, -1) separator2 = gtk.SeparatorToolItem() separator2.props.draw = True separator2.set_expand(False) toolbar_box.toolbar.insert(separator2, -1) separator2.show() sound_button = ToolButton('speaker-muted-100') sound_button.set_tooltip(_('Sound')) sound_button.connect('clicked', self.sound_control) toolbar_box.toolbar.insert(sound_button, -1) separator3 = gtk.SeparatorToolItem() separator3.props.draw = False separator3.set_expand(True) toolbar_box.toolbar.insert(separator3, -1) separator3.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.show_all()
def build_toolbar(self): toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) toolbar_box.show() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, -1) activity_button.show() separator1 = gtk.SeparatorToolItem() separator1.props.draw = True separator1.set_expand(False) toolbar_box.toolbar.insert(separator1, -1) separator1.show() item1 = gtk.ToolItem() label1 = gtk.Label() label1.set_text(_('Levels') + ' ') item1.add(label1) toolbar_box.toolbar.insert(item1, -1) item2 = gtk.ToolItem() levels = ( _('Cross'), _('Cross 2'), #TRANS:'chimney' - the place where you make fire _('Hearth'), _('Arrow'), _('Pyramid'), _('Diamond'), _('Solitaire')) combo = Combo(levels) item2.add(combo) combo.connect('changed', self.change_combo) toolbar_box.toolbar.insert(item2, -1) separator2 = gtk.SeparatorToolItem() separator2.props.draw = True separator2.set_expand(False) toolbar_box.toolbar.insert(separator2, -1) separator2.show() sound_button = ToolButton('speaker-muted-100') sound_button.set_tooltip(_('Sound')) sound_button.connect('clicked', self.sound_control) toolbar_box.toolbar.insert(sound_button, -1) separator3 = gtk.SeparatorToolItem() separator3.props.draw = False separator3.set_expand(True) toolbar_box.toolbar.insert(separator3, -1) separator3.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.show_all()
class MainToolbar(gtk.Toolbar): """ Main toolbar of the control panel """ __gtype_name__ = 'MainToolbar' __gsignals__ = { 'stop-clicked': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])), 'search-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([str])), } def __init__(self): gtk.Toolbar.__init__(self) self._add_separator() tool_item = gtk.ToolItem() self.insert(tool_item, -1) tool_item.show() self._search_entry = iconentry.IconEntry() self._search_entry.set_icon_from_name(iconentry.ICON_ENTRY_PRIMARY, 'system-search') self._search_entry.add_clear_button() self._search_entry.set_width_chars(25) self._search_entry.connect('changed', self.__search_entry_changed_cb) tool_item.add(self._search_entry) self._search_entry.show() self._add_separator(True) self.stop = ToolButton(icon_name='dialog-cancel') self.stop.set_tooltip(_('Done')) self.stop.connect('clicked', self.__stop_clicked_cb) self.stop.show() self.insert(self.stop, -1) self.stop.show() def get_entry(self): return self._search_entry def _add_separator(self, expand=False): separator = gtk.SeparatorToolItem() separator.props.draw = False if expand: separator.set_expand(True) else: separator.set_size_request(style.DEFAULT_SPACING, -1) self.insert(separator, -1) separator.show() def __search_entry_changed_cb(self, search_entry): self.emit('search-changed', search_entry.props.text) def __stop_clicked_cb(self, button): self.emit('stop-clicked')
class EditToolbar(activity.EditToolbar): def __init__(self, _parent): activity.EditToolbar.__init__(self) self._parent = _parent self.undo.connect('clicked', self.__undo_cb) self.redo.connect('clicked', self.__redo_cb) self.copy.connect('clicked', self.__copy_cb) self.paste.connect('clicked', self.__paste_cb) menu_item = MenuItem(_('Cut')) menu_item.connect('activate', self.__cut_cb) menu_item.show() self.copy.get_palette().menu.append(menu_item) self.insert(gtk.SeparatorToolItem(), -1) self.erase_button = ToolButton('edit-delete') self.erase_button.set_tooltip(_('Erase selected thought(s)')) self.erase_button.connect('clicked', self.__delete_cb) self.insert(self.erase_button, -1) self.show_all() self.clipboard = gtk.Clipboard() self.copy.child.set_sensitive(False) self.paste.child.set_sensitive(False) self.erase_button.set_sensitive(False) def __undo_cb(self, button): self._parent._undo.undo_action(None) def __redo_cb(self, button): self._parent._undo.redo_action(None) def __cut_cb(self, event): self._parent._main_area.cut_clipboard(self.clipboard) def __copy_cb(self, event): self._parent._main_area.copy_clipboard(self.clipboard) def __paste_cb(self, event): self._parent._main_area.paste_clipboard(self.clipboard) def __delete_cb(self, widget): self._stop_moving() self.stop_dragging() self._parent._main_area.delete_selected_elements() def stop_dragging(self): if self._parent._main_area.is_dragging(): self._parent._main_area.drag_menu_cb(self._sw, False) def _stop_moving(self): self._parent._main_area.move_mode = False
def build_colors_toolbar(self, toolbox): barra_colors = gtk.Toolbar() item1 = gtk.ToolItem() label1 = gtk.Label() label1.set_text(_('Color mode') + ' ') item1.add(label1) barra_colors.insert(item1, -1) item2 = gtk.ToolItem() modes = ('RGB', 'YUV', 'HSV') combo = Combo(modes) item2.add(combo) combo.connect('changed', self.change_combo) barra_colors.insert(item2, -1) separator1 = gtk.SeparatorToolItem() separator1.props.draw = True barra_colors.insert(separator1, -1) item_l = gtk.ToolItem() label4 = gtk.Label() label4.set_text(_('Brightness') + ' ') item_l.add(label4) barra_colors.insert(item_l, -1) item = gtk.ToolItem() brightness_spin = gtk.SpinButton() brightness_spin.set_range(-1, 255) brightness_spin.set_increments(1, 10) brightness_spin.props.value = int(self.brightness) brightness_spin.connect('notify::value', self.brightness_spin_change) item.add(brightness_spin) barra_colors.insert(item, -1) separator2 = gtk.SeparatorToolItem() separator2.props.draw = True barra_colors.insert(separator2, -1) item3 = gtk.ToolItem() label3 = gtk.Label() label3.set_text(_('Show threshold view')) item3.add(label3) barra_colors.insert(item3, -1) threshold_view = ToolButton('media-playback-stop') threshold_view.connect('clicked', self.threshold_view) threshold_view.set_tooltip(_('Yes')) barra_colors.insert(threshold_view, -1) barra_colors.show_all() colors_button = ToolbarButton(label=_('Colors'), page=barra_colors, icon_name='toolbar-colors') toolbox.toolbar.insert(colors_button, -1) colors_button.show()
class EditToolbar(activity.EditToolbar): def __init__(self, _parent): activity.EditToolbar.__init__(self) self._parent = _parent self.undo.connect('clicked', self.__undo_cb) self.redo.connect('clicked', self.__redo_cb) self.copy.connect('clicked', self.__copy_cb) self.paste.connect('clicked', self.__paste_cb) menu_item = MenuItem(_('Cut')) menu_item.connect('activate', self.__cut_cb) menu_item.show() self.copy.get_palette().menu.append(menu_item) self.insert(gtk.SeparatorToolItem(), -1) self.erase_button = ToolButton('edit-delete') self.erase_button.set_tooltip(_('Erase selected thought(s)')) self.erase_button.connect('clicked', self.__delete_cb) self.insert(self.erase_button, -1) self.show_all() self.clipboard = gtk.Clipboard() self.copy.child.set_sensitive(False) self.paste.child.set_sensitive(False) self.erase_button.set_sensitive(False) def __undo_cb(self, button): self._parent._undo.undo_action(None) def __redo_cb(self, button): self._parent._undo.redo_action(None) def __cut_cb(self, event): self._parent._main_area.cut_clipboard(self.clipboard) def __copy_cb(self, event): self._parent._main_area.copy_clipboard(self.clipboard) def __paste_cb(self, event): self._parent._main_area.paste_clipboard(self.clipboard) def __delete_cb(self, widget): self._stop_moving() self.stop_dragging() self._parent._main_area.delete_selected_elements() def stop_dragging(self): if self._parent._main_area.is_dragging(): self._parent._main_area.drag_menu_cb(self._sw, False) def _stop_moving(self): self._parent._main_area.move_mode = False
def __init__(self, handle): activity.Activity.__init__(self, handle) toolbar_box = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() change_color_button = ToolButton('toolbar-colors') change_color_button.set_tooltip(_('Click here to change the background color')) change_color_button.connect('clicked', self.on_change_color_clicked) toolbar_box.toolbar.insert(change_color_button, -1) change_color_button.show() 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() button = gtk.Button("Click here to change the background color") button.connect('clicked', self.on_change_color_clicked) button.set_flags(gtk.CAN_DEFAULT) button.grab_default() toolbar_box.add(button) button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() canvas = gtk.HBox(False, 0) color = gtk.gdk.color_parse("skyblue") self.d_area = gtk.DrawingArea() self.d_area.connect("expose-event", self.expose) self.d_area.modify_bg(gtk.STATE_NORMAL, color) canvas.add(self.d_area) self.set_canvas(canvas) self.show_all()
def Boton(tooltip=None, icon=None, connect=None): if icon != None: Boton = ToolButton(icon) else: Boton = ToolButton('gtk-missing-image') if tooltip != None: Boton.set_tooltip(tooltip) if connect != None: Boton.connect("clicked", connect) return Boton
class ImageToolbar(gtk.Toolbar): def __init__(self, toolbox, abiword_canvas, parent): gtk.Toolbar.__init__(self) self._toolbox = toolbox self._abiword_canvas = abiword_canvas self._parent = parent self._image = ToolButton('insert-image') self._image.set_tooltip(_('Insert Image')) self._image_id = self._image.connect('clicked', self._image_cb) self.insert(self._image, -1) self._image.show() self._abiword_canvas.connect('image-selected', self._image_selected_cb) ####btn salir del barrido del menu item self._btn_barrido_menu = ToolButton() self._btn_barrido_menu.set_tooltip(_('Salir \nMenú')) self._btn_barrido_menu_id = self._btn_barrido_menu.connect( 'clicked', self._btn_barrido_menu_cb) self.insert(self._btn_barrido_menu, -1) self._btn_barrido_menu.set_no_show_all(True) #self._btn_barrido_menu.show() # en realidad mostrar solo si esta barriendo def _btn_barrido_menu_cb(self, button): if (self._parent.BOTONESxBARRIDO_MENU_ITEM): self._parent.BOTONESxBARRIDO_MENU = False self._parent.BOTONESxBARRIDO_MENU_ITEM = False self._parent.BOTONESxBARRIDO = False # si le doy True va a ejectuar el escribir porque llama al metodo del eventbox #self._parent.chk_activarBarrido_botones_menu.emit("clicked") self._parent.chk_activarBarrido_botones.set_active(True) ####fin btn salir del barrido del menu item def _image_cb(self, button): chooser = ObjectChooser( _('Choose image'), self._parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT) try: result = chooser.run() if result == gtk.RESPONSE_ACCEPT: logging.debug('ObjectChooser: %r' % chooser.get_selected_object()) jobject = chooser.get_selected_object() if jobject and jobject.file_path: self._abiword_canvas.insert_image(jobject.file_path, True) finally: chooser.destroy() del chooser def _image_selected_cb(self, abi, b): if b: self._toolbox.set_current_toolbar(TOOLBAR_IMAGE) self._abiword_canvas.grab_focus() # hack: bad toolbox, bad!
def add_button(icon_name, tooltip, signal_name): button = ToolButton(icon_name) toolbar.add(button) def callback(source): self.emit(signal_name) button.connect('clicked', callback) button.set_tooltip(tooltip) return button
def __init__(self, parent, web_view): gobject.GObject.__init__(self) self._help = parent self._web_view = web_view self._back = ToolButton('go-previous-paired') self._back.set_tooltip(_('Back')) self._back.props.sensitive = False self._back.connect('clicked', self._go_back_cb) self.insert(self._back, -1) self._back.show() self._forward = ToolButton('go-next-paired') self._forward.set_tooltip(_('Forward')) self._forward.props.sensitive = False self._forward.connect('clicked', self._go_forward_cb) self.insert(self._forward, -1) self._forward.show() home = ToolButton('zoom-home') home.set_tooltip(_('Home')) home.connect('clicked', self._go_home_cb) self.insert(home, -1) home.show() separator = gtk.SeparatorToolItem() separator.set_draw(False) separator.set_expand(True) self.insert(separator, -1) separator.show() stop_button = ToolButton('activity-stop') stop_button.set_tooltip(_('Stop')) #stop_button.props.accelerator = '<Ctrl>Q' stop_button.connect('clicked', self.__stop_clicked_cb) self.insert(stop_button, -1) stop_button.show() if version < 0.838: self._listener = xpcom.server.WrapObject( EarlyListener(self), interfaces.nsIWebProgressListener) weak_ref = xpcom.client.WeakReference(self._listener) mask = interfaces.nsIWebProgress.NOTIFY_STATE_NETWORK | \ interfaces.nsIWebProgress.NOTIFY_LOCATION self._web_view.web_progress.addProgressListener( self._listener, mask) else: progress_listener = self._web_view.progress progress_listener.connect('location-changed', self._location_changed_cb) progress_listener.connect('loading-stop', self._loading_stop_cb)
def __init__(self, handle): gtk.Toolbar.__init__(self) self.handle = handle self._logger = logging.getLogger("activity-knut") self._logger.setLevel(logging.DEBUG) # First log handler: outputs to a file file_handler = logging.FileHandler("/home/wiktor/code/knut.log") file_formatter = logging.Formatter("%(message)s") file_handler.setFormatter(file_formatter) self._logger.addHandler(file_handler) # Tytuł pola tekstowego self.add_widget(gtk.Label("Kategoria: ")) # Pole tekstowe self.test_type = ComboBox() for id, name in BrowseToolbar.TEST_CATEGORIES.items(): self.test_type.append_item(id, name) self.test_type.set_active(0) self.add_widget(self.test_type) # Separator # separator = gtk.SeparatorToolItem() # separator.set_draw(True) # separator.set_size_request(50,25) # self.add_widget(separator) # Tytuł pola tekstowego self.add_widget(gtk.Label(" Szukaj w tytule: ")) # Pole tekstowe self.search_entry = gtk.Entry() self.search_entry.set_size_request(100, 25) # self.pass_entry.set_text('123123') self.add_widget(self.search_entry) # Przycisk pobierania download_button = ToolButton("download") download_button.set_tooltip("Przeglądaj testy") download_button.connect("clicked", self.list_download) self.add_widget(download_button) separator2 = gtk.SeparatorToolItem() separator2.set_draw(True) separator2.set_size_request(50, 25) self.add_widget(separator2) self.add_widget(gtk.Label("Hasło: ")) self.pass_entry = gtk.Entry() self.pass_entry.set_size_request(100, 25) # self.pass_entry.set_text('123123') self.add_widget(self.pass_entry)
def build_toolbar(self): self.max_participants = 1 toolbox = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbox.toolbar.insert(activity_button, -1) activity_button.show() pano_toolbar = toolbox.toolbar new_button = ToolButton('stock_refresh') new_button.set_tooltip(_('New Panorama')) new_button.connect('clicked', self.new_event) pano_toolbar.insert(new_button, -1) new_button.show() capture_button = ToolButton('add_capture') capture_button.set_tooltip(_('Add a capture to the Panorama')) capture_button.connect('clicked', self.capture_event) pano_toolbar.insert(capture_button, -1) capture_button.show() stitch_button = ToolButton('format-columns-triple') stitch_button.set_tooltip(_('Stitch Panorama')) stitch_button.connect('clicked', self.stitch_event) pano_toolbar.insert(stitch_button, -1) stitch_button.show() stiching_auto = ToolButton('media-playback-start') stiching_auto.set_tooltip(_('Enable auto-stitch')) stiching_auto.connect('clicked', self.change_stich) pano_toolbar.insert(stiching_auto, -1) save_button = ToolButton('filesave') save_button.set_tooltip(_('Save Panorama')) save_button.connect('clicked', self.save_event) pano_toolbar.insert(save_button, -1) save_button.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) pano_toolbar.insert(separator,-1) stop_button = StopButton(self) stop_button.props.accelerator = '<Ctrl>q' pano_toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbox) toolbox.show_all()
def enable_zoom_bestfit(self, on_zoom_bestfit): """ Enables zoom-to-best-fit support on this toolbar. @param on_zoom_bestfit: The callback function to be called when user wants to zoom to best extent. """ zoom_best_fit_btn = ToolButton('zoom-best-fit') zoom_best_fit_btn.set_tooltip(_('Zoom best fitting extent.')) zoom_best_fit_btn.connect('clicked', on_zoom_bestfit) zoom_best_fit_btn.show() self.insert(zoom_best_fit_btn, -1)
def __init__(self, abiword_canvas): gtk.Toolbar.__init__(self) self._abiword_canvas = abiword_canvas self._table = abiword.TableCreator() self._table.set_labels(_('Table'), _('Cancel')) self._table_id = self._table.connect('selected', self._table_cb) image = gtk.Image() image.set_from_icon_name('insert-table', -1) self._table.set_image(image) self._table.set_relief(gtk.RELIEF_NONE) tool_item = gtk.ToolItem() tool_item.add(self._table) self.insert(tool_item, -1) tool_item.show_all() self._table_rows_after = ToolButton('row-insert') self._table_rows_after.set_tooltip(_('Insert Row')) self._table_rows_after_id = self._table_rows_after.connect( \ 'clicked', self._table_rows_after_cb) self.insert(self._table_rows_after, -1) self._table_delete_rows = ToolButton('row-remove') self._table_delete_rows.set_tooltip(_('Delete Row')) self._table_delete_rows_id = self._table_delete_rows.connect( \ 'clicked', self._table_delete_rows_cb) self.insert(self._table_delete_rows, -1) self._table_cols_after = ToolButton('column-insert') self._table_cols_after.set_tooltip(_('Insert Column')) self._table_cols_after_id = self._table_cols_after.connect( \ 'clicked', self._table_cols_after_cb) self.insert(self._table_cols_after, -1) self._table_delete_cols = ToolButton('column-remove') self._table_delete_cols.set_tooltip(_('Delete Column')) self._table_delete_cols_id = self._table_delete_cols.connect( \ 'clicked', self._table_delete_cols_cb) self.insert(self._table_delete_cols, -1) separator = gtk.SeparatorToolItem() self.insert(separator, -1) image = ToolButton('insert-picture') image.set_tooltip(_('Insert Image')) self._image_id = image.connect('clicked', self._image_cb) self.insert(image, -1) self.show_all() self._abiword_canvas.connect('table-state', self._isTable_cb)
def __init__(self, abiword_canvas): gtk.Toolbar.__init__(self) self._abiword_canvas = abiword_canvas self._table = abiword.TableCreator() self._table.set_labels(_('Table'), _('Cancel')) self._table_id = self._table.connect('selected', self._table_cb) image = gtk.Image() image.set_from_icon_name('insert-table', -1) self._table.set_image(image) self._table.set_relief(gtk.RELIEF_NONE) tool_item = gtk.ToolItem() tool_item.add(self._table) self.insert(tool_item, -1) tool_item.show_all() self._table_rows_after = ToolButton('row-insert') self._table_rows_after.set_tooltip(_('Insert Row')) self._table_rows_after_id = self._table_rows_after.connect( \ 'clicked', self._table_rows_after_cb) self.insert(self._table_rows_after, -1) self._table_delete_rows = ToolButton('row-remove') self._table_delete_rows.set_tooltip(_('Delete Row')) self._table_delete_rows_id = self._table_delete_rows.connect( \ 'clicked', self._table_delete_rows_cb) self.insert(self._table_delete_rows, -1) self._table_cols_after = ToolButton('column-insert') self._table_cols_after.set_tooltip(_('Insert Column')) self._table_cols_after_id = self._table_cols_after.connect( \ 'clicked', self._table_cols_after_cb) self.insert(self._table_cols_after, -1) self._table_delete_cols = ToolButton('column-remove') self._table_delete_cols.set_tooltip(_('Delete Column')) self._table_delete_cols_id = self._table_delete_cols.connect( \ 'clicked', self._table_delete_cols_cb) self.insert(self._table_delete_cols, -1) separator = gtk.SeparatorToolItem() self.insert(separator, -1) image = ToolButton('insert-picture') image.set_tooltip(_('Insert Image')) self._image_id = image.connect('clicked', self._image_cb) self.insert(image, -1) self.show_all() self._abiword_canvas.connect('table-state', self._isTable_cb)
class Toolbar(gtk.Toolbar): def __init__(self, web_view): gobject.GObject.__init__(self) self._web_view = web_view self._back = ToolButton('go-previous-paired') self._back.set_tooltip(_('Back')) self._back.props.sensitive = False self._back.connect('clicked', self._go_back_cb) self.insert(self._back, -1) self._back.show() self._forward = ToolButton('go-next-paired') self._forward.set_tooltip(_('Forward')) self._forward.props.sensitive = False self._forward.connect('clicked', self._go_forward_cb) self.insert(self._forward, -1) self._forward.show() home = ToolButton('zoom-home') home.set_tooltip(_('Home')) home.connect('clicked', self._go_home_cb) self.insert(home, -1) home.show() progress_listener = self._web_view.progress progress_listener.connect('location-changed', self._location_changed_cb) progress_listener.connect('loading-stop', self._loading_stop_cb) def _location_changed_cb(self, progress_listener, uri): self.update_navigation_buttons() def _loading_stop_cb(self, progress_listener): self.update_navigation_buttons() def update_navigation_buttons(self): can_go_back = self._web_view.web_navigation.canGoBack self._back.props.sensitive = can_go_back can_go_forward = self._web_view.web_navigation.canGoForward self._forward.props.sensitive = can_go_forward def _go_back_cb(self, button): self._web_view.web_navigation.goBack() def _go_forward_cb(self, button): self._web_view.web_navigation.goForward() def _go_home_cb(self, button): self._web_view.load_uri(HOME)
def __init__(self, activity): self._activity = activity gtk.ToolItem.__init__(self) help_button = ToolButton('toolbar-help') help_button.set_tooltip(_('Ayuda')) self.add(help_button) help_button.show() self._palette = help_button.get_palette() help_button.connect('clicked', self.__help_button_clicked_cb)
def __init__(self, activity): self._activity = activity gtk.ToolItem.__init__(self) help_button = ToolButton('toolbar-help') help_button.set_tooltip(_('Ayuda')) self.add(help_button) help_button.show() self._palette = help_button.get_palette() help_button.connect('clicked', self.__help_button_clicked_cb)
class T2Activity(activity.Activity): def xois_clicked(self, widget, data=None): self.webview.load_uri('http://teach-teacher.ep.io/slides/1') def guide_clicked(self, widget, data=None): self.webview.load_uri('http://teach-teacher.ep.io/slides/17') def diary_clicked(self, widget, data=None): self.webview.load_uri('http://laptop.org/') def society_clicked(self, widget, data=None): self.webview.load_uri('http://147.47.120.20/~olpc_community/') def __init__(self, handle): print "running activity init", handle activity.Activity.__init__(self, handle) print "activity running" self.set_title('Teach Teacher') toolbox = activity.ActivityToolbox(self) self.set_toolbox(toolbox) toolbar = gtk.Toolbar() self.xois = ToolButton('computer-xo') self.xois.set_tooltip("T's XO") self.xois.connect('clicked', self.xois_clicked) toolbar.insert(self.xois, -1) self.xois.show() self.guide = ToolButton('go-next') self.guide.set_tooltip("T's Guide") self.guide.connect('clicked', self.guide_clicked) toolbar.insert(self.guide, -1) self.guide.show() self.diary = ToolButton('activity-journal') self.diary.set_tooltip("T's Diary") self.diary.connect('clicked', self.diary_clicked) toolbar.insert(self.diary, -1) self.diary.show() self.society = ToolButton('zoom-neighborhood') self.society.set_tooltip("T's Society") self.society.connect('clicked', self.society_clicked) toolbar.insert(self.society, -1) self.society.show() toolbar.show() toolbox.add_toolbar("Menu", toolbar) toolbox.show() self.webview = WebView() self.set_canvas(self.webview) self.webview.show() self.webview.load_uri('http://teach-teacher.ep.io/') print "AT END OF THE CLASS"
def __init__(self, activity): self._activity = activity self._current_palette = 'turtle' gtk.ToolItem.__init__(self) help_button = ToolButton('help-toolbar') help_button.set_tooltip(_('Help')) self.add(help_button) help_button.show() self._palette = help_button.get_palette() help_button.connect('clicked', self.__help_button_clicked_cb)
def __init__(self, activity): self._activity = activity self._current_palette = 'turtle' gtk.ToolItem.__init__(self) help_button = ToolButton('help-toolbar') help_button.set_tooltip(_('Help')) self.add(help_button) help_button.show() self._palette = help_button.get_palette() help_button.connect('clicked', self.__help_button_clicked_cb)
class EditToolbar(gtk.Toolbar): """Provides the standard edit toolbar for Activities. Members: undo -- the undo button redo -- the redo button copy -- the copy button paste -- the paste button separator -- A separator between undo/redo and copy/paste This class only provides the 'edit' buttons in a standard layout, your activity will need to either hide buttons which make no sense for your Activity, or you need to connect the button events to your own callbacks: ## Example from Read.activity: # Create the edit toolbar: self._edit_toolbar = EditToolbar(self._view) # Hide undo and redo, they're not needed self._edit_toolbar.undo.props.visible = False self._edit_toolbar.redo.props.visible = False # Hide the separator too: self._edit_toolbar.separator.props.visible = False # As long as nothing is selected, copy needs to be insensitive: self._edit_toolbar.copy.set_sensitive(False) # When the user clicks the button, call _edit_toolbar_copy_cb() self._edit_toolbar.copy.connect('clicked', self._edit_toolbar_copy_cb) # Add the edit toolbar: toolbox.add_toolbar(_('Edit'), self._edit_toolbar) # And make it visible: self._edit_toolbar.show() """ def __init__(self): gtk.Toolbar.__init__(self) self.undo = ToolButton('edit-undo') self.undo.set_tooltip(_('Undo')) self.insert(self.undo, -1) self.undo.show() self.redo = ToolButton('edit-redo') self.redo.set_tooltip(_('Redo')) self.insert(self.redo, -1) self.redo.show() self.separator = gtk.SeparatorToolItem() self.separator.set_draw(True) self.insert(self.separator, -1) self.separator.show() self.copy = ToolButton('edit-copy') self.copy.set_tooltip(_('Copy')) self.insert(self.copy, -1) self.copy.show() self.paste = ToolButton('edit-paste') self.paste.set_tooltip(_('Paste')) self.insert(self.paste, -1) self.paste.show()
def __init__(self, main_area): gtk.Toolbar.__init__(self) self._main_area = main_area tool = ToolButton('zoom-best-fit') tool.set_tooltip(_('Fit to window')) tool.set_accelerator(_('<ctrl>9')) tool.connect('clicked', self.__zoom_tofit_cb) self.insert(tool, -1) tool = ToolButton('zoom-original') tool.set_tooltip(_('Original size')) tool.set_accelerator(_('<ctrl>0')) tool.connect('clicked', self.__zoom_original_cb) self.insert(tool, -1) tool = ToolButton('zoom-out') tool.set_tooltip(_('Zoom out')) tool.set_accelerator(_('<ctrl>minus')) tool.connect('clicked', self.__zoom_out_cb) self.insert(tool, -1) tool = ToolButton('zoom-in') tool.set_tooltip(_('Zoom in')) tool.set_accelerator(_('<ctrl>equal')) tool.connect('clicked', self.__zoom_in_cb) self.insert(tool, -1) self.show_all()
def __init__(self, main_area): gtk.Toolbar.__init__(self) self._main_area = main_area tool = ToolButton('zoom-best-fit') tool.set_tooltip(_('Fit to window')) tool.set_accelerator(_('<ctrl>9')) tool.connect('clicked', self.__zoom_tofit_cb) self.insert(tool, -1) tool = ToolButton('zoom-original') tool.set_tooltip(_('Original size')) tool.set_accelerator(_('<ctrl>0')) tool.connect('clicked', self.__zoom_original_cb) self.insert(tool, -1) tool = ToolButton('zoom-out') tool.set_tooltip(_('Zoom out')) tool.set_accelerator(_('<ctrl>minus')) tool.connect('clicked', self.__zoom_out_cb) self.insert(tool, -1) tool = ToolButton('zoom-in') tool.set_tooltip(_('Zoom in')) tool.set_accelerator(_('<ctrl>equal')) tool.connect('clicked', self.__zoom_in_cb) self.insert(tool, -1) self.show_all()
class T2Activity(activity.Activity): def xois_clicked(self, widget, data=None): self.webview.load_uri('http://teach-teacher.ep.io/slides/1') def guide_clicked(self, widget, data=None): self.webview.load_uri('http://teach-teacher.ep.io/slides/17') def back_clicked(self, widget, data=None): if self.webview.get_web_navigation().canGoBack: self.webview.get_web_navigation().goBack() def home_clicked(self, widget, data=None): self.webview.load_uri('http://147.47.120.20/~tsquare/menu.php') def __init__(self, handle): print "running activity init", handle activity.Activity.__init__(self, handle) print "activity running" self.set_title('Teach Teacher') toolbox = activity.ActivityToolbox(self) self.set_toolbox(toolbox) toolbar = gtk.Toolbar() self.goBack = ToolButton('go-left') self.goBack.set_tooltip("Go Back") self.goBack.connect('clicked', self.back_clicked) toolbar.insert(self.goBack, -1) self.goBack.show() self.home = ToolButton('go-home') self.home.set_tooltip("Home") self.home.connect('clicked', self.home_clicked) toolbar.insert(self.home, -1) self.home.show() self.xois = ToolButton('computer-xo') self.xois.set_tooltip("T's XO") self.xois.connect('clicked', self.xois_clicked) # toolbar.insert(self.xois, -1) # self.xois.show() self.guide = ToolButton('go-next') self.guide.set_tooltip("T's Guide") self.guide.connect('clicked', self.guide_clicked) # toolbar.insert(self.guide, -1) # self.guide.show() toolbar.show() toolbox.add_toolbar("Menu", toolbar) toolbox.show() self.webview = WebView() self.set_canvas(self.webview) self.webview.show() self.webview.load_uri('http://147.47.120.20/~tsquare/menu.php') print "AT END OF THE CLASS"
def addButton(self, nameID, image1path, image2path, tooltip1, tooltip2, cb): button = ToolButton() log.info("addButtonIMAGE PATH ____ " + image1path ) button.image1 = gtk.Image() button.image1.set_from_file(image1path) button.image2 = gtk.Image() button.image2.set_from_file(image2path) button.image1.show() button.tooltip1, button.tooltip2 = tooltip1, tooltip2 button.set_icon_widget(button.image1) button.connect('clicked', cb) button.set_tooltip(_(button.tooltip1)) button.nameID = nameID self.toolbar_box.toolbar.insert(button, -1) button.show() self.nameID.update({nameID:button})
def addButton(self, nameID, image1path, image2path, tooltip1, tooltip2, cb): button = ToolButton() button.image1 = gtk.Image() button.image1.set_from_file(image1path) button.image2 = gtk.Image() button.image2.set_from_file(image2path) button.image1.show() button.nameID = nameID button.tooltip1, button.tooltip2 = tooltip1, tooltip2 button.set_icon_widget(button.image1) button.connect('clicked', cb) button.set_tooltip(_(button.tooltip1)) button.active = False self.insert(button, -1) button.show() return button
def __init__(self, title, bundle_path, document_path): gtk.Toolbar.__init__(self) self._add_separator() activity_bundle = ActivityBundle(bundle_path) file_name = activity_bundle.get_icon() if document_path is not None and os.path.exists(document_path): document_button = DocumentButton(file_name, document_path, title) document_button.connect('toggled', self.__button_toggled_cb, document_path) self.insert(document_button, -1) document_button.show() self._add_separator() if bundle_path is not None and os.path.exists(bundle_path): activity_button = RadioToolButton() icon = Icon(file=file_name, icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR, fill_color=style.COLOR_TRANSPARENT.get_svg(), stroke_color=style.COLOR_WHITE.get_svg()) activity_button.set_icon_widget(icon) icon.show() if document_path is not None: activity_button.props.group = document_button activity_button.props.tooltip = _('Activity Bundle Source') activity_button.connect('toggled', self.__button_toggled_cb, bundle_path) self.insert(activity_button, -1) activity_button.show() self._add_separator() text = _('View source: %r') % title label = gtk.Label() label.set_markup('<b>%s</b>' % text) label.set_alignment(0, 0.5) self._add_widget(label) self._add_separator(True) stop = ToolButton(icon_name='dialog-cancel') stop.set_tooltip(_('Close')) stop.connect('clicked', self.__stop_clicked_cb) stop.show() self.insert(stop, -1) stop.show()
def __init__(self): gtk.HBox.__init__(self) self.toolbar = VTray() copy = ToolButton("edit-copy") copy.set_tooltip('Copy') copy.connect("clicked", self.__copy_cb) copy.show() self.toolbar.add_item(copy, -1) paste = ToolButton("edit-paste") paste.set_tooltip("Paste") paste.connect("clicked", self.__paste_cb) paste.show() self.toolbar.add_item(paste, -1) fgcolor = ColorToolButton() fgcolor.get_child()._title = "Font Color" self.toolbar.add_item(fgcolor, -1) fgcolor.connect('notify::color', self._fgcolor_cb) fgcolor.show_all() bgcolor = ColorToolButton() bgcolor.get_child()._title = "Background Color" bgcolor.connect('notify::color', self._bgcolor_cb) self.toolbar.add_item(bgcolor, -1) bgcolor.show_all() self.console = Console() self.console.set_bgcolor(gtk.gdk.color_parse("#FFFFFF")) self.console.set_fgcolor(gtk.gdk.color_parse("#000000")) bgcolor.set_color(gtk.gdk.color_parse("#FFFFFF")) fgcolor.set_color(gtk.gdk.color_parse("#000000")) self.console.show() font = ToolButton("format-text") font.set_tooltip("Console Font") fontselection = gtk.FontSelection() fontselection.get_family_list().get_selection().connect("changed", self.update_font, fontselection) fontselection.get_face_list().get_selection().connect("changed", self.update_font, fontselection) fontselection.get_size_entry().connect("changed", self.update_font, fontselection) fontselection.get_size_entry().connect("activate", self.update_font, fontselection) fontselection.show() font.props.palette.set_content(fontselection) fontselection.set_font_name("Monospace Regular 10") font.show() self.toolbar.add_item(font, -1) reset = ToolButton("view-refresh") reset.set_tooltip("Reset Console") reset.connect("clicked", self.reset) reset.show() self.toolbar.add_item(reset, -1) self.toolbar.show() self.pack_start(self.toolbar, False, True, 0) self.console.run_command("python") self.pack_start(self.console)
def __init__(self, icon_name, title): super(_DialogToolbar, self).__init__() if icon_name is not None: sep = gtk.SeparatorToolItem() sep.set_draw(False) self._add_widget(sep) icon = Icon() icon.set_from_icon_name(icon_name, gtk.ICON_SIZE_LARGE_TOOLBAR) self._add_widget(icon) label = gtk.Label(' ' + title) self._add_widget(label) self._add_separator(expand=True) stop = ToolButton(icon_name='dialog-cancel') stop.set_tooltip('Salir') stop.connect('clicked', self._stop_clicked_cb) self.add(stop)
def button_factory(icon_name, toolbar, callback, cb_arg=None, tooltip=None, accelerator=None): '''Factory for making toolbar buttons''' button = ToolButton(icon_name) if tooltip is not None: button.set_tooltip(tooltip) button.props.sensitive = True if accelerator is not None: button.props.accelerator = accelerator if cb_arg is not None: button.connect('clicked', callback, cb_arg) else: button.connect('clicked', callback) if hasattr(toolbar, 'insert'): # the main toolbar toolbar.insert(button, -1) else: # or a secondary toolbar toolbar.props.page.insert(button, -1) button.show() return button
class RecordToolbar(gtk.Toolbar): def __init__(self, jam): gtk.Toolbar.__init__(self) def _insertSeparator(x=1): for i in range(x): self.separator = gtk.SeparatorToolItem() self.separator.set_draw(True) self.insert(self.separator, -1) self.separator.show() #self.toolbox = toolbox self.jam = jam if Config.FEATURES_MIC: self.micRec1Button = ToolButton('rec1') self.micRec1Button.connect('clicked', self.jam.micRec, 'mic1') self.insert(self.micRec1Button, -1) self.micRec1Button.show() self.micRec1Button.set_tooltip(_('Record microphone into slot 1')) self.micRec2Button = ToolButton('rec2') self.micRec2Button.connect('clicked', self.jam.micRec, 'mic2') self.insert(self.micRec2Button, -1) self.micRec2Button.show() self.micRec2Button.set_tooltip(_('Record microphone into slot 2')) self.micRec3Button = ToolButton('rec3') self.micRec3Button.connect('clicked', self.jam.micRec, 'mic3') self.insert(self.micRec3Button, -1) self.micRec3Button.show() self.micRec3Button.set_tooltip(_('Record microphone into slot 3')) self.micRec4Button = ToolButton('rec4') self.micRec4Button.connect('clicked', self.jam.micRec, 'mic4') self.insert(self.micRec4Button, -1) self.micRec4Button.show() self.micRec4Button.set_tooltip(('Record microphone into slot 4')) _insertSeparator() if Config.FEATURES_NEWSOUNDS: self._loopSettingsPalette = LoopSettingsPalette( _('Add new Sound'), self.jam) self.loopSetButton = ToggleToolButton('loop') self.loopSetButton.set_palette(self._loopSettingsPalette) self.insert(self.loopSetButton, -1) self.loopSetButton.show() self.show_all()
def build_toolbar(self): """Build our Activity toolbar for the Sugar system.""" toolbar_box = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) separator.show() easier_button = ToolButton('create-easier') easier_button.set_tooltip(_('Easier level')) easier_button.connect('clicked', self._easier_button_cb) toolbar_box.toolbar.insert(easier_button, -1) harder_button = ToolButton('create-harder') harder_button.set_tooltip(_('Harder level')) harder_button.connect('clicked', self._harder_button_cb) toolbar_box.toolbar.insert(harder_button, -1) separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_size_request(0, -1) separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show_all() self.connect("destroy", self.__stop_pygame) return toolbar_box
class ViewToolbar(gtk.Toolbar): __gtype_name__ = 'ViewToolbar' __gsignals__ = { 'needs-update-size': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])), 'go-fullscreen': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])) } def __init__(self): gtk.Toolbar.__init__(self) self.fullscreen = ToolButton('view-fullscreen') self.fullscreen.set_tooltip(_('Fullscreen')) self.fullscreen.connect('clicked', self.fullscreen_cb) self.insert(self.fullscreen, -1) self.fullscreen.show() def fullscreen_cb(self, button): self.emit('go-fullscreen')
def __init__(self): gtk.Toolbar.__init__(self) self._metadata = None self._temp_file_path = None self._resume = ToolButton('activity-start') self._resume.connect('clicked', self._resume_clicked_cb) self.add(self._resume) self._resume.show() client = gconf.client_get_default() color = XoColor(client.get_string('/desktop/sugar/user/color')) self._copy = ToolButton() icon = Icon(icon_name='edit-copy', xo_color=color) self._copy.set_icon_widget(icon) icon.show() self._copy.set_tooltip(_('Copy to')) self._copy.connect('clicked', self._copy_clicked_cb) self.add(self._copy) self._copy.show() self._duplicate = ToolButton() icon = Icon(icon_name='edit-duplicate', xo_color=color) self._duplicate.set_icon_widget(icon) self._duplicate.set_tooltip(_('Duplicate')) self._duplicate.connect('clicked', self._duplicate_clicked_cb) self.add(self._duplicate) separator = gtk.SeparatorToolItem() self.add(separator) separator.show() erase_button = ToolButton('list-remove') erase_button.set_tooltip(_('Erase')) erase_button.connect('clicked', self._erase_button_clicked_cb) self.add(erase_button) erase_button.show()
class ViewToolbar(gtk.Toolbar): __gsignals__ = { 'go-fullscreen': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])) } def __init__(self): gtk.Toolbar.__init__(self) self._zoom_out = ToolButton('zoom-out') self._zoom_out.set_tooltip(_('Zoom out')) self._zoom_out.connect('clicked', self._zoom_out_cb) self.insert(self._zoom_out, -1) self._zoom_out.props.sensitive = False self._zoom_out.show() self._zoom_in = ToolButton('zoom-in') self._zoom_in.set_tooltip(_('Zoom in')) self._zoom_in.connect('clicked', self._zoom_in_cb) self.insert(self._zoom_in, -1) self._zoom_in.props.sensitive = True self._zoom_in.show() spacer = gtk.SeparatorToolItem() spacer.props.draw = False self.insert(spacer, -1) spacer.show() self._fullscreen = ToolButton('view-fullscreen') self._fullscreen.set_tooltip(_('Fullscreen')) self._fullscreen.connect('clicked', self._fullscreen_cb) self.insert(self._fullscreen, -1) self._fullscreen.show() def _zoom_in_cb(self, button): self._zoom_in.props.sensitive = False self._zoom_out.props.sensitive = True self.activity.zoom_to_width() def _zoom_out_cb(self, button): self._zoom_in.props.sensitive = True self._zoom_out.props.sensitive = False self.activity.zoom_to_fit() def enable_zoom_in(self): self._zoom_in.props.sensitive = True self._zoom_out.props.sensitive = False def enable_zoom_out(self): self._zoom_in.props.sensitive = False self._zoom_out.props.sensitive = True def set_activity(self, activity): self.activity = activity def _fullscreen_cb(self, button): self.emit('go-fullscreen')
class WebToolbar(gtk.Toolbar): def __init__(self,browser): from sugar.graphics.toolbutton import ToolButton self.logger = logging.getLogger("gvr.Widgets.WebToolbar") gtk.Toolbar.__init__(self) self._browser = browser self._back = ToolButton('go-previous') self._back.set_tooltip(_('Go back one page')) self._back.connect('clicked', self._go_back_cb) self.insert(self._back, -1) self._back.show() self._forw = ToolButton('go-next') self._forw.set_tooltip(_('Go one page forward')) self._forw.connect('clicked', self._go_forward_cb) self.insert(self._forw, -1) self._forw.show() def _go_forward_cb(self,button): self._browser.web_navigation.goForward() def _go_back_cb(self,button): self._browser.web_navigation.goBack()
class Toolbar(gtk.Toolbar): def __init__(self, web_view): gobject.GObject.__init__(self) self._web_view = web_view self._back = ToolButton("go-previous-paired") self._back.set_tooltip(_("Back")) self._back.props.sensitive = False self._back.connect("clicked", self._go_back_cb) self.insert(self._back, -1) self._back.show() self._forward = ToolButton("go-next-paired") self._forward.set_tooltip(_("Forward")) self._forward.props.sensitive = False self._forward.connect("clicked", self._go_forward_cb) self.insert(self._forward, -1) self._forward.show() self._home = ToolButton("go-home") self._home.set_tooltip(_("Home")) self._home.connect("clicked", self._go_home_cb) self.insert(self._home, -1) self._home.show() progress_listener = self._web_view.progress progress_listener.connect("location-changed", self._location_changed_cb) progress_listener.connect("loading-stop", self._loading_stop_cb) def _location_changed_cb(self, progress_listener, uri): self.update_navigation_buttons() def _loading_stop_cb(self, progress_listener): self.update_navigation_buttons() def update_navigation_buttons(self): can_go_back = self._web_view.web_navigation.canGoBack self._back.props.sensitive = can_go_back can_go_forward = self._web_view.web_navigation.canGoForward self._forward.props.sensitive = can_go_forward def _go_back_cb(self, button): self._web_view.web_navigation.goBack() def _go_forward_cb(self, button): self._web_view.web_navigation.goForward() def _go_home_cb(self, button): self._web_view.load_uri(HOME)
class ViewToolbar(gtk.Toolbar): def __init__(self, activity): gtk.Toolbar.__init__(self) self._activity = activity self._browser = self._activity._web_view self.zoomout = ToolButton('zoom-out') self.zoomout.set_tooltip(_('Zoom out')) self.zoomout.connect('clicked', self.__zoomout_clicked_cb) self.insert(self.zoomout, -1) self.zoomout.show() self.zoomin = ToolButton('zoom-in') self.zoomin.set_tooltip(_('Zoom in')) self.zoomin.connect('clicked', self.__zoomin_clicked_cb) self.insert(self.zoomin, -1) self.zoomin.show() self.separator = gtk.SeparatorToolItem() self.separator.set_draw(True) self.insert(self.separator, -1) self.separator.show() self.fullscreen = ToolButton('view-fullscreen') self.fullscreen.set_tooltip(_('Fullscreen')) self.fullscreen.connect('clicked', self.__fullscreen_clicked_cb) self.insert(self.fullscreen, -1) self.fullscreen.show() def __zoomin_clicked_cb(self, button): self._browser.zoom_in() def __zoomout_clicked_cb(self, button): self._browser.zoom_out() def __fullscreen_clicked_cb(self, button): self._activity.fullscreen()
class ViewToolbar(gtk.Toolbar): __gtype_name__ = 'ViewToolbar' __gsignals__ = { 'needs-update-size': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])), 'go-fullscreen': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])) } def __init__(self): gtk.Toolbar.__init__(self) self.zoom_out = ToolButton('zoom-out') self.zoom_out.set_tooltip(_('Zoom out')) self.insert(self.zoom_out, -1) self.zoom_out.show() self.zoom_in = ToolButton('zoom-in') self.zoom_in.set_tooltip(_('Zoom in')) self.insert(self.zoom_in, -1) self.zoom_in.show() spacer = gtk.SeparatorToolItem() spacer.props.draw = False self.insert(spacer, -1) spacer.show() self.fullscreen = ToolButton('view-fullscreen') self.fullscreen.set_tooltip(_('Fullscreen')) self.fullscreen.connect('clicked', self.fullscreen_cb) self.insert(self.fullscreen, -1) self.fullscreen.show() def fullscreen_cb(self, button): self.emit('go-fullscreen')
class Activity(sugar.activity.activity.Activity): def __init__(self, handle): super(Activity, self).__init__(handle) self.paused = False watch = gtk.gdk.Cursor(gtk.gdk.WATCH) self.window.set_cursor(watch) self.p = gtk.VPaned() self.p.connect("notify::position", self.redraw) self.box = gtk.Notebook() self.p.pack2(self.box) self.p.show() self.box.set_show_tabs(False) self.splash = gtk.Image() pixbuf = gtk.gdk.pixbuf_new_from_file("images/splash_comodo.png") screen = self.window.get_screen() width, height = screen.get_width(), screen.get_height() - style.GRID_CELL_SIZE pixbuf = pixbuf.scale_simple(width, height, gtk.gdk.INTERP_BILINEAR) self.splash.set_from_pixbuf(pixbuf) self.splash.show() eb = gtk.EventBox() eb.add(self.splash) eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white")) eb.show() self.box.append_page(eb, gtk.Label("Inicio")) self._pygamecanvas = sugargame2.canvas.PygameCanvas(self) self._pygamecanvas.set_flags(gtk.EXPAND) self._pygamecanvas.set_flags(gtk.FILL) self.connect("visibility-notify-event", self.redraw) self._pygamecanvas.set_events(gtk.gdk.BUTTON_PRESS_MASK) self._pygamecanvas.connect("button-press-event", self._pygamecanvas.grab_focus) self.box.append_page(self._pygamecanvas, gtk.Label("Juego")) self.box.show() self.set_canvas(self.p) gobject.timeout_add(300, self.pump) gobject.timeout_add(2000, self.init_interpreter) #gobject.timeout_add(1000, self.build_editor) gobject.timeout_add(1500, self.check_modified) self.build_toolbar() self.credits = None self.editor = None #self.reader = None self._pygamecanvas.run_pygame(self.run_game) def redraw(self, widget=None, b=None, c=None): scene = spyral.director.get_scene() if scene: scene.redraw() def alert(self, title=None, text=None, delay=5): alert = NotifyAlert(delay) alert.props.title = title alert.props.msg = text self.add_alert(alert) alert.connect('response', self._alert_ok) alert.show() def _alert_ok(self, alert, *args): self.remove_alert(alert) def check_modified(self): if self.box.current_page()==2: if not self.save_button.get_sensitive(): if self.editor.modificado(): self.save_button.set_sensitive(True) return False return True def pump(self): # Esto es necesario porque sino pygame acumula demasiados eventos. pygame.event.pump() def focus_interpreter(self, widget, event): self._interpreter.text.grab_focus() return True def init_interpreter(self): # diferido unos segundos para evitar ver errores superfluos al iniciar self._interpreter = GTKInterpreterConsole(self.redraw) self._interpreter.text.connect('button-press-event', self.focus_interpreter) self.p.pack1(self._interpreter) return False def open_file(self, widget, path): if path: if not os.path.isdir(path): self.editor.open_file(widget, path) def save_file(self, widget): if self.editor.modificado(): self.save_button.set_sensitive(False) self.editor.save_file() filename = self.editor.current_file() self.alert(filename, "Archivo guardado.") gobject.timeout_add(1500, self.check_modified) def build_editor(self): dir_real = os.getcwd() f = os.path.realpath(JUEGO.__file__) f = "." + f.replace(dir_real ,"") # todo esto para obtener una ruta relativa f = f.rstrip("c") # en caso que sea .pyc compilado self.h = gtk.HPaned() self.tree = FileViewer(".", os.path.basename(f)) self.tree.connect("file-selected", self.open_file) self.tree.show() self.h.pack1(self.tree) self.box.append_page(self.h, gtk.Label("Editor")) if False: #os.path.isfile("/usr/bin/gvim"): # Si podemos, lo hacemos self.socket = gtk.Socket() self.socket.show() self.h.pack2(self.socket) sock_id = str(self.socket.get_id()) self.editor = VimSourceView(sock_id) if not self.editor.bufInfo.bufferList: f = JUEGO.__file__ if f.endswith("pyc"): f = f[:-1] self.open_file(None, f) else: self.editor = SourceView() scroller = gtk.ScrolledWindow() scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scroller.add(self.editor) scroller.show() self.h.pack2(scroller) self.editor.show() self.h.show() self.open_file(None, f) def build_reader(self): self.reader = webkit.WebView() curdir = os.getcwd() self.reader.load_uri("file://%s/docs/index.html" % curdir) self.box.append_page(self.reader, gtk.Label("Lector")) self.reader.show() def build_toolbar(self): toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) toolbar_box.show() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, -1) activity_button.show() tool_group = None self.game_button = RadioToolButton() self.game_button.props.icon_name = 'gamecanvas' self.game_button.set_tooltip(_('Juego')) self.game_button.accelerator = "<Ctrl>1" self.game_button.props.group = tool_group self.game_button.connect('clicked', self.show_game) toolbar_box.toolbar.insert(self.game_button, -1) self.game_button.show() tool_group = self.game_button button = RadioToolButton() button.props.icon_name = 'view-source' button.set_tooltip(_('Editor')) button.accelerator = "<Ctrl>2" button.props.group = tool_group button.connect('clicked', self.show_editor) toolbar_box.toolbar.insert(button, -1) button.show() self.save_button = ToolButton('dialog-ok') self.save_button.set_tooltip(_('Guardar')) self.save_button.accelerator = "<Ctrl>s" self.save_button.connect('clicked', self.save_file) self.save_button.set_sensitive(False) toolbar_box.toolbar.insert(self.save_button, -1) self.save_button.show() separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) separator.show() button = ToolButton('system-restart') button.set_tooltip(_('Reiniciar juego')) button.accelerator = "<Alt><Shift>r" button.connect('clicked', self.restart_game) toolbar_box.toolbar.insert(button, -1) button.show() self.editor_button = ToolButton('sources') self.editor_button.set_tooltip(_('Consola')) self.editor_button.accelerator = "<Ctrl>grave" self.editor_button.connect('clicked', self.toggle_console) toolbar_box.toolbar.insert(self.editor_button, -1) self.editor_button.show() separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) separator.show() button = helpbutton.HelpButton(self) toolbar_box.toolbar.insert(button, -1) button.show() button = ToolButton() button.props.icon_name = 'activity-about' button.set_tooltip(_('Acerca de')) button.accelerator = "<Ctrl>i" button.connect('clicked', self.run_credits) toolbar_box.toolbar.insert(button, -1) button.show() # Blank space (separator) and Stop button at the end: separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() def run_game(self): spyral.director.init((0,0), fullscreen=False, max_fps=30) self.game = JUEGO.Juego(self, callback=self.game_ready) self.box.connect("switch-page", self.redraw) spyral.director.push(self.game) self.start() def run_credits(self, widget): if not (spyral.director.get_scene()==self.credits): self.credits = game.credits.Creditos(self.game.size) spyral.director.push(self.credits) def start(self): try: spyral.director.run(sugar = True) except AttributeError as detail: detail2 = traceback.format_exc() self.box.set_page(0) self.alert( detail2, "Spyral se ha detenido abruptamente.", 60) def show_game(self, widget): self.box.set_page(1) self.redraw() def show_editor(self, widget): if not self.editor: self.build_editor() self.box.set_page(2) self.redraw() def show_reader(self, widget): if not self.reader: self.build_reader() self.box.set_page(3) self.redraw() def restart_game(self, widget): global JUEGO import objetos try: objetos.reset() except AttributeError: pass self.box.set_page(0) watch = gtk.gdk.Cursor(gtk.gdk.WATCH) self.window.set_cursor(watch) JUEGO = reload(JUEGO) self.game = JUEGO.Juego(self, callback=self.game_ready) spyral.director.replace(self.game) self.start() def game_ready(self, widget = None): self.game_button.set_active(True) self.box.set_page(1) self._pygamecanvas.grab_focus() self.window.set_cursor(None) def read_file(self, file_path): pass def write_file(self, file_path): pass def can_close(self): if self.editor: self.editor.close() self.box.set_page(0) try: spyral.director.quit() except spyral.exceptions.GameEndException: pass finally: return True def toggle_console(self, e): if self._interpreter.props.visible: self._interpreter.hide() self._pygamecanvas.grab_focus() else: self.p.set_position(160) self._interpreter.show() self._interpreter.text.grab_focus() self.redraw() def animate_console(self): easing = spyral.easing.Linear(0,160) self.p.set_position(0)