예제 #1
0
    def __init__(self, activity,**kwargs):
        super(BasicToolbar, self).__init__(**kwargs)
        
        
        activity_button = ActivityButton(activity)
        self.toolbar.insert(activity_button, 0)
        activity_button.show()

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

        description_item = DescriptionItem(activity)
        self.toolbar.insert(description_item, -1)
        description_item.show()

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

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

        stop_button = StopButton(activity)
        self.toolbar.insert(stop_button, -1)
        stop_button.show()
예제 #2
0
    def make_toolbar(self):
        # 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()

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.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()
예제 #3
0
def toolbar(self):
        # 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()

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.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()

        return toolbar_box
예제 #4
0
    def __init__(self, activity, **kwargs):
        super(BasicToolbar, self).__init__(**kwargs)

        activity_button = ActivityButton(activity)
        self.toolbar.insert(activity_button, 0)
        activity_button.show()

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

        description_item = DescriptionItem(activity)
        self.toolbar.insert(description_item, -1)
        description_item.show()

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

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

        stop_button = StopButton(activity)
        self.toolbar.insert(stop_button, -1)
        stop_button.show()
예제 #5
0
    def __init__(self, handle):
        """Set up the Astroangles 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()

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.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.game = AstroanglesGame(self)
        self.game.canvas = sugargame.canvas.PygameCanvas(
            self, main=self.game.run, modules=[pygame.display, pygame.font])

        w = Gdk.Screen.width()
        h = Gdk.Screen.height() - 2 * GRID_CELL_SIZE

        self.game.canvas.set_size_request(w, h)

        self._notebook = Gtk.Notebook(show_tabs=False)
        self._notebook.add(self.game.canvas)

        self.set_canvas(self.game.canvas)
        Gdk.Screen.get_default().connect('size-changed', self.__configure_cb)
        self.canvas = self._notebook

        self.show_all()
    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()

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.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()

        # Main layout setup
        layout = Gtk.Grid()
        layout.set_halign(Gtk.Align.CENTER)
        layout.set_valign(Gtk.Align.CENTER)
        self.msg = Gtk.Label("This is a secret message!")
        self.sbutton = Gtk.Button("Show message")
        self.sbutton.connect("clicked", self._show)
        self.sbutton.set_sensitive(False)
        self.hbutton = Gtk.Button("Hide Message")
        self.hbutton.connect("clicked", self._hide)
        layout.attach(self.msg, 0, 0, 2, 1)
        layout.attach_next_to(self.sbutton, self.msg, Gtk.PositionType.BOTTOM,
                              1, 1)
        layout.attach_next_to(self.hbutton, self.sbutton,
                              Gtk.PositionType.RIGHT, 1, 1)
        self.set_canvas(layout)
        self.show_all()
    def __init__(self, handle):
        """Set up the ToDo 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()

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.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.scrollabeWindow = Gtk.ScrolledWindow()

        self.vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.scrollabeWindow.add(self.vbox)
        self.todo = {}
        self.count = 0

        self.create()

        self.set_canvas(self.scrollabeWindow)
        self.scrollabeWindow.show_all()
예제 #8
0
    def __init__(self, handle):
        self.mini = None

        activity.Activity.__init__(self, handle)

        #color = Gdk.color_parse(Config.WS_BCK_COLOR)
        #self.modify_bg(Gtk.StateType.NORMAL, color)

        self.set_title('TamTam Mini')
        self.set_resizable(False)

        self.trackpad = Trackpad(self)
        self.trackpad.setContext('mini')

        self.connect('notify::active', self.onActive)
        self.connect('destroy', self.onDestroy)

        #load the sugar toolbar
        toolbox = ToolbarBox()
        toolbox.toolbar.insert(widgets.ActivityButton(self), -1)
        toolbox.toolbar.insert(widgets.TitleEntry(self), -1)

        description_item = DescriptionItem(self)
        toolbox.toolbar.insert(description_item, -1)
        description_item.show()

        toolbox.toolbar.insert(widgets.ShareButton(self), -1)

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

        toolbox.toolbar.insert(widgets.StopButton(self), -1)
        toolbox.toolbar.show_all()

        toolbox.show()
        self.set_toolbar_box(toolbox)

        self.mini = miniTamTamMain(self)
        self.mini.onActivate(arg=None)
        self.mini.updateInstrumentPanel()

        #self.modeList[mode].regenerate()

        self.set_canvas(self.mini)
        self.mini.instrumentPanel.grab_focus()
        self.set_size_request(Gdk.Screen.width(), Gdk.Screen.height())
        self.show()
        logging.error('Activity startup end')
