保存Python等离子体的配置

2024-04-16 14:32:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我设法用Python编写了一个等离子体,其中有一个配置对话框,可以在其中选择一个文件。我还设法读出了选定的值。在

但是我怎样才能使选择持久化呢?我很确定有一些KDE/Qt预定义的函数或方法来实现它,但是我没有找到相关的文档。在

以下是我的代码(可以从等离子窗口开始):

在元数据.desktop公司名称:

[Desktop Entry]
Encoding=UTF-8
Name=Config Test
Type=Service
ServiceTypes=Plasma/Applet
X-Plasma-API=python
X-Plasma-MainScript=code/main.py

目录/代码/主.py公司名称:

^{pr2}$

目录/ui/配置界面公司名称:

<?xml version="1.0" encoding="UTF-8"?> 
<ui version="4.0"> 
 <class>Config</class> 
  <widget class="QWidget" name="verticalLayoutWidget"> 
   <layout class="QVBoxLayout" name="verticalLayout"> 
    <item> 
     <widget class="KUrlRequester" name="kcfg_testEntry"/> 
    </item> 
   </layout> 
  </widget> 
 <resources/> 
 <connections/> 
</ui>

目录/配置/主.xml公司名称:

<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
                          http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
  <kcfgfile name="configTestrc"/>
  <include>kglobalsettings.h</include>
  <group name="main">
    <entry name="testEntry" type="Url"></entry>
  </group>
</kcfg>

提前感谢大家的帮助!在


Tags: nameorg目录名称httpuiversionwww
1条回答
网友
1楼 · 发布于 2024-04-16 14:32:04

我终于可以自己回答这个问题了。上面的代码确实有效,而且配置是自动存储的-只要包已经安装(通过plasmapkg)并由plasma桌面工具启动。在

当等离子体通过等离子窗口启动时,情况并非如此。在

相关问题 更多 >