#!/usr/bin/python
# -*- coding: utf-8 -*- """
ZetCode PyQt4 tutorial In this example, we create a simple
window in PyQt4. author: Jan Bodnar
website: zetcode.com
last edited: October 2011
"""
# Here we provide the necessary imports. The basic GUI widgets are located in the QtGui module.
import sys
from PyQt4 import QtGui def main(): # Every PyQt4 application must create an application object. The application object is located in the QtGui module. The sys.argv parameter is a list of arguments from the command line. Python scripts can be run from the shell. It is a way how we can control the startup of our scripts.
app = QtGui.QApplication(sys.argv) # The QtGui.QWidget widget is the base class of all user interface objects in PyQt4. We provide the default constructor for QtGui.QWidget. The default constructor has no parent. A widget with no parent is called a window.
w = QtGui.QWidget()
# The resize() method resizes the widget. It is 250px wide and 150px high.
w.resize(250, 150)
# The move() method moves the widget to a position on the screen at x=300 and y=300 coordinates.
w.move(300, 300)
# Here we set the title for our window. The title is shown in the titlebar.
w.setWindowTitle('Simple')
# The show() method displays the widget on the screen. A widget is first created in memory and later shown on the screen.
w.show() # Finally, we enter the mainloop of the application. The event handling starts from this point. The mainloop receives events from the window system and dispatches them to the application widgets. The mainloop ends if we call the exit() method or the main widget is destroyed. The sys.exit() method ensures a clean exit. The environment will be informed how the application ended.
# The exec_() method has an underscore. It is because the exec is a Python keyword. And thus, exec_() was used instead.
sys.exit(app.exec_()) # When the Python interpreter reads a source file, it executes all of the code found in it. Before executing the code, it will define a few special variables. For example, if the python interpreter is running that module (the source file) as the main program, it sets the special __name__ variable to have a value "__main__". If this file is being imported from another module, __name__ will be set to the module's name.
if __name__ == '__main__':
main()

ZetCode PyQt4 tutorial First programs的更多相关文章

  1. ZetCode PyQt4 tutorial Drag and Drop

    #!/usr/bin/python # -*- coding: utf-8 -*- """ ZetCode PyQt4 tutorial This is a simple ...

  2. ZetCode PyQt4 tutorial widgets II

    #!/usr/bin/python # -*- coding: utf-8 -*- """ ZetCode PyQt4 tutorial In this example, ...

  3. ZetCode PyQt4 tutorial widgets I

    #!/usr/bin/python # -*- coding: utf-8 -*- """ ZetCode PyQt4 tutorial In this example, ...

  4. ZetCode PyQt4 tutorial Dialogs

    #!/usr/bin/python # -*- coding: utf-8 -*- """ ZetCode PyQt4 tutorial In this example, ...

  5. ZetCode PyQt4 tutorial signals and slots

    #!/usr/bin/python # -*- coding: utf-8 -*- """ ZetCode PyQt4 tutorial In this example, ...

  6. ZetCode PyQt4 tutorial layout management

    !/usr/bin/python -*- coding: utf-8 -*- """ ZetCode PyQt4 tutorial This example shows ...

  7. ZetCode PyQt4 tutorial work with menus, toolbars, a statusbar, and a main application window

    !/usr/bin/python -*- coding: utf-8 -*- """ ZetCode PyQt4 tutorial This program create ...

  8. ZetCode PyQt4 tutorial custom widget

    #!/usr/bin/python # -*- coding: utf-8 -*- """ ZetCode PyQt4 tutorial In this example, ...

  9. ZetCode PyQt4 tutorial basic painting

    #!/usr/bin/python # -*- coding: utf-8 -*- """ ZetCode PyQt4 tutorial In this example, ...

随机推荐

  1. Sparsity稀疏编码(一)

    稀疏编码来源于神经科学,计算机科学和机器学习领域一般一开始就从稀疏编码算法讲起,上来就是找基向量(超完备基),但是我觉得其源头也比较有意思,知道根基的情况下,拓展其应用也比较有底气.哲学.神经科学.计 ...

  2. expdp&impdp备份恢复常用命令

    备份前准备 创建备份用户 create user backup identified by backup#2018 ; 授予导入导出角色 grant connect,resource to backu ...

  3. jquery map方法使用示例

    jquery的map方法非常好用,其作用是将数组或单个对象,替换为新的内容 感觉jquery的map方法非常好用. 方法作用:将数组或单个对象,替换为新的内容.  应用实例:获取一组checkbox的 ...

  4. 随机生成气泡碰撞(原生js)

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>随 ...

  5. 逆向及BOF基础实践

    逆向及BOF基础实践 20145316 许心远 一.缓冲区溢出基础知识 缓冲区溢出是一种非常普遍.非常危险的漏洞,在各种操作系统.应用软件中广泛存在.利用缓冲区溢出攻击,可以导致程序运行失败.系统宕机 ...

  6. DB开发之postgresql

    1.环境变量配置: PGLIB=/usr/local/pgsql/lib PGDATA=$HOME/data PATH=$PATH:/usr/local/pgsql/bin MANPATH=$MANP ...

  7. c++第三十天

    P154~p159:语句1.通常情况下顺序执行. 2.C++提供一组控制流(flow-of-control)语句以支持更复杂的执行路径. 3.空语句的作用:语法上需要一条语句,但是逻辑上不需要. ) ...

  8. kali_常用软件记录

    可参考:http://www.lvzejun.cn/2015/03/31/ubuntu-software/ 录屏软件 http://www.kohaupt-online.de/hp/ http://l ...

  9. HDU 6438 网络赛 Buy and Resell(贪心 + 优先队列)题解

    思路:维护一个递增队列,如果当天的w比队首大,那么我们给收益增加 w - q.top(),这里的意思可以理解为w对总收益的贡献而不是真正获利的具体数额,这样我们就能求出最大收益.注意一下,如果w对收益 ...

  10. pod状态为Back-off

    查看pod状态为CrashLoopBackOff [root@master yaml]# kubectl get pods NAME READY STATUS RESTARTS AGE mysql-7 ...