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

📄 index.lxp@lxpwrap=x4954_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>Menus</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="Actions: menus, toolbars and accelerators"HREF="c4807.htm"><LINKREL="PREVIOUS"TITLE="Actions: menus, toolbars and accelerators"HREF="c4807.htm"><LINKREL="NEXT"TITLE="Toolbars"HREF="x4974.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=c4807_252ehtm.htm">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 13. Actions: menus, toolbars and accelerators</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><A accesskey="N" href="index.lxp@lxpwrap=x4974_252ehtm.htm">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1">Menus</A></H1><P>Most of the time, you can simply add      actions or action groups to menus. This is what we did above, in      the docview framework. However, in some cases it is desirable to      have a dynamic list of menu options. This is a bit more      complicated. This is useful, for instance, in applications where      the user can open more than one window, or for lists of recently      opened files. In almost every other case, it is awfully      confusing to the user if menu options are added and removed at      the whim of the application.      </P><P>By connecting the      <TTCLASS="FUNCTION">aboutToShow()</TT> signal of a menu to a slot      (for example, <TTCLASS="FUNCTION">slotWindowMenuAboutToShow</TT>),      you can exercise precise control over the contents of the menu      by first clearing it, and then building it up again. Note the      use of <TTCLASS="FUNCTION">setItemChecked()</TT> to place a      checkmark next to selected windows. This is something you get      for free with a <TTCLASS="CLASSNAME">QActionGroup</TT>, but      recreating a <TTCLASS="CLASSNAME">QActionGroup</TT> every time the      user selects the window menu is just as much a bore as      recreating the menu, if not more so.</P><PRECLASS="PROGRAMLISTING">  def slotWindowMenuAboutToShow(self):        self.windowMenu.clear()        self.actions["windowNewWindow"].addTo(self.windowMenu)        self.actions["windowCascade"].addTo(self.windowMenu)	self.actions["windowTile"].addTo(self.windowMenu)        if self.workspace.windowList()==[]:            self.actions["windowAction"].setEnabled(FALSE)        else:            self.actions["windowAction"].setEnabled(TRUE)        self.windowMenu.insertSeparator()        i=0 # window numbering        self.menuToWindowMap={}        for window in self.workspace.windowList():            i+=1            index=self.windowMenu.insertItem(("&#38;%i " % i) +                                             str(window.caption()),                                             self.slotWindowMenuActivated)            self.menuToWindowMap[index]=window            if self.workspace.activeWindow()==window:                self.windowMenu.setItemChecked(index, TRUE)    def slotWindowMenuActivated(self, index):        self.menuToWindowMap[index].setFocus()      </PRE><P>We will investigage the creation of      application frameworks containing more than one window in      chapter <A href="index.lxp@lxpwrap=c5288_252ehtm.htm">Chapter 15</A>.</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=c4807_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=x4974_252ehtm.htm">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Actions: menus, toolbars and accelerators</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><A accesskey="U" href="index.lxp@lxpwrap=c4807_252ehtm.htm">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Toolbars</TD></TR></TABLE></DIV></BODY></HTML>      </td>      </tr>      </table>      </td>    </tr>  </table>      

⌨️ 快捷键说明

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