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

Python activity.get_activity_root函数代码示例

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

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



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

示例1: __configure_cb

 def __configure_cb(self, event):
     """ Screen size has changed """
     self.write_file(os.path.join(activity.get_activity_root(), "data", "data"))
     w = Gdk.Screen.width()
     h = Gdk.Screen.height() - 2 * GRID_CELL_SIZE
     pygame.display.set_mode((w, h), pygame.RESIZABLE)
     self.read_file(os.path.join(activity.get_activity_root(), "data", "data"))
     self.game.run(True)
开发者ID:sugarlabs,项目名称:physics,代码行数:8,代码来源:activity.py


示例2: __configure_cb

 def __configure_cb(self, event):
     ''' Screen size has changed '''
     self.write_file(os.path.join(
                     activity.get_activity_root(), 'data', 'data'))
     pygame.display.set_mode((Gdk.Screen.width(),
                              Gdk.Screen.height() - 2 * GRID_CELL_SIZE),
                             pygame.RESIZABLE)
     self.read_file(os.path.join(
                    activity.get_activity_root(), 'data', 'data'))
     self.game.run(True)
开发者ID:i5o,项目名称:physics,代码行数:10,代码来源:activity.py


示例3: favicon

    def favicon(self, webview, icono):
        d = urllib.urlopen(icono)
        if os.path.exists(activity.get_activity_root() + "/data/Favicons/" + icono.split("/")[-1]):
            os.remove("Favicons/" + icono.split("/")[-1])

        fav = open(activity.get_activity_root() + "/data/Favicons/" + icono.split("/")[-1], "a")
        for x in d.readlines():
            fav.write(x)

        fav.close()

        self.favicon_i.set_from_file(activity.get_activity_root() + "/data/Favicons/" + icono.split("/")[-1])
开发者ID:sugarlabs,项目名称:agubrowser-activity,代码行数:12,代码来源:AguBrowse.py


示例4: __init__

    def __init__(self, download, browser):
        self._download = download
        self._activity = browser.get_toplevel()
        self._source = download.get_uri()

        self._download.connect('notify::status', self.__state_change_cb)
        self._download.connect('error', self.__error_cb)

        self.datastore_deleted_handler = None

        self.dl_jobject = None
        self._object_id = None
        self._stop_alert = None

        self._progress = 0
        self._last_update_progress = 0
        self._progress_sid = None

        # figure out download URI
        self.temp_path = os.path.join(activity.get_activity_root(), 'instance')
        if not os.path.exists(self.temp_path):
            os.makedirs(self.temp_path)

        fd, self._dest_path = tempfile.mkstemp(
            dir=self.temp_path, suffix=download.get_suggested_filename(),
            prefix='tmp')
        os.close(fd)
        logging.debug('Download destination path: %s' % self._dest_path)

        # We have to start the download to get 'total-size'
        # property. It not, 0 is returned
        self._download.set_destination_uri('file://' + self._dest_path)
        self._download.start()
开发者ID:Daksh,项目名称:browse-activity,代码行数:33,代码来源:downloadmanager.py


示例5: __init__

    def __init__(self, handle):
        super(PhysicsActivity, self).__init__(handle)
        self.metadata['mime_type'] = 'application/x-physics-activity'
        self.add_events(Gdk.EventMask.ALL_EVENTS_MASK |
                        Gdk.EventMask.VISIBILITY_NOTIFY_MASK)

        self.connect('visibility-notify-event', self._focus_event)
        self.connect('window-state-event', self._window_event)

        self.game_canvas = sugargame.canvas.PygameCanvas(self)
        self.game = physics.main(self)

        self.preview = None
        self._sample_window = None

        self._fixed = Gtk.Fixed()
        self._fixed.put(self.game_canvas, 0, 0)

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

        self.game_canvas.set_size_request(w, h)

        self._constructors = {}
        self.build_toolbar()

        self.set_canvas(self._fixed)
        Gdk.Screen.get_default().connect('size-changed',
                                         self.__configure_cb)

        logging.debug(os.path.join(
                      activity.get_activity_root(), 'data', 'data'))
        self.game_canvas.run_pygame(self.game.run)
        GObject.idle_add(self._setup_sharing)
        self.show_all()
开发者ID:godiard,项目名称:physics,代码行数:35,代码来源:activity.py


