示例#1
0
    def __init__(self, handle):
        """Set up the HelloWorld 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.load_data()
        self.cargar_ui()
示例#2
0
    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()

        # advanced example widgets
        vbox = gtk.VBox()
        self.label = gtk.Label()
        self.entry = gtk.Entry()
        self.text = gtk.TextView()

        vbox.add(self.label)
        vbox.add(self.entry)
        vbox.add(self.text)

        self.set_canvas(vbox)
        vbox.show_all()

        self._logging_example()
        self._i18n_example()
示例#3
0
    def __init__(self, handle):
        """Set up the Pilas 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()

        socket = gtk.Socket()
        socket.connect("plug-added", self._on_plugged_event)
        socket.set_flags(gtk.CAN_FOCUS)
        self.set_canvas(socket)
        self.set_focus(socket)
        socket.show()

        screen_width = gtk.gdk.screen_width()
        screen_height = gtk.gdk.screen_height()

        Popen(["python", "pilas_plug.py", str(socket.get_id()),
               str(screen_width), str(screen_height)], env=new_env)
示例#4
0
    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)
示例#5
0
    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()
示例#6
0
    def __init__(self, handle):
        """Set up the ActivityTemplate 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()

        # Code changes made by glucosa team, the three lines
        # makes the game graphic area.
        self.game = Game()
        self.set_canvas(self.game.canvas)

        self.game.canvas.show()
    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
        #label = gtk.Label(_("Hello World!"))
        main = Main()

        self.set_canvas(main)
        main.show()
示例#8
0
    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()
示例#9
0
    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()
示例#10
0
    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 __init__(self, handle):
		"""Set up the HelloWorld activity."""
		activity.Activity.__init__(self, handle)

		self._logger = logging.getLogger('home-work-viewer')
                self._logger.setLevel(logging.DEBUG)
	
		self._logger.debug("Inside to __init__ of HomeWorkViewer")	
		ts = time.time()
		self._logger.debug(ts)
		#self._logger.debug( datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S'))

		'''Obtenemos el JSON de la Actividad'''
		json_data=open('json.txt')
		self.activity = json.load(json_data, object_hook=lambda d: namedtuple('Activity', d.keys())(*d.values()))
		json_data.close()

		
		# 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()

		
		separator = gtk.SeparatorToolItem()
		separator.props.draw = False
		separator.set_expand(True)
		toolbar_box.toolbar.insert(separator, -1)
		separator.show()

		self.buttonBefore = ToolButton('go-previous')
		self.buttonBefore.set_tooltip(_('Back'))
		self.buttonBefore.connect("clicked", self.backButtonCallBack)
		toolbar_box.toolbar.insert(self.buttonBefore, 2)
		self.buttonBefore.show()

		self.buttonNext = ToolButton('go-next')
		self.buttonNext.set_tooltip(_('Next'))
		self.buttonNext.connect("clicked", self.nextButtonCallBack)
		toolbar_box.toolbar.insert(self.buttonNext, 3)
		self.buttonNext.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.vBoxMain = gtk.VBox(True, 2)
		self.vBoxMain.show()
		self.set_canvas(self.vBoxMain)
		
		self.jsonState = None
		self.createWindowExercises()	
		"""Leave this line always in the last"""
示例#12
0
    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()
示例#13
0
    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 &")
示例#14
0
    def __init__(self, handle):
        """Set up the StopWatch activity."""
        Activity.__init__(self, handle)
        self._logger = logging.getLogger('stopwatch-activity')
        
        gobject.threads_init()

        # top toolbar with share and close buttons:
        OLD_TOOLBAR = False

        try:
            from sugar.graphics.toolbarbox import ToolbarBox, ToolbarButton
            from sugar.activity.widgets import ActivityToolbarButton, StopButton, \
                    ShareButton, TitleEntry, ActivityButton
        except ImportError:
            OLD_TOOLBAR = True

        if OLD_TOOLBAR:
            toolbox = ActivityToolbox(self)
            self.set_toolbox(toolbox)
            toolbox.show()
        else:
            toolbar_box = ToolbarBox()
            self.activity_button = ActivityButton(self)
            toolbar_box.toolbar.insert(self.activity_button, 0)
            self.activity_button.show()

            title_entry = TitleEntry(self)
            toolbar_box.toolbar.insert(title_entry, -1)
            title_entry.show()

            try:
                from sugar.activity.widgets import DescriptionItem
                description_item = DescriptionItem(self)
                toolbar_box.toolbar.insert(description_item, -1)
                description_item.show()
            except:
                pass

            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)

        self.tubebox = dobject.TubeBox()
        self.timer = dobject.TimeHandler("main", self.tubebox)
        self.gui = stopwatch.GUIView(self.tubebox, self.timer)

        self.set_canvas(self.gui.display)
        self.show_all()

        self.initiating = False

        # get the Presence Service
        self.pservice = presenceservice.get_instance()
        # Buddy object for you
        owner = self.pservice.get_owner()
        self.owner = owner

        self.connect('shared', self._shared_cb)
        self.connect('joined', self._joined_cb)

        self.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK)
        self.connect("visibility-notify-event", self._visible_cb)
        self.connect("notify::active", self._active_cb)
示例#15
0
    def __init__(self, handle):
        if os.path.exists('/tmp/1'):
            os.remove('/tmp/1')
            """Set up the HelloWorld activity."""
            activity.Activity.__init__(self, handle)

        if os.path.exists('/tmp/2'):
            os.remove('/tmp/2')
            # 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)
            toolbar_box.toolbar.insert(title_entry, -1)
            title_entry.show()

            share_button = ShareButton(self)
            toolbar_box.toolbar.insert(share_button, -1)
            share_button.show()

            keep_button = KeepButton(self)
            toolbar_box.toolbar.insert(keep_button, -1)
            keep_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.container = gtk.VBox()
            self.container.show()
            self.set_canvas(self.container)

        if os.path.exists('/tmp/3'):
            os.remove('/tmp/3')
            self.label = gtk.Label(_("Hello World!"))
            self.container.add(self.label)
            self.label.set_angle(self.angle)
            self.label.show()

        if os.path.exists('/tmp/4'):
            os.remove('/tmp/4')
            self.button = gtk.Button("Rotate")
            self.container.add(self.button)
            self.button.connect('clicked', self.hello, None)
            self.button.show()
示例#16
0
    def __init__(self, handle):
        """Set up the Chutar 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()

        hbox = gtk.HBox()
        vbox = gtk.VBox()

        #se usaran para el marcador
        self.label = gtk.Label()
        self.label.modify_font(pango.FontDescription("Purisa 14"))
        frame = gtk.Frame("Marcador")

        #asignacion de variables a widgest de gtk
        self.vadjustment = gtk.Adjustment()
        self.hadjustment = gtk.Adjustment()

        #asignacion de valores por defecto del adjustment
        self.vadjustment.set_upper(100)
        self.vadjustment.set_value(0)
        self.hadjustment.set_upper(100)
        self.hadjustment.set_value(0)

        #asignacion de propiedades de widgets
        self.vslide = gtk.VScale(self.vadjustment)
        self.hslide = gtk.HScale(self.hadjustment)

        #propiedad para que no se muestre valor del slide
        self.vslide.set_draw_value(False)
        self.hslide.set_draw_value(False)

        #variables globales que se utilizan en los slides
        self.increment_x = self.increment_y = 1
        self.indicator_x = self.indicator_y = -1
        self.goles = 0

        #asignacion de variables de widgets
        self.drawing_area = gtk.DrawingArea()
        self.drawing_area.set_size_request(WIDTH, HEIGHT)

        #asignando cancha y arquero
        self.cancha = gtk.gdk.pixbuf_new_from_file('images/arcosugar.jpg')
        self.portero = gtk.gdk.pixbuf_new_from_file(
            'images/goalkeeper_downcenter.png')

        #window.connect("destroy", lambda w: gtk.main_quit())

        #callbacks al invocar el area de dibujo
        self.drawing_area.connect('configure_event', self.__configure_cb)
        self.drawing_area.connect('expose-event', self.__expose_cb)

        #evento que invoca funcion al presionar cualquier tecla
        self.connect('key-press-event', self.__key_press_event_cb)

        #anhadiendo widgets dentro del contenedor principal
        self.set_canvas(hbox)
        hbox.add(vbox)
        frame.add(self.label)
        vbox.add(frame)
        vbox.add(self.drawing_area)
        vbox.add(self.hslide)
        hbox.add(self.vslide)

        #mostrando los widgets
        self.show_all()

        #invocacion de la funcion que realiza loop del slider horizontal
        gobject.timeout_add(DELAY, self.__hslider_move_cb)
