• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python activity.get_bundle_path函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sugar3.activity.activity.get_bundle_path函数的典型用法代码示例。如果您正苦于以下问题:Python get_bundle_path函数的具体用法?Python get_bundle_path怎么用?Python get_bundle_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_bundle_path函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, handle):
        # fork pygame before we initialize the activity.

        pygame.init()
        windowid = pygame.display.get_wm_info()['wmwindow']
        self.child_pid = os.fork()

        if self.child_pid == 0:
            library_path = os.path.join(activity.get_bundle_path(), 'library')
            app_path = os.path.join(activity.get_bundle_path(), 'app.py')
            sys.path[0:0] = [library_path]
            g = globals()
            g['__name__'] = '__main__'
            execfile(app_path, g, g) # start pygame
            sys.exit(0)

        super(PyGameActivity, self).__init__(handle)

        toolbarbox = ToolbarBox()
        self.set_toolbar_box(toolbarbox)

        toolbar = toolbarbox.toolbar

        socket = Gtk.Socket()
        socket.set_can_focus(True)
        socket.add_id(windowid)
        self.set_canvas(socket)
        self.show_all()

        socket.grab_focus()
        GObject.child_watch_add(self.child_pid, lambda pid, cond: self.close())
开发者ID:sugarlabs,项目名称:pocket-lrad-activity,代码行数:31,代码来源:activity.py


示例2: get_index_uri

def get_index_uri():
    index_path = os.path.join(
        activity.get_bundle_path(),
        'html/%s/index.html' % get_current_language())

    if not os.path.isfile(index_path):
        index_path = os.path.join(
            activity.get_bundle_path(), 'html/index.html')
    return 'file://' + index_path
开发者ID:i5o,项目名称:help-activity,代码行数:9,代码来源:helpactivity.py


示例3: __init__

    def __init__(self, layout_name, selected=False):
        super(Gtk.Image, self).__init__()

        if selected:
            path = os.path.join(activity.get_bundle_path(), 'layouts',
                                'format-' + layout_name + '-selected.png')
        else:
            path = os.path.join(activity.get_bundle_path(), 'layouts',
                                'format-' + layout_name + '.png')
        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
            path, style.GRID_CELL_SIZE, style.GRID_CELL_SIZE)
        self.set_from_pixbuf(pixbuf)
        self.show()
开发者ID:sugarlabs,项目名称:wordcloud,代码行数:13,代码来源:activity.py


示例4: make_mainview

    def make_mainview(self):
        """Create the activity view"""
        # Create global box
        vbox = Gtk.VBox(True)

        # Create webview
        self.webview = webview  = WebKit.WebView()
        webview.show()
        vbox.pack_start(webview, True, True, 0)
        vbox.show()

        # Activate Enyo interface
        self.enyo = Enyo(webview)
        self.enyo.connect("ready", self.init_context)
        self.enyo.connect("save-context", self.save_context)
        self.enyo.connect("refresh-screen", self.refresh)
        self.enyo.connect("set_categories", self.set_categories)

        # Go to first page
        web_app_page = os.path.join(activity.get_bundle_path(), "index.html")
        self.webview.load_uri('file://' + web_app_page+"?onsugar=1")

        # Display all
        self.set_canvas(vbox)
        vbox.show()
开发者ID:llaske,项目名称:VideoViewer.activity,代码行数:25,代码来源:activity.py


示例5: __load_error_cb

    def __load_error_cb(self, web_view, web_frame, uri, web_error):
        """Show Sugar's error page"""

        # Don't show error page if the load was interrupted by policy
        # change or the request is going to be handled by a
        # plugin. For example, if a file was requested for download or
        # an .ogg file is going to be played.
        if web_error.code in (
                WebKit.PolicyError.FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE,
                WebKit.PluginError.WILL_HANDLE_LOAD):
            if self._inject_media_style:
                css_style_file = open(os.path.join(activity.get_bundle_path(),
                                                   "data/media-controls.css"))
                css_style = css_style_file.read().replace('\n', '')
                inject_style_script = \
                    "var style = document.createElement('style');" \
                    "style.innerHTML = '%s';" \
                    "document.body.appendChild(style);" % css_style
                web_view.execute_script(inject_style_script)
            return True

        data = {
            'page_title': _('This web page could not be loaded'),
            'title': _('This web page could not be loaded'),
            'message': _('"%s" could not be loaded. Please check for '
                         'typing errors, and make sure you are connected '
                         'to the Internet.') % uri,
            'btn_value': _('Try again'),
            'url': uri,
            }

        html = open(DEFAULT_ERROR_PAGE, 'r').read() % data
        web_frame.load_alternate_string(html, uri, uri)

        return True
开发者ID:City-busz,项目名称:browse-activity,代码行数:35,代码来源:browser.py


示例6: __init__

    def __init__(self, handle):
        """ Initialize the toolbars and the game board """
        try:
            super(SearchActivity, self).__init__(handle)
        except dbus.exceptions.DBusException as e:
            _logger.error(str(e))

        self.path = activity.get_bundle_path()
        self.all_scores = []

        self.nick = profile.get_nick_name()
        if profile.get_color() is not None:
            self.colors = profile.get_color().to_string().split(',')
        else:
            self.colors = ['#A0FFA0', '#FF8080']

        self._setup_toolbars()
        self._setup_dispatch_table()

        # Create a canvas
        canvas = Gtk.DrawingArea()
        canvas.set_size_request(Gdk.Screen.width(),
                                Gdk.Screen.height())
        self.set_canvas(canvas)
        canvas.show()
        self.show_all()

        self._game = Game(canvas, parent=self, path=self.path,
                          colors=self.colors)
        self._setup_presence_service()

        if 'dotlist' in self.metadata:
            self._restore()
        else:
            self._game.new_game()
开发者ID:sugarlabs,项目名称:cookiesearch,代码行数:35,代码来源:SearchActivity.py


示例7: load_instruments

    def load_instruments(self):
        self._instruments_store = Gtk.ListStore(str, GdkPixbuf.Pixbuf, str)
        self._instruments_store.set_sort_column_id(0, Gtk.SortType.ASCENDING)
        self.instruments_iconview = Gtk.IconView(self._instruments_store)
        self.instruments_iconview.set_text_column(2)
        self.instruments_iconview.set_pixbuf_column(1)

        # load the images
        images_path = os.path.join(activity.get_bundle_path(),
                                   'instruments')
        logging.error('Loading instrument images from %s', images_path)
        for file_name in os.listdir(images_path):
            image_file_name = os.path.join(images_path, file_name)
            logging.error('Adding %s', image_file_name)
            pxb = GdkPixbuf.Pixbuf.new_from_file_at_size(
                image_file_name, 75, 75)
            #instrument_name = image_file_name[image_file_name.rfind('/'):]
            instrument_name = image_file_name[image_file_name.rfind('/') + 1:]
            instrument_name = instrument_name[:instrument_name.find('.')]
            instrument_desc = \
                self.instrumentDB.instNamed[instrument_name].nameTooltip
            self._instruments_store.append([instrument_name, pxb,
                                           instrument_desc])
        self.instruments_iconview.connect(
            'selection-changed', self.__instrument_iconview_activated_cb)
开发者ID:shridharmishra4,项目名称:mainline,代码行数:25,代码来源:activity.py


示例8: __init__

 def __init__(self, handle):
     # fork pygame before we initialize the activity.
     import os
     import pygame
     import sys
     pygame.init()
     windowid = pygame.display.get_wm_info()['wmwindow']
     self.child_pid = os.fork()
     if self.child_pid == 0:
         bp = activity.get_bundle_path()
         library_path = os.path.join(bp, 'library')
         pippy_app_path = os.path.join(bp, 'pippy_app.py')
         sys.path[0:0] = [library_path]
         g = globals()
         g['__name__'] = '__main__'
         execfile(pippy_app_path, g, g)  # start pygame
         sys.exit(0)
     super(PyGameActivity, self).__init__(handle)
     from gi.repository import GObject
     from gi.repository import Gtk
     toolbox = activity.ActivityToolbox(self)
     toolbar = toolbox.get_activity_toolbar()
     self.set_toolbox(toolbox)
     toolbox.show()
     socket = Gtk.Socket()
     socket.set_flags(socket.flags() | Gtk.CAN_FOCUS)
     socket.show()
     self.set_canvas(socket)
     socket.add_id(windowid)
     self.show_all()
     socket.grab_focus()
     GObject.child_watch_add(self.child_pid, lambda pid, cond: self.close())
     # hide the buttons we don't use.
     toolbar.share.hide()  # this should share bundle.
     toolbar.keep.hide()
