代码拉取完成,页面将自动刷新
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from PyQt5.QtWidgets import QMainWindow,QApplication
from PyQt5.QtWidgets import QMessageBox,QListWidget,QListWidgetItem,QListView
from PyQt5.QtGui import QIcon
from forms.mainform import Ui_MainWindow
from toFuelRecordForm import ToFuelRecordForm
from maintenceRecordForm import MaintenceRecordForm
from settingForm import SettingForm
import dbUtil
class MainWindow(QMainWindow,Ui_MainWindow):
def __init__(self):
super(MainWindow, self).__init__()
# Set up the user interface from Designer.
self.setupUi(self)
for i in range(0,self.swFaces.count()):
self.swFaces.removeWidget(self.swFaces.widget(i))
if not dbUtil.createConnection():
QMessageBox.warning(self,"警告信息","数据库打开失败!")
self.swFaces.insertWidget(0,ToFuelRecordForm())
self.swFaces.insertWidget(1,MaintenceRecordForm())
self.swFaces.insertWidget(2,SettingForm())
self.lwFaces.setViewMode(QListView.IconMode)
self.lwFaces.setFlow(QListView.TopToBottom)
self.lwFaces.setSpacing(20)
self.lwFaces.currentRowChanged.connect(self.swFaces.setCurrentIndex)
QListWidgetItem(QIcon(":/icons/fuelRecord.png"),'加油',self.lwFaces)
QListWidgetItem(QIcon(":/icons/maintence.png"),'维护',self.lwFaces)
QListWidgetItem(QIcon(":/icons/settings.png"),'设置',self.lwFaces)
self.lwFaces.setCurrentRow(0)
self.actSetting.triggered.connect(self.onSettingSelected)
self.actExit.triggered.connect(QApplication.instance().closeAllWindows)
def closeEvent(self, event):
if self.maybeSave():
#QMessageBox.critical(self,'出错信息','保存出错!')
event.accept()
else:
event.ignore()
def maybeSave(self):
self.swFaces.widget(0).submit()
self.swFaces.widget(2).save()
return True
def onSettingSelected(self):
self.lwFaces.setCurrentRow(2)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。