예제 #9
0
    def __init__(self, handle):
        self.mini = None

        activity.Activity.__init__(self, handle)

        #color = Gdk.color_parse(Config.WS_BCK_COLOR)
        #self.modify_bg(Gtk.StateType.NORMAL, color)

        self.set_title('TamTam Mini')
        self.set_resizable(False)

        self.trackpad = Trackpad(self)
        self.trackpad.setContext('mini')

        self.connect('notify::active', self.onActive)
        self.connect('destroy', self.onDestroy)

        #load the sugar toolbar
        toolbox = ToolbarBox()
        toolbox.toolbar.insert(widgets.ActivityButton(self), -1)
        toolbox.toolbar.insert(widgets.TitleEntry(self), -1)

        description_item = DescriptionItem(self)
        toolbox.toolbar.insert(description_item, -1)
        description_item.show()

        toolbox.toolbar.insert(widgets.ShareButton(self), -1)

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

        toolbox.toolbar.insert(widgets.StopButton(self), -1)
        toolbox.toolbar.show_all()

        toolbox.show()
        self.set_toolbar_box(toolbox)

        self.mini = miniTamTamMain(self)
        self.mini.onActivate(arg=None)
        self.mini.updateInstrumentPanel()

        #self.modeList[mode].regenerate()

        self.set_canvas(self.mini)
        self.mini.instrumentPanel.grab_focus()
        self.set_size_request(Gdk.Screen.width(), Gdk.Screen.height())
        self.show()
        logging.error('Activity startup end')
예제 #10
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()

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.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!"))
        self.set_canvas(label)
        label.show()
    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()

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.show()

        if self.max_participants > 1:
            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()

        canvas = Gtk.DrawingArea()
        self.block_party = BlockParty(
            self, canvas,
            font_face=style.FONT_FACE, font_size=style.FONT_SIZE * 2,
            gcs=style.GRID_CELL_SIZE)
        self.set_canvas(canvas)
        canvas.show()