示例6: __copy_activate_cb

    def __copy_activate_cb(self, menu_item):
        file_name = os.path.basename(urlparse.urlparse(self._url).path)
        if '.' in file_name:
            base_name, extension = file_name.split('.')
            extension = '.' + extension
        else:
            base_name = file_name
            extension = ''

        temp_path = os.path.join(activity.get_activity_root(), 'instance')
        fd, temp_file = tempfile.mkstemp(dir=temp_path, prefix=base_name,
                                               suffix=extension)
        os.close(fd)
        os.chmod(temp_file, 0664)

        cls = components.classes['@mozilla.org/network/io-service;1']
        io_service = cls.getService(interfaces.nsIIOService)
        uri = io_service.newURI(self._url, None, None)

        cls = components.classes['@mozilla.org/file/local;1']
        target_file = cls.createInstance(interfaces.nsILocalFile)
        target_file.initWithPath(temp_file)

        cls = components.classes[ \
                '@mozilla.org/embedding/browser/nsWebBrowserPersist;1']
        persist = cls.createInstance(interfaces.nsIWebBrowserPersist)
        persist.persistFlags = 1  # PERSIST_FLAGS_FROM_CACHE
        listener = xpcom.server.WrapObject(_ImageProgressListener(temp_file),
                                           interfaces.nsIWebProgressListener)
        persist.progressListener = listener
        persist.saveURI(uri, None, None, None, None, target_file)
开发者ID:georgejhunt,项目名称:HaitiDictionary.activity,代码行数:31,代码来源:palettes.py


示例7: run

    def run(self):
        jobject = None
        _file = None
        try:
            result = ObjectChooser.run(self)
            if result == Gtk.ResponseType.ACCEPT:
                jobject = self.get_selected_object()
                logging.debug('FilePicker.show: %r', jobject)

                if jobject and jobject.file_path:
                    tmp_dir = tempfile.mkdtemp(prefix='', \
                            dir=os.path.join(get_activity_root(), 'tmp'))
                    _file = os.path.join(tmp_dir, _basename_strip(jobject))

                    os.rename(jobject.file_path, _file)

                    global _temp_dirs_to_clean
                    _temp_dirs_to_clean.append(tmp_dir)

                    logging.debug('FilePicker.show: file=%r', _file)
        finally:
            if jobject is not None:
                jobject.destroy()

        return _file
开发者ID:georgejhunt,项目名称:HaitiDictionary.activity,代码行数:25,代码来源:filepicker.py


示例8: __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.tmp_path = os.path.join(activity.get_activity_root(), 'tmp')

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

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


示例9: _download_from_http

    def _download_from_http(self, remote_uri):
        """Download the PDF from a remote location to a temporal file."""

        # Display a message
        self._message_box = PDFProgressMessageBox(
            message=_("Downloading document..."),
            button_callback=self.close_tab)
        self.pack_start(self._message_box, True, True, 0)
        self._message_box.show()

        # Figure out download URI
        temp_path = os.path.join(activity.get_activity_root(), 'instance')
        if not os.path.exists(temp_path):
            os.makedirs(temp_path)

        fd, dest_path = tempfile.mkstemp(dir=temp_path)

        self._pdf_uri = 'file://' + dest_path

        network_request = WebKit.NetworkRequest.new(remote_uri)
        self._download = WebKit.Download.new(network_request)
        self._download.set_destination_uri('file://' + dest_path)

        # FIXME: workaround for SL #4385
        # self._download.connect('notify::progress',
        #                        self.__download_progress_cb)
        self._download.connect('notify::current-size',
                               self.__current_size_changed_cb)
        self._download.connect('notify::status', self.__download_status_cb)
        self._download.connect('error', self.__download_error_cb)

        self._download.start()
开发者ID:Daksh,项目名称:browse-activity,代码行数:32,代码来源:pdfviewer.py


示例10: get_path

def get_path(activity, subpath):
    """ Find a Rainbow-approved place for temporary files. """
    try:
        return(os.path.join(activity.get_activity_root(), subpath))
    except:
        # Early versions of Sugar didn't support get_activity_root()
        return(os.path.join(
                os.environ['HOME'], ".sugar/default", SERVICE, subpath))
开发者ID:leonardcj,项目名称:AEIOU,代码行数:8,代码来源:aeiou.py


