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

📄 index.lxp@lxpwrap=x179_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>GUI programming with Python</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="Introduction"HREF="c88.htm"><LINKREL="PREVIOUS"TITLE="Introduction"HREF="c88.htm"><LINKREL="NEXT"TITLE="About the BlackAdder IDE"HREF="x258.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=c88_252ehtm.htm">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 1. Introduction</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><A accesskey="N" href="index.lxp@lxpwrap=x258_252ehtm.htm">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1">GUI programming with Python</A></H1><P>One area where you      <SPAN><ICLASS="EMPHASIS">do</I></SPAN> want the snappiest response possible is      your user interface. Users are notoriously impatient creatures,      and they are right. Responsiveness is important. Likewise,      conformance to platform standards is important, as is a well      thought-out programming model, to make <SPAN><ICLASS="EMPHASIS">your</I></SPAN>      life easier. You want to have as little GUI code to as possible,      because that means that there are less opportunities for bugs.      With these criteria, we can set out to select a good GUI      toolkit.</P><P>That it is possible at all to      <SPAN><ICLASS="EMPHASIS">select</I></SPAN> a GUI toolkit might come as a bit of      a surprise to Visual Basic developers, who cannot choose, but      have to use whatever Microsoft provides. There is a cornucopia      of GUI toolkits available for Unix/X11. Because Python is so      easily extensible with  C and C++ modules, a large part of them      is usable, &#8216;bound to' is the technical term, from Python. Quite      a few of those toolkits are available on Windows too. Because      all computer intensive drawing and interaction code runs in      native machine code, outside the Python virtual machine, the      interface can be as responsive as the interface of an      application written in C or C++.</P><P>The following GUI toolkits exist for Python:</P><DIVCLASS="TABLE"></A><P><B>Table 1-1. GUI Toolkits for Python</B></P><TABLEBORDER="1"WIDTH="100%"CLASS="CALSTABLE"><THEAD><TR><THWIDTH="50"ALIGN="LEFT"VALIGN="TOP">Gui Toolkit</TH><THWIDTH="50"ALIGN="LEFT"VALIGN="TOP">Windows</TH><THWIDTH="50"ALIGN="LEFT"VALIGN="TOP">Unix/X11</TH><THWIDTH="50"ALIGN="LEFT"VALIGN="TOP">MacOS</TH><THWIDTH="100%"ALIGN="LEFT"VALIGN="TOP">Notes</TH></TR></THEAD><TBODY><TR><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">Tkinter</TD><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">Yes</TD><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">Yes</TD><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">Yes, mostly</TD><TDWIDTH="100%"ALIGN="LEFT"VALIGN="TOP">Tkinter is the most ancient Python GUI toolkit. It              is based on tcl/tk, and has neither the real platform UI              look and feel, nor a real Python programming style. A              good resource is John Grayson's book, Python and Tkinter              programming.</TD></TR><TR><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">PyQt</TD><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">Yes</TD><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">Yes</TD><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">OS X only</TD><TDWIDTH="100%"ALIGN="LEFT"VALIGN="TOP">PyQt is based on Qt, the cross-platform GUI toolkit              by Troll Tech. It's also, not so coincidentally, the              subject of this book.</TD></TR><TR><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">wxPython</TD><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">Yes</TD><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">Yes</TD><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">No</TD><TDWIDTH="100%"ALIGN="LEFT"VALIGN="TOP">wxPython is based on the wxWindows toolkit.              wxWindows is a crossplatform wrapper around a native              toolkit of each platform: the standard Win32 controls on              Windows and GTK on Unix/X11.</TD></TR><TR><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">FxPy</TD><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">Yes</TD><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">Yes</TD><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">No</TD><TDWIDTH="100%"ALIGN="LEFT"VALIGN="TOP">One of the smaller - in terms of user base -              toolkits, it is based on the FOX toolkit. FxPy's main              feature is execution speed.</TD></TR><TR><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">PyGTK (+PyGnome)</TD><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">Yes (a bit)</TD><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">Yes</TD><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">(If you run a separate X Server on OS X)</TD><TDWIDTH="100%"ALIGN="LEFT"VALIGN="TOP">PyGTK is based on GTK (formerly known as the Gimp              Toolkit). Not really intended for cross-platform work,              it has recently been ported (more or less) to Windows.            </TD></TR><TR><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">Pythonwin</TD><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">Yes</TD><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">No</TD><TDWIDTH="50"ALIGN="LEFT"VALIGN="TOP">No</TD><TDWIDTH="100%"ALIGN="LEFT"VALIGN="TOP">Pythonwin is the - rather underdocumented - binding              to Microsofts MFC library. It's not portable, of              course.</TD></TR></TBODY></TABLE></DIV><P>There are many others GUI toolkits      available, both dead and alive. For a complete listing, please      see Cameron Laird's notes on Python GUI's at:      http://starbase.neosoft.com/~claird/comp.lang.python/python_GUI.html.       However, the really serious options for someone selecting a      toolkit are Tkinter, PyQt and wxPython. I have selected PyQt for      my own use, based on criteria of performance, programming model,      completeness of the assortment of widgets and ease of      installation. Oh, and because it was the most fun to use, of      course!</P><P>There were other considerations, of      course. Tkinter is often very slow - try running the IDLE IDE      that comes with Python. In contrast, PyQt is very snappy. The      Tcl-tk programming model that Tkinter is based on doesn't      translate as well to Python as the modified C++ programming      model of PyQt. PyQt has also been very well designed: I just      love the signal/slot mechanism of PyQt. There is also just about      every type of widget I need, and PyQt is easy to install.      WxPython, because it's a library (wxPython) based on a library      (wxWindows) based on a library (MFC or GTK) can be really      difficult to get up and running. Finally, the GUI designer in      BlackAdder (or the free equivalent Qt Designer) is a strong      point in favor of Qt, too.</P><P>The most important features of PyQt are:</P><P>    <P></P><UL><LI><P>Based on Trolltechs C++ Qt            toolkit.</P></LI><LI><P>Runs on Windows and            Unix/X11 (and soon on Apple's OS X)</P></LI><LI><P>Uses the innovative            signals/slots paradigm to couple GUI items and            actions.</P></LI><LI><P>Binds almost the complete            Qt library</P></LI><LI><P>Allows subclassing of Qt            classes in Python</P></LI><LI><P>Allows applications to            mimic the look and feel of Windows, Motif, CDE, SGI and            MacOS 9, or take on a custom look and feel.</P></LI><LI><P>Comes with an enormous            inventory of advanced GUI controls, such as a canvas, an            editable table module and a rich text editor (in version            3.0).</P></LI></UL>    </P></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=c88_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=x258_252ehtm.htm">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Introduction</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><A accesskey="U" href="index.lxp@lxpwrap=c88_252ehtm.htm">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">About the BlackAdder IDE</TD></TR></TABLE></DIV></BODY></HTML>      </td>      </tr>      </table>      </td>    </tr>  </table>      

⌨️ 快捷键说明

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