开发者ID:dnarvaez,项目名称:Pippy,代码行数:35,代码来源:activity.py


示例9: create_activity

def create_activity(name, base_path, skeleton):
    path = os.path.expanduser(os.path.join(base_path,
                              '%s.activity' % name.replace(' ', '')))
    os.makedirs(path)
    activity_path = os.path.join(path, 'activity')
    os.mkdir(activity_path)

    # copy all the files in the skeleton directory
    skeleton_path = os.path.join(activity.get_bundle_path(), 'skeletons',
                                 skeleton)
    for cur, dirs, files in os.walk(skeleton_path):
        destination_path = os.path.join(path, cur[len(skeleton_path) + 1:])
        for directory in dirs:
            directory_path = os.path.join(destination_path, directory)
            try:
                os.mkdir(directory_path)
            except:
                logging.error('Error trying to create %s', directory_path)

        for file_name in files:
            shutil.copyfile(os.path.join(cur, file_name),
                            os.path.join(destination_path, file_name))

    # create activity.info file
    activity_info_path = os.path.join(activity_path, 'activity.info')
    with open(activity_info_path, 'w') as activity_info_file:
        activity_info_file.write(
            activity_info_template(name,
                                   (skeleton == 'Web (sugar >= 0.100)')))

    return path
开发者ID:godiard,项目名称:develop-activity,代码行数:31,代码来源:new_activity.py


示例10: is_the_correct

    def is_the_correct(self, x, y):
        for option in self.options:
            data = self.options[option]
            if (x >= data["min_x"] and x <= data["max_x"]) and \
               (y >= data["min_y"] and y <= data["max_y"]):
                break

        cursor = Gdk.Cursor.new(Gdk.CursorType.WATCH)
        self._parent.get_window().set_cursor(cursor)
        self.disconnect(self._id)
        self._id = None

        if option == self.current_option:
            self.finished = True
            image = random.choice(IMAGES_OK)
            message = "☺ ☺ ☺ ☺ ☺"
            self.queue_draw()
        else:
            image = random.choice(IMAGES_BAD)
            message = "☹ ☹ ☹ ☹ ☹"

        self._parent.word_label.set_text(message)
        image_path = os.path.join(activity.get_bundle_path(),
                                  "images", image)

        self._face = image_path
        self.draw_face(self._face)

        GObject.timeout_add(2000, self.new_game)
开发者ID:i5o,项目名称:whatis,代码行数:29,代码来源:activity.py


示例11: _sample_loader

 def _sample_loader(self):
     # Convert from thumbnail path to sample path
     basename = os.path.basename(self._selected_sample)[:-4]
     file_path = os.path.join(activity.get_bundle_path(),
                              'samples', basename + '.json')
     self.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.LEFT_PTR))
     self.__load_game(file_path)
开发者ID:godiard,项目名称:physics,代码行数:7,代码来源:activity.py


示例12: init

def init():
    if _catalog:
        return

    svg_dir = os.path.join(get_bundle_path(), 'icons', 'smilies')

    for index, (name, hint, codes) in enumerate(THEME):
        archivo = os.path.join(svg_dir, '%s.svg' % (name))
        if name[0:7] == 'unicode':
            # Create the icon from unicode character on the fly
            pl = GdkPixbuf.PixbufLoader.new_with_type('svg')
            pl.write(_generate_svg(codes[0]))
            pl.close()
            pixbuf = pl.get_pixbuf()
            if not os.path.exists(archivo):
                try:
                    fd = open(archivo, 'w')
                    fd.write(_generate_svg(codes[0]))
                    fd.close()
                except IOError:
                    pass
        else:
            pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
                archivo, SMILIES_SIZE, SMILIES_SIZE)
        for i in codes:
            _catalog[i] = pixbuf
            THEME[index] = (archivo, hint, codes)
