Beispiel #1
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()
    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()
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)
        self.set_title('SocialCalc')
        self._logger = logging.getLogger('OnePageWiki-Activity')

        # The XOCom object helps us communicate with the browser
        # This uses web/index.html as the default page to load
        self.xocom = XOCom(self.control_sending_text)                   #REMEMBER THAT I HAVE STILL TO SEND THE ARGUMENT IN THE XOCOM CLASS

        toolbox = ToolbarBox()

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

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

        stop_button = ShareButton(self)
        toolbox.toolbar.insert(stop_button, -1)
        stop_button.show()
        self.set_toolbar_box(toolbox)
        toolbox.show()

        stop_button = StopButton(self)
        toolbox.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbox)
        toolbox.show()
        ##self.xocom.send_to_browser_localize(['initlocalize'])

        self.set_canvas( self.xocom.create_webview() )

        self.hellotube = None  # Shared session    #REQUIRED
        self.initiating = False
        
        self.pservice = presenceservice.get_instance()
        
        owner = self.pservice.get_owner()
        self.owner = owner   
        
        self.connect('shared', self._shared_cb)
        self.connect('joined', self._joined_cb)
        
        self.filename=''       #ADDED SPECIFICALLY TO CALL WRITE AND READ METHODS
        self.content=''

        #calling to initialize strings in localization
        #should wait for init complete from browser
        GObject.timeout_add(4000, self.xocom.send_to_browser_localize,['initlocalize'])
Beispiel #4
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()
Beispiel #7
0
    def build_toolbar(self, activity):
        # Prepare Primary Toolbar Container
        toolbar_box = ToolbarBox()

        # Create activity button
        toolbar_box.toolbar.insert(ActivityButton(activity), -1)

        # Video Toggle
        video_toggle_button = ToolButton()
        video_toggle_button.connect("clicked", self.toggle_video)
        toolbar_box.toolbar.insert(video_toggle_button, 1)
        self.toggle_video(video_toggle_button)

        # Audio Toggle
        audio_toggle_button = ToolButton()
        audio_toggle_button.connect("clicked", self.toggle_audio)
        toolbar_box.toolbar.insert(audio_toggle_button, 2)
        self.toggle_audio(audio_toggle_button)

        # Toggle Preview Display Button
        preview_toggle_button = ToolButton()
        preview_toggle_button.connect("clicked",
                                      self.toolbar_toggle_preview_visibility)
        toolbar_box.toolbar.insert(preview_toggle_button, 3)
        self.toolbar_toggle_preview_visibility(preview_toggle_button)

        # Forced Refresh
        reload_video = ToolButton("view-refresh")
        reload_video.set_tooltip_text(_("Reload Video"))
        reload_video.connect("clicked", self.force_redraw)
        toolbar_box.toolbar.insert(reload_video, -1)

        # Push stop button to far right
        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        toolbar_box.toolbar.insert(separator, -1)

        # Create Share Button
        toolbar_box.toolbar.insert(ShareButton(activity), -1)

        # Create stop button
        toolbar_box.toolbar.insert(StopButton(activity), -1)

        # Add reference to toolbar items
        self.toolbar = toolbar_box.toolbar

        # Display all components & Return
        toolbar_box.show_all()
        return toolbar_box
Beispiel #8
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()
        self.scroll = Gtk.ScrolledWindow()
        self.scroll.set_policy(Gtk.PolicyType.AUTOMATIC,
                               Gtk.PolicyType.AUTOMATIC)
        # Uso un widget principal para los problemas de resolucion x2..
        self.widget_principal = Gtk.EventBox()
        self.crear_menu()
        self.scroll.add(self.widget_principal)
        self.maximize()
        # self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("light blue"))
        self.widget_principal.modify_bg(Gtk.StateType.NORMAL,
                                        Gdk.color_parse("white"))

        self.set_canvas(self.scroll)
        self.scroll.show_all()
    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)
    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()
Beispiel #11
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):
        """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()
Beispiel #13
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()
    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()
Beispiel #15
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)
Beispiel #16
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)
Beispiel #17
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()
    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)
Beispiel #19
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
Beispiel #20
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)
Beispiel #21
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()
Beispiel #22
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)
Beispiel #23
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)
    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)
    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

        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.scrolled_window = Gtk.ScrolledWindow()
        self.scrolled_window.set_policy(Gtk.PolicyType.NEVER,
                                        Gtk.PolicyType.AUTOMATIC)
        self.scrolled_window.props.shadow_type = Gtk.ShadowType.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
Beispiel #26
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()
Beispiel #27
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()
Beispiel #28
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_vbox = Gtk.VBox()
            self.container_vbox.show()
            self.set_canvas(self.container_vbox)

        if os.path.exists('/tmp/3'):
            os.remove('/tmp/3')
            self.label = Gtk.Label(_("Hello World!"))
            self.container_vbox.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_vbox.add(self.button)
            self.button.connect('clicked', self.hello, None)
            self.button.show()