应如何侏儒小程序存储配置数据? [英] How should a Gnome applet store its configuration data?

查看:89
本文介绍了应如何侏儒小程序存储配置数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个侏儒小程序用Python编写的。为了保存配置数据/设置,它会创建一个文件〜/ .appname

I have a Gnome applet written in Python. In order to save configuration data/settings, it creates a file ~/.appname.

不过,这$ P $被添加到面板,因为每个不能有自己的设置pvents小程序的多个实例。

However, this prevents multiple instances of the applet from being added to the panel because each cannot have its own settings.

如何可以存储在一个方式,允许每个实例有其自己独特的设置的设置

How can I store the settings in a way that allows each instance to have its own unique settings?

更新:我特别想知道如何保存设置每个实例

Update: I specifically want to know how to store settings per instance.

推荐答案

该建议的方式进行的applet是使用的 GConf信息存储preferences ,并使用每个实例都有一个键,以便你可以存储个人设置。从<一个href=\"http://library.gnome.org/devel/panel-applet/stable/panel-applet-Panel-Applet-GConf-Utilities.html\">Panel小程序的GConf公用事业的:

The recommend way for an applet would be to use GConf to store preferences and to use one key per instance so that you can store individual settings. From Panel Applet GConf Utilities:

小程序通常定义一套
  $ P使用模式文件$ pferences和
  panel_applet_add_ preferences()。这样
  preferences仅适用于
  个别小应用程序实例。对于
  例如,您可以添加两个时钟小程序
  到面板和配置它们
  不同的。

Applets typically define a set of preferences using a schemas file and panel_applet_add_preferences(). Such preferences apply only to an individual applet instance. For example, you may add two clock applets to the panel and configure them differently.

为了为preferences只
  适用于单个小程序,每个applet
  必须有一个单独的GConf键
  每个preferences的。方法
  下面介绍提供无限便捷
  各地通常的GConfClient包装
  功能以及对这些操作
  每个小应用程序键。

In order for the preferences to only apply to a single applet, each applet must have a seperate GConf key for each of these preferences. The methods described below provide convient wrappers around the usual GConfClient functions and operate on these per-applet keys.

这篇关于应如何侏儒小程序存储配置数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