def initUI(self):
"""
Initialize the Dialog layout.
"""
self.setWindowTitle('B3 database update')
self.setFixedSize(420, 160)
self.setStyleSheet("""
QDialog {
background: #F2F2F2;
}
""")
## INIT CLOSE BUTTON
self.btn_close = Button(parent=self, text='Close')
self.btn_close.clicked.connect(self.close)
self.btn_close.hide()
## INIT UPDATE BUTTON
self.btn_update = Button(parent=self, text='Update')
self.btn_update.clicked.connect(self.do_update)
self.btn_update.show()
## CREATE THE PROGRESS BAR
self.progress = ProgressBar(self)
self.progress.setAlignment(Qt.AlignHCenter)
self.progress.hide()
self.progress.setRange(0, 0)
self.progress.setValue(-1)
## INIT DISPLAY MESSAGE
self.message = QLabel("This tool will update all your B3 databases to version %s.\n"
"The update process should take less than 2 minutes and\n"
"cannot be interrupted." % b3.__version__, self)
def __get_top_layout(parent):
parent.layout1 = QVBoxLayout()
parent.layout1.addWidget(parent.progress)
parent.layout1.addWidget(parent.message)
parent.layout1.setAlignment(Qt.AlignTop|Qt.AlignHCenter)
parent.layout1.setContentsMargins(0, 0, 0, 0)
return parent.layout1
def __get_bottom_layout(parent):
parent.layout2 = QHBoxLayout()
parent.layout2.addWidget(parent.btn_close)
parent.layout2.addWidget(parent.btn_update)
parent.layout2.setAlignment(Qt.AlignHCenter)
parent.layout2.setSpacing(20 if b3.getPlatform() != 'win32' else 10)
parent.layout2.setContentsMargins(0, 10, 0, 0)
return parent.layout2
self.setModal(True)
self.main_layout = QVBoxLayout()
self.main_layout.addLayout(__get_top_layout(self))
self.main_layout.addLayout(__get_bottom_layout(self))
self.main_layout.setAlignment(Qt.AlignCenter)
self.setLayout(self.main_layout)
评论列表
文章目录