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

📄 225.html

📁 Python Ebook Python&XML
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<a namE="4"></a>Figure 16.9. Python Projects: tree widget that displays Python directories and files.</h5>
						
							
								<iMG BOrder="0" WIDTh="500" heiGHT="352" Src="graphics/16fig09.gif" alT="graphics/16fig09.gif">
							
						
					</CENter>

					<p>Another option provided is the ability to make changes on the Pythonwin Registry settings, as you can see in <a href="225#5.html">Figure 16.10</a>. In order to open this window, you need to call the menu item named <a name="idx1073749848"></a>
						<tt clAss="monofont">Edit PythonPath.</Tt>
					</p>

					<cEnter>
						<H5>
<a naME="5"></A>Figure 16.10. The Registry Editor allows you to make changes on the registry settings of Pythonwin.</H5>
						
							
								<img bORDEr="0" widTH="467" HEight="285" SRC="graphics/16fig10.gif" Alt="graphics/16fig10.gif">
							
						
					</center>

					<p>The next two options are used when you have to write COM interfaces using Python. The first option <a name="idx1073749849"></a>
						<tt claSs="monofont">COM Makepy utility</tT> is mentioned in <a hrEf="128.html">Chapter 7, "Objects Interfacing and Distribution."
						</a>  It lists all the available COM objects registered in the system and allows you to create a Python interface for them (see <a hRef="225#6.html">Figure 16.11</a>). In this example, we are highlighting the Excel 8.0 Object Library in order to create a Python interface that will allow us to use Excel COM interface.<A NAMe="idx1073749850"></a>
						<a nAME="idx1073749851"></A>
						<a namE="idx1073749852"></A>
						<A Name="idx1073749853"></a>
						<A NAMe="idx1073749854"></a>
						<a name="idx1073749855"></a>
						<a name="idx1073749856"></a>
					</p>

					<centeR>
						<h5>
<a Name="6"></A>Figure 16.11. A list of available COM libraries.</h5>
						
							
								<img BordER="0" WIdth="305" hEIGHt="331" src="graphics/16fig11.gif" ALT="graphics/16fig11.gif">
							
						
					</CenteR>

					<P>This next option <A Name="idx1073749857"></a>
						<tt class="monofont">COM Browser</tt> allows you to visualize all the properties of registered COM objects (see <a href="225#7.html">Figure 16.12</a>). <a NamE="idx1073749858"></a>
						<a nAme="idx1073749859"></a>
						<a Name="idx1073749860"></A>
					</P>

					<CEnter>
						<H5>
<A NAme="7"></a>Figure 16.12. The Python Object Browser.</h5>
						
							
								<IMG BordeR="0" WIDth="338" height="352" src="graphics/16fig12.gif" alt="graphics/16fig12.gif">
							
						
					</center>

					<P>Pythonwin supports <a nAme="idx1073749861"></a>
						<A name="idx1073749862"></A>
						<a naME="idx1073749863"></A>source code folding, which means that it has the capability to collapse sections of source code into single lines, and later expand them back to the original structure (see <A href="225#8.html">Figure 16.13</A>). This folding featured was added to Pythonwin thanks to Scintilla. You can <A NAme="idx1073749864"></a>
						<a NAME="idx1073749865"></a>fold and unfold any Python statement that introduces a new block either by clicking on the indicator in the folding margin, by selecting one of the folding keystrokes, or by using View, Folding menu. Note that the folding feature must be enabled via the menu option <tt cLASS="monofont">View/Options/Editor dialog.</tt> You can also change the configuration so that all files have only their top-levels folded when opened. All editing functions work properly when code is folded. If necessary, functions like <tt class="monofont">find,</tt>
						<tt class="monofont">replace,</tt> and <Tt cLass="monofont">goto</Tt> are able to unfold the code before they start performing their tasks. For more information, check out</p>

					<ceNter>
						<H5>
<A NAme="8"></a>Figure 16.13. Opening a file and toggling the breakpoint.</h5>
						
							
								<IMG BordeR="0" WIDth="500" heIGHT="348" src="graphics/16fig13.gif" alt="graphics/16fig13.gif">
							
						
					</center>

					<blockquoTe>
<p>
							<P>Scintilla</p>

						</p>
<p>
							<P>
								<a tarGet="_blank" hREF="http://www.scintilla.org">http://www.scintilla.org</A>
								<a namE="idx1073749866"></A>
								<A Name="idx1073749867"></a>
								<A NAMe="idx1073749868"></a>
							</p>

						</p>
