index.lxp@lxpwrap=x5458_252ehtm.htm

来自「GUI Programming with Python」· HTM 代码 · 共 256 行

HTM
256
字号
    <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>View</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="A More Complex Framework: Multiple Documents, Multiple    Views"HREF="c5288.htm"><LINKREL="PREVIOUS"TITLE="Document"HREF="x5451.htm"><LINKREL="NEXT"TITLE="The actual application"HREF="x5469.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=x5451_252ehtm.htm">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 15. A More Complex Framework: Multiple Documents, Multiple    Views</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><A accesskey="N" href="index.lxp@lxpwrap=x5469_252ehtm.htm">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1">View</A></H1><P>As with the document, the view is still a      relatively uncomplicated object. It still knows which document      it belongs to. I have added <TTCLASS="FUNCTION">close(self)</TT> to      make it easier to follow the execution flow when closing a      window. What is more important, however, is the      <TTCLASS="FUNCTION">closeEvent()</TT> function &#8212; this is      subclassed to completely override      <TTCLASS="CLASSNAME">QWidget's</TT> default functionality. Close      events are handled by the application itself, not by the view.      The view doesn't know anything about the document manager, which      ultimately handles the close event for all views.</P><DIVCLASS="EXAMPLE"></A><P><B>Example 15-4. The view class</B></P><PRECLASS="PROGRAMLISTING">"""mdiview.py &#8212; view componentcopyright: (C) 2001, Boudewijn Remptemail:     boud@rempt.xs4all.nl"""from qt import *class MDIView(QWidget):    """    The MDIView class can represent object of class    MDIDoc on screen.    slots:          slotDocModified    """    def __init__(self, parent, doc, *args):        apply(QWidget.__init__,(self, parent) + args)        self.doc = doc        self.connect(self.doc, PYSIGNAL("sigDocModified"),                     self.slotDocModified)        self.connect(self.doc, PYSIGNAL("sigDocTitleChanged"),                     self.setCaption)        # Set initial values        self.slotDocModified(self.doc.modified())    def slotDocModified(self, value):        if value:            self.setBackgroundColor(QColor("red"))        else:            self.setBackgroundColor(QColor("green"))    def mouseDoubleClickEvent(self, ev):        self.doc.slotModify() # direct call to the document    def document(self):        return self.doc    def closeEvent(self, e):        pass    def close(self, destroy=0):        return QWidget.close(self, destroy)    </PRE></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=x5451_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=x5469_252ehtm.htm">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Document</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><A accesskey="U" href="index.lxp@lxpwrap=c5288_252ehtm.htm">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">The actual application</TD></TR></TABLE></DIV></BODY></HTML>      </td>      </tr>      </table>      </td>    </tr>  </table>      

⌨️ 快捷键说明

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