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

📄 a8834.htm

📁 GUI Programming with Python
💻 HTM
字号:
<HTML><HEAD><TITLE>First Steps with Sip</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="Appendices"HREF="p8645.htm"><LINKREL="PREVIOUS"TITLE="PyQwt"HREF="x8818.htm"><LINKREL="NEXT"TITLE="How sip works"HREF="x8867.htm"></HEAD><BODYCLASS="APPENDIX"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="x8818.htm"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="x8867.htm"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="APPENDIX"><H1><ANAME="SIP">Appendix C. First Steps with Sip</A></H1><DIVCLASS="TOC"><DL><DT><B>Table of Contents</B></DT><DT><AHREF="a8834.htm#AEN8842">Introduction</A></DT><DT><AHREF="x8867.htm">How sip works</A></DT><DT><AHREF="x8887.htm">Creating .sip files</A></DT><DT><AHREF="x8949.htm">Things <BCLASS="COMMAND">sip</B> can't do      automatically</A></DT><DT><AHREF="x9012.htm">Where to look to start writing your own    wrappers/bindings</A></DT><DT><AHREF="x9022.htm">Sip usage and syntax</A></DT><DT><AHREF="x9236.htm">Directives</A></DT><DT><AHREF="x9571.htm">Accepted C++ / Qt constructs</A></DT><DT><AHREF="x9684.htm">SIPLIB Functions</A></DT></DL></DIV><FONTCOLOR="RED">&#13;    Jim Bublitz  </FONT><P>Jim Bublitz knows far more about    <SPAN><ICLASS="EMPHASIS">sip</I></SPAN>, the tool used to wrap C++ libraries for    Python, than I do. For instance, he's the author of the bindings    to the KDE2 libraries. For these reasons, I asked him to write an    appendix on using sip.</P><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="AEN8842">Introduction</A></H1><P>Wrapping C++ libraries for use from Python is      a profitable undertaking, given the wealth of functionality that      becomes available after doing so. Python, in contrast with Java,      has been designed from the outset to be easily extensible with      &#8216;foreign' libraries written in C. C++, however, is a far more      complex language than C, and requires careful attention to the      creation, ownership and destruction of objects. Trolltech have      made the work even more complicated with the invention of a      special meta-object pre-compiler needed to get techniques like      signals and slots working.</P><P>These days it is not usual to wrap C++      libraries by hand. If only because of the size of the Qt      libraries, it probably isn't practical to write these bindings      manually, so an automated tool, <SPAN><ICLASS="EMPHASIS">sip</I></SPAN>, was      developed by Phil Thompson (the PyQt developer) to generate the      necessary binding code.</P><P>As you know, PyQt is a set of Python      bindings for the Qt libraries. That means that PyQt isn't a      translation of Qt into Python&#8212;instead, the &#8216;bindings' let      you access and use the C++ Qt libraries from the Python language      via an intermediate wrapper library, which is also written (or      rather, generated) in C++.</P><P>The <SPAN><ICLASS="EMPHASIS">sip</I></SPAN> program      generates these C++ &#8216;wrappers'. Wrappers are chunks of C++ code      that allow Python to pass data to and from other C++ code and to      invoke C++ methods or functions. <SPAN><ICLASS="EMPHASIS">Sip</I></SPAN> gets      its name (and some of it's architecture) from another wrapper      generator named <SPAN><ICLASS="EMPHASIS">swig</I></SPAN>. In fact,      <SPAN><ICLASS="EMPHASIS">sip</I></SPAN> started out as a small      <SPAN><ICLASS="EMPHASIS">swig</I></SPAN>, although it has grown a bit since      then.  It is specifically designed to generate Python bindings      for C++ libraries, while <SPAN><ICLASS="EMPHASIS">swig</I></SPAN> is more      general purpose, and can wrap C libraries for a variety of      scripting languages. Of course, <SPAN><ICLASS="EMPHASIS">sip</I></SPAN> also      offers some additional functionality, like support for signals      and slots, Python inheritance of C++ objects, and many other C++      language features:</P><P></P><UL><LI><P>Re-implementation of C++ virtual methods          in Python.</P></LI><LI><P>Sub-classing C++ classes from          Python.</P></LI><LI><P>Access to a C++ class's protected          methods.</P></LI><LI><P>Overloading of C++ functions and methods          with different parameter type signatures.</P></LI><LI><P>Automatic translation between C++          classes and similar (but more appropriate) Python          types.</P></LI></UL></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="x8818.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="x8867.htm"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">PyQwt</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="p8645.htm"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">How sip works</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

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