예제 #12
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()

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.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()
예제 #13
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()

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.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()
예제 #14
0
    def __init__(self, handle):
        """Set up the 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()

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.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.display_menu()
예제 #15
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()

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.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()

        # main view
        touch_area = TouchArea()
        self.set_canvas(touch_area)
        touch_area.show()
예제 #16
0
    def __init__(self, handle):
        "The entry point to the Activity"
        activity.Activity.__init__(self, handle)
        self._timeout = None

        self.accelerometer = False
        try:
            open(ACCELEROMETER_DEVICE).close()
            self.accelerometer = True
        except:
            pass

        if not self.accelerometer and not self.shared_activity:
            return self._incompatible()

        self.buddies = {}

        canvas = MyCanvas(self)
        self.set_canvas(canvas)
        canvas.show()

        toolbar_box = ToolbarBox()
        self.set_toolbar_box(toolbar_box)

        toolbar_box.toolbar.insert(ActivityButton(self), 0)
        toolbar_box.toolbar.insert(TitleEntry(self), -1)
        toolbar_box.toolbar.insert(DescriptionItem(self), -1)
        toolbar_box.toolbar.insert(ShareButton(self), -1)

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

        self._udp = Udp()
        self.hosts = {}

        self._collab = CollabWrapper(self)
        self._collab.message.connect(self.__message_cb)
        self._collab.buddy_joined.connect(self.__buddy_joined_cb)
        self._collab.buddy_left.connect(self.__buddy_left_cb)
        self._collab.setup()

        self._fuse = 1
        self._timeout = GLib.timeout_add(100, self._timeout_cb, canvas)
예제 #17
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()

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.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()

        #make a grid
        self.grid = Gtk.Grid()
        self.set_canvas(self.grid)

        #chat
        self.button2 = Gtk.Button(label="Submit")
        self.button2.connect("clicked", self.chat)
        self.grid.attach(self.button2, 15, 0, 4, 1)
        self.button2.show()

        #entry
        self.entry = Gtk.Entry()
        self.entry.set_width_chars(60)
        self.entry.set_placeholder_text(
            _("Type in your question or add a question"))
        self.entry.connect("activate", self.chat)
        self.grid.attach(self.entry, 10, 0, 4, 1)
        self.entry.show()

        #Help
        alignment = Gtk.Alignment.new(0., 0.5, 0., 0.)
        self.help_label = Gtk.Label()
        alignment.add(self.help_label)
        help_message = '%s\n%s\n%s\n%s\n\n%s' % (
            _("To ask a question, type the question into the form without a question mark."
              ), _("To add a new question, type Question?Answer"),
            _("To import questions type in \
i: JSON-encoded Q/A dictionary entries,"),
            _("To export questions, type in e:"),
            _("See full docs at https://bit.do/mcbh"))
        self.help_label.set_text(help_message)
        self.help_label.show()
        self.grid.attach(alignment, 0, 1, 4, 5)
        alignment.show()
        self.grid.show()

        self.label = Gtk.Label("")
        self.grid.attach(self.label, 0, 0, 4, 1)
예제 #18
0
    def __init__(self, handle):
        """Set up the ImagineNumber activity."""
        activity.Activity.__init__(self, handle)

        # No es necesario compartir
        # Esto hace que la opcion de compartir no funcione
        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()

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.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()

        #Ahora generaremos los numeros aleatorios y le creamos la cadena correspondiente
        ran_a = random.randint(1, 100)
        ran_b = random.randint(1, 100)
        ran_c = random.randint(1, 100)
        num_imagined = ran_a + ran_b - ran_c
        cad_1 = _("Now add ")
        cad_2 = _("Now subtract ")
        cad_3 = _(" to the number you have imagined")
        cad_4 = _("The final number is ")
        cad_5 = _("I have already added")
        cad_6 = _("I have already subtracted")
        cad_7 = _("Imagine a number between 1 and 100")
        cad_8 = _(
            "Now subtract the number that you have imagined at the beginning")
        str_1 = cad_1 + str(ran_a) + cad_3
        str_2 = cad_1 + str(ran_b) + cad_3
        str_3 = cad_2 + str(ran_c) + cad_3
        str_4 = cad_4 + str(num_imagined)

        #Creamos la primera caja con todo lo que contendra
        box_1 = Gtk.VBox()
        label_1 = Gtk.Label()
        label_1.set_markup("<span font=\"30\"><b>" + cad_7 + "</b></span>")
        button_1 = Gtk.Button(_("Already imagined"))

        #Creamos la segunda caja
        box_2 = Gtk.VBox()
        label_2 = Gtk.Label()
        label_2.set_markup("<span font=\"30\"><b>" + str_1 + "</b></span>")
        button_2 = Gtk.Button(cad_5)

        #Creamos la tercera caja
        box_3 = Gtk.VBox()
        label_3 = Gtk.Label()
        label_3.set_markup("<span font=\"30\"><b>" + str_2 + "</b></span>")
        button_3 = Gtk.Button(cad_5)

        #Creamos la cuarta caja
        box_4 = Gtk.VBox()
        label_4 = Gtk.Label()
        label_4.set_markup("<span font=\"30\"><b>" + str_3 + "</b></span>")
        button_4 = Gtk.Button(cad_6)

        #Creamos la quinta caja
        box_5 = Gtk.VBox()
        label_5 = Gtk.Label()
        label_5.set_markup("<span font=\"30\"><b>" + cad_8 + "</b></span>")
        button_5 = Gtk.Button(cad_6)

        #Creamos la sexta caja
        box_6 = Gtk.VBox()
        label_6 = Gtk.Label()
        label_6.set_markup("<span font=\"30\"><b>" + str_4 + "</b></span>")
        button_6 = Gtk.Button(_("Play again"))

        #Empaquetamos todo a las cajas correspondientes
        box_1.pack_start(label_1, True, True, 10)
        box_1.pack_start(button_1, False, False, 10)

        box_2.pack_start(label_2, True, True, 10)
        box_2.pack_start(button_2, False, False, 10)

        box_3.pack_start(label_3, True, True, 10)
        box_3.pack_start(button_3, False, False, 10)

        box_4.pack_start(label_4, True, True, 10)
        box_4.pack_start(button_4, False, False, 10)

        box_5.pack_start(label_5, True, True, 10)
        box_5.pack_start(button_5, False, False, 10)

        box_6.pack_start(label_6, True, True, 10)
        box_6.pack_start(button_6, False, False, 10)

        #Ahora le configuramos una accion al evento clicked del boton
        button_1.connect("clicked", self.action, box_1, box_2)
        button_2.connect("clicked", self.action, box_2, box_3)
        button_3.connect("clicked", self.action, box_3, box_4)
        button_4.connect("clicked", self.action, box_4, box_5)
        button_5.connect("clicked", self.action, box_5, box_6)
        button_6.connect("clicked", self.action, box_6, box_1)

        #Ahora agregamos la primera caja a la ventana principal
        self.set_canvas(box_1)

        box_1.show_all()
예제 #19
0
    def __init__(self, handle):
        pservice = presenceservice.get_instance()
        self.owner = pservice.get_owner()

        self._ebook_mode_detector = EbookModeDetector()

        self.chatbox = ChatBox(self.owner,
                               self._ebook_mode_detector.get_ebook_mode())
        self.chatbox.connect('open-on-journal', self.__open_on_journal)

        super(Chat, self).__init__(handle)

        self._entry = None
        self._has_alert = False
        self._has_osk = False

        self._setup_canvas()

        self._entry.grab_focus()

        toolbar_box = ToolbarBox()
        self.set_toolbar_box(toolbar_box)

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

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.show()

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

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

        # Chat is room or one to one:
        self._chat_is_room = False
        self.text_channel = None

        if _HAS_SOUND:
            self.element = Gst.ElementFactory.make('playbin', 'Player')

        if self.shared_activity:
            # we are joining the activity following an invite
            self._entry.props.placeholder_text = \
                _('Please wait for a connection before starting to chat.')
            self.connect('joined', self._joined_cb)
            if self.get_shared():
                # we have already joined
                self._joined_cb(self)
        elif handle.uri:
            # XMPP non-sugar3 incoming chat, not sharable
            self._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.'))
            else:
                # resume of shared activity from journal object without invite
                self._entry.props.placeholder_text = \
                    _('Please wait for a connection before starting to chat.')
            self.connect('shared', self._shared_cb)
예제 #20
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()

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.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()

        #make a grid
        self.grid = Gtk.Grid()
        self.set_canvas(self.grid)

        #chat
        self.button2 = Gtk.Button(label="Submit")
        self.button2.connect("clicked", self.chat)
        self.grid.attach(self.button2, 15, 0, 4, 1)
        self.button2.show()

        #entry
        self.entry = Gtk.Entry()
        self.entry.set_width_chars(60)
        self.entry.set_placeholder_text(
            _("Type in your question or add a question"))
        self.entry.connect("activate", self.chat)
        self.grid.attach(self.entry, 10, 0, 4, 1)
        self.entry.show()

        #Help
        alignment = Gtk.Alignment.new(0., 0.5, 0., 0.)
        self.help_label = Gtk.Label()
        alignment.add(self.help_label)
        help_message = '%s\n%s\n%s\n%s\n%s\n' % (
            _("here are some example questions"),
            _("Pick a number from X to XX"), _("Roll a die or a dreidel"),
            _("flip a coin"), _("rock, paper, scissors"))
        self.help_label.set_text(help_message)
        self.help_label.show()
        self.grid.attach(alignment, 0, 1, 4, 5)
        alignment.show()
        self.grid.show()

        self.label = Gtk.Label("")
        self.grid.attach(self.label, 0, 0, 4, 1)
예제 #21
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

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
        self.add(box)
        self.set_canvas(box)

        # toolbar with the new toolbar redesign
        toolbar_box = ToolbarBox()

        self.image = Gtk.Image()
        self.image.show()
        self.label = Gtk.Label()

        activity_button = ActivityButton(self)
        toolbar_box.toolbar.insert(activity_button, 0)
        activity_button.show()

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.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.text = Gtk.Entry()

        self.text.show()
        #textbuffer = self.text.get_buffer()
        #textbuffer.set_text("hello")
        self.text.set_placeholder_text("URL")

        self.label.show()

        label1 = Gtk.Label()
        label1.show()
        label1.set_text("Image URL goes here")

        label2 = Gtk.Label()
        label2.show()
        label2.set_text("")

        button = Gtk.Button(_("Describe"))
        button.connect("clicked", self.on_open_clicked)
        box.show()
        box.add(label2)
        box.add(label1)
        box.add(self.text)
        button.show()
        box.add(button)
        box.add(self.image)
        box.add(self.label)
예제 #22
0
    def __init__(self, handle):
        '''Set up the Acoustic Tape Measure activity.'''
        super(AcousticMeasureActivity, self).__init__(handle)

        #self.set_title(_('Acoustic Tape Measure Activity'))
        self._logger = logging.getLogger('acousticmeasure-activity')

        GObject.threads_init()

        try:
            self._logger.debug("locale: " +
                               locale.setlocale(locale.LC_ALL, ''))
        except locale.Error:
            self._logger.error("setlocale failed")

        # top toolbar with share and close buttons:

        from sugar3.graphics.toolbarbox import ToolbarBox
        from sugar3.graphics.toolbarbox import ToolbarButton
        from sugar3.activity.widgets import ShareButton
        from sugar3.activity.widgets import StopButton
        from sugar3.activity.widgets import ActivityButton
        from sugar3.activity.widgets import 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()

        try:
            from sugar3.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()
        toolbar_box.toolbar.insert(separator, -1)
        separator.show()

        self._t_h_bar = atm_toolbars.TempToolbar()
        tb = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        self._t_h_bar.show_all()
        adj_button = ToolbarButton(page=self._t_h_bar,
                                   icon_name='preferences-system')
        toolbar_box.toolbar.insert(adj_button, -1)
        adj_button.show()

        self._smoot_bar = smoot_toolbar.SmootToolbar(self)
        self._smoot_bar.show_all()
        custom_button = ToolbarButton(page=self._smoot_bar,
                                      icon_name='view-source')
        toolbar_box.toolbar.insert(custom_button, -1)
        custom_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()
        toolbar = toolbar_box.toolbar

        if not self.powerd_running():
            try:
                bus = dbus.SystemBus()
                proxy = bus.get_object('org.freedesktop.ohm',
                                       '/org/freedesktop/ohm/Keystore')
                self.ohm_keystore = dbus.Interface(
                    proxy, 'org.freedesktop.ohm.Keystore')
            except dbus.DBusException, e:
                self._logger.warning("Error setting OHM inhibit: %s" % e)
                self.ohm_keystore = None
예제 #23
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

        self.gameLoader = GameLoader()
        self.userInput = False

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

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.show()

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

        execute_button = ToolButton('run-icon')
        toolbar_box.toolbar.insert(execute_button, -1)
        execute_button.connect("clicked", self.start_game)
        execute_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.grid = Gtk.Grid(column_homogeneous=True,
                             row_homogeneous=True,
                             column_spacing=20,
                             row_spacing=20)
        self.add(self.grid)

        self.title = Gtk.Label('Simon-Says')
        self.title.modify_font(Pango.FontDescription("sans 32"))
        self.title.show()
        self.grid.attach(self.title, 0, 0, 8, 1)

        self.score = Gtk.Label('')
        self.score.modify_font(Pango.FontDescription("sans 18"))
        self.score.show()
        self.grid.attach(self.score, 0, 1, 8, 1)

        self.set_canvas(self.grid)
        self.grid.show()
예제 #24
0
파일: activity.py 프로젝트: sugarlabs/chat
    def __init__(self, handle):
        pservice = presenceservice.get_instance()
        self.owner = pservice.get_owner()

        self._ebook_mode_detector = EbookModeDetector()

        self.chatbox = ChatBox(
            self.owner, self._ebook_mode_detector.get_ebook_mode())
        self.chatbox.connect('open-on-journal', self.__open_on_journal)

        super(Chat, self).__init__(handle)

        self._entry = None
        self._has_alert = False
        self._has_osk = False

        self._setup_canvas()

        self._entry.grab_focus()

        toolbar_box = ToolbarBox()
        self.set_toolbar_box(toolbar_box)

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

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.show()

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

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

        # Chat is room or one to one:
        self._chat_is_room = False
        self.text_channel = None

        if _HAS_SOUND:
            self.element = Gst.ElementFactory.make('playbin', 'Player')

        if self.shared_activity:
            # we are joining the activity following an invite
            self._entry.props.placeholder_text = \
                _('Please wait for a connection before starting to chat.')
            self.connect('joined', self._joined_cb)
            if self.get_shared():
                # we have already joined
                self._joined_cb(self)
        elif handle.uri:
            # XMPP non-sugar3 incoming chat, not sharable
            self._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.'))
            else:
                # resume of shared activity from journal object without invite
                self._entry.props.placeholder_text = \
                    _('Please wait for a connection before starting to chat.')
            self.connect('shared', self._shared_cb)
예제 #25
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 = 1s

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=20)
        self.add(box)
        self.set_canvas(box)

        # toolbar with the new toolbar redesign
        toolbar_box = ToolbarBox()
        
        activity_button = ActivityButton(self)
        toolbar_box.toolbar.insert(activity_button, 0)
        activity_button.show()

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.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 = Gtk.Label()
        label.set_text(_("Enter text"))
        label.show()
        
        self.text = Gtk.Entry()
        self.text.set_placeholder_text(_("Enter here"))
        self.text.show()
        
        self.text2 = Gtk.Entry()
        self.text2.set_placeholder_text(_("Out"))
        self.text2.show()
        
        button = Gtk.Button(_("Morse It"))
        button.connect("clicked", self.on_clicked)
        button.show()
        
        image = Gtk.Image()
        image.set_from_file("morse")
        image.show()

        box.show()
        box.add(label)
        box.add(self.text)
        box.add(button)
        box.add(self.text2)
        box.add(image)
예제 #26
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)

        GObject.threads_init()

        self.set_title(_("Translate Activity"))

        self._logger = logging.getLogger('Translate')
        self._logger.info('Starting translate activity')

        # XXX: Perhaps spin up a local server instead of specifying an invalid
        #      one?
        self.client = translate.client.Client(
            os.environ.get('TRANSLATE_SERVER', DEFAULT_SERVER),
            port=os.environ.get('TRANSLATE_PORT', DEFAULT_PORT))

        toolbar_box = ToolbarBox()
        activity_button = widgets.ActivityToolbarButton(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()

        description_item = DescriptionItem(self)
        description_item.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()

        # Main vertical layout of this window
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
        # Text areas
        text_hbox = Gtk.Box(spacing=6)
        # Selection area (langs + translate button)
        select_hbox = Gtk.Box(spacing=6)

        vbox.pack_start(select_hbox, False, True, 6)
        vbox.pack_start(text_hbox, True, True, 0)

        # Spacers
        text_hbox.pack_start(Gtk.Box(), False, True, 10)
        text_hbox.pack_end(Gtk.Box(), False, True, 10)
        select_hbox.pack_start(Gtk.Box(), False, True, 10)
        select_hbox.pack_end(Gtk.Box(), False, True, 10)
        vbox.pack_end(Gtk.Box(), False, True, 10)

        select_hbox.pack_start(Gtk.Label(_("Translate from:")),
                               False, False, 0)

        # Models for the ComboBoxes
        from_lang_store = Gtk.ListStore(str, str)
        to_lang_store = Gtk.ListStore(str, str)

        self.lang_from = Gtk.ComboBox.new_with_model_and_entry(from_lang_store)
        self.lang_to = Gtk.ComboBox.new_with_model_and_entry(to_lang_store)

        self.lang_from.connect("changed", self._lang_from_changed_cb)

        self.lang_from.set_entry_text_column(1)
        self.lang_to.set_entry_text_column(1)

        select_hbox.pack_start(self.lang_from, False, False, 0)
        select_hbox.pack_start(Gtk.Label(_("Translate to:")), False, False, 6)
        select_hbox.pack_start(self.lang_to, False, False, 0)

        self.translate_button = Gtk.Button(_("Translate text!"))

        # Disable the button
        self.translate_button.set_sensitive(False)

        self.translate_button.connect("clicked", self._translate_btn_cb)
        select_hbox.pack_end(self.translate_button, False, False, 0)

        # Visible while waiting for results from server.
        self.translate_spinner = Gtk.Spinner()
        self.translate_spinner.start()
        select_hbox.pack_end(self.translate_spinner, False, True, 6)

        scrolled_window = Gtk.ScrolledWindow()
        scrolled_window.set_hexpand(False)
        scrolled_window.set_vexpand(True)

        self.text_from = Gtk.TextView()
        self.text_from.get_buffer().set_text("This is where you would type in \
some text to translate.")

        scrolled_window.add(self.text_from)
        text_hbox.pack_start(scrolled_window, True, True, 0)

        # Spacer
        text_hbox.pack_start(Gtk.Box(), False, True, 10)

        scrolled_window = Gtk.ScrolledWindow()
        scrolled_window.set_hexpand(False)
        scrolled_window.set_vexpand(True)

        self.text_to = Gtk.TextView()
        self.text_to.get_buffer().set_text("This is where the translated text \
would show up.")
        self.text_to.set_editable(False)
        self.text_to.set_cursor_visible(False)

        scrolled_window.add(self.text_to)
        text_hbox.pack_start(scrolled_window, True, True, 0)

        self.text_from.override_font(Pango.FontDescription("Sans 13"))
        self.text_to.override_font(Pango.FontDescription("Sans 13"))

        self.set_canvas(vbox)
        vbox.show_all()

        self.translate_spinner.hide()

        alert = self._create_alert(_("Connecting"),
                                   _("Trying to reach server..."))

        # Run the rest of the initialization in the background
        GObject.idle_add(self._init_translate, alert)
예제 #27
0
    def __init__(self, handle):
        """Set up the StopWatch activity."""
        Activity.__init__(self, handle)
        self._logger = logging.getLogger('stopwatch-activity')

        GObject.threads_init()

        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 sugar3.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)

        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(Gdk.EventMask.VISIBILITY_NOTIFY_MASK)
        self.connect("visibility-notify-event", self._visible_cb)
        self.connect("notify::active", self._active_cb)

        self.connect('key-press-event', self._keypress_cb)
예제 #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()

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.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()

        # FONT DEFINITIONS
        FONT_FACE = 'Monospace'
        input_font = Pango.FontDescription('%s %d' % (FONT_FACE, int(FONT_SIZE * 1.2)))
        entry_font = Pango.FontDescription('%s %d' % (FONT_FACE, int(FONT_SIZE * 10.0 )))

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        # label with the text, make the string translatable
        center_in_panel = Gtk.Alignment.new(0.5, 0, 0, 0)
        graphics = Graphics()
        first = 'methane'
        self._first_entry = graphics.add_entry(first)
        self._first_entry.override_font(input_font)
        self._spac1 = graphics.add_text(' ')

        print("LOG: #56, ", self._first_entry, self._first_entry )
        button = graphics.add_button(_("COMPUTE"), self.something )
        self._spac2 = graphics.add_text(' ')
        button.show()

        self.hold_hi3 = graphics.add_text(
            _(" "), size="xx-large", bold=True, justify=Gtk.Justification.CENTER)
        self.hold_hi3.override_font(input_font)

        self.hold_hi2 = graphics.add_text(
            _(" "), size="xx-large", bold=True, justify=Gtk.Justification.CENTER)
        self.hold_hi2.override_font(input_font)
        self.hold_hi1 = graphics.add_text(
            _(" "), size="xx-large", bold=True, justify=Gtk.Justification.CENTER)
        self.hold_hi1.override_font(input_font)
        self.hold0 = graphics.add_text(
            _("CH4"), size="xx-large", bold=True, justify=Gtk.Justification.CENTER)
        self.hold0.override_font(input_font)
        self.hold_lo1 = graphics.add_text(
            _(" "), size="xx-large", bold=True, justify=Gtk.Justification.CENTER)
        self.hold_lo1.override_font(input_font)
        self.hold_lo2 = graphics.add_text(
            _(" "), size="xx-large", bold=True, justify=Gtk.Justification.CENTER)
        self.hold_lo2.override_font(input_font)
        self.hold_lo3 = graphics.add_text(
            _(" "), size="xx-large", bold=True, justify=Gtk.Justification.CENTER)
        self.hold_lo3.override_font(input_font)

        center_in_panel.add(graphics)
        graphics.show()
        self.set_canvas(center_in_panel)
        center_in_panel.show()
예제 #29
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()

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.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()

        #set background color
        self.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(1.0,1.0,0.0,1.0))
        #set up screen
        fix = Gtk.Fixed()
        fix.set_size_request(1000,750)
        self.lang = Gtk.Label('Language')
        fix.put(self.lang, 100,0)
        self.activity = Gtk.Label('Activity')
        fix.put(self.activity, 500, 0)
        self.fix = fix
        
        #initialize listview
        #display list of languages as listview
        items  = path('/usr/share/locale').dirs()
        locales = []
        for item in items:
            locales.append(item.namebase)
        locales.sort()
        self.languages = Listview('Language', locales, self.lang_cb)

        #get directories from /usr/share/locale
        vbox = self.languages.vbox
        self.fix.put(vbox, 100, 200)
        self.set_canvas(self.fix)
        self.fix.show_all()
예제 #30
0
    def __init__(self, handle):
        '''Set up the Acoustic Tape Measure activity.'''
        super(AcousticMeasureActivity, self).__init__(handle)

        self._logger = logging.getLogger('acousticmeasure-activity')

        GObject.threads_init()

        try:
            self._logger.debug("locale: " +
                               locale.setlocale(locale.LC_ALL, ''))
        except locale.Error:
            self._logger.error("setlocale failed")

        # top toolbar with share and close buttons:

        from sugar3.graphics.toolbarbox import ToolbarBox
        from sugar3.graphics.toolbarbox import ToolbarButton
        from sugar3.activity.widgets import ShareButton
        from sugar3.activity.widgets import StopButton
        from sugar3.activity.widgets import ActivityButton
        from sugar3.activity.widgets import 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()

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

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

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

        self._t_h_bar = atm_toolbars.TempToolbar()
        self._t_h_bar.show_all()
        adj_button = ToolbarButton(page=self._t_h_bar,
                                   icon_name='preferences-system')
        toolbar_box.toolbar.insert(adj_button, -1)
        adj_button.show()

        self._smoot_bar = smoot_toolbar.SmootToolbar(self)
        self._smoot_bar.show_all()
        custom_button = ToolbarButton(page=self._smoot_bar,
                                      icon_name='view-source')
        toolbar_box.toolbar.insert(custom_button, -1)
        custom_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()

        if not self.powerd_running():
            try:
                bus = dbus.SystemBus()
                proxy = bus.get_object('org.freedesktop.ohm',
                                       '/org/freedesktop/ohm/Keystore')
                self.ohm_keystore = dbus.Interface(
                    proxy, 'org.freedesktop.ohm.Keystore')
            except dbus.DBusException as e:
                self._logger.warning("Error setting OHM inhibit: %s" % e)
                self.ohm_keystore = None

        # distance in meters
        self.current_distance = 0.0

        # worker thread
        self._button_event = threading.Event()
        thread.start_new_thread(self._helper_thread, ())

        # Main Panel GUI
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.main_panel = vbox
        self._message_dict['unshared'] = _("To measure the distance between \
two laptops, you must first share this Activity.")
        self._message_dict['ready'] = _("Press the button to measure the \
distance to another laptop")
        self._message_dict['preparing'] = _("Preparing to measure distance")
        self._message_dict['waiting'] = _("Ready to make a measurement.  \
Waiting for partner to be ready.")
        self._message_dict['playing'] = _("Recording sound from each laptop.")
        self._message_dict['processing'] = _("Processing recorded audio.")
        self._message_dict['done'] = self._message_dict['ready']
        self._message_dict['full'] = _("This activity already has two \
participants, so you cannot join.")

        self._button_dict['waiting'] = _("Begin Measuring Distance")
        self._button_dict['going'] = _("Stop Measuring Distance")

        self.button = Gtk.ToggleButton(label=self._button_dict['waiting'])
        self.button.connect('clicked', self._button_clicked)
        self.button.set_sensitive(False)
        check = Gtk.Image()
        check.set_from_file('check.svg')
        self.button.set_image(check)

        self.message = Gtk.Label(label=self._message_dict['unshared'])
        self.message.set_selectable(True)
        self.message.set_single_line_mode(True)

        img = Gtk.Image()
        pb = GdkPixbuf.Pixbuf.new_from_file(
            sugar3.activity.activity.get_bundle_path() + '/dist.svg')
        img.set_from_pixbuf(pb)

        self.value = Gtk.Label()
        self.value.set_selectable(True)
        thread.start_new_thread(self._update_distance, (0, ))

        valuefont = Pango.FontDescription()
        valuefont.set_family("monospace")
        valuefont.set_absolute_size(100 * Pango.SCALE)

        self.value.modify_font(valuefont)
        self.value.set_single_line_mode(True)
        self.value.set_width_chars(6)

        eb = Gtk.EventBox()
        eb.add(self.value)
        eb.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("white"))
        eb.set_margin_left(10)
        eb.set_margin_right(10)
        eb.set_margin_top(10)

        self.fr = Gtk.Frame()
        self.fr.set_label(_('Measured distance in %s') % _('meters'))
        self.fr.set_label_align(0.5, 0.5)
        self.fr.add(eb)

        self.main_panel.pack_start(self.button,
                                   expand=False,
                                   fill=False,
                                   padding=6)
        self.main_panel.pack_start(self.message,
                                   expand=False,
                                   fill=True,
                                   padding=0)
        self.main_panel.pack_start(img, expand=True, fill=False, padding=0)
        self.main_panel.pack_start(self.fr,
                                   expand=False,
                                   fill=False,
                                   padding=10)

        self.set_canvas(self.main_panel)
        self.show_all()

        self.server_socket = None
        self.main_socket = None
        self.main_socket_addr = None
        self.main_tube_id = None
        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.connect('key-press-event', self._keypress_cb)