示例11: writer

        def writer(view, result):
            temp_path = os.path.join(activity.get_activity_root(), 'instance')
            file_path = os.path.join(temp_path, '%i' % time.time())

            file_handle = file(file_path, 'w')
            file_handle.write(view.get_data_finish(result))
            file_handle.close()
            async_cb(file_path)
开发者ID:leonardcj,项目名称:browse-activity,代码行数:8,代码来源:browser.py


示例12: get_document_path

 def get_document_path(self, async_cb, async_err_cb):
     html_uri = self._web_view.get_uri()
     rst_path = html_uri.replace('file:///', '/')
     rst_path = rst_path.replace('html/', 'source/')
     rst_path = rst_path.replace('.html', '.rst')
     tmp_path = os.path.join(activity.get_activity_root(), 'instance',
                             'source.rst')
     os.symlink(rst_path, tmp_path)
     async_cb(tmp_path)
开发者ID:i5o,项目名称:help-activity,代码行数:9,代码来源:helpactivity.py


示例13: set_activity

 def set_activity(self, activity):
     self.activity = activity
     if os.path.exists(os.path.join(activity.get_activity_root(), 'instance',  'pitch.txt')):
         f = open(os.path.join(activity.get_activity_root(), 'instance',  'pitch.txt'),  'r')
         line = f.readline()
         pitch = int(line.strip())
         self.pitchadj.set_value(pitch)
         speech.pitch = pitch
         f.close()
     if os.path.exists(os.path.join(activity.get_activity_root(), 'instance',  'rate.txt')):
         f = open(os.path.join(activity.get_activity_root(), 'instance',  'rate.txt'),  'r')
         line = f.readline()
         rate = int(line.strip())
         self.rateadj.set_value(rate)
         speech.rate = rate
         f.close()
     self.pitchadj.connect("value_changed", self.pitch_adjusted_cb)
     self.rateadj.connect("value_changed", self.rate_adjusted_cb)
开发者ID:leonardcj,项目名称:readetexts,代码行数:18,代码来源:readtoolbar.py


示例14: get_qr

    def get_qr(self):
        photo_filename = os.path.join(activity.get_activity_root(),
                    "instance", "qr.png")
        if os.path.exists(photo_filename):
            os.remove(photo_filename)

        self.camerabin.set_property("location", photo_filename)
        self.camerabin.emit("start-capture")
        return photo_filename
开发者ID:i5o,项目名称:qr-reader,代码行数:9,代码来源:activity.py


示例15: write

    def write(self, file_path):
        instance_path = os.path.join(activity.get_activity_root(), 'instance')

        book_data = {}
        book_data['version'] = '1'
        book_data['cover_path'] = self.cover_path

        pages = []
        for page in self._pages:
            page_data = {}
            page_data['text'] = page.text
            page_data['background_path'] = page.background_path
            page_data['images'] = []
            for image in page.images:
                image_data = {}
                image_data['x'] = image.x
                image_data['y'] = image.y
                image_data['path'] = image.path
                image_data['width'] = image.width
                image_data['height'] = image.height
                image_data['h_mirrored'] = image.h_mirrored
                image_data['v_mirrored'] = image.v_mirrored
                image_data['angle'] = image.angle
                page_data['images'].append(image_data)
            pages.append(page_data)
        book_data['pages'] = pages
        logging.debug('book_data %s', book_data)

        data_file_name = 'data.json'
        f = open(os.path.join(instance_path, data_file_name), 'w')
        try:
            json.dump(book_data, f)
        finally:
            f.close()

        logging.debug('file_path %s', file_path)

        z = zipfile.ZipFile(file_path, 'w')
        z.write(os.path.join(instance_path, data_file_name), data_file_name)

        # zip the cover image
        if self.cover_path and os.path.exists(self.cover_path):
            z.write(self.cover_path, os.path.basename(self.cover_path))

        # zip the pages
        for page in self._pages:
            if page.background_path is not None and \
                    page.background_path != '':
                z.write(page.background_path,
                        os.path.basename(page.background_path))
            for image in page.images:
                if image.path is not None and image.path != '':
                    z.write(image.path, os.path.basename(image.path))
        z.close()
开发者ID:leonardcj,项目名称:write-books-activity,代码行数:54,代码来源:bookmodel.py


