pyqt 配置文件例子学习
# -*- coding: utf-8 -*-
# python:2.x
__author__ = 'Administrator'
import sys,datetime
from PyQt4.QtCore import Qt
from PyQt4 import QtGui,QtCore,Qt
from aa import Ui_Form
class Example(QtGui.QDialog,Ui_Form):
def __init__(self,parnet=None):
super(Example, self).__init__(parnet)
self.setupUi(self)
self.read1()
def read1(self):#读取
settings1=QtCore.QSettings(r'a.ini',QtCore.QSettings.IniFormat)#当前目录的INI文件
settings1.beginGroup('a')
settings1.setIniCodec('UTF-8')
s1=settings1.value(r'cpu:',self.lineEdit.text()).toString()
s2=settings1.value(r'cpu1:',self.lineEdit_2.text()).toString()
self.lineEdit.setText(unicode(s1))
self.lineEdit_2.setText(unicode(s2))
settings1.endGroup()
return True
def write(self):#写入
settings1=QtCore.QSettings(r'a.ini',QtCore.QSettings.IniFormat)#当前目录的INI文件
settings1.beginGroup('a')
settings1.setIniCodec('UTF-8')
s1=settings1.setValue(r'cpu:',self.lineEdit.text())
s2=settings1.setValue(r'cpu1:',self.lineEdit_2.text())
self.lineEdit.setText(unicode(s1))
self.lineEdit_2.setText(unicode(s2))
settings1.endGroup()
return True
def closeEvent(self, event):
reply = QtGui.QMessageBox.question(self, 'Message',
"Are you sure to quit?", QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes:
self.write()
event.accept()
else:
event.ignore()
def main():
app = QtGui.QApplication(sys.argv)
ex = Example()
ex.show()
sys.exit(app.exec_())
main()
如图:

pyqt 配置文件例子学习的更多相关文章
- pyqt QTreeWidget例子学习
# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from Py ...
- pyqt columnView例子学习
# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from Py ...
- pyqt QTableView例子学习
# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from Py ...
- pyqt QTableWidget例子学习(重点)
# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from PyQ ...
- pyqt 托盘例子学习
# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from PyQ ...
- pyqt 正则表达式例子学习
def rex01(self): username=QtCore.QRegExp('[a-zA-Z0-9_]{2,10}') self.names.setValidator(QtGui.QRegExp ...
- pyqt tabWidget例子学习1
from PyQt4 import QtGui from PyQt4 import QtCore from PyQt4.QtCore import pyqtSlot,SIGNAL,SLOT impor ...
- pyqt 自定义例子学习
# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' import sys from PyQt4.QtCore impor ...
- 数百个 HTML5 例子学习 HT 图形组件 – 3D建模篇
http://www.hightopo.com/demo/pipeline/index.html <数百个 HTML5 例子学习 HT 图形组件 – WebGL 3D 篇>里提到 HT 很 ...
随机推荐
- c++11 NULL、0、nullptr
C的NULL 在C语言中,我们使用NULL表示空指针,也就是我们可以写如下代码: int *i = NULL;foo_t *f = NULL; 实际上在C语言中,NULL通常被定义为如下: #de ...
- C# WPF 建立无边框(标题栏)的登录窗口
前言:笔者最近用c#写WPF做了一个项目,此前未曾做过完整的WPF项目,算是一边学一边用,网上搜了不少资料,效率当然是不敢恭维的,有时会在一些很简单的问题上纠结很长时间,血与泪的教训可不少. 不过,正 ...
- [转]iOS hybrid App 的实现原理及性能监测
转自:http://www.cocoachina.com/ios/20151118/14270.html iOS hybrid App 的实现原理及性能监测 2015-11-18 11:39 编辑: ...
- ewebeditor下利用ckplayer增加html5 (mp4)全平台的支持
学校数字化平台富文本编辑器一直用的ewebeditor,应该说非常的好,支持常用office文档的直接导入,极大的方便了老师们资料的上传,最近在规划整个数字化校园向全平台改版,框架采用bootstra ...
- DIV+CSS 自适应布局
两栏布局,左边定宽200px,右边自适应.如何实现?我的第一个反应就是:用flex伸缩盒呀,然后balabala...说完之后,面试官说,还有没有别的方法?flex有些浏览器不支持嗯...我愣了一下, ...
- Android测试框架1(非原创)
1.继承AndroidTestCase :public class JunitTest3 extends AndroidTestCase {} 2.在AndroidManifest.xml清单文件中添 ...
- ORACLE SQL单行函数(二)【weber出品必属精品】
11.dual:虚表,任何用户都可以使用,表结构如下: SQL> desc dual Name Null? Type -------------------------------------- ...
- textField:shouldChangeCharactersInRange:replacementString:
http://blog.csdn.net/mamong/article/details/44964801
- iOS中UISearchBar(搜索框)使用总结
http://my.oschina.net/u/2340880/blog/509756
- MYSQL 磁盘临时表和文件排序
因为Memory引擎不支持BOLB和TEXT类型,所以,如果查询使用了BLOB或TEXT列并且需要使用隐式临时表,将不得不使用MyISAM磁盘临时表,即使只有几行数据也是如此. 这会导致严重的性能开销 ...