5 Star 13 Fork 5

小灵猫/CarManager

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
mainWindow.py 1.98 KB
一键复制 编辑 原始数据 按行查看 历史
小灵猫 提交于 2016-01-24 16:57 . 初次加入工程文件
#!/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)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/ssc/CarManager.git
[email protected]:ssc/CarManager.git
ssc
CarManager
CarManager
master

搜索帮助