QtGui.QFontDialog
The QtGui.QFontDialog
is a dialog widget for selecting a font.
#!/usr/bin/python
# -*- coding: utf-8 -*- """
ZetCode PyQt4 tutorial In this example, we select a font name
and change the font of a label. author: Jan Bodnar
website: zetcode.com
last edited: October 2011
""" import sys
from PyQt4 import QtGui class Example(QtGui.QWidget): def __init__(self):
super(Example, self).__init__() self.initUI() def initUI(self): vbox = QtGui.QVBoxLayout() btn = QtGui.QPushButton('Dialog', self)
btn.setSizePolicy(QtGui.QSizePolicy.Fixed,
QtGui.QSizePolicy.Fixed) btn.move(20, 20) vbox.addWidget(btn) btn.clicked.connect(self.showDialog) self.lbl = QtGui.QLabel('Knowledge only matters', self)
self.lbl.move(130, 20) vbox.addWidget(self.lbl)
self.setLayout(vbox) self.setGeometry(300, 300, 250, 180)
self.setWindowTitle('Font dialog')
self.show() def showDialog(self): font, ok = QtGui.QFontDialog.getFont()
if ok:
self.lbl.setFont(font) def main(): app = QtGui.QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_()) if __name__ == '__main__':
main()
In our example, we have a button and a label. With QtGui.QFontDialog
, we change the font of the label.
font, ok = QtGui.QFontDialog.getFont()
Here we pop up the font dialog. The getFont()
method returns the font name and the ok parameter. It is equal to True if the user clicked OK; otherwise it is False.
if ok:
self.label.setFont(font)
If we clicked ok, the font of the label would be changed.
QtGui.QFontDialog的更多相关文章
- PyQt4字体对话框QFontDialog
字体对话框时用来显示字体的对话框部件. #!/usr/bin/python # -*- coding: utf-8 -*- import sys from PyQt4 import QtGui, Qt ...
- PyQt4入门学习笔记(五)
PyQt4里的对话框 对话框是大多数GUI应用中不可分割的一部分.一个对话框是两者或多者的会话.在GUI内,对话框是应用向人说话的方式.一个对话框可以用来输入数据,修改数据,改变应用设置等等. QtG ...
- Qt: 内建对话框(各种对话框都有了,且用到了qobject_cast解析sender的技术)
#include "BuiltinDialog.h" #include <QtGui/QTextEdit> #include <QtGui/QPushButton ...
- Python -- Gui编程 -- Qt库的使用 -- 菜单与对话框
1.菜单 import sys from PyQt4 import QtCore, QtGui class MyWindow(QtGui.QMainWindow): def __init__(self ...
- QDialog:输入对话框、颜色对话框、字体对话框、文件对话框
# _*_ coding:utf-8 _*_ import sys from PyQt4 import QtCore,QtGui class Example(QtGui.QWidget): def _ ...
- ZetCode PyQt4 tutorial Dialogs
#!/usr/bin/python # -*- coding: utf-8 -*- """ ZetCode PyQt4 tutorial In this example, ...
- PyQt4 颜色选择,字体选择代码
# -*- coding: utf-8 -*- """ ------------------------------------------------- File Na ...
- 读Pyqt4教程,带你入门Pyqt4 _005
对话框窗体或对话框是现代GUI应用不可或缺的一部分.dialog定义为两个或多个人之间的交谈.在计算机程序中dialog是一个窗体,用来和程序“交谈”.对话框用来输入数据.修改数据.改变程序设置等等. ...
- 六、pyqt5对话框——QInputDialog、QColorDialog、QFontDialog、QMessageBox、QFileDialog
目录: 一.对话框综合示例 二.QDialog 三.QInputDialog 四.QMessageDialog 五.QFileDialog pyqt5的对话框有多种类型,比如输入对话框(QInput ...
随机推荐
- python中后端数据序列化不显示中文的解决方法
我们在前后端交互的时候,让序列化的数据更友好的显示,我们会用到 import json js = json.loads('{"name": "多多"}') pr ...
- 【原创】MySQL+MyEclipse+对象映射文件,schema与category的关系
(一) 1.映射文件的类如下写法:class name="com.sanqing.po.SysUser" table="sys_user" catalog=& ...
- iOS Contact框架功能研究
兄弟们,直接复制,感谢度娘,感谢谷哥!!! 1.读取联系人通讯录 /** * 读取联系人通讯录 */ -(NSMutableArray*)getContactList{ NSMutableArray ...
- Python3的变化
http://www.cnblogs.com/tips4python/archive/2011/05/31/2064290.html print 由一个语句(statement)变为一个函数 Pyth ...
- iOS学习之sqlite的创建数据库,表,插入查看数据
目录(?)[-] 新建项目sqliteDemo添加使用sqlite的库libsqlite3dylib sqlite 的方法 获取沙盒目录并创建或打开数据库 创建数据表 插入数据 查询数据库并打印数据 ...
- IDA 中文字符串
http://www.pediy.com/kssd/pediy05/pediy50528.htm Ida Pro 的默认设置里对中文字串的支持比较差,对于首字节大于'E0'的都显示成?了.其实... ...
- Surface Mount Package Details
http://www.centralsemi.com/product/packages/index2.php http://www.infineon.com/cms/cn/product/packag ...
- java string(2)
1. indexOf()函数是一个执行速度非常快的函数,可以用其与subString()实现高效的字符串分割,比内置的要高效. 2. charAt()方法也是高效率的函数,可以用其实现高效的start ...
- boa cgi程序cgi_header: unable to find LFLF
ftp必须用二进制模式上传才可以 sqlite3 arm-linux-gcc hello.c -o hello.cgi -I /cgi/include -L /cgi/lib -static -lsq ...
- EventStore .NET API Client在使用线程池线程同步写入Event导致EventStore连接中断的问题研究
最近,在使用EventStore的.NET Client API采用大量线程池线程同步写入Event时(用于模拟ASP.NET服务端大并发写入Event的情况),发现EventStore的连接会随机中 ...