这里的 smart dialogs一般都是指的非模态对话框,就是用户想要实时的看到自己的操作对主窗口的影响,当然在某些模态对话框中,添加预览功能可以实现上面的需求,但是这
些在非模态对话框中是很容易做到的。
我们在前面模态对话框的字体选择程序基础上加以修改。先写一个类,ModelessDialog.py,如下:
#!/usr/bin/env python
#coding=utf-8
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class FontPropertiesDlg(QDialog):
def __init__(self,parent=None):
super(FontPropertiesDlg, self).__init__(parent)
self.format=format
FontStyleLabel = QLabel(u"中文字体:")
self.FontstyleComboBox = QComboBox()
self.FontstyleComboBox.addItems([u"宋体", u"黑体", u"仿宋",
u"隶书", u"楷体"])
self.FontEffectCheckBox =QCheckBox(u"使用特效")
FontSizeLabel = QLabel(u"字体大小")
self.FontSizeSpinBox = QSpinBox()
self.FontSizeSpinBox.setRange(1, 90)
applyButton = QPushButton(u"应用")
cancelButton = QPushButton(u"取消")
buttonLayout = QHBoxLayout()
buttonLayout.addStretch()
buttonLayout.addWidget(applyButton)
buttonLayout.addWidget(cancelButton)
layout = QGridL