V1.0
This commit is contained in:
41
bottom_control_widget.py
Normal file
41
bottom_control_widget.py
Normal file
@ -0,0 +1,41 @@
|
||||
from PySide6.QtWidgets import (QWidget, QHBoxLayout, QLabel, QPushButton,
|
||||
QMessageBox, QSpacerItem, QSizePolicy)
|
||||
from PySide6.QtGui import QPixmap, QPainter, QFont, QPen
|
||||
from PySide6.QtCore import Qt, QDateTime, QEvent, QSize
|
||||
|
||||
class BottomControlWidget(QWidget):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.initUI()
|
||||
|
||||
def initUI(self):
|
||||
# 1. 加载背景图并设置控件尺寸
|
||||
bg_path = "底部背景.png"
|
||||
self.bg_pixmap = QPixmap(bg_path)
|
||||
if self.bg_pixmap.isNull():
|
||||
print("警告:底部背景.png 加载失败,请检查路径!")
|
||||
self.setFixedSize(1280, 66)
|
||||
else:
|
||||
self.setFixedSize(self.bg_pixmap.size())
|
||||
|
||||
# 2. 主布局(水平布局,组件间距6px)
|
||||
main_layout = QHBoxLayout(self)
|
||||
main_layout.setContentsMargins(10, 10, 10, 10) # 适当留白避免贴边
|
||||
main_layout.setSpacing(6)
|
||||
|
||||
def paintEvent(self, event):
|
||||
"""绘制背景图"""
|
||||
super().paintEvent(event)
|
||||
if not self.bg_pixmap.isNull():
|
||||
painter = QPainter(self)
|
||||
painter.drawPixmap(0, 0, self.bg_pixmap)
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
widget = BottomControlWidget()
|
||||
widget.show()
|
||||
sys.exit(app.exec())
|
||||
|
||||
Reference in New Issue
Block a user