In the last example of this section, we create a menubar, a toolbar and a statusbar. We also create a central widget.

#!/usr/bin/python
# -*- coding: utf-8 -*- """
ZetCode PyQt4 tutorial This program creates a skeleton of
a classic GUI application with a menubar,
toolbar, statusbar and a central widget. author: Jan Bodnar
website: zetcode.com
last edited: September 2011
""" import sys
from PyQt4 import QtGui class Example(QtGui.QMainWindow): def __init__(self):
super(Example, self).__init__() self.initUI() def initUI(self): textEdit = QtGui.QTextEdit()
self.setCentralWidget(textEdit) exitAction = QtGui.QAction(QtGui.QIcon('exit24.png'), 'Exit', self)
exitAction.setShortcut('Ctrl+Q')
exitAction.setStatusTip('Exit application')
exitAction.triggered.connect(self.close) self.statusBar() menubar = self.menuBar()
fileMenu = menubar.addMenu('&File')
fileMenu.addAction(exitAction) toolbar = self.addToolBar('Exit')
toolbar.addAction(exitAction) self.setGeometry(300, 300, 350, 250)
self.setWindowTitle('Main window')
self.show() def main(): app = QtGui.QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_()) if __name__ == '__main__':
main()

This code example creates a skeleton of a classic GUI application with a menubar, toolbar, and a statusbar.

textEdit = QtGui.QTextEdit()
self.setCentralWidget(textEdit)

Here we create a text edit widget. We set it to be the central widget of the QtGui.QMainWindow. The central widget occupies all space that is left.

Figure: MainWindow

Statusbar、Menubar、Toolbar合集的更多相关文章

  1. 掘金 Android 文章精选合集

    掘金 Android 文章精选合集 掘金官方 关注 2017.07.10 16:42* 字数 175276 阅读 50053评论 13喜欢 669 用两张图告诉你,为什么你的 App 会卡顿? - A ...

  2. 最新最全的 Android 开源项目合集

    原文链接:https://github.com/opendigg/awesome-github-android-ui 在 Github 上做了一个很新的 Android 开发相关开源项目汇总,涉及到 ...

  3. SQL Server技术内幕笔记合集

    SQL Server技术内幕笔记合集 发这一篇文章主要是方便大家找到我的笔记入口,方便大家o(∩_∩)o Microsoft SQL Server 6.5 技术内幕 笔记http://www.cnbl ...

  4. 【Android】开发中个人遇到和使用过的值得分享的资源合集

    Android-Classical-OpenSource Android开发中 个人遇到和使用过的值得分享的资源合集 Trinea的OpenProject 强烈推荐的Android 开源项目分类汇总, ...

  5. [Erlang 0122] Erlang Resources 2014年1月~6月资讯合集

    虽然忙,有些事还是要抽时间做; Erlang Resources 小站 2014年1月~6月资讯合集,方便检索.      小站地址: http://site.douban.com/204209/   ...

  6. [Erlang 0114] Erlang Resources 小站 2013年7月~12月资讯合集

    Erlang Resources 小站 2013年7月~12月资讯合集,方便检索.     附 2013上半年盘点: Erlang Resources 小站 2013年1月~6月资讯合集    小站地 ...

  7. SQL用法操作合集

    SQL用法操作合集   一.表的创建 1.创建表 格式: 1 CREATE TABLE 表名 2 (列名 数据类型(宽度)[DEFAULT 表达式][COLUMN CONSTRAINT], 3 ... ...

  8. Python学习路径及练手项目合集

    Python学习路径及练手项目合集 https://zhuanlan.zhihu.com/p/23561159

  9. Lucene搜索方式大合集

    package junit; import java.io.File; import java.io.IOException; import java.text.ParseException; imp ...

随机推荐

  1. [BZOJ2429][HAOI2006]聪明的猴子(最小生成树)

    性质:最小生成树上任意两点间的最大边权,一定是这两点间所有路径的最大边权中最小的.证明显然. #include<cstdio> #include<cstring> #inclu ...

  2. KMP的小结

    http://www.cnblogs.com/kuangbin/archive/2012/08/14/2638803.html 如果有哪一天不记得模板了就去看看大神的 .  非常清晰易懂.

  3. fir.im Weekly - 嘘,关于***!

    上 Github 交友刷 StackOverflow 解惑,是攻城狮必备技能,加快打怪练级速度.关于,@左耳朵耗子 在微博上分享了一篇文档,轻一点教你建一个VPN服务器,重一点到教你在路由器上***, ...

  4. bzoj 1012 BST 支持插入,区间最大

    水... /************************************************************** Problem: 1012 User: idy002 Lang ...

  5. VK Cup 2016 - Qualification Round 1 (Russian-Speaking Only, for VK Cup teams) D. Running with Obstacles 贪心

    D. Running with Obstacles 题目连接: http://www.codeforces.com/contest/637/problem/D Description A sports ...

  6. HDU 5291 Candy Distribution DP 差分 前缀和优化

    Candy Distribution 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5291 Description WY has n kind of ...

  7. uoj 66 新年的巧克力棒 数学

    #66. 新年的巧克力棒 Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://uoj.ac/problem/66 Description 马上就要 ...

  8. 在iOS 7中使用storyboard(part 1)

    原文:Storyboards Tutorial in iOS 7: Part 1        感谢翻译小组成员heartasice热心翻译.如果您有不错的原创或译文,欢迎提交给我们,更欢迎其他朋友加 ...

  9. Eclipse 中导入jar包

    导入到工程即可使用了1. 在程序目录下,创建一个文件夹,如 lib. 2. 将第三方jar包复制到该目录下3.右键工程,选择Build path4.java build path,选择 librari ...

  10. Appium+python自动化21-DesiredCapabilities详解

    Appium Desired Capabilities Desired Capabilities 是由 keys 和 values 组成的 JSON 对象. 举个简单例子: { "platf ...