</BLOCkquote>
					<p>Pythonwin's <a name="idx1073749869"></a>debugger had a great improvement since the last version. To use the Debug mechanism, you need to open a program and set the breakpoints on the code. You can toggle the breakpoints by clicking on a specific line and using the F9 key binding, as shown in <a href="225#8.html">Figure 16.13</a>. You don't need to run the debugger just to set the breakpoints; you can do that while the debugger is not running. While the debugger is inactive, the breakpoints are shown without any coloring.<a NamE="idx1073749870"></a>
						<a nAme="idx1073749871"></a>
						<a Name="idx1073749872"></A>
						<A NAme="idx1073749873"></a>
					</p>

					<P>You just can't let the breakpoints remain there and pray for something to happen. You need to <A NAme="idx1073749874"></a>activate the debugger by either using the <tT CLAss="monofont">Step in</tt> (F11) option, the <TT CLass="monofont">Go</tt> (F5) option, or one of the shortcuts in the toolbar and in the menu. When you start the debugging process, all breakpoints become red (see <a href="225#9.html">Figure 16.14</a>梟ote that as the figure isn't in color, it might feel that some colors are not easily identified in the book).</p>

					<center>
						<h5>
<a NamE="9"></a>Figure 16.14. The Debug Framework.</h5>
						
							
								<iMg borDer="0" wIDTH="500" heigHT="375" SRc="graphics/16fig14.gif" alt="graphics/16fig14.gif">
							
						
					</CENTer>

					<p>In order to <a NAME="idx1073749875"></a>
						<a name="idx1073749876"></a>
						<a name="idx1073749877"></a>
						<a name="idx1073749878"></a>add watch variables and <a NamE="idx1073749879"></a>
						<a nAme="idx1073749880"></a>
						<a Name="idx1073749881"></A>
						<A NAme="idx1073749882"></a>break-point conditions, you need to click on a specific part of the Debugging window. To add variables, you need to click on the Expression/Value text box and click on the &lt;New item&gt; text. The prompt will let you type the name of the variables that you want to watch. In case you want to delete something from there, you just need to press the Delete key.</p>

					<P>If you close the Debugging toolbar, you can <A NAme="idx1073749883"></a>
						<a NAME="idx1073749884"></a>
						<a naME="idx1073749885"></A>open it using the menu option View, Toolbars, Debugging. Note that this toolbar follows the standard found in other languages, as we can see in the <A href="225#9.html">Figure 16.14</a> (from left to right):<a name="idx1073749886"></a>
						<a name="idx1073749887"></a>
						<a naMe="idx1073749888"></a>
						<A namE="idx1073749889"></a>
					</p>

					<ul>
<Li>
							<p>Watch Window toggle option</p>

						</LI>
<LI>
							<p>Stack Viewer Window toggle option</p>

						</li>
<LI>
							<P>Breakpoint List Window toggle option</P>

						</li>
<li>
							<P>Option to toggle a breakpoint</P>

						</LI>
<li>
							<p>Option to clear all breakpoints</p>

						</LI>
<LI>
							<p>Step into a statement</p>

						</li>
<li>
							<p>Step over a function</p>

						</li>
<li>
							<p>Step out of a structure</p>

						</li>
<li>
							<p>Go</p>

						</Li>
<lI>
							<p>Close the debugger</p>

						</lI>
</ul>
					<p>As you can see in <a Href="225#9.html">Figure 16.14</A>, when you select all debug windows to be open, you get a Debug Framework containing five windows. Let's go clockwise, starting from the top-left corner: We have the variable watch window, the stack viewer, the Python path browser, the interactive window that displays the source code, and a list of breakpoint conditions (on the bottom).</P>

				
				
					<H4>

Keyboard Bindings</H4>
					<p>Pythonwin has a customizable keyboard binding mechanism that allows you to define your own custom events and keyboard bindings. All this information gets stored in a file called <tt cLASS="monofont">default.cfg,</tt> which is located in the <tt CLASs="monofont">pywin</tt> directory. You can freely edit this file if you want. All the documentation necessary to create the new bindings is kept in this file, including how to create your own configuration based on the default file. This last feature is a handful to incorporate into your system <tT CLAss="monofont">default</tt> file from new versions of Pythonwin without changing your code. This directory also contains a configuration file called <tt class="monofont">IDLE.cfg</tt> that simulates the keyboard bindings of <tt class="monofont">IDLE,</Tt> providing a good customization example.</p>

					<P>The bindings in <a hrEf="225#11.html">Table 16.3</a> are part of Pythonwin's default configuration.<a nAme="idx1073749890"></a>
						<A NAMe="idx1073749891"></a>
						<a nAME="idx1073749892"></A>
						<a namE="idx1073749893"></A>
						<A Name="idx1073749894"></a>
						<A NAMe="idx1073749895"></a>
					</p>

					<a name="11"></a><p><table bordeR="1" ceLlspAcing="0" CellPADDing="1" wIDTH="100%">
<captION><H5>Table

⌨️ 快捷键说明

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