开发者ID:sugarlabs,项目名称:speak,代码行数:27,代码来源:smilies.py


示例13: run_game

    def run_game(self):
        self.__source_object_id = None
        bundle_path = activity.get_bundle_path()

        # creates vte widget
        self._vte = Vte.Terminal()
        self._vte.connect('child-exited', self.exit_with_sys)

        argv = [
            "/bin/sh",
            "-c",
            os.path.join(bundle_path, "bin/tuxmath"),
            "--homedir %s" % os.path.join(bundle_path, "tux_homedir("),
            "--fullscreen"
        ]

        if hasattr(self._vte, 'fork_command_full'):
            self._vte.fork_command_full(
                Vte.PtyFlags.DEFAULT,
                os.environ['HOME'],
                argv,
                [],
                GLib.SpawnFlags.DO_NOT_REAP_CHILD,
                None,
                None)
        else:
            self._vte.spawn_sync(
                Vte.PtyFlags.DEFAULT,
                os.environ['HOME'],
                argv,
                [],
                GLib.SpawnFlags.DO_NOT_REAP_CHILD,
                None,
                None)
开发者ID:sugarlabs,项目名称:tuxmath-activity,代码行数:34,代码来源:activity.py


示例14: __init__

    def __init__(self, act):
        self._activity = act

        src_path = os.path.join(activity.get_bundle_path(),
                                "data/web-console.html")
        self._src_uri = "file://" + src_path

        self._extraction_dir = os.path.join(act.get_activity_root(),
                                            "instance")

        if not os.path.exists(self._extraction_dir):
            os.makedirs(self._extraction_dir)

        self._parent_dir = os.path.join(self._extraction_dir,
                                        "Web_Console_Files")
        if not os.path.exists(self._parent_dir):
            os.makedirs(self._parent_dir)

        self._storage_dir = os.path.join(self._parent_dir, "default")
        self._default_dir = self._storage_dir

        if os.path.exists(self._storage_dir):
            shutil.rmtree(self._storage_dir)
        os.makedirs(self._storage_dir)

        self._index_html_path = os.path.join(self._storage_dir, "index.html")

        self._load_status_changed_hid = None
        self._file_path = None
开发者ID:iamutkarshtiwari,项目名称:Browse-fiddleFeature,代码行数:29,代码来源:webconsole.py


示例15: __init__

    def __init__(self, handle):
        ''' Initialize the toolbar '''
        try:
            super(OneSupportActivity, self).__init__(handle)
        except dbus.exceptions.DBusException as e:
            _logger.error(str(e))

        self.connect('realize', self.__realize_cb)

        if hasattr(self, 'metadata') and 'font_size' in self.metadata:
            self.font_size = int(self.metadata['font_size'])
        else:
            self.font_size = 8
        self.zoom_level = self.font_size / float(len(FONT_SIZES))
        _logger.debug('zoom level is %f' % self.zoom_level)

        # _check_gconf_settings()  # For debugging purposes

        self._setup_toolbars()
        self.modify_bg(Gtk.StateType.NORMAL,
                       style.COLOR_WHITE.get_gdk_color())

        self.bundle_path = activity.get_bundle_path()

        self._copy_entry = None
        self._paste_entry = None
        self._webkit = None
        self._clipboard_text = ''
        self._fixed = None
        self._notify_transfer_status = False

        get_power_manager().inhibit_suspend()
        self._launch_task_master()
开发者ID:cottonpaul,项目名称:OneSupport,代码行数:33,代码来源:activity.py


