def __init__(self, handle): """Set up the Expresar activity.""" activity.Activity.__init__(self, handle) # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() 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.set_toolbar_box(toolbar_box) toolbar_box.show() self._pressButton_counter = 0 self.listaSecciones = [] parsear(self.listaSecciones) self.lenghtSecciones = int(math.sqrt(len(self.listaSecciones))) self.hbox = gtk.HBox() self.table = gtk.Table(LENGHT, LENGHT, True) self.indiceSecciones = 0 self.create_interior(self.table, self.listaSecciones) self.set_canvas(self.hbox) self.hbox.show() self._button_index = 0 self._button_index_2 = 0 self._indice = 0 self._button_list = [] gobject.timeout_add(DELAY, self.__timeout_cb, self.table)
def __init__(self, handle): activity.Activity.__init__(self, handle, False) accel_group = gtk.AccelGroup() self.add_accel_group(accel_group) self.menu = Menu(accel_group) toolbar = ToolbarBox() item = gtk.ToolItem() item.set_expand(True) item.add(self.menu) toolbar.toolbar.insert(item, -1) separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar.toolbar.insert(separator, -1) separator.show() toolbar.toolbar.insert(StopButton(self), -1) self.set_toolbar_box(toolbar) self.updater = False self.sourceview = False self.base_panel = BasePanel() self.set_canvas(self.base_panel) self.show_all() self.maximize() self.menu.connect('accion_ver', self.__ejecutar_accion_ver) self.menu.connect('accion_codigo', self.__ejecutar_accion_codigo) self.menu.connect('accion_proyecto', self.__ejecutar_accion_proyecto) self.menu.connect('accion_archivo', self.__ejecutar_accion_archivo) self.base_panel.connect("update", self.__new_handler) self.connect("destroy", self.__exit)
def build_toolbar(self): toolbar_box = ToolbarBox() 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(True) toolbar_box.toolbar.insert(separator, -1) stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show_all()
def __init__(self, handle): """Set up the HelloWorld activity.""" activity.Activity.__init__(self, handle) # we do not have collaboration features # make the share option insensitive self.max_participants = 1 # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) share_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) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() # label with the text, make the string translatable self.ser = serial.Serial('/dev/ttyACM0', 9600) hbox = gtk.HBox()
def __init__(self, handle): activity.Activity.__init__(self, handle) # we do not have collaboration features # make the share option insensitive self.max_participants = 1 # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, 0) toolbar_box.toolbar.insert(gtk.SeparatorToolItem(), -1) self.image_viewer = ImageCollectionViewer(False) prev_bt = ToolButton("go-previous-paired") prev_bt.connect("clicked", self.image_viewer.prev_anim_clicked_cb, None) toolbar_box.toolbar.insert(prev_bt, -1) next_bt = ToolButton("go-next-paired") next_bt.connect("clicked", self.image_viewer.next_anim_clicked_cb, None) toolbar_box.toolbar.insert(next_bt, -1) separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) self.set_toolbar_box(toolbar_box) toolbar_box.show_all() self.modify_bg(gtk.STATE_NORMAL, style.COLOR_WHITE.get_gdk_color()) self.set_canvas(self.image_viewer)
def __init__(self, handle): activity.Activity.__init__(self, handle) self._name = handle self._main_view = gtk.VBox() self.num = mynum.Numbers() if NEW_TOOLBARS: toolbar_box = ToolbarBox() 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() else: toolbox = ActivityToolbox(self) self.set_toolbox(toolbox) toolbox.show() if self.num.widget.parent: self.num.widget.parent.remove(self.num.widget) self._main_view.pack_start(self.num.widget) self.num.widget.show() self._main_view.show() self.set_canvas(self._main_view) self.show_all()
def __init__(self, handle): """Set up the LiveDemo activity.""" activity.Activity.__init__(self, handle) # we do not have collaboration features # make the share option insensitive self.max_participants = 1 # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() activity_button = ActivityButton(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() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() # box principal main_box = gtk.VBox() self.init_gui(main_box) self.set_canvas(main_box) self.set_toolbar_box(toolbar_box) self.set_canvas(main_box) self.set_toolbar_box(toolbar_box) toolbar_box.show() main_box.show_all() self.__path = os.path.dirname(os.path.abspath(__file__)) self.__recognizer = helper.RecognitionHelper(self.__path) self.__recognizer.listen(self.final_result) self.__recognizer.start_listening()
def build_toolbar(self): toolbox = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbox.toolbar.insert(activity_button, -1) activity_button.show() barra = toolbox.toolbar separator2 = gtk.SeparatorToolItem() separator2.props.draw = False separator2.set_expand(True) barra.insert(separator2, -1) stop_button = StopButton(self) stop_button.props.accelerator = '<Ctrl>q' barra.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbox) toolbox.show_all()
def __init__(self, handle): """Set up the HelloWorld activity.""" activity.Activity.__init__(self, handle) # Change the following number to change max participants self.max_participants = 1 toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) share_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) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() # Change the following text to change the message (Default: 'Hello World!' label = gtk.Label(_("Hello World!")) self.set_canvas(label) label.show()
def __init__(self, handle): """Set up the PiensaEscribe activity.""" activity.Activity.__init__(self, handle) # we do not have collaboration features # make the share option insensitive self.max_participants = 1 # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) share_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) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() self.createGUI()
def _setup_toolbars(self): ''' Add buttons to toolbars ''' custom_toolbar = gtk.Toolbar() if HAS_TOOLBARBOX: toolbox = ToolbarBox() self.toolbar = toolbox.toolbar activity_button = ActivityToolbarButton(self) self.toolbar.insert(activity_button, 0) activity_button.show() custom_toolbar_button = ToolbarButton( label=_('Custom'), page=custom_toolbar, icon_name='view-source') custom_toolbar.show() self.toolbar.insert(custom_toolbar_button, -1) custom_toolbar_button.show() self._load_standard_buttons(self.toolbar) separator_factory(self.toolbar, expand=True, visible=False) stop_button = StopButton(self) stop_button.props.accelerator = _('<Ctrl>Q') self.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbox(toolbox) toolbox.show() else: toolbox = activity.ActivityToolbox(self) self.set_toolbox(toolbox) self.toolbar = gtk.Toolbar() toolbox.add_toolbar(_('Project'), self.toolbar) toolbox.add_toolbar(_('Custom'), custom_toolbar) self._load_standard_buttons(self.toolbar) self._load_custom_buttons(custom_toolbar)
def build_toolbar(self): # Creates the Toolbox. It contains the Activity Toolbar, which is the # bar that appears on every Sugar window and contains essential # functionalities, such as the 'Collaborate' and 'Close' buttons. toolbox = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbox.toolbar.insert(activity_button, -1) activity_button.show() # Blank space (separator) and Stop button at the end: separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbox.toolbar.insert(separator, -1) separator.show() # Activity stop button stop_button = StopButton(self) toolbox.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbox(toolbox) toolbox.show()
def __init__(self, handle): ''' Init canvas, toolbars, etc. The toolbars are in sensor_toolbar.py and toolbar_side.py The audio controls are in audiograb.py The rendering happens in drawwaveform.py Logging is in journal.py ''' activity.Activity.__init__(self, handle) self.mode_images = {} self.mode_images['sound'] = gtk.gdk.pixbuf_new_from_file_at_size( os.path.join(ICONS_DIR, 'media-audio.svg'), 45, 45) self.mode_images['resistance'] = gtk.gdk.pixbuf_new_from_file_at_size( os.path.join(ICONS_DIR, 'resistance.svg'), 45, 45) self.mode_images['voltage'] = gtk.gdk.pixbuf_new_from_file_at_size( os.path.join(ICONS_DIR, 'voltage.svg'), 45, 45) self.icon_colors = self.get_icon_colors_from_sugar() self.stroke_color, self.fill_color = self.icon_colors.split(',') self.nick = self.get_nick_from_sugar() self.CONTEXT = '' self.adjustmentf = None # Freq. slider control self.new_recording = False self.session_id = 0 self.read_metadata() self._active = True self._dsobject = None self.connect('notify::active', self._notify_active_cb) self.connect('destroy', self.on_quit) self.data_logger = DataLogger(self) self.hw = _get_hardware() log.debug('running on %s hardware' % (self.hw)) self.wave = DrawWaveform(self) if self.hw == XO15: self.audiograb = AudioGrab_XO15(self.wave.new_buffer, self) elif self.hw == XO175: self.audiograb = AudioGrab_XO175(self.wave.new_buffer, self) elif self.hw == XO4: self.audiograb = AudioGrab_XO4(self.wave.new_buffer, self) elif self.hw == XO1: self.audiograb = AudioGrab_XO1(self.wave.new_buffer, self) else: self.audiograb = AudioGrab_Unknown(self.wave.new_buffer, self) # no sharing self.max_participants = 1 box3 = gtk.HBox(False, 0) box3.pack_start(self.wave, True, True, 0) # We need event boxes in order to set the background color. side_eventboxes = [] self.side_toolbars = [] for i in range(self.audiograb.channels): side_eventboxes.append(gtk.EventBox()) side_eventboxes[i].modify_bg( gtk.STATE_NORMAL, style.COLOR_TOOLBAR_GREY.get_gdk_color()) self.side_toolbars.append(SideToolbar(self, channel=i)) side_eventboxes[i].add(self.side_toolbars[i].box1) box3.pack_start(side_eventboxes[i], False, True, 0) event_box = gtk.EventBox() self.text_box = gtk.Label() self.text_box.set_justify(gtk.JUSTIFY_LEFT) alist = pango.AttrList() alist.insert(pango.AttrForeground(65535, 65535, 65535, 0, -1)) self.text_box.set_attributes(alist) event_box.add(self.text_box) event_box.modify_bg(gtk.STATE_NORMAL, style.COLOR_TOOLBAR_GREY.get_gdk_color()) box1 = gtk.VBox(False, 0) box1.pack_start(box3, True, True, 0) box1.pack_start(event_box, False, True, 0) self.set_canvas(box1) toolbox = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbox.toolbar.insert(activity_button, 0) activity_button.show() self.sensor_toolbar = SensorToolbar(self, self.audiograb.channels) #Added by Lego # Turn on bobot Server log.debug('Starting Server...') self.bobot = subprocess.Popen(['python', 'pybot_server.py'], cwd='./pybot') log.debug("Start : %s" % time.ctime()) time.sleep(bobot_delay_start) log.debug("Started : %s" % time.ctime()) self.lego_toolbar = LegoToolbar(self, self.audiograb.channels) #Lego end # Added by Butia self.butia_toolbar = ButiaToolbar(self, self.audiograb.channels) #Butia end #Added by Arduino self.arduino_toolbar = ArduinoToolbar(self, self.audiograb.channels) #Arduino end self.tuning_toolbar = TuningToolbar(self) self.new_instrument_toolbar = InstrumentToolbar(self) self._extras_toolbar = gtk.Toolbar() self.control_toolbar = gtk.Toolbar() sensor_button = ToolbarButton(label=_('Sensors'), page=self.sensor_toolbar, icon_name='sensor-tools') toolbox.toolbar.insert(sensor_button, -1) #Added by Lego sensor_button.connect('clicked', self._sensor_toolbar_cb) #Lego end sensor_button.show() lego_button = ToolbarButton(label=_('Lego'), page=self.lego_toolbar, icon_name='LEGO-tools') toolbox.toolbar.insert(lego_button, -1) lego_button.connect('clicked', self._lego_toolbar_cb) lego_button.show() #Lego end #Added by Butia sensor_button.connect('clicked', self._sensor_toolbar_cb) #Butia end sensor_button.show() #Added by Butia butia_button = ToolbarButton(label=_('Butia'), page=self.butia_toolbar, icon_name='butia-tools') toolbox.toolbar.insert(butia_button, -1) butia_button.connect('clicked', self._butia_toolbar_cb) butia_button.show() #Butia end #Added by Arduino sensor_button.connect('clicked', self._sensor_toolbar_cb) #Arduino end sensor_button.show() #Added by Arduino arduino_button = ToolbarButton(label=_('Arduino'), page=self.arduino_toolbar, icon_name='arduino-tools') toolbox.toolbar.insert(arduino_button, -1) arduino_button.connect('clicked', self._arduino_toolbar_cb) arduino_button.show() #Arduino end tuning_button = ToolbarButton( # TRANS: Tuning insruments label=_('Tuning'), page=self.tuning_toolbar, icon_name='tuning-tools') toolbox.toolbar.insert(tuning_button, -1) tuning_button.show() new_instrument_button = ToolbarButton(label=_('Add instrument'), page=self.new_instrument_toolbar, icon_name='view-source') toolbox.toolbar.insert(new_instrument_button, -1) new_instrument_button.show() #Added by butia self.butia_toolbar.show() #Butia end self._extras_button = ToolbarButton(page=self._extras_toolbar, icon_name='domain-time') toolbox.toolbar.insert(self._extras_button, -1) self._extras_toolbar_item = gtk.ToolItem() self._extras_toolbar.insert(self._extras_toolbar_item, -1) self._extras_button.hide() self.sensor_toolbar.show() self._extra_tools = gtk.HBox() # Set up Frequency-domain Button self.freq = ToolButton('domain-time') self.freq.set_tooltip(_('Time Base')) self.freq.connect('clicked', self.timefreq_control) self.freq.show() self._extra_tools.add(self.freq) self.sensor_toolbar.add_frequency_slider(self._extra_tools) self._extra_item = gtk.ToolItem() self._extra_item.add(self._extra_tools) self._extra_tools.show() toolbox.toolbar.insert(self._extra_item, -1) self._extra_item.show() self._pause = ToolButton('media-playback-pause') self._pause.set_tooltip(_('Freeze the display')) self._pause.connect('clicked', self._pause_play_cb) self._pause.show() toolbox.toolbar.insert(self._pause, -1) self._capture = ToolButton('image-saveoff') self._capture.set_tooltip(_('Capture sample now')) self._capture.connect('clicked', self._capture_cb) self._capture.show() toolbox.toolbar.insert(self._capture, -1) separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbox.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) stop_button.props.accelerator = _('<Ctrl>Q') toolbox.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbox(toolbox) sensor_button.set_expanded(True) toolbox.show() self.sensor_toolbar.update_page_size() self.show_all() self._first = True # Always start in 'sound' mode. self.sensor_toolbar.set_mode('sound') self.sensor_toolbar.set_sound_context() self.sensor_toolbar.set_show_hide_windows() self.wave.set_active(True) self.wave.set_context_on() gtk.gdk.screen_get_default().connect('size-changed', self._configure_cb) self._configure_cb(None)
def __init__(self,handle): activity.Activity.__init__(self, handle, True) cs = ActivityToolbarButton(self) c = gtk.SeparatorToolItem() c.set_expand(True) lugar = activity.get_bundle_path() self.Musica = gst.element_factory_make('playbin') self.Musica.set_property('uri','file://'+lugar+'/Musica.ogg') self.Musica.set_state(gst.STATE_PLAYING) self.Toolbar = ToolbarBox() self.Toolbar.toolbar.insert(cs,-1) self.F = ToolButton('F') self.Toolbar.toolbar.insert(self.F,-1) self.cambiado = False self.cambiadoc = False self.E = ToolButton('E') self.Toolbar.toolbar.insert(self.E,-1) self.L = ToolButton('L') self.Toolbar.toolbar.insert(self.L,-1) self.I = ToolButton('I') self.Toolbar.toolbar.insert(self.I,-1) self.Z = ToolButton('Z') self.Toolbar.toolbar.insert(self.Z,-1) self.N = ToolButton('N') self.Toolbar.toolbar.insert(self.N,-1) self.AA = ToolButton('A') self.Toolbar.toolbar.insert(self.AA,-1) self.V = ToolButton('V') self.Toolbar.toolbar.insert(self.V,-1) self.II = ToolButton('I') self.Toolbar.toolbar.insert(self.II,-1) self.D = ToolButton('D') self.Toolbar.toolbar.insert(self.D,-1) self.AAA = ToolButton('A') self.Toolbar.toolbar.insert(self.AAA,-1) self.DD = ToolButton('D') self.Toolbar.toolbar.insert(self.DD,-1) self.cambiar() Stop = StopButton(self) b = gtk.SeparatorToolItem() b.set_expand(True) self.Toolbar.toolbar.insert(Stop,-1) self.vox = gtk.EventBox() vs = gtk.VBox() self.vox.add(vs) Imagen = gtk.Image() Imagen.set_from_file('Imagen.svg') bs = gtk.TextBuffer() bs.set_text('El equipo de CeibalJAM! te desea feliz navidad y prospero año nuevo') entry = gtk.TextView(bs) fuente = pango.FontDescription('11') entry.set_editable(False) entry.modify_font(fuente) self.vox.connect('button-release-event',self.color,entry) self.color('a','b',entry) self.label = gtk.Label(saber()) self.label.modify_font(fuente) vs.pack_start(self.label,False,False,0) color(self.label) vs.pack_end(entry,False,False,0) self.set_canvas(self.vox) vs.pack_start(Imagen,True,True,0) self.set_toolbar_box(self.Toolbar) self.show_all() gobject.timeout_add(37500, self.sonido)
def build_toolbar(self): toolbox = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbox.toolbar.insert(activity_button, -1) activity_button.show() barra = toolbox.toolbar separador1 = gtk.SeparatorToolItem() separador1.props.draw = True barra.insert(separador1, 1) item1 = gtk.ToolItem() self.label_radio1 = gtk.Label() self.label_radio1.set_text(_('Circles between') + ' ') item1.add(self.label_radio1) barra.insert(item1, 2) item2 = gtk.ToolItem() self.cradio1 = gtk.SpinButton() self.cradio1.set_range(1, 20) self.cradio1.set_increments(1, 2) self.cradio1.props.value = self.radio_uno self.cradio1_handler = self.cradio1.connect('notify::value', self.cradio1_valor) item2.add(self.cradio1) barra.insert(item2, 3) item3 = gtk.ToolItem() self.label_and = gtk.Label() self.label_and.set_text(' ' + _('and') + ' ') item3.add(self.label_and) barra.insert(item3, 4) item4 = gtk.ToolItem() self.cradio2 = gtk.SpinButton() self.cradio2.set_range(1, 20) self.cradio2.set_increments(1, 2) self.cradio2.props.value = self.radio_dos self.cradio2_handler = self.cradio2.connect('notify::value', self.cradio2_valor) item4.add(self.cradio2) barra.insert(item4, 5) separator1 = gtk.SeparatorToolItem() separator1.props.draw = True separator1.set_expand(False) barra.insert(separator1, 6) save_button = ToolButton('filesave') save_button.set_tooltip(_('Save Image')) save_button.connect('clicked', self._savebutton_cb) barra.insert(save_button, 7) save_button.show() separator2 = gtk.SeparatorToolItem() separator2.props.draw = False separator2.set_expand(True) barra.insert(separator2, 8) stop_button = StopButton(self) stop_button.props.accelerator = '<Ctrl>q' barra.insert(stop_button, 9) stop_button.show() self.set_toolbar_box(toolbox) toolbox.show_all()
def __init__(self, handle): activity.Activity.__init__(self, handle, True) self.max_participants = 1 # CHART_OPTIONS self.x_label = "" self.y_label = "" self.chart_color = utils.get_user_fill_color('str') self.chart_line_color = utils.get_user_stroke_color('str') self.current_chart = None self.charts_area = None self.chart_data = [] # TOOLBARS toolbarbox = ToolbarBox() activity_button = ActivityToolbarButton(self) activity_btn_toolbar = activity_button.page activity_btn_toolbar.title.connect('changed', self._set_chart_title) save_as_image = ToolButton("save-as-image") save_as_image.connect("clicked", self._save_as_image) save_as_image.set_tooltip(_("Save as image")) activity_btn_toolbar.insert(save_as_image, -1) save_as_image.show() toolbarbox.toolbar.insert(activity_button, 0) import_freespace = ToolButton("import-freespace") import_freespace.connect("clicked", self.__import_freespace_cb) import_freespace.set_tooltip(_("Read Freespace data")) toolbarbox.toolbar.insert(import_freespace, -1) import_freespace.show() import_journal = ToolButton('import-journal') import_journal.connect('clicked', self.__import_journal_cb) import_journal.set_tooltip(_('Read Journal data')) toolbarbox.toolbar.insert(import_journal, -1) import_journal.show() import_turtle = ToolButton('import-turtle') import_turtle.connect('clicked', self.__import_turtle_cb) import_turtle.set_tooltip(_('Read Turtle data')) toolbarbox.toolbar.insert(import_turtle, -1) import_turtle.show() separator = gtk.SeparatorToolItem() separator.set_draw(True) separator.set_expand(False) toolbarbox.toolbar.insert(separator, -1) add_vbar_chart = RadioToolButton() add_vbar_chart.connect("clicked", self._add_chart_cb, "vbar") add_vbar_chart.set_tooltip(_("Vertical Bar Chart")) add_vbar_chart.props.icon_name = "vbar" charts_group = add_vbar_chart toolbarbox.toolbar.insert(add_vbar_chart, -1) add_hbar_chart = RadioToolButton() add_hbar_chart.connect("clicked", self._add_chart_cb, "hbar") add_hbar_chart.set_tooltip(_("Horizontal Bar Chart")) add_hbar_chart.props.icon_name = "hbar" add_hbar_chart.props.group = charts_group toolbarbox.toolbar.insert(add_hbar_chart, -1) add_pie_chart = RadioToolButton() add_pie_chart.connect("clicked", self._add_chart_cb, "pie") add_pie_chart.set_tooltip(_("Pie Chart")) add_pie_chart.props.icon_name = "pie" add_pie_chart.props.group = charts_group add_pie_chart.set_active(True) toolbarbox.toolbar.insert(add_pie_chart, -1) self.chart_type_buttons = [ add_vbar_chart, add_hbar_chart, add_pie_chart ] separator = gtk.SeparatorToolItem() separator.set_draw(True) separator.set_expand(False) toolbarbox.toolbar.insert(separator, -1) fullscreen_btn = ToolButton('view-fullscreen') fullscreen_btn.set_tooltip(_('Fullscreen')) fullscreen_btn.connect("clicked", self.__fullscreen_cb) toolbarbox.toolbar.insert(fullscreen_btn, -1) charthelp.create_help(toolbarbox.toolbar) separator = gtk.SeparatorToolItem() separator.set_draw(False) separator.set_expand(True) toolbarbox.toolbar.insert(separator, -1) stopbtn = StopButton(self) toolbarbox.toolbar.insert(stopbtn, -1) self.set_toolbar_box(toolbarbox) # CANVAS paned = gtk.HPaned() box = gtk.VBox() self.box = box # Set the info box width to 1/3 of the screen: def size_allocate_cb(widget, allocation): paned.disconnect(self._setup_handle) box_width = allocation.width / 3 box.set_size_request(box_width, -1) self._setup_handle = paned.connect('size_allocate', size_allocate_cb) scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.labels_and_values = ChartData(self) scroll.add(self.labels_and_values) self.labels_and_values.connect("label-changed", self._label_changed) self.labels_and_values.connect("value-changed", self._value_changed) box.pack_start(scroll, True, True, 0) paned.add1(box) # CHARTS AREA eventbox = gtk.EventBox() self.charts_area = ChartArea(self) self.charts_area.connect('size_allocate', self._chart_size_allocate) eventbox.modify_bg(gtk.STATE_NORMAL, _WHITE) eventbox.add(self.charts_area) paned.add2(eventbox) self.set_canvas(paned) 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() 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 __init__(self, handle): """Set up the Words activity.""" super(WordsActivity, self).__init__(handle) self._logger = logging.getLogger('words-activity') from sugar.graphics.menuitem import MenuItem from sugar.graphics.icon import Icon # Instantiate a language model. # FIXME: We should ask the language model what langs it supports. self.langs = ["French", "German", "Italian", "Portuguese", "Spanish"] # Initial values. self.fromlang = "English" self.tolang = "Spanish" import LanguageModel self.languagemodel = LanguageModel.LanguageModel() # we do not have collaboration features # make the share option insensitive self.max_participants = 1 # Main layout. hbox = gtk.HBox(homogeneous=True) vbox = gtk.VBox() # Toolbar. try: from sugar.graphics.toolbarbox import ToolbarBox, ToolbarButton from sugar.activity.widgets import ActivityButton, StopButton, \ ShareButton, KeepButton, TitleEntry toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) share_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) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbox(toolbar_box) toolbar_box.show() except ImportError: toolbox = ActivityToolbox(self) self.set_toolbox(toolbox) toolbox.show() # transbox: <label> - <text entry> - <speak button> transbox1 = gtk.HBox() transbox2 = gtk.HBox() # Labels. label1 = gtk.Label(_("Word")) label2 = gtk.Label(_("Translation")) # Text entry box to enter word to be translated. self.totranslate = gtk.Entry(max=50) self.totranslate.connect("changed", self.totranslate_cb) self.totranslate.modify_font(pango.FontDescription("Sans 14")) # Text entry box to receive word translated. self.translated = gtk.Entry(max=50) self.translated.set_property('editable', False) self.translated.modify_font(pango.FontDescription("Sans 14")) # Speak buttons. speak1 = gtk.Button("Speak") speak1.connect("clicked", self.speak1_cb) speak2 = gtk.Button("Speak") speak2.connect("clicked", self.speak2_cb) transbox1.pack_start(label1, expand=False) transbox1.pack_start(self.totranslate) transbox1.pack_start(speak1, expand=False) transbox2.pack_start(label2, expand=False) transbox2.pack_start(self.translated) transbox2.pack_start(speak2, expand=False) vbox.pack_start(transbox1, expand=False) vbox.pack_start(transbox2, expand=False) # The language choice combo boxes. combohbox = gtk.HBox(homogeneous=True) self.lang1combo = gtk.combo_box_new_text() self.lang1combo.append_text("English") self.lang1combo.connect("changed", self.lang1combo_cb) self.lang1combo.set_active(0) self.lang2combo = gtk.combo_box_new_text() for x in self.langs: self.lang2combo.append_text(x) self.lang2combo.connect("changed", self.lang2combo_cb) self.lang2combo.set_active(4) self.lang1combo.set_size_request(600, 50) self.lang2combo.set_size_request(600, 50) combohbox.pack_start(self.lang1combo, expand=False) combohbox.pack_start(self.lang2combo, expand=False) vbox.pack_start(combohbox, expand=False) # The "lang1" treeview box self.lang1model = gtk.ListStore(str) lang1view = gtk.TreeView(self.lang1model) lang1cell = gtk.CellRendererText() lang1treecol = gtk.TreeViewColumn("", lang1cell, text=0) lang1view.get_selection().connect("changed", self.lang1sel_cb) lang1view.append_column(lang1treecol) # The "lang2" box self.lang2model = gtk.ListStore(str) lang2view = gtk.TreeView(self.lang2model) lang2cell = gtk.CellRendererText() lang2treecol = gtk.TreeViewColumn("", lang2cell, text=0) lang2view.get_selection().connect("changed", self.lang2sel_cb) lang2view.append_column(lang2treecol) hbox.pack_start(lang1view) hbox.pack_start(lang2view) vbox.pack_start(hbox) self.set_canvas(vbox) self.totranslate.grab_focus() self.show_all()
def __init__(self, handle): self.client = gconf.client_get_default() """Set up the MouseCam activity.""" activity.Activity.__init__(self, handle) # we do not have collaboration features # make the share option insensitive self.max_participants = 1 self.has_toolbarbox = HAS_TOOLBARBOX #register destroy callback self.connect("destroy", self.cb_cleanup) if (self.has_toolbarbox): # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) share_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) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) else: # toolbar with the old toolbar design toolbar_box = activity.ActivityToolbox(self) self.set_toolbox(toolbar_box) toolbar_box.show() # Set default values for keypad and returnkey events self.client.set_bool('/apps/mousecam/keypad_events', False) self.client.set_bool('/apps/mousecam/return_key_instead_click', False) # And, one last HScale widget for adjusting the mouse speed box1 = gtk.VBox(False, 0) box1.set_border_width(10) self.set_canvas(box1) box1.show() # value, lower, upper, step_increment, page_increment, page_size # Note that the page_size value only makes a difference for # scrollbar widgets, and the highest value you'll get is actually # (upper - page_size). gconf_persist_value = self.client.get_float('/apps/mousecam/adj') if (gconf_persist_value == NOT_DEFINED): slide_vel_start_value = 50.0 self.client.set_float('/apps/mousecam/adj', slide_vel_start_value) else: slide_vel_start_value = gconf_persist_value adj1 = gtk.Adjustment(slide_vel_start_value, 1.0, 101.0, 0.1, 1.0, 1.0) adj1.connect("value_changed", self.cb_change_event) box1_1 = gtk.VBox(False, 10) box1.pack_start(box1_1, True, True, 0) box1_1.show() gconf_persist_value = self.client.get_int('/apps/mousecam/threshold') if (gconf_persist_value == NOT_DEFINED): slide_threshold_start_value = 100 self.client.set_int('/apps/mousecam/threshold', slide_threshold_start_value) else: slide_threshold_start_value = gconf_persist_value adj2 = gtk.Adjustment(slide_threshold_start_value, 0, 256, 1.0, 1.0, 1.0) adj2.connect("value_changed", self.cb_threshold_change_event) box1_2 = gtk.VBox(False, 10) box1.pack_start(box1_2, True, True, 0) box1_2.show() # Reuse the same adjustment self.hscale = gtk.HScale(adj1) self.hscale.set_size_request(600, 90) ###scale_set_default_values(self.hscale) box1_1.pack_start(self.hscale, True, True, 0) self.hscale.show() self.hscale2 = gtk.HScale(adj2) self.hscale2.set_digits(0) self.hscale2.set_size_request(600, 90) box1_2.pack_start(self.hscale2, True, True, 0) self.hscale2.show() # An option menu to change the position of the value #label = gtk.Label(_('Deslice la barra para enlentecer el mouse:')) label = gtk.Label(_('Slide the bar to slow the mouse speed:')) box1_1.pack_start(label, False, False, 0) label.show() label = gtk.Label(_('Slide the bar to decrease the threshold:')) box1_2.pack_start(label, False, False, 0) label.show() # Check button for mouse / keypad event switch button_keypad = gtk.CheckButton(_('Enable keypad events')) button_keypad.connect("toggled", self.cb_keypad_events) button_keypad.show() # Check button for click / return key event switch button_returnkey = gtk.CheckButton( _('Enable the return key in place of the mouse click')) button_returnkey.connect("toggled", self.cb_keypad_events) button_returnkey.show() box1_3 = gtk.VBox(False, 10) box1_3.show() box1_3.pack_start(button_keypad, False, False, 2) box1_3.pack_start(button_returnkey, False, False, 2) box1.pack_start(box1_3, True, True, 0) menu = gtk.Menu() self.window.show() os.system("bin/execute.sh &")
def instance(self): book.wiki = book.WikiBook() if not book.custom: book.custom = book.CustomBook() self.edit_page = 1 self.edit = edit.View() self.library = library.View(self) if OLD_TOOLBAR: self.edit_toolbar = gtk.Toolbar() self.edit_bar = edit.ToolbarBuilder(self.edit, self.edit_toolbar) self.edit_toolbar.show_all() self.library_toolbar = gtk.Toolbar() self.library_bar = library.ToolbarBuilder(self.library, self.library_toolbar) self.library_toolbar.show_all() toolbox = ActivityToolbox(self) toolbox.connect('current-toolbar-changed', self._toolbar_changed_cb) self.set_toolbox(toolbox) toolbox.add_toolbar(_('Library'), self.library_toolbar) toolbox.add_toolbar(_('Edit'), self.edit_toolbar) toolbox.set_current_toolbar(1) else: toolbar_box = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, 0) self.set_toolbar_box(toolbar_box) self._toolbar = toolbar_box.toolbar tool_group = None search_button = RadioToolButton() search_button.props.group = tool_group tool_group = search_button search_button.props.icon_name = 'white-search' search_button.set_tooltip(_('Library')) search_button.mode = 'search' search_button.connect('clicked', self.__mode_button_clicked) self._toolbar.insert(search_button, -1) edit_button = RadioToolButton() edit_button.props.group = tool_group edit_button.props.icon_name = 'toolbar-edit' edit_button.set_tooltip(_('Edit')) edit_button.mode = 'edit' edit_button.connect('clicked', self.__mode_button_clicked) self._toolbar.insert(edit_button, -1) self._toolbar.insert(gtk.SeparatorToolItem(), -1) self.edit_bar = edit.ToolbarBuilder(self.edit, self._toolbar) self.library_bar = library.ToolbarBuilder(self.library, self._toolbar) edit_fake = gtk.EventBox() self.notebook.append_page(self.library) self.notebook.append_page(self.edit) self.notebook.append_page(edit_fake) self.show_all() if not OLD_TOOLBAR: self.__mode_button_clicked(search_button) separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) separator.show() self._toolbar.insert(separator, -1) stop_button = StopButton(self) stop_button.show() self._toolbar.insert(stop_button, -1)
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() toolbar_box.toolbar.insert(separator, -1) separator.show() self.build_colors_toolbar(toolbar_box) separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) separator.show() # new game button new_game = ToolButton('new-game') new_game.connect('clicked', self._new_game) new_game.set_tooltip(_('New game')) toolbar_box.toolbar.insert(new_game, -1) separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) separator.show() #current item = gtk.ToolItem() label = gtk.Label() label.set_text(' %s ' % _('Current player:')) item.add(label) toolbar_box.toolbar.insert(item, -1) #player item = gtk.ToolItem() self.current_label = gtk.Label() self.current_label.set_text(' %s' % 1) item.add(self.current_label) toolbar_box.toolbar.insert(item, -1) separator = gtk.SeparatorToolItem() toolbar_box.toolbar.insert(separator, -1) separator.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) # separator and stop 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, handle): super(PeterActivity, self).__init__(handle) # Get user's Sugar colors sugarcolors = profile.get_color().to_string().split(',') colors = [[ int(sugarcolors[0][1:3], 16), int(sugarcolors[0][3:5], 16), int(sugarcolors[0][5:7], 16) ], [ int(sugarcolors[1][1:3], 16), int(sugarcolors[1][3:5], 16), int(sugarcolors[1][5:7], 16) ]] # No sharing self.max_participants = 1 self.datapath = os.path.join(activity.get_activity_root(), 'instance') # Build the activity toolbar. toolbox = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbox.toolbar.insert(activity_button, 0) activity_button.show() self._add_speed_slider(toolbox.toolbar) cyan = ToolButton('cyan') toolbox.toolbar.insert(cyan, -1) cyan.set_tooltip(_('Next pattern')) cyan.connect('clicked', self._button_cb, 'cyan') cyan.set_sensitive(False) cyan.show() green = ToolButton('green') toolbox.toolbar.insert(green, -1) green.set_tooltip(_('Draw')) green.connect('clicked', self._button_cb, 'green') green.show() red = ToolButton('red') toolbox.toolbar.insert(red, -1) red.set_tooltip(_('Stop')) red.connect('clicked', self._button_cb, 'red') red.show() separator = gtk.SeparatorToolItem() separator.props.draw = True toolbox.toolbar.insert(separator, -1) separator.show() label = gtk.Label('') label.set_use_markup(True) label.show() labelitem = gtk.ToolItem() labelitem.add(label) toolbox.toolbar.insert(labelitem, -1) labelitem.show() export = ToolButton('export-turtleblocks') toolbox.toolbar.insert(export, -1) export.set_tooltip(_('Export to TurtleBlocks')) export.connect('clicked', self._export_turtleblocks_cb) export.show() separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbox.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) stop_button.props.accelerator = _('<Ctrl>Q') toolbox.toolbar.insert(stop_button, -1) stop_button.show() toolbox.show() self.set_toolbox(toolbox) # Create the game instance. self.game = Spirolaterals.Spirolaterals(colors) # Build the Pygame canvas. self._pygamecanvas = \ sugargame.canvas.PygameCanvas(self) # Note that set_canvas implicitly calls # read_file when resuming from the Journal. self.set_canvas(self._pygamecanvas) self.game.canvas = self._pygamecanvas gtk.gdk.screen_get_default().connect('size-changed', self.__configure_cb) # Start the game running. self.game.set_cyan_button(cyan) self.game.set_label(label) self._speed_range.set_value(200) self._pygamecanvas.run_pygame(self.game.run)
def _setup_toolbars(self, have_toolbox): """ Setup the toolbars.. """ if have_toolbox: toolbox = ToolbarBox() # Activity toolbar activity_button = ActivityToolbarButton(self) toolbox.toolbar.insert(activity_button, 0) activity_button.show() self.set_toolbar_box(toolbox) toolbox.show() toolbar = toolbox.toolbar else: # Use pre-0.86 toolbar design games_toolbar = gtk.Toolbar() toolbox = activity.ActivityToolbox(self) self.set_toolbox(toolbox) toolbox.add_toolbar(_('Game'), games_toolbar) toolbox.show() toolbox.set_current_toolbar(1) toolbar = games_toolbar # Add the buttons and labels to the toolbars self.level_button = button_factory(LEVEL_ICONS[self._play_level], toolbar, self.change_play_level_cb, tooltip=_('Set difficulty level.')) mode = self._play_mode mode += 1 if mode == len(GAME_ICONS): mode = 0 self.game_buttons = [] for i in range(len(GAME_ICONS)): if i == 0: self.game_buttons.append( radio_factory(GAME_ICONS[0], toolbar, self.change_play_mode_cb, cb_arg=0, tooltip=_('Select game.'), group=None)) else: self.game_buttons.append( radio_factory(GAME_ICONS[i], toolbar, self.change_play_mode_cb, cb_arg=i, tooltip=_('Select game.'), group=self.game_buttons[0])) self.game_buttons[mode].set_active(True) separator_factory(toolbar, False, True) self.status_label = label_factory(toolbar, _("drag to swap")) if _have_toolbox: separator_factory(toolbox.toolbar, True, False) stop_button = StopButton(self) stop_button.props.accelerator = '<Ctrl>q' toolbox.toolbar.insert(stop_button, -1) stop_button.show()
def __init__(self, handle): activity.Activity.__init__(self, handle) self.max_participants = 1 self.toolbarbox = ToolbarBox() self.toolbar = self.toolbarbox.toolbar self.start_vnc = RadioToolButton(icon_name="start_vnc", tooltip=_("Start VNC Server")) self.stop_vnc = RadioToolButton(icon_name="stop_vnc", tooltip=_("Stop VNC Server"), group=self.start_vnc) self.stop_vnc.set_active(True) self.get_ipbutton = ToolButton(icon_name="get_ip", tooltip=_("Get the current IP")) ## self.messages = gtk.TreeView() self.messages.set_rules_hint(True) modelo = gtk.ListStore(str, str, gtk.gdk.Color) self.messages.set_model(modelo) render = gtk.CellRendererText() render1 = gtk.CellRendererText() column1 = gtk.TreeViewColumn(_("Hour"), render, markup=0) column2 = gtk.TreeViewColumn(_("Message"), render1, markup=1) column1.add_attribute(render, 'foreground-gdk', 2) column2.add_attribute(render1, 'foreground-gdk', 2) self.messages.append_column(column1) self.messages.append_column(column2) color = gtk.gdk.color_parse("dark blue") modelo.insert(0, [ time.strftime("\n<b>%H:%M:%S</b>\n"), _("\n<b>Start of activity.</b>\n"), color ]) self.showed_message_stop = True self.showed_message_start = False self.isrunning = True self.stop_vnc.connect("clicked", self.__stop_vnc) self.start_vnc.connect("clicked", self.__start_vnc) self.clear_model = ToolButton(icon_name="clear_console", tooltip=_("Delete messages")) self.clear_model.connect("clicked", lambda x: modelo.clear()) self.get_ipbutton.connect("clicked", self.__get_ip) self.last_message = 1 self.__get_x11vnc_path() ## separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self.stop_activity = StopButton(self) self.toolbar.insert(ActivityToolbarButton(self), -1) self.toolbar.insert(gtk.SeparatorToolItem(), -1) self.toolbar.insert(self.start_vnc, -1) self.toolbar.insert(self.stop_vnc, -1) self.toolbar.insert(gtk.SeparatorToolItem(), -1) self.toolbar.insert(self.get_ipbutton, -1) self.toolbar.insert(self.clear_model, -1) self.toolbar.insert(separator, -1) self.toolbar.insert(self.stop_activity, -1) self.messages_scroll = gtk.ScrolledWindow() self.messages_scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.messages_scroll.add_with_viewport(self.messages) self.set_toolbar_box(self.toolbarbox) self.set_canvas(self.messages_scroll) self.show_all() gobject.timeout_add(100, self.__check_is_on)
def __init__(self, handle): activity.Activity.__init__(self, handle) self.props.max_participants = 1 self._web_view = Browser() try: from sugar.graphics.toolbarbox import ToolbarBox, ToolbarButton from sugar.activity.widgets import ActivityToolbarButton, StopButton, \ ShareButton from mybutton import MyActivityToolbarButton toolbar_box = ToolbarBox() activity_button = MyActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() viewtoolbar = ViewToolbar(self) viewbutton = ToolbarButton(page=viewtoolbar, \ icon_name='camera') toolbar_box.toolbar.insert(viewbutton, -1) viewbutton.show() separator = gtk.SeparatorToolItem() #separator.props.draw = False #separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() #lets reuse the code below navtoolbar = Toolbar(self._web_view) toolitem = gtk.ToolItem() navtoolbar._home.reparent(toolitem) toolbar_box.toolbar.insert(toolitem, -1) navtoolbar._home.show() toolitem.show() toolitem = gtk.ToolItem() navtoolbar._back.reparent(toolitem) toolbar_box.toolbar.insert(toolitem, -1) navtoolbar._back.show() toolitem.show() toolitem = gtk.ToolItem() navtoolbar._forward.reparent(toolitem) toolbar_box.toolbar.insert(toolitem, -1) navtoolbar._forward.show() toolitem.show() # we do not have collaboration features # make the share option insensitive self.max_participants = 1 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() except ImportError: toolbox = activity.ActivityToolbox(self) self.set_toolbox(toolbox) toolbox.show() toolbar = Toolbar(self._web_view) toolbox.add_toolbar(_('Navigation'), toolbar) toolbar.show() viewtoolbar = ViewToolbar(self) toolbox.add_toolbar(_('View'), viewtoolbar) viewtoolbar.show() toolbox.set_current_toolbar(1) self.set_canvas(self._web_view) self._web_view.show() self._web_view.load_uri(HOME)
def ui_init(self): self._fullscreen = False self._showing_info = False # FIXME: if _thumb_tray becomes some kind of button group, we wouldn't # have to track which recd is active self._active_recd = None self.connect_after('key-press-event', self._key_pressed) self._active_toolbar_idx = 0 self._toolbar_box = ToolbarBox() activity_button = ActivityToolbarButton(self) self._toolbar_box.toolbar.insert(activity_button, 0) self.set_toolbar_box(self._toolbar_box) self._toolbar = self.get_toolbar_box().toolbar tool_group = None if self.model.get_has_camera(): self._photo_button = RadioToolButton() self._photo_button.props.group = tool_group tool_group = self._photo_button self._photo_button.props.icon_name = 'camera-external' self._photo_button.props.label = _('Photo') self._photo_button.mode = constants.MODE_PHOTO self._photo_button.connect('clicked', self._mode_button_clicked) self._toolbar.insert(self._photo_button, -1) self._video_button = RadioToolButton() self._video_button.props.group = tool_group self._video_button.props.icon_name = 'media-video' self._video_button.props.label = _('Video') self._video_button.mode = constants.MODE_VIDEO self._video_button.connect('clicked', self._mode_button_clicked) self._toolbar.insert(self._video_button, -1) else: self._photo_button = None self._video_button = None self._audio_button = RadioToolButton() self._audio_button.props.group = tool_group self._audio_button.props.icon_name = 'media-audio' self._audio_button.props.label = _('Audio') self._audio_button.mode = constants.MODE_AUDIO self._audio_button.connect('clicked', self._mode_button_clicked) self._toolbar.insert(self._audio_button, -1) self._toolbar.insert(gtk.SeparatorToolItem(), -1) self._toolbar_controls = RecordControl(self._toolbar) separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) self._toolbar.insert(separator, -1) self._toolbar.insert(StopButton(self), -1) self.get_toolbar_box().show_all() main_box = gtk.VBox() self.set_canvas(main_box) main_box.get_parent().modify_bg(gtk.STATE_NORMAL, COLOR_BLACK) main_box.show() self._media_view = MediaView() self._media_view.connect('media-clicked', self._media_view_media_clicked) self._media_view.connect('pip-clicked', self._media_view_pip_clicked) self._media_view.connect('info-clicked', self._media_view_info_clicked) self._media_view.connect('full-clicked', self._media_view_full_clicked) self._media_view.connect('tags-changed', self._media_view_tags_changed) self._media_view.show() self._controls_hbox = gtk.HBox() self._controls_hbox.show() self._shutter_button = ShutterButton() self._shutter_button.connect("clicked", self._shutter_clicked) self._controls_hbox.pack_start(self._shutter_button, expand=True, fill=False) self._countdown_image = CountdownImage() self._controls_hbox.pack_start(self._countdown_image, expand=True, fill=False) self._play_button = PlayButton() self._play_button.connect('clicked', self._play_pause_clicked) self._controls_hbox.pack_start(self._play_button, expand=False) self._playback_scale = PlaybackScale(self.model) self._controls_hbox.pack_start(self._playback_scale, expand=True, fill=True) self._progress = ProgressInfo() self._controls_hbox.pack_start(self._progress, expand=True, fill=True) self._title_label = gtk.Label() self._title_label.set_markup("<b><span foreground='white'>"+_('Title:')+'</span></b>') self._controls_hbox.pack_start(self._title_label, expand=False) self._title_entry = gtk.Entry() self._title_entry.modify_bg(gtk.STATE_INSENSITIVE, COLOR_BLACK) self._title_entry.connect('changed', self._title_changed) self._controls_hbox.pack_start(self._title_entry, expand=True, fill=True, padding=10) container = RecordContainer(self._media_view, self._controls_hbox) main_box.pack_start(container, expand=True, fill=True, padding=6) container.show() self._thumb_tray = HTray() self._thumb_tray.set_size_request(-1, 150) main_box.pack_end(self._thumb_tray, expand=False) self._thumb_tray.show_all()
def _setup_toolbars(self, have_toolbox): """ Setup the toolbars. """ self.max_participants = MAX_HANDS if have_toolbox: toolbox = ToolbarBox() # Activity toolbar activity_button = ActivityToolbarButton(self) toolbox.toolbar.insert(activity_button, 0) activity_button.show() self.set_toolbar_box(toolbox) toolbox.show() self.toolbar = toolbox.toolbar else: # Use pre-0.86 toolbar design games_toolbar = gtk.Toolbar() toolbox = activity.ActivityToolbox(self) self.set_toolbox(toolbox) toolbox.add_toolbar(_('Game'), games_toolbar) toolbox.show() toolbox.set_current_toolbar(1) self.toolbar = games_toolbar self._new_game_button = button_factory('new-game', self.toolbar, self._new_game_cb, tooltip=_('Start a new game.')) self.robot_button = button_factory('robot-off', self.toolbar, self._robot_cb, tooltip=_('Play with the robot.')) self.player = image_factory(svg_str_to_pixbuf( generate_xo(scale=0.8, colors=['#303030', '#303030'])), self.toolbar, tooltip=self.nick) self.dialog_button = button_factory('go-next', self.toolbar, self._dialog_cb, tooltip=_('Turn complete')) self.status = label_factory(self.toolbar, '') self.hint_button = button_factory('help-toolbar', self.toolbar, self._hint_cb, tooltip=_('Help')) self.score = label_factory(self.toolbar, _('Score: ') + '0') if _have_toolbox: separator_factory(toolbox.toolbar, True, False) stop_button = StopButton(self) stop_button.props.accelerator = '<Ctrl>q' toolbox.toolbar.insert(stop_button, -1) stop_button.show()
def _setup_toolbars(self): ''' Setup the toolbars. ''' self.max_participants = 1 # no sharing if HAVE_TOOLBOX: toolbox = ToolbarBox() # Activity toolbar activity_button = ActivityToolbarButton(self) toolbox.toolbar.insert(activity_button, 0) activity_button.show() self.set_toolbar_box(toolbox) toolbox.show() self.toolbar = toolbox.toolbar adjust_toolbar = gtk.Toolbar() adjust_toolbar_button = ToolbarButton( label=_('Adjust'), page=adjust_toolbar, icon_name='preferences-system') adjust_toolbar.show_all() adjust_toolbar_button.show() else: # Use pre-0.86 toolbar design primary_toolbar = gtk.Toolbar() toolbox = activity.ActivityToolbox(self) self.set_toolbox(toolbox) toolbox.add_toolbar(_('Page'), primary_toolbar) adjust_toolbar = gtk.Toolbar() toolbox.add_toolbar(_('Adjust'), adjust_toolbar) toolbox.show() toolbox.set_current_toolbar(1) self.toolbar = primary_toolbar self._prev_button = button_factory('go-previous-inactive', _('Prev slide'), self._prev_cb, self.toolbar, accelerator='<Ctrl>P') self._next_button = button_factory('go-next', _('Next slide'), self._next_cb, self.toolbar, accelerator='<Ctrl>N') separator_factory(self.toolbar) self._auto_button = button_factory('media-playlist-repeat', _('Autoplay'), self._autoplay_cb, self.toolbar) if HAVE_TOOLBOX: toolbox.toolbar.insert(adjust_toolbar_button, -1) label = label_factory(_('Adjust playback speed'), adjust_toolbar) label.show() self._unit_combo = combo_factory(UNITS, TEN, _('Adjust playback speed'), self._unit_combo_cb, adjust_toolbar) self._unit_combo.show() separator_factory(self.toolbar) self._thumb_button = button_factory('thumbs-view', _('Thumbnail view'), self._thumbs_cb, self.toolbar) button_factory('view-fullscreen', _('Fullscreen'), self.do_fullscreen_cb, self.toolbar, accelerator='<Alt>Return') separator_factory(self.toolbar) self._save_button = button_factory('save-as-html', _('Save as HTML'), self._save_as_html_cb, self.toolbar) if HAVE_TOOLBOX: separator_factory(toolbox.toolbar, False, True) stop_button = StopButton(self) stop_button.props.accelerator = '<Ctrl>q' toolbox.toolbar.insert(stop_button, -1) stop_button.show()
def __init__(self, handle): activity.Activity.__init__(self, handle) # we do not have collaboration features # make the share option insensitive self.max_participants = 1 # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) share_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) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() principalVbox = gtk.VBox(False, 50) cabeceraHbox = gtk.HBox() jugarButton = gtk.Button() principalVbox.pack_start(cabeceraHbox, fill=False) jugarButton.set_label('JUGAR') jugarButton.connect('focus-in-event', self.__say_text) labels_generados = '' cabeceraHbox.pack_start(jugarButton, fill=False) jugarButton.set_size_request(150, 50) cancelarButton = gtk.Button() cancelarButton.set_label('CANCELAR') cancelarButton.connect('focus-in-event', self.__say_text) cabeceraHbox.pack_start(cancelarButton, fill=False) cancelarButton.connect('clicked', self.__button_clicked_cb, 'CANCELAR') cuerpoHbox = gtk.HBox(False, 20) cancelarButton.set_size_request(150, 50) seleccionadosTable = gtk.Table(4, 1, True) seleccionadoUnoButton = gtk.Button() seleccionadoDosButton = gtk.Button() seleccionadoTresButton = gtk.Button() self.resultadoButton = gtk.Button() seleccionadosTable.set_size_request(200, 400) opcionesTable = gtk.Table(3, 3, True) self.opcionUno = gtk.Button() self.opcionDos = gtk.Button() self.opcionTres = gtk.Button() self.opcionCuatro = gtk.Button() self.opcionCinco = gtk.Button() self.opcionSeis = gtk.Button() self.opcionSiete = gtk.Button() self.opcionOcho = gtk.Button() self.opcionNueve = gtk.Button() self.opcionUno.connect('focus-in-event', self.__say_text) self.opcionDos.connect('focus-in-event', self.__say_text) self.opcionTres.connect('focus-in-event', self.__say_text) self.opcionCuatro.connect('focus-in-event', self.__say_text) self.opcionCinco.connect('focus-in-event', self.__say_text) self.opcionSeis.connect('focus-in-event', self.__say_text) self.opcionSiete.connect('focus-in-event', self.__say_text) self.opcionOcho.connect('focus-in-event', self.__say_text) self.opcionNueve.connect('focus-in-event', self.__say_text) self.set_canvas(principalVbox) self.connect('key-press-event', self.__on_key_press_event, seleccionadoUnoButton, seleccionadoDosButton, seleccionadoTresButton, jugarButton) cabeceraHbox.add(jugarButton) cabeceraHbox.add(cancelarButton) principalVbox.add(cabeceraHbox) principalVbox.add(cuerpoHbox) cuerpoHbox.add(seleccionadosTable) cuerpoHbox.add(opcionesTable) seleccionadosTable.attach(seleccionadoUnoButton, 0, 1, 0, 1, 10, 20, 10, 5) seleccionadoUnoButton.set_size_request(180, 80) seleccionadosTable.attach(seleccionadoDosButton, 0, 1, 1, 2, 10, 30, 10, 5) seleccionadoDosButton.set_size_request(180, 80) seleccionadosTable.attach(seleccionadoTresButton, 0, 1, 2, 3, 10, 20, 10, 5) seleccionadoTresButton.set_size_request(180, 80) seleccionadosTable.attach(self.resultadoButton, 0, 1, 3, 4, 10, 20, 10, 5) self.resultadoButton.set_size_request(180, 80) seleccionadosTable.set_row_spacings(5) seleccionadosTable.set_col_spacings(10) opcionesTable.attach(self.opcionUno, 0, 1, 0, 1, 10, 10) self.opcionUno.set_size_request(180, 80) opcionesTable.attach(self.opcionDos, 1, 2, 0, 1, 10, 10) self.opcionDos.set_size_request(180, 80) opcionesTable.attach(self.opcionTres, 2, 3, 0, 1, 10, 10) self.opcionTres.set_size_request(180, 80) opcionesTable.attach(self.opcionCuatro, 0, 1, 1, 2, 10, 10) self.opcionCuatro.set_size_request(180, 80) opcionesTable.attach(self.opcionCinco, 1, 2, 1, 2, 10, 10) self.opcionCinco.set_size_request(180, 80) opcionesTable.attach(self.opcionSeis, 2, 3, 1, 2, 10, 10) self.opcionSeis.set_size_request(180, 80) opcionesTable.attach(self.opcionSiete, 0, 1, 2, 3, 10, 10) self.opcionSiete.set_size_request(180, 80) opcionesTable.attach(self.opcionOcho, 1, 2, 2, 3, 10, 10) self.opcionOcho.set_size_request(180, 80) opcionesTable.attach(self.opcionNueve, 2, 3, 2, 3, 10, 10) self.opcionNueve.set_size_request(180, 80) opcionesTable.set_row_spacings(50) opcionesTable.set_col_spacings(10) principalVbox.show_all()
def __init__(self, handle): activity.Activity.__init__(self, handle) self.max_participants = 1 toolbar_box = ToolbarBox() activity_button = ActivityButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) share_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) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() image = gtk.Image() vbox = gtk.VBox() hbox = gtk.HBox() self.set_canvas(vbox) button_0 = gtk.Button() button_1 = gtk.Button() button_2 = gtk.Button() button_3 = gtk.Button() vbox.add(button_0) vbox.add(image) vbox.add(hbox) hbox.add(button_1) hbox.add(button_2) hbox.add(button_3) vbox.show_all() try: self.puntaje=self.metadata["puntaje"] self.total=self.metadata["total"] self.numero=self.metadata["numero"] self.anterior=self.metadata["anterior"] button_0.set_label(str(self.puntaje) + '/' +str( self.total)) except KeyError: self.puntaje=0 self.numero=random.randint(1,100) self.anterior=self.numero self.total=0 button_0.set_label('click para saber tu puntaje') self.parser = SafeConfigParser() self.parser.read('config.ini') Popen(['espeak', '-v', 'es', self.parser.get('pregunta'+str(self.numero), 'enunciado')]) pixbuf = gtk.gdk.pixbuf_new_from_file(self.parser.get('pregunta'+str(self.numero), 'imagen')) scaled_pixbuf = pixbuf.scale_simple(400,400,gtk.gdk.INTERP_BILINEAR) image.set_from_pixbuf(scaled_pixbuf) button_1.set_label(self.parser.get('pregunta'+str(self.numero), 'correcta')) button_2.set_label(self.parser.get('pregunta'+str (self.numero), 'incorrecta2')) button_3.set_label(self.parser.get('pregunta'+str (self.numero), 'incorrecta1')) button_1.connect('clicked',self.__cambiar_imagen_cb, button_2,button_3,button_0,image) button_2.connect('clicked',self.__cambiar_imagen_cb, button_3,button_1,button_0,image) button_3.connect('clicked',self.__cambiar_imagen_cb, button_2,button_1,button_0,image) button_0.connect('clicked',self.__decir_puntaje_cb)