# -*- 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 配置文件例子学习的更多相关文章

  1. pyqt QTreeWidget例子学习

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import  * from Py ...

  2. pyqt columnView例子学习

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import  * from Py ...

  3. pyqt QTableView例子学习

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import  * from Py ...

  4. pyqt QTableWidget例子学习(重点)

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from PyQ ...

  5. pyqt 托盘例子学习

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from PyQ ...

  6. pyqt 正则表达式例子学习

    def rex01(self): username=QtCore.QRegExp('[a-zA-Z0-9_]{2,10}') self.names.setValidator(QtGui.QRegExp ...

  7. pyqt tabWidget例子学习1

    from PyQt4 import QtGui from PyQt4 import QtCore from PyQt4.QtCore import pyqtSlot,SIGNAL,SLOT impor ...

  8. pyqt 自定义例子学习

    # -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' import sys from PyQt4.QtCore impor ...

  9. 数百个 HTML5 例子学习 HT 图形组件 – 3D建模篇

    http://www.hightopo.com/demo/pipeline/index.html <数百个 HTML5 例子学习 HT 图形组件 – WebGL 3D 篇>里提到 HT 很 ...

随机推荐

  1. 【计算机视觉】基于行为的ReID演示

    帮老师做了一个简单的基于行为(主要是步态)的ReID问题的Demo,效果例如以下图: 以下是提取的集中特征,前三个都是GEI系的,后几个是基于光流场的.然后右边是识别出的几个对象的排序,由于没有角度和 ...

  2. Network 20Q--Q2 How does Google sell ad spaces?

    在使用Google搜索的时候会发现,搜索出来的页面除了在左边显示搜索结果以外,还会页面的右边推荐一些广告.那么Google是怎么从这些广告挣钱以及广告商可以通过Google广告获得什么利益呢? Goo ...

  3. Android应用开发提高系列(4)——Android动态加载(上)——加载未安装APK中的类

    前言 近期做换肤功能,由于换肤程度较高,受限于平台本身,实现起来较复杂,暂时搁置了该功能,但也积累了一些经验,将分两篇文章来写这部分的内容,欢迎交流! 关键字:Android动态加载 声明 欢迎转载, ...

  4. linux 终止用户会话

    第一步使用 tty 命令 查看自己会话id:本例中会话id为1[root@localhost ~]# tty/dev/pts/1[root@localhost ~]# 第二步 使用 w 命令 查看当前 ...

  5. Web Service学习笔记(webservice、soap、wsdl、jws详细分析) (转)

    Web Service概述 Web Service的定义 W3C组织对其的定义如下,它是一个软件系统,为了支持跨网络的机器间相互操作交互而设计.Web Service服务通常被定义为一组模块化的API ...

  6. hdu 1009 贪心基础题

    B - 贪心 基础 Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:32768KB     64bi ...

  7. open_basedir restriction in effect. File() is not within the allowed path(s)

    目前发现eaccelerator安装之后如果php.ini中设置open_basedir将导致open_basedir的一些报错(open_basedir restriction in effect. ...

  8. python文件批量改名

    python对文件进行批量改名用到的是os模块中的listdir方法和rename方法. os.listdir(dir)  :获取指定目录下的所有子目录和文件名 os.rename(原文件名,新文件名 ...

  9. Win8 X64下JDK版本切换问题

    1:现在笔记本上安装的是,执行java -version: 2:现在又安装了,想通过修改环境变量,使JDK切换到1.6版本上 JDK的安装目录:D:\Java\ 修改环境变量: (1)JAVA_HOM ...

  10. 懂说话,让冲突、尴尬时刻都bye-bye

    回忆一下自己从小到大的成长历程,你容不容易交到新朋友?在不熟悉的社交场合中,你是否也曾面临坐立难安.不知从何聊起的窘境?事实上,无论身处学校或社会,担任职务是基础或高阶,终其一生都会派上用场的能力,就 ...