示例16: __init__

    def __init__(self, handle):
        """ Initialize the toolbars and the game board """
        super(RecallActivity, self).__init__(handle)

        self.path = activity.get_bundle_path()

        self.nick = profile.get_nick_name()
        if profile.get_color() is not None:
            self.colors = profile.get_color().to_string().split(",")
        else:
            self.colors = ["#A0FFA0", "#FF8080"]

        self._restoring = False
        self._setup_toolbars(True)
        self._setup_dispatch_table()

        # Create a canvas
        canvas = Gtk.DrawingArea()
        canvas.set_size_request(Gdk.Screen.width(), Gdk.Screen.height())
        self.set_canvas(canvas)
        canvas.show()
        self.show_all()

        self._game = Game(canvas, parent=self, path=self.path, colors=self.colors)
        self._setup_presence_service()

        if "dotlist" in self.metadata:
            self._restore()
        else:
            self._game.new_game()
开发者ID:cristian99garcia,项目名称:recall,代码行数:30,代码来源:RecallActivity.py


示例17: _load_ball_cb

 def _load_ball_cb(self, widget, event, ball):
     if ball == 'custom':
         chooser(self, 'Image', self._new_ball_from_journal)
     else:
         self._bounce_window.ball.new_ball(os.path.join(
             activity.get_bundle_path(), 'images', ball + '.svg'))
         self._bounce_window.set_background(BGDICT[BALLDICT[ball][1]][1])
     self._current_ball = ball
开发者ID:leonardcj,项目名称:fractionbounce,代码行数:8,代码来源:FractionBounceActivity.py


示例18: _reset_ball

    def _reset_ball(self):
        ''' If we switch back from sector mode, we need to restore the ball '''
        if self._bounce_window.mode != 'sectors':
            return

        if self._current_ball == 'custom':  # TODO: Reload custom ball
            self._current_ball = 'soccerball'
        self._bounce_window.ball.new_ball(os.path.join(
            activity.get_bundle_path(), 'images', self._current_ball + '.svg'))
开发者ID:leonardcj,项目名称:fractionbounce,代码行数:9,代码来源:FractionBounceActivity.py


示例19: __init__

    def __init__(self, handle):
        ''' Initiate activity. '''
        super(FractionBounceActivity, self).__init__(handle)

        self.nick = profile.get_nick_name()
        if profile.get_color() is not None:
            self._colors = profile.get_color().to_string().split(',')
        else:
            self._colors = ['#A0FFA0', '#FF8080']

        self.max_participants = 4  # sharing
        self._playing = True

        self._setup_toolbars()
        self._setup_dispatch_table()
        canvas = self._setup_canvas()

        # Read any custom fractions from the project metadata
        if 'custom' in self.metadata:
            custom = self.metadata['custom']
        else:
            custom = None

        self._current_ball = 'soccerball'

        self._toolbar_was_expanded = False

        # Initialize the canvas
        self._bounce_window = Bounce(canvas, activity.get_bundle_path(), self)

        Gdk.Screen.get_default().connect('size-changed', self._configure_cb)

        # Restore any custom fractions
        if custom is not None:
            fractions = custom.split(',')
            for f in fractions:
                self._bounce_window.add_fraction(f)

        if self.shared_activity:
            # We're joining
            if not self.get_shared():
                xocolors = XoColor(profile.get_color().to_string())
                share_icon = Icon(icon_name='zoom-neighborhood',
                                  xo_color=xocolors)
                self._joined_alert = NotifyAlert()
                self._joined_alert.props.icon = share_icon
                self._joined_alert.props.title = _('Please wait')
                self._joined_alert.props.msg = _('Starting connection...')
                self._joined_alert.connect('response', self._alert_cancel_cb)
                self.add_alert(self._joined_alert)

                self._label.set_label(_('Wait for the sharer to start.'))

                # Wait for joined signal
                self.connect("joined", self._joined_cb)

        self._setup_sharing()
开发者ID:leonardcj,项目名称:fractionbounce,代码行数:57,代码来源:FractionBounceActivity.py


示例20: _scan_for_samples

 def _scan_for_samples(self):
     samples = sorted(
         glob.glob(
             os.path.join(
                 activity.get_bundle_path(),
                 'samples',
                 'thumbnails',
                 '*.png')))
     return samples
开发者ID:godiard,项目名称:physics,代码行数:9,代码来源:activity.py



注:本文中的sugar3.activity.activity.get_bundle_path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python widgets.ActivityToolbarButton类代码示例发布时间:2022-05-27
下一篇:
Python activity.get_activity_root函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap