当前位置: 首页>>代码示例>>Python>>正文


Python activity.get_activity_root函数代码示例

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


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


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