示例#17
0
    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)
示例#18
0
    def __init__(self, handle):
        if os.path.exists('/tmp/1'):
            os.remove('/tmp/1')
            """Set up the HelloWorld activity."""
            activity.Activity.__init__(self, handle)


        if os.path.exists('/tmp/2'):
            os.remove('/tmp/2')
            # 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)
            toolbar_box.toolbar.insert(title_entry, -1)
            title_entry.show()

            share_button = ShareButton(self)
            toolbar_box.toolbar.insert(share_button, -1)
            share_button.show()

            keep_button = KeepButton(self)
            toolbar_box.toolbar.insert(keep_button, -1)
            keep_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.container = gtk.VBox()
            self.container.show() 
            self.set_canvas(self.container)

        if os.path.exists('/tmp/3'):
            os.remove('/tmp/3')   
            self.label = gtk.Label(_("Hello World!"))
            self.container.add(self.label)  
            self.label.set_angle(self.angle)
            self.label.show()    
            
        if os.path.exists('/tmp/4'):
            os.remove('/tmp/4')      
            self.button = gtk.Button("Rotate")
            self.container.add(self.button)
            self.button.connect('clicked', self.hello, None)
            self.button.show()
示例#19
0
    def __init__(self, handle):
        """Set up the Elephant 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()

        # Instances to Elephants classes
        words = elephant.word_list()

        # Get a word form word list and path
        self.get_random_word(words)

        # Vertical box conteinter definition
        vbox_main = gtk.VBox()

        # Horizontal boxes conteiners definition
        hbox_01 = gtk.HBox()
        hbox_02 = gtk.HBox()
        hbox_03 = gtk.HBox()

        # Buttons definitions
        self.button_repeat = gtk.Button()
        self.button_repeat.set_label('Repetir')

        self.button_option1 = gtk.Button()
        self.button_option2 = gtk.Button()
        self.button_option3 = gtk.Button()

        # Image and label word
        self.label_word = gtk.Label()
        self.image_word = gtk.Image()
        #self.image_word = self.show_image(path)
        #self.label_word = self.show_label(word)

        # Create layout
        self.set_canvas(vbox_main)
        vbox_main.add(hbox_01)
        vbox_main.add(hbox_02)
        vbox_main.add(hbox_03)

        # Put label and label on layout
        hbox_02.add(self.image_word)
        hbox_02.add(self.label_word)

        # conectors
        self.connect('realize', self.__window_realize)
        self.button_repeat.connect('clicked', self.__button_clicked_rep)
        self.button_option1.connect('clicked', self.__button_clicked_op)
        self.button_option2.connect('clicked', self.__button_clicked_op)
        self.button_option3.connect('clicked', self.__button_clicked_op)

        # Put buttons on layout
        hbox_01.add(self.button_repeat)
        hbox_03.add(self.button_option1)
        hbox_03.add(self.button_option2)
        hbox_03.add(self.button_option3)

        # ShowMeTheMoney!!!
        vbox_main.show_all()
        #label_word.show()
        self.elephant_is_saying()
示例#20
0
    def __init__(self, handle):
        """Set up the Words 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.parser = SafeConfigParser()
        self.parser.read('config.ini')

        eb = gtk.EventBox()
        vbox = gtk.VBox()
        hbox = gtk.HBox()
        self.label = gtk.Label()
        self.label2 = gtk.Label()

        self.button1 = gtk.Button()
        self.button2 = gtk.Button()
        self.button3 = gtk.Button()

        self.add(eb)
        eb.add(vbox)
        eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('#f0f8ff'))
        vbox.add(self.label)
        vbox.add(self.label2)
        pangoFont = pango.FontDescription("Comic Sans MS 25")
        self.label.modify_font(pangoFont)
        self.label2.modify_font(pangoFont)
        self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#8b008b'))
        vbox.add(hbox)
        hbox.add(self.button1)
        hbox.add(self.button2)
        hbox.add(self.button3)

        self.button1.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color('#00fa9f'))
        self.button1.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('#00fa9f'))
        self.button1.modify_fg(gtk.STATE_ACTIVE, gtk.gdk.Color('#00fa9f'))
        self.button1.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.Color('#00fa9f'))
        self.button1.modify_fg(gtk.STATE_PRELIGHT, gtk.gdk.Color('#00fa9f'))
        self.button1.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color('#00fa9f'))
        self.button1.modify_fg(gtk.STATE_SELECTED, gtk.gdk.Color('#00fa9f'))
        self.button1.modify_bg(gtk.STATE_SELECTED, gtk.gdk.Color('#00fa9f'))
        self.button1.modify_fg(gtk.STATE_INSENSITIVE, gtk.gdk.Color('#00fa9f'))
        self.button1.modify_bg(gtk.STATE_INSENSITIVE, gtk.gdk.Color('#00fa9f'))

        self.button2.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color('#00fa9f'))
        self.button2.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('#00fa9f'))
        self.button2.modify_fg(gtk.STATE_ACTIVE, gtk.gdk.Color('#00fa9f'))
        self.button2.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.Color('#00fa9f'))
        self.button2.modify_fg(gtk.STATE_PRELIGHT, gtk.gdk.Color('#00fa9f'))
        self.button2.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color('#00fa9f'))
        self.button2.modify_fg(gtk.STATE_SELECTED, gtk.gdk.Color('#00fa9f'))
        self.button2.modify_bg(gtk.STATE_SELECTED, gtk.gdk.Color('#00fa9f'))
        self.button2.modify_fg(gtk.STATE_INSENSITIVE, gtk.gdk.Color('#00fa9f'))
        self.button2.modify_bg(gtk.STATE_INSENSITIVE, gtk.gdk.Color('#00fa9f'))

        self.button3.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color('#00fa9f'))
        self.button3.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('#00fa9f'))
        self.button3.modify_fg(gtk.STATE_ACTIVE, gtk.gdk.Color('#00fa9f'))
        self.button3.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.Color('#00fa9f'))
        self.button3.modify_fg(gtk.STATE_PRELIGHT, gtk.gdk.Color('#00fa9f'))
        self.button3.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color('#00fa9f'))
        self.button3.modify_fg(gtk.STATE_SELECTED, gtk.gdk.Color('#00fa9f'))
        self.button3.modify_bg(gtk.STATE_SELECTED, gtk.gdk.Color('#00fa9f'))
        self.button3.modify_fg(gtk.STATE_INSENSITIVE, gtk.gdk.Color('#00fa9f'))
        self.button3.modify_bg(gtk.STATE_INSENSITIVE, gtk.gdk.Color('#00fa9f'))

        self.set_canvas(eb)
        self.connect('destroy', self.destroy)
        self.show_all()

        self.actualizar()

        self.button1.connect('clicked', self.__button_clicked_cb, 'op1')
        self.button2.connect('clicked', self.__button_clicked_cb, 'op2')
        self.button3.connect('clicked', self.__button_clicked_cb, 'op3')
