#-*- coding: utf-8 -*- import sys from PyQt4.QtGui import * from PyQt4.QtCore import * class Change(QWidget): def __init__(self, parent = None): super(Change, self).__init__(parent) self.setWindowTitle(u"文件更改器") self.setWindowFlags(Qt.WindowMinimizeButtonHint) self.setFixedSize(200, 200) btnFile = QPushButton(u"修改文件") btnDir = QPushButton(u"修改文件夹") QObject.connect(btnFile, SIGNAL("clicked()"), self.changeFile) QObject.connect(btnDir, SIGNAL("clicked()"), self.changeDir) hbox = QHBoxLayout() hbox.addWidget(btnFile) hbox.addWidget(btnDir) self.setLayout(hbox) self.center() def center(self): screenGeometry = QDesktopWidget() windowGeometry = self.size() self.move((screenGeometry.width() - windowGeometry.width()) / 2, (screenGeometry.height() - windowGeometry.height()) / 2) def changeDir(self): dirName = QFileDialog.getExistingDirectory(self, u"请选择要修改的文件夹") if not dirName.isEmpty(): pass def changeFile(self): pass app = QApplication(sys.argv) change = Change() change.show() sys.exit(app.exec_())
时间: 2024-10-05 23:25:26