示例16: get_source

    def get_source(self, async_cb, async_err_cb):
        data_source = self.get_main_frame().get_data_source()
        data = data_source.get_data()
        if data_source.is_loading() or data is None:
            async_err_cb()
        temp_path = os.path.join(activity.get_activity_root(), 'instance')
        file_path = os.path.join(temp_path, '%i' % time.time())

        file_handle = file(file_path, 'w')
        file_handle.write(data.str)
        file_handle.close()
        async_cb(file_path)
开发者ID:georgejhunt,项目名称:HaitiDictionary.activity,代码行数:12,代码来源:browser.py


示例17: get_thumbnail

 def get_thumbnail(self):
     if self.thumbnail is None:
         instance_path = os.path.join(activity.get_activity_root(),
                                      'instance')
         if (not self.image_name.startswith(instance_path)):
             self.thumbnail = GdkPixbuf.Pixbuf.new_from_file_at_size(
                 os.path.join(instance_path, self.image_name),
                 THUMB_SIZE[0], THUMB_SIZE[1])
         else:
             self.thumbnail = GdkPixbuf.Pixbuf.new_from_file_at_size(
                 self.image_name, THUMB_SIZE[0], THUMB_SIZE[1])
     return self.thumbnail
开发者ID:quozl,项目名称:fototoon-activity,代码行数:12,代码来源:historietaactivity.py


示例18: _on_send_button_clicked_cb

    def _on_send_button_clicked_cb(self, button):
        window = self._activity.get_window()
        old_cursor = window.get_cursor()
        window.set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH))
        Gdk.flush()

        identifier = str(int(time.time()))
        filename = '%s.zip' % identifier
        filepath = os.path.join(activity.get_activity_root(), filename)
        success = True
        # FIXME: subprocess or thread
        try:
            self._collector.write_logs(archive=filepath, logbytes=0)
        except:
            success = False

        self.popdown(True)

        if not success:
            title = _('Logs not captured')
            msg = _('The logs could not be captured.')

            notify = NotifyAlert()
            notify.props.title = title
            notify.props.msg = msg
            notify.connect('response', _notify_response_cb, self._activity)
            self._activity.add_alert(notify)

        jobject = datastore.create()
        metadata = {
            'title': _('log-%s') % filename,
            'title_set_by_user': '0',
            'suggested_filename': filename,
            'mime_type': 'application/zip',
        }
        for k, v in metadata.items():
            jobject.metadata[k] = v
        jobject.file_path = filepath
        datastore.write(jobject)
        self._last_log = jobject.object_id
        jobject.destroy()
        activity.show_object_in_journal(self._last_log)
        os.remove(filepath)

        window.set_cursor(old_cursor)
        Gdk.flush()
开发者ID:sugarlabs,项目名称:log-activity,代码行数:46,代码来源:logviewer.py


示例19: __init__

    def __init__(self, filepath=None):
        PREINSTALLED = [
            (_('Giraffe'), "giraffe-blank.dita") ]

        root = os.path.join(get_activity_root(), 'tmp', 'book')
        shutil.rmtree(root, True)

        if not filepath:
            Book.__init__(self, PREINSTALLED, root)
        else:
            zip = zipfile.ZipFile(filepath, 'r')
            for i in zip.namelist():
                path = os.path.join(root, i)
                os.makedirs(os.path.dirname(path), 0775)
                file(path, 'wb').write(zip.read(i))
            zip.close()

            Book.__init__(self, [], root)
开发者ID:iamutkarshtiwari,项目名称:infoslicer,代码行数:18,代码来源:book.py


示例20: create_playlist_jobject

    def create_playlist_jobject(self):
        """Create an object in the Journal to store the playlist.

        This is needed if the activity was not started from a playlist
        or from scratch.
        """

        jobject = datastore.create()
        jobject.metadata['mime_type'] = "audio/x-mpegurl"
        jobject.metadata['title'] = _('Jukebox playlist')

        temp_path = os.path.join(activity.get_activity_root(),
                                 'instance')
        if not os.path.exists(temp_path):
            os.makedirs(temp_path)

        jobject.file_path = tempfile.mkstemp(dir=temp_path)[1]
        return jobject
开发者ID:cristian99garcia,项目名称:jukebox-activity,代码行数:18,代码来源:playlist.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python activity.get_bundle_path函数代码示例发布时间:2022-05-27
下一篇:
Python profile.get_color函数代码示例发布时间: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