示例#21
0
    def __init__(self, handle):
        """Set up the StopWatch activity."""
        Activity.__init__(self, handle)
        self._logger = logging.getLogger('stopwatch-activity')

        gobject.threads_init()

        # top toolbar with share and close buttons:
        OLD_TOOLBAR = False

        try:
            from sugar.graphics.toolbarbox import ToolbarBox, ToolbarButton
            from sugar.activity.widgets import ActivityToolbarButton, StopButton, \
                    ShareButton, TitleEntry, ActivityButton
        except ImportError:
            OLD_TOOLBAR = True

        if OLD_TOOLBAR:
            toolbox = ActivityToolbox(self)
            self.set_toolbox(toolbox)
            toolbox.show()
        else:
            toolbar_box = ToolbarBox()
            self.activity_button = ActivityButton(self)
            toolbar_box.toolbar.insert(self.activity_button, 0)
            self.activity_button.show()

            title_entry = TitleEntry(self)
            toolbar_box.toolbar.insert(title_entry, -1)
            title_entry.show()

            try:
                from sugar.activity.widgets import DescriptionItem
                description_item = DescriptionItem(self)
                toolbar_box.toolbar.insert(description_item, -1)
                description_item.show()
            except:
                pass

            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)

        self.tubebox = dobject.TubeBox()
        self.timer = dobject.TimeHandler("main", self.tubebox)
        self.gui = stopwatch.GUIView(self.tubebox, self.timer)

        self.set_canvas(self.gui.display)
        self.show_all()

        self.initiating = False

        # get the Presence Service
        self.pservice = presenceservice.get_instance()
        # Buddy object for you
        owner = self.pservice.get_owner()
        self.owner = owner

        self.connect('shared', self._shared_cb)
        self.connect('joined', self._joined_cb)

        self.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK)
        self.connect("visibility-notify-event", self._visible_cb)
        self.connect("notify::active", self._active_cb)
示例#22
0
    def __init__(self, handle):
        """Set up the Textdungeon activity."""
        activity.Activity.__init__(self, handle)

        # we do not have collaboration features
        # make the share option insensitive
        self.max_participants = 1

        if _NEW_TOOLBAR_SUPPORT:
            # toolbar with the new toolbar redesign >= Sugar 0.88?
            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()

            keep_button = KeepButton(self)
            toolbar_box.toolbar.insert(keep_button, -1)
            keep_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()

        else:
            toolbox = activity.ActivityToolbox(self)
            self.set_toolbox(toolbox)
            toolbox.show()

        self.scrolled_window = gtk.ScrolledWindow()
        self.scrolled_window.set_policy(gtk.POLICY_NEVER,
            gtk.POLICY_AUTOMATIC)
        self.scrolled_window.props.shadow_type = \
            gtk.SHADOW_NONE
        self.textview = gtk.TextView()
        self.textview.set_editable(True)
        self.textview.set_cursor_visible(True)
        self.textview.set_wrap_mode(True)
        self.textview.connect("key_press_event",
            self.keypress_cb)

        self.scrolled_window.add(self.textview)
        self.set_canvas(self.scrolled_window)
        self.textview.show()
        self.scrolled_window.show()
        self.textview.grab_focus()
        self.font_desc = pango.FontDescription("sans %d" %
            style.zoom(8))
        self.textview.modify_font(self.font_desc)
#        self.stringthing=""

        self.loc =[0, 0]
        self.direction =0
        self.roomdata  =[]
        self.items=[]
        self.doors=[]
        self.inventory=[]
        self.keyboardentrystring=''
        self.filecontents=''
        self.printtobuf( 'Press h for help')
        self.printtobuf( 'Use a text editor such as the Write Activity to edit this dungeon, create new ones or reset a dungeon\n')
        self.printtobuf( 'You are in a dimly lit cavern ' + 'facing '+ compass(self.direction))
        if handle.object_id==None:
            readroomfile(self)                  #load the default room 
示例#23
0
文件: activity.py 项目: icarito/a8
  def __init__(self, handle):
    """Set up the activity."""
    activity.Activity.__init__(self, handle)

    """Create the user interface."""
    self.stack = gtk.VBox()
    self.add(self.stack)
    self.hpaned = gtk.HPaned()
    self.stack.pack_end(self.hpaned)
    self.vpaned = gtk.VPaned()
    self.hpaned.pack2(self.vpaned, shrink=False)
    self.hpaned.set_position(200)
    self.plugins = window.PluginTabs()
    self.hpaned.pack1(self.plugins.widget, shrink=False)

    self.model = Abominade(self)

    self.plugins.add_main(self.model.buffers)
    self.plugins.add_tab(self.model.files)
    self.plugins.add_tab(self.model.bookmarks)
    self.plugins.add_tab(self.model.terminals)
    self.vpaned.pack1(self.model.vim.widget, resize=True, shrink=False)
    self.vpaned.pack2(self.model.terminals.book, resize=False, shrink=False)
    # make sure buffers list isn't zero-height
    if self.plugins.stack.get_position() < 200:
      self.plugins.stack.set_position(200)
    
    self.stack.show_all()
    self.set_canvas(self.stack)

    self.init_interpreter()
    label = gtk.Label("Consola")
    self.model.terminals.book.prepend_page(self.interpreter, tab_label=label)

    # 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()

    self.sidebar_button = ToggleToolButton('folder')
    self.sidebar_button.set_active(True)
    self.sidebar_button.set_tooltip('Consola')
    self.sidebar_button.accelerator = "<Ctrl>grave"
    self.sidebar_button.connect('clicked', self.toggle_sidebar)
    toolbar_box.toolbar.insert(self.sidebar_button, -1)
    self.sidebar_button.show()

    self.bottom_button = ToggleToolButton('tray-show')
    self.bottom_button.set_active(True)
    self.bottom_button.set_tooltip('Consola')
    self.bottom_button.accelerator = "<Ctrl>grave"
    self.bottom_button.connect('clicked', self.toggle_bottom)
    toolbar_box.toolbar.insert(self.bottom_button, -1)
    self.bottom_button.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.model.start()
示例#24
0
    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 &")
示例#25
0
    def __init__(self, handle):
        super(Chat, self).__init__(handle)

        smilies.init()

        self.entry = None
        self.chatbox = None

        root = self.make_root()
        self.set_canvas(root)
        root.show_all()
        self.entry.grab_focus()

        toolbar_box = ToolbarBox()
        self.set_toolbar_box(toolbar_box)
        toolbar_box.toolbar.insert(ActivityButton(self), -1)
        toolbar_box.toolbar.insert(TitleEntry(self), -1)

        share_button = ShareButton(self)
        toolbar_box.toolbar.insert(share_button, -1)

        separator = gtk.SeparatorToolItem()
        toolbar_box.toolbar.insert(separator, -1)

        self._smiley = RadioMenuButton(icon_name='smilies')
        self._smiley.palette = Palette(_('Insert smiley'))
        self._smiley.props.sensitive = False
        toolbar_box.toolbar.insert(self._smiley, -1)

        table = self._create_pallete_smiley_table()
        table.show_all()
        self._smiley.palette.set_content(table)

        separator = gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        toolbar_box.toolbar.insert(separator, -1)

        toolbar_box.toolbar.insert(StopButton(self), -1)
        toolbar_box.show_all()

        pservice = presenceservice.get_instance()
        self.owner = pservice.get_owner()
        # Chat is room or one to one:
        self._chat_is_room = False
        self.text_channel = None

        if self.shared_activity:
            # we are joining the activity
            self.connect('joined', self._joined_cb)
            if self.get_shared():
                # we have already joined
                self._joined_cb(self)
        elif handle.uri:
            # XMPP non-Sugar incoming chat, not sharable
            share_button.props.visible = False
            self._one_to_one_connection(handle.uri)
        else:
            # we are creating the activity
            if not self.metadata or self.metadata.get(
                    'share-scope',
                    activity.SCOPE_PRIVATE) == activity.SCOPE_PRIVATE:
                # if we are in private session
                self._alert(_('Off-line'), _('Share, or invite someone.'))
            self.connect('shared', self._shared_cb)
示例#26
0
    def __init__(self, handle):
        """Set up the CalculArte 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()

        vbox = gtk.VBox()
        hbox = gtk.HBox(True)
        self.label_historial = gtk.Label()
        self.label_historial.set_line_wrap(True)
        self.entry_visor = gtk.Entry()
        self.table = gtk.Table(5, 5, True)
        boton = gtk.Button('boton falso')
        self.label_historial.set_text('Ultimo resultado:')
        self.set_canvas(hbox)
        hbox.add(vbox)
        hbox.add(self.label_historial)
        vbox.add(self.entry_visor)
        vbox.add(self.table)
        vbox.add(boton)

        OPTIONS.reverse()
        for j in range(4):
            for i in range(OPT_LENGHT):
                button = gtk.Button()
                option = OPTIONS.pop()
                button.set_label(option)
                button.connect('activate', self.__button_cb, self.entry_visor,
                               boton, self.label_historial)
                self.connect('key-press-event', self.__barrido_columnas_cb)
                #canvas = self.get_canvas()
                #canvas.connect('key-press-event', self.__barrido_columnas_cb)
                if option == 'Aceptar':
                    self.table.attach(button, i, i + 3, j, j + 1)
                    break
                else:
                    self.table.attach(button, i, i + 1, j, j + 1)
        hbox.show_all()
        boton.hide()

        OPTIONS.reverse()

        self._filas_index = 0
        self._columnas_index = 0
        self._flag_fila_columna = 0
        gobject.timeout_add(DELAY, self.__timeout_cb, self.table)
示例#27
0
    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()
示例#28
0
    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()

        # label with the text, make the string translatable
        win = gtk.VBox()
        eb = gtk.EventBox()
        eb.add(win)
        eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('White'))
        title = gtk.Image()
        achehety = gtk.Image()
        texto = gtk.Entry()
        traducido = gtk.TextView()
        traducido.set_editable(False)
        traducido.set_wrap_mode(gtk.WRAP_WORD)
        dic = gtk.TextView()
        textbuffer = dic.get_buffer()
        dic.set_wrap_mode(gtk.WRAP_WORD)
        dic.set_editable(False)

        hbox3 = gtk.HButtonBox()
        hbox3.set_layout(gtk.BUTTONBOX_CENTER)

        parser = SafeConfigParser()
        parser.read('config.ini')
        bo1 = gtk.Button(parser.get('dic', 'A'))
        bo1.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('#FCB947'))
        bo2 = gtk.Button(parser.get('dic', 'E'))
        bo3 = gtk.Button(parser.get('dic', 'I'))
        bo3.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('#FCB947'))
        bo4 = gtk.Button(parser.get('dic', 'O'))
        bo5 = gtk.Button(parser.get('dic', 'U'))
        bo5.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('#FCB947'))
        bo6 = gtk.Button(parser.get('dic', 'Y'))
        bo7 = gtk.Button(parser.get('dic', 'G'))
        bo7.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color('#FCB947'))
        #connect
        pixbuf = gtk.gdk.pixbuf_new_from_file('images/logo.jpg')
        scaled_pixbuf = pixbuf.scale_simple(400, 100, gtk.gdk.INTERP_BILINEAR)
        title.set_from_pixbuf(scaled_pixbuf)
        pixbuf = gtk.gdk.pixbuf_new_from_file('images/achegety.jpg')
        scaled_pixbuf = pixbuf.scale_simple(600, 200, gtk.gdk.INTERP_BILINEAR)
        achehety.set_from_pixbuf(scaled_pixbuf)
        bo1.connect('clicked', self.__agregar__, texto, 'A')
        bo2.connect('clicked', self.__agregar__, texto, 'E')
        bo3.connect('clicked', self.__agregar__, texto, 'I')
        bo4.connect('clicked', self.__agregar__, texto, 'O')
        bo5.connect('clicked', self.__agregar__, texto, 'U')
        bo6.connect('clicked', self.__agregar__, texto, 'Y')
        bo7.connect('clicked', self.__agregar__, texto, 'G')
        #Cargando archivo .txt
        infile = open("lang/guarani/dic.txt", "r")
        if infile:
            string = infile.read()
            infile.close()
            textbuffer.set_text(string)

        hbox2 = gtk.HBox()

        # Conexion de botones
        texto.connect("activate", self.traducir_cb, traducido)
        texto.connect("backspace", self.__backspace_cb, traducido)

        # creando scrolled
        scrolled_window = gtk.ScrolledWindow()
        scrolled_window.set_border_width(10)
        scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)

        scrolled_window.add_with_viewport(dic)
        #Disenho de ventana
        self.set_canvas(eb)
        win.add(title)
        win.add(hbox3)
        hbox3.add(bo1)
        hbox3.add(bo2)
        hbox3.add(bo3)
        hbox3.add(bo4)
        hbox3.add(bo5)
        hbox3.add(bo6)
        hbox3.add(bo7)
        win.add(texto)
        win.add(traducido)
        win.add(hbox2)
        win.add(achehety)
        win.add(scrolled_window)

        eb.show_all()