PyQtPicUpload/main/__main__.py

74 lines
2.4 KiB
Python
Raw Normal View History

2022-03-25 17:35:45 +08:00
import os
2022-03-16 21:59:09 +08:00
import sys
2022-03-25 17:35:45 +08:00
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import Qt, QSize
2022-03-16 21:59:09 +08:00
2022-03-25 17:35:45 +08:00
from tool.UploadTip import UploadTip
from tool.ConfigWidget import ConfigView
from tool import QSSLoader
2022-03-16 21:59:09 +08:00
2022-03-25 17:35:45 +08:00
class MainWindow(QWidget):
2022-03-16 21:59:09 +08:00
def __init__(self):
2022-03-25 17:35:45 +08:00
super(MainWindow, self).__init__()
2022-03-25 20:24:47 +08:00
self.setWindowTitle("OSS图床上传")
2022-03-25 17:35:45 +08:00
layout = QHBoxLayout(self, spacing=0)
self.listWidget = QListWidget()
self.resize(800, 600)
layout.addWidget(self.listWidget)
2022-03-16 21:59:09 +08:00
2022-03-25 17:35:45 +08:00
# 右侧层叠窗口
self.stackedWidget = QStackedWidget(self)
layout.addWidget(self.stackedWidget)
2022-03-16 21:59:09 +08:00
2022-03-25 17:35:45 +08:00
layout.setContentsMargins(0, 0, 0, 0)
2022-03-16 21:59:09 +08:00
self.setLayout(layout)
2022-03-25 17:35:45 +08:00
self.iniUI()
def iniUI(self):
# 初始化界面
# 通过QListWidget的当前item变化来切换QStackedWidget中的序号
self.listWidget.currentRowChanged.connect(
self.stackedWidget.setCurrentIndex)
# 去掉边框
# self.listWidget.setFrameShape(QListWidget.NoFrame)
# # 隐藏滚动条
self.listWidget.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.listWidget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
2022-03-16 21:59:09 +08:00
2022-03-25 17:35:45 +08:00
# print(os.getcwd())
self.upload_item = QListWidgetItem(
QIcon(QPixmap(os.getcwd()+'/images/upload.png')), '上传区', self.listWidget)
self.set_item = QListWidgetItem(
QIcon(QPixmap(os.getcwd()+'/images/setting_icon.png')), '配置区域')
self.upload_item.setSizeHint(QSize(16777215, 60))
# 文字居中
self.upload_item.setTextAlignment(Qt.AlignCenter)
2022-03-16 21:59:09 +08:00
2022-03-25 17:35:45 +08:00
self.set_item.setSizeHint(QSize(16777215, 60))
# 文字居中
self.set_item.setTextAlignment(Qt.AlignCenter)
self.listWidget.addItem(self.upload_item)
self.listWidget.addItem(self.set_item)
upload_widget = UploadTip()
config_widget = ConfigView()
self.stackedWidget.addWidget(upload_widget)
self.stackedWidget.addWidget(config_widget)
2022-03-16 21:59:09 +08:00
if __name__ == '__main__':
app = QApplication(sys.argv)
2022-03-25 17:35:45 +08:00
main = MainWindow()
2022-03-25 20:24:47 +08:00
style_file = os.getcwd()+'/resource/current.qss'
2022-03-25 17:35:45 +08:00
style_sheet = QSSLoader.QSSLoader.read_qss_file(style_file)
# apply_stylesheet(app, theme='light_blue.xml')
2022-03-25 20:24:47 +08:00
app.setWindowIcon(QIcon(os.getcwd()+'/images/icon.svg'))
2022-03-25 17:35:45 +08:00
main.setStyleSheet(style_sheet)
2022-03-16 21:59:09 +08:00
main.show()
sys.exit(app.exec_())