亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? c6996.htm

?? GUI Programming with Python
?? HTM
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
<HTML><HEAD><TITLE>A Macro Language for Kalam</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="Creating real applications with PyQt"HREF="p4627.htm"><LINKREL="PREVIOUS"TITLE="Conclusion"HREF="x6992.htm"><LINKREL="NEXT"TITLE="Integrating macros with a GUI"HREF="x7161.htm"></HEAD><BODYCLASS="CHAPTER"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="x6992.htm"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="x7161.htm"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="CHAPTER"><H1><ANAME="CH15">Chapter 20. A Macro Language for <SPANCLASS="APPLICATION">Kalam</SPAN></A></H1><DIVCLASS="TOC"><DL><DT><B>Table of Contents</B></DT><DT><AHREF="c6996.htm#AEN7006">Executing Python code from Python</A></DT><DT><AHREF="x7161.htm">Integrating macros with a GUI</A></DT><DT><AHREF="x7295.htm">Creating a macro API from an application</A></DT><DT><AHREF="x7388.htm">Conclusion</A></DT></DL></DIV><P>One thing that separates a run-of-the-mill    application from a real tool&#8212;one that users will take refuge    in day after day&#8212;is a good macro facility. Python, which was    designed with ease of use in mind, is a natural choice for a macro    language. Nine out of ten secretaries would choose Python over the    WordPerfect macro language or Visual Basic, given the choice!    Isn't it fortunate that we have already begun developing our    application in Python?</P><P>This chapter deals with integrating a Python    based macro facility in <SPANCLASS="APPLICATION">Kalam</SPAN>. In the    course of this chapter we investigate the execution of Python code    while dynamically adding actions and menu items. We also cover    granting user access to a predefined API of our application    objects.</P><P>Of course, the underlying mechanics of a    macro facility are not particular to any GUI toolkit. And if you    decide to convert your application to C++, you can still embed    Python, wrap the API using <SPANCLASS="APPLICATION">sip</SPAN>, and    allow your users to execute the same macros. We handle powerful    stuff in this chapter, and it's well worth the effort. </P><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="AEN7006">Executing Python code from Python</A></H1><P>There are three basic ways to execute      Python code that is not directly (i.e. imported as a module)      part of your application. Single statements can be executed with      <TTCLASS="FUNCTION">eval()</TT>; we already encountered      <TTCLASS="FUNCTION">eval()</TT> in <AHREF="c6013.htm">Chapter 18</A>. Strings      that contain more than a single statement of Python code can be      executed with <TTCLASS="FUNCTION">exec()</TT>, while Python code      that is saved in a file can be executed with      <TTCLASS="FUNCTION">execfile()</TT>.</P><P>Both <TTCLASS="FUNCTION">eval()</TT> and      <TTCLASS="FUNCTION">exec()</TT> can be fed either plain text strings      or pre-compiled Python byte code. You can create blobs of byte      code with the <TTCLASS="FUNCTION">compile()</TT> function, but you      don't have to&#8212;it is simply a little more efficient to use      bytecode if you execute the same code more than once. The      <TTCLASS="FUNCTION">evalfile()</TT> function reads in a file and      executes the contents, which must be plain text. You cannot feed      <TTCLASS="FUNCTION">execfile</TT> compiled Python byte code.</P><P>Please note that      <TTCLASS="FUNCTION">eval()</TT>, <TTCLASS="FUNCTION">exec()</TT>,      <TTCLASS="FUNCTION">execfile()</TT> and      <TTCLASS="FUNCTION">compile()</TT> are the real ginger: this is what      your Python interpreter uses to execute your code.</P><P>The mere ability to execute random bits of      code is quite powerful in itself, but code only becomes truly      useful if it no longer exists in a void, but can call other,      pre-existing bits of code.</P><P>The code we execute with    <TTCLASS="FUNCTION">eval()</TT>, <TTCLASS="FUNCTION">exec()</TT> and    <TTCLASS="FUNCTION">execfile()</TT> should be brought into relation    with the other Python modules that exist in the library, and with    the code of our application. Not only that, but preferably also    with the <SPAN><ICLASS="EMPHASIS">state</I></SPAN>, that is, the variables and    objects, of the application that asks <TTCLASS="FUNCTION">eval()</TT>,    <TTCLASS="FUNCTION">exec()</TT> and <TTCLASS="FUNCTION">execfile()</TT> to    execute the code.</P><P>To that end, <TTCLASS="FUNCTION">eval()</TT>,      <TTCLASS="FUNCTION">exec()</TT> and <TTCLASS="FUNCTION">execfile()</TT>      take two parameters. The first, <TTCLASS="VARNAME">globals</TT>, is a      dictionary that represents the <SPAN><ICLASS="EMPHASIS">global</I></SPAN>      namespace. You can retrieve the global namespace of your      application with the function <TTCLASS="FUNCTION">globals()</TT>.      The global namespace contains all imported classes, built-in      functions and all global      variables, but you can also construct a restricted global      environment dictionary yourself.</P><P>The second argument,      <TTCLASS="VARNAME">locals</TT>, is a dictionary that represents the      <SPAN><ICLASS="EMPHASIS">local</I></SPAN> namespace. You can retrieve it with      <TTCLASS="FUNCTION">locals()</TT>. The <TTCLASS="VARNAME">locals</TT>      dictionary contains whatever names are local to the function      your application is currently in. You can also create a      restricted (or expanded) <TTCLASS="VARNAME">locals</TT> dictionary      yourself.</P><DIVCLASS="WARNING"><P></P><TABLECLASS="WARNING"BORDER="1"WIDTH="100%"><TR><TDALIGN="CENTER"><B>Warning</B></TD></TR><TR><TDALIGN="LEFT"><P>If you mess about with the globals and        locals dictionary, be prepared to encounter what the Python        Language Reference calls "undefined behavior". For instance,        if you execute a bit of code with an empty locals dictionary,        you cannot add new names to the namespace. This means that        import won't work, for instance, or even variable assignments.        Generally speaking, it is best to simply pass the        globals dictionary, which means that the locals dictionary        used by the executed code will be a copy of the globals        dictionary.</P></TD></TR></TABLE></DIV><P>Let's compare these locals and globals      from an interactive Python session:</P><PRECLASS="SCREEN">Python 2.0 (#1, Mar  1 2001, 02:42:21)[GCC 2.95.2 19991024 (release)] on linux2Type "copyright", "credits" or "license" for more information.&#62;&#62;&#62; globals(){'__doc__': None, '__name__': '__main__', '__builtins__': &#60;module '__builtin__' (built-in)&#62;}&#62;&#62;&#62; def f():...     a=1...     print "locals: ", locals()...&#62;&#62;&#62; globals(){'f': &#60;function f at 0x8124a94&#62;, '__doc__': None, '__name__': '__main__', '__builtins__': &#60;module '__builtin__' (built-in)&#62;}&#62;&#62;&#62; f()locals:  {'a': 1}&#62;&#62;&#62;    </PRE><P>First, we take a look at the contents of      the <TTCLASS="VARNAME">globals</TT> dictionary when Python is first      started. Then, we define a simple function      <TTCLASS="FUNCTION">f</TT>, that creates a variable      <TTCLASS="VARNAME">a</TT>, which contains the value 1 and which      prints the <TTCLASS="VARNAME">locals</TT> dictionary. Retrieving the      value of <TTCLASS="VARNAME">globals</TT> shows that      <TTCLASS="FUNCTION">f</TT> is now part of      <TTCLASS="VARNAME">globals</TT>. Running <TTCLASS="FUNCTION">f</TT> shows      that <TTCLASS="VARNAME">a</TT> is the only member of      <TTCLASS="VARNAME">locals</TT>.</P><P>By default, the <TTCLASS="VARNAME">globals</TT>      and <TTCLASS="VARNAME">locals</TT> arguments of      <TTCLASS="FUNCTION">eval()</TT>, <TTCLASS="FUNCTION">exec()</TT> and

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品中文字幕欧美| 97超碰欧美中文字幕| 亚洲欧美综合网| 91精选在线观看| 91久久香蕉国产日韩欧美9色| 国内精品伊人久久久久av影院 | 精品国产1区2区3区| 一本一道久久a久久精品 | 精久久久久久久久久久| 一区二区国产视频| 久久精品视频在线看| 欧美狂野另类xxxxoooo| 成人免费视频网站在线观看| 日本人妖一区二区| 一区二区三区日韩在线观看| 久久久噜噜噜久久人人看| 91麻豆精品国产91久久久资源速度 | 国产成+人+日韩+欧美+亚洲| 日韩成人精品视频| 亚洲一区二区成人在线观看| 国产精品人成在线观看免费| 精品国产欧美一区二区| 欧美一级精品在线| 欧美日本高清视频在线观看| 日本道精品一区二区三区| 99久久国产综合精品色伊| 国产盗摄视频一区二区三区| 久久99精品久久久久久国产越南 | 午夜精彩视频在线观看不卡| 一区二区三区中文在线| 日韩理论电影院| 中文字幕高清不卡| 国产精品网友自拍| 国产亚洲婷婷免费| 欧美国产精品v| 中文字幕不卡三区| 国产精品伦理在线| 一区精品在线播放| 亚洲黄色免费电影| 一区二区成人在线| 亚洲综合在线免费观看| 亚洲影院在线观看| 午夜久久久久久久久久一区二区| 亚洲一区二区综合| 亚洲成人免费视| 亚洲成人综合视频| 日本女人一区二区三区| 久久99精品国产| 国产毛片精品视频| 不卡电影免费在线播放一区| 99久久久久久| 欧美午夜视频网站| 欧美日韩电影在线播放| 91精品国产色综合久久ai换脸| 欧美一区二区三区视频| 久久亚洲一区二区三区四区| 国产亚洲一本大道中文在线| 成人免费视频在线观看| 亚洲一本大道在线| 久久精品国产一区二区| 国产一本一道久久香蕉| 99re热这里只有精品免费视频| 91国产免费观看| 91精品免费在线观看| 久久综合狠狠综合| **网站欧美大片在线观看| 性久久久久久久久久久久| 精品亚洲免费视频| 不卡的电影网站| 91精品国产色综合久久不卡电影| 久久精品综合网| 亚洲人妖av一区二区| 亚洲五码中文字幕| 亚洲视频在线一区| 青青草成人在线观看| 久久国产婷婷国产香蕉| 国产精品一区免费在线观看| 91麻豆精品视频| 精品国产91九色蝌蚪| 亚洲欧美日韩国产一区二区三区| 青青草原综合久久大伊人精品 | 欧美精品第1页| 日本一区二区三区四区| 亚洲国产综合91精品麻豆| 韩国视频一区二区| 97精品视频在线观看自产线路二| av一区二区三区四区| 日韩一区国产二区欧美三区| 久久伊人蜜桃av一区二区| 国产精品久久久久久福利一牛影视| 成人欧美一区二区三区白人| 亚洲第一二三四区| 精品制服美女久久| 国产一区在线看| 欧美日韩精品一区二区三区四区| 日韩精品一区二区三区在线观看| 久久精品无码一区二区三区| 一区二区三区精品在线观看| 日本一道高清亚洲日美韩| 国产成人免费高清| 色综合天天性综合| 欧美激情中文字幕一区二区| 亚洲一区国产视频| 国产一区欧美一区| a级精品国产片在线观看| 日韩一二三区不卡| 亚洲欧洲国产日本综合| 丝袜a∨在线一区二区三区不卡 | 国产在线观看免费一区| 欧美在线一区二区| 欧美成人vps| 一区二区在线观看不卡| 久久精品国产久精国产| 色综合久久综合网97色综合| 在线播放欧美女士性生活| 亚洲欧洲av在线| 黑人精品欧美一区二区蜜桃| 欧美专区日韩专区| 国产精品乱码一区二三区小蝌蚪| 日本欧美在线观看| 欧洲一区二区三区在线| 欧美一区二区人人喊爽| 国产精品系列在线| 日本成人在线看| 色94色欧美sute亚洲13| 日韩精品影音先锋| 婷婷久久综合九色综合伊人色| 国产精品系列在线播放| 欧洲一区在线电影| 久久精品夜色噜噜亚洲aⅴ| 日韩经典中文字幕一区| 色婷婷精品久久二区二区蜜臂av | 久久久久久久久久久久电影| 亚洲一区二区av在线| 欧美四级电影网| 亚洲六月丁香色婷婷综合久久| 成人午夜视频网站| 久久久久9999亚洲精品| 精品一区二区在线视频| 欧美日韩一区二区三区高清| 亚洲国产一区在线观看| 色综合视频在线观看| 日韩一区在线播放| 成人看片黄a免费看在线| 久久精品日产第一区二区三区高清版 | 中文字幕综合网| av不卡在线观看| 最新不卡av在线| 成人激情黄色小说| 国产女主播一区| 日本韩国欧美国产| 亚洲精品视频自拍| 99麻豆久久久国产精品免费 | 亚洲免费观看高清完整版在线观看熊 | 亚洲色图19p| 99国产精品久| 亚洲欧美一区二区三区孕妇| 不卡的av在线| 国产精品美女一区二区三区| 91片黄在线观看| 亚洲一区二区三区自拍| 欧美色网站导航| 日韩高清欧美激情| 日韩视频一区二区三区| 五月天激情综合| 久久在线免费观看| 国产成人亚洲综合色影视| 久久久久久夜精品精品免费| 国产电影一区二区三区| 国产精品久久久久影院老司| 懂色一区二区三区免费观看 | 国产精品欧美久久久久无广告 | 成人免费在线观看入口| 91黄视频在线观看| 亚洲成人第一页| 欧美一区二视频| 国产精品一区二区x88av| 国产精品美日韩| 91黄色免费网站| 久久精工是国产品牌吗| 国产日韩影视精品| 福利电影一区二区| 天堂av在线一区| 久久综合国产精品| 91社区在线播放| 亚洲h动漫在线| 欧美成va人片在线观看| 97精品久久久久中文字幕| 日日夜夜免费精品| 国产欧美一区二区三区在线老狼| 91麻豆swag| 乱中年女人伦av一区二区| 精品久久久久一区二区国产| 成人性生交大片| 亚洲精品免费电影| 精品理论电影在线观看| 国产成人av资源| 午夜成人免费视频| 中文字幕精品一区二区精品绿巨人 | 色94色欧美sute亚洲线路一ni |