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

📄 index.lxp@lxpwrap=x327_252ehtm.htm

📁 GUI Programming with Python
💻 HTM
字号:
    <table border="0" cellspacing="0" cellpadding="3" width="100%"><tr><td>    <div align="center" id="bldcontent">      <a href="../default.htm"><img src="../images/opendocs.png" width="63" height="76" border="0"></a>      <br>      <div class="symbol">Your OpenSource Publisher&#153;</div>    </div>      </td></tr></table>    <div align="center" class="author">      	<a href="../products.lxp">Products</a>	&nbsp;|&nbsp;	<a href="../wheretobuy.lxp">Where to buy</a>	&nbsp;|&nbsp;	<a href="../bookstore.lxp">Retailers</a>	&nbsp;|&nbsp;	<a href="../faq.lxp">FAQ</a>	&nbsp;|&nbsp;        <a href="../writeforus.lxp">Write for Us.</a>        &nbsp;|&nbsp;        <a href="#contact">Contact Us.</a>  </div>    <table border="0" cellspacing="3" cellpadding="0" width="100%"><tr><td width="100%">      <div class="content">        <table border="0" cellspacing="2" cellpadding="0" width="100%"><tr><td width="100%">          <div align="center"><H4 CLASS="AUTHOR"><A NAME="AEN5">Boudewijn Rempt</A><br><a href="../../https@secure.linuxports.com/opendocs/default.htm"><img src=odpyqt125.png></a><br>ISBN: 0-97003300-4-4<br><a href="../../https@secure.linuxports.com/opendocs/default.htm">Available from bookstores everywhere or you can order it here.</a><p>You can download the source files for the book <a href="pyqtsrc.tgz">(code / eps) here.</a><hr></div>                    <HTML><HEAD><TITLE>Installing       sip and PyQt without BlackAdder</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="Installation"HREF="c271.htm"><LINKREL="PREVIOUS"TITLE="Installation"HREF="c271.htm"><LINKREL="NEXT"TITLE="Interface"HREF="c411.htm"></HEAD><BODYCLASS="SECT1"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"><A accesskey="P" href="index.lxp@lxpwrap=c271_252ehtm.htm">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 2. Installation</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><A accesskey="N" href="index.lxp@lxpwrap=c411_252ehtm.htm">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1">Installing       sip and PyQt without BlackAdder</A></H1><P>All components that combine to form a PyQt      development environment are also freely available. Python, Qt,      Qt Designer, sip, PyQt and editors are all available as open      source. If you use Linux&#8212;and particularly if you use a      modern and complete distribution like SuSE or      Redhat&#8212;everything you need is included on your      distribution media, including PyQt. There are also Debian      packages of PyQt available. Installing these ready-made packages      is very easy, but they are not always completely up-to-date. In      the next section, I will discuss building PyQt from source,      which is necessary if you want to always run the latest version      of PyQt.</P><P>Windows users who want to use PyQt without      BlackAdder have some downloading to do, but all components are      available as binary packages that come with easy to use Windows      installers.</P><P>Installing PyQt from source on Windows falls outside the      scope of this book, partly because it is quite complicated, and      partly because I don't have a C++ compiler for Windows. The Qt      library essentially demands Visual C++.</P><P>You can also access the PyQt CVS      repository (the central place where the most current code is      kept &#8212; also at http://www.thekompany.com). Compiling PyQt      from CVS source entails creating the C++ bindings code from the      sip definition files, and then carrying on as if you had      downloaded the source. Keep in mind that CVS versions of      software are not expected to work!</P><DIVCLASS="SECT2"><H2CLASS="SECT2">Building from source on Linux</A></H2><P>Assuming you already have an        installation of Python and Qt, you first need to gather the        following packages if you want to build PyQt from        source:</P><P></P><UL><LI><P>sip</P></LI><LI><P>PyQt</P></LI><LI><P>Eventually: PyKDE</P></LI></UL><P>Be careful to choose versions of        packages that fit each other. You can compile PyQt with most        versions of Qt, but Python 2.1 will give better results than        Python 2.0, and so on.</P><P>You need to compile and install sip        before compiling PyQt. After unpacking the sip tar archive,        you will need to give the following commands:</P><PRECLASS="SCREEN">        boud@calcifer:~/src/sip-2.5 &#62; ./configure; make      </PRE><P>And, when building is complete, become        superuser and type:</P><PRECLASS="SCREEN">        root@calcifer:/home/boud/src/sip-2.5 &#62; make install      </PRE><P>If your Python or Qt installation is in        an odd place, then chances are that the        <TTCLASS="FILENAME">configure</TT> script cannot find it. In that        case, you should give their locations on the command        line:</P><PRECLASS="SCREEN">        boud@calcifer:~/src/sip-2.5 &#62; ./configure \        --with-qt-dir=/opt/qt \ --with-python=/usr/local/bin/python      </PRE><P>This will build the sip library and        executable, and install them (most likely in        <TTCLASS="FILENAME">/usr/local/</TT>). With this done, it is time        to do the same with PyQt. This time, the make command will        take a long time to run, because PyQt is a very large set of        bindings, and the GNU C++ compiler isn't the fastest        around.</P><PRECLASS="SCREEN">        boud@calcifer:~/src/PyQt-2.5 &#62; ./configure; make ...        boud@calcifer:~/src/PyQt-2.5 &#62; su Password:        root@calcifer:/home/boud/src/PyQt-2.5 &#62; make install      </PRE><P>The whole process might take a while,        but should not pose any problem. Sometimes, however, things go        wrong...</P><DIVCLASS="SECT3"><H3CLASS="SECT3">Problems with compilation</A></H3><P>While not really          <SPAN><ICLASS="EMPHASIS">difficult</I></SPAN>, compiling from source is an          exercise to be attempted only by the technically adept.          Certain problems have cropped up throughout the life of          PyQt, only to be solved in later versions. Other problems          have been caused by the version of the GNU C++ compiler used          in certain releases of Redhat: gcc 2.96.</P><P>If you are experiencing problems, you          probably have several versions of Python or Qt on your          system, and the compilation configuration process inevitably          picks the wrong one &#8212; for instance Qt 2.3.1 for sip          and then Qt 3.0.0 for PyQt. Murphy's law cannot be avoided!          This hurts compilation &#8212; but is easily avoided by          giving the right versions at the ./configure command          line.</P><P>If you have determined that this is          not the problem, your best bet will be to subscribe to the          PyQt mailinglist: http://mats.gmd.de/mailman/listinfo/pykde,          where most of us have found succor more than once.</P></DIV></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2">Windows</A></H2><P>You can develop applications on Windows        systems with PyQt using only gratis software. Life will        certainly be more difficult than if you buy BlackAdder,        because you miss the nice integration of editor, debugger and        operating system. Another issue is licensing: if you buy the        professional edition of BlackAdder, you can write commercial        software. If you use the non-commercial version of the Qt        library and the separately available packages of sip and PyQt,        you are not allowed to sell your programs: you are not even        allowed to use your software yourself in a commercial setting.        However, if you want to develop PyQt on windows without        spending any money, you need the following components:</P><P></P><UL><LI><P>The Non-commercial licensed Qt            library from http://www.trolltech.com. This a full version            of Qt. You cannot build commercial applications with this            library, and you cannot use your software in a commercial            setting. Additionally, you must make the source to your            software available. See            http://www.trolltech.com/products/download/freelicense/noncommercial-dl.html             for more information.          </P></LI><LI><P>You also need the precompiled PyQt            for Windows library from            http://www.thekompany.com/projects/pykde/. This is made            available under the same license as the non-commercial            version of Qt. You don't need to download a separate copy            of sip.                     </P></LI><LI><P>Of course, Python is needed, too! Get it from            http://www.python.org.</P></LI></UL><P>You also need a nice editor to type your        Python code with. notepad just won't do - SciTE, which uses        the same editor component as BlackAdder, is very powerful and        pleasant to use. Get SciTE from        http://www.scintilla.org/SciTE.html. (SciTE is also available        for Linux.)</P><DIVCLASS="MEDIAOBJECT"><P><DIVCLASS="CAPTION"><P><SPANCLASS="APPLICATION">The SciTE                editor.</SPAN></P></DIV></P></DIV><P>You job is then reduced to manually        installing Python, Qt, PyQt, and an editor. Then you can get        started on developing your application.</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"><A accesskey="P" href="index.lxp@lxpwrap=c271_252ehtm.htm">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><A accesskey="H" href="index.lxp@lxpwrap=book1_252ehtm">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><A accesskey="N" href="index.lxp@lxpwrap=c411_252ehtm.htm">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Installation</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><A accesskey="U" href="index.lxp@lxpwrap=c271_252ehtm.htm">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Interface</TD></TR></TABLE></DIV></BODY></HTML>      </td>      </tr>      </table>      </td>    </tr>  </table>      

⌨️ 快捷键说明

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