Ejemplo n.º 1
0
 def __init__(self, parent=None):
     super(ConfigurationPage, self).__init__(parent)
     self.configGroup = QGroupBox(u"相关配置信息")
     
     self.remoteIPLabel = QLabel(u"数据库所在IP地址:")
     self.editRemoteIP = QLineEdit(u"数据库所在IP地址")
     self.remotePortLabel= QLabel(u"使用端口:")
     self.editPort = QLineEdit(u"使用端口")
     self.userLabel = QLabel(u"用户名:")
     self.editUser = QLineEdit(u"用户名")
     self.passwordLabel= QLabel(u"密码:")
     self.editPassword= QLineEdit(u"密码")
     self.dabasenameLabel= QLabel(u"数据库名:")
     self.editDatabaseName= QLineEdit(u"数据库名")
     self.backupdirLabel = QLabel(u"备份文件存放目录:")
     self.editBackupDir = QLineEdit(u"备份文件存放目录")
     self.browseButton = QPushButton(u"浏览")
     self.browseButton.clicked.connect(self.onBrowse)
     
     self.paremeterLayout= QGridLayout();
     self.paremeterLayout.addWidget(self.remoteIPLabel, 0, 0)
     self.paremeterLayout.addWidget(self.editRemoteIP, 0, 1, 1, 2)
     self.paremeterLayout.addWidget(self.remotePortLabel, 1, 0)
     self.paremeterLayout.addWidget(self.editPort, 1, 1, 1, 2)
     self.paremeterLayout.addWidget(self.userLabel, 2, 0)
     self.paremeterLayout.addWidget(self.editUser, 2, 1, 1, 2)
     self.paremeterLayout.addWidget(self.passwordLabel, 3, 0)
     self.paremeterLayout.addWidget(self.editPassword, 3, 1, 1, 2)
     self.paremeterLayout.addWidget(self.dabasenameLabel, 4, 0)
     self.paremeterLayout.addWidget(self.editDatabaseName, 4, 1, 1, 2)
     self.paremeterLayout.addWidget(self.backupdirLabel, 5, 0)
     self.paremeterLayout.addWidget(self.editBackupDir, 5, 1)
     self.paremeterLayout.addWidget(self.browseButton, 5, 2)
     
     self.btnSave = QPushButton(u"保存")
     self.btnSave.setMinimumHeight(50)
     self.btnSave.clicked.connect(self.onSave)
     
     self.configGroup.setLayout(self.paremeterLayout)
     
     self.mainLayout= QVBoxLayout()
     self.mainLayout.addWidget(self.configGroup)
     self.mainLayout.addSpacing(20)
     self.mainLayout.addWidget(self.btnSave)
     self.mainLayout.addStretch(1)
     
     self.setLayout(self.mainLayout)
     
     self.config = ApplicationConfig()
     self.doInitialize()
Ejemplo n.º 2
0
class ConfigurationPage(QWidget):
    def __init__(self, parent=None):
        super(ConfigurationPage, self).__init__(parent)
        self.configGroup = QGroupBox(u"相关配置信息")
        
        self.remoteIPLabel = QLabel(u"数据库所在IP地址:")
        self.editRemoteIP = QLineEdit(u"数据库所在IP地址")
        self.remotePortLabel= QLabel(u"使用端口:")
        self.editPort = QLineEdit(u"使用端口")
        self.userLabel = QLabel(u"用户名:")
        self.editUser = QLineEdit(u"用户名")
        self.passwordLabel= QLabel(u"密码:")
        self.editPassword= QLineEdit(u"密码")
        self.dabasenameLabel= QLabel(u"数据库名:")
        self.editDatabaseName= QLineEdit(u"数据库名")
        self.backupdirLabel = QLabel(u"备份文件存放目录:")
        self.editBackupDir = QLineEdit(u"备份文件存放目录")
        self.browseButton = QPushButton(u"浏览")
        self.browseButton.clicked.connect(self.onBrowse)
        
        self.paremeterLayout= QGridLayout();
        self.paremeterLayout.addWidget(self.remoteIPLabel, 0, 0)
        self.paremeterLayout.addWidget(self.editRemoteIP, 0, 1, 1, 2)
        self.paremeterLayout.addWidget(self.remotePortLabel, 1, 0)
        self.paremeterLayout.addWidget(self.editPort, 1, 1, 1, 2)
        self.paremeterLayout.addWidget(self.userLabel, 2, 0)
        self.paremeterLayout.addWidget(self.editUser, 2, 1, 1, 2)
        self.paremeterLayout.addWidget(self.passwordLabel, 3, 0)
        self.paremeterLayout.addWidget(self.editPassword, 3, 1, 1, 2)
        self.paremeterLayout.addWidget(self.dabasenameLabel, 4, 0)
        self.paremeterLayout.addWidget(self.editDatabaseName, 4, 1, 1, 2)
        self.paremeterLayout.addWidget(self.backupdirLabel, 5, 0)
        self.paremeterLayout.addWidget(self.editBackupDir, 5, 1)
        self.paremeterLayout.addWidget(self.browseButton, 5, 2)
        
        self.btnSave = QPushButton(u"保存")
        self.btnSave.setMinimumHeight(50)
        self.btnSave.clicked.connect(self.onSave)
        
        self.configGroup.setLayout(self.paremeterLayout)
        
        self.mainLayout= QVBoxLayout()
        self.mainLayout.addWidget(self.configGroup)
        self.mainLayout.addSpacing(20)
        self.mainLayout.addWidget(self.btnSave)
        self.mainLayout.addStretch(1)
        
        self.setLayout(self.mainLayout)
        
        self.config = ApplicationConfig()
        self.doInitialize()
    #----------------------------------------------------------------------
    def onSave(self):
        """保存处理"""
        try:
            self.config.remoteIp = self.editRemoteIP.text()
            self.config.remotePort = self.editPort.text()
            self.config.user = self.editUser.text()
            self.config.password = self.editPassword.text()
            self.config.databasename = self.editDatabaseName.text()
            self.config.backupdir = self.editBackupDir.text()
            self.config.save()
        except:
            print "some exceptions occured when invoke onSave() method, please check it!"
        #print unicode(self.config.remoteIp)
    #----------------------------------------------------------------------
    def onBrowse(self):
        """选择目录"""
        directory= QFileDialog.getExistingDirectory(self, u"查找备份目录",
                                                    QDir.currentPath())
        if directory:
            self.editBackupDir.setText(directory)
        
    #----------------------------------------------------------------------
    def doInitialize(self):
        """初始化相关参数"""
        self.config.load()
        self.editRemoteIP.setText(unicode(self.config.remoteIp))
        self.editPort.setText(unicode(self.config.remotePort))
        self.editUser.setText(unicode(self.config.user))
        self.editPassword.setText(unicode(self.config.password))
        self.editDatabaseName.setText(unicode(self.config.databasename))
        self.editBackupDir.setText(unicode(self.config.backupdir))