⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c6013.htm

📁 GUI Programming with Python
💻 HTM
字号:
<HTML><HEAD><TITLE>Application Configuration</TITLE><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.72"><LINKREL="HOME"TITLE="GUI Programming with Python: QT Edition"HREF="book1.htm"><LINKREL="UP"TITLE="Creating real applications with PyQt"HREF="p4627.htm"><LINKREL="PREVIOUS"TITLE="Conclusion"HREF="x6008.htm"><LINKREL="NEXT"TITLE="The Python way of handling configuration      settings"HREF="x6053.htm"></HEAD><BODYCLASS="CHAPTER"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">GUI Programming with Python: QT Edition</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="x6008.htm"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="x6053.htm"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="CHAPTER"><H1><ANAME="CH13">Chapter 18. Application Configuration</A></H1><DIVCLASS="TOC"><DL><DT><B>Table of Contents</B></DT><DT><AHREF="c6013.htm#AEN6019">Platform differences</A></DT><DT><AHREF="x6053.htm">The Python way of handling configuration      settings</A></DT><DT><AHREF="x6082.htm">Implementing configurations settings for      <SPANCLASS="APPLICATION">Kalam</SPAN></A></DT><DT><AHREF="x6300.htm">Settings in Qt 3.0</A></DT><DT><AHREF="x6342.htm">Conclusion</A></DT></DL></DIV><P>Every user has a preferred way of doing    things &#8212; and a good application should be accommodating    enough that important choices&#8212;such as what font to    use&#8212; can be set by the user. Of course, no one likes    applying their favorite settings every time they start an    application, so we will need to store the settings, too. This    chapter deals with settings &#8212; retrieving, storing and using.  </P><P>Unfortunately, different platforms have    vastly differing traditions for the storing of user preferences.    You can either use the platform standard, or create your own    solution.</P><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="AEN6019">Platform differences</A></H1><P>On a Windows system, most applications      store user preferences in a central database, called the      Registry. This book is not the place to argue about the wisdom      or folly of keeping all application and system settings in one      database, which can only be accessed with specialized tools.      Most modern windows applications no longer use the once      prevalent <TTCLASS="FILENAME">.ini</TT> standard. Using      <TTCLASS="FILENAME">.ini</TT>, an application could store settings      in a file in either the installation directory, the      <TTCLASS="FILENAME">windows</TT> directory, or in one of two      configuration files: <TTCLASS="FILENAME">win.ini</TT> or      <TTCLASS="FILENAME">system.ini</TT>. Windows has only recently      become a multi-user system, so it is still difficult to      determine where to store user specific settings. In Windows      2000, I suggest the <TTCLASS="FILENAME">C:\Documents and        Settings\{Username}\Local Settings\Application Data</TT>      directory. In the registry, there is the HKEY_USER      branch.</P><P>The Unix standard is not so much a standard      as a gentle guide. You can store system-wide application      settings in the <TTCLASS="FILENAME">/etc</TT> directory, or one of      its subdirectories, or in the <TTCLASS="FILENAME">/usr/share</TT>      directory together with resources... Or in      <TTCLASS="FILENAME">/usr/local/share</TT> &#8212; or in any number      of other places.</P><P>User settings on a Unix system are      generally stored in so-called dot files, or dot directories.      These are files or directories that start with a dot (.) and are      thus &#8216;invisible' when the user asks for the contents of a      directory using <TTCLASS="FILENAME">ls</TT> (or browses the      directory with a filemanager like konqueror). The dot-files or      dot-directories are located in the home directory of the user. A      Unix home directory can be compared to the user's directory      under <TTCLASS="FILENAME">C:\Documents And Settings</TT> in Windows      2000. It is generally found under <TTCLASS="FILENAME">/home</TT>.      You can retrieve the location of this directory with:</P><PRECLASS="PROGRAMLISTING">os.environ["HOME"]    </PRE><P>This returns None when HOME is not set. If      you are developing for KDE, you might want to store the user      settings in      <TTCLASS="FILENAME">$HOME/.kde/share/config/</TT>instead, and the      application settings in      <TTCLASS="FILENAME">$KDEDIR/share/apps</TT>.</P></DIV></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="x6008.htm"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="book1.htm"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="x6053.htm"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Conclusion</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="p4627.htm"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">The Python way of handling configuration      settings</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -