TestLyric/app.py

55 lines
1.8 KiB
Python
Raw Normal View History

2024-11-17 11:17:14 +08:00
import sys
from tracemalloc import Frame
from PySide6.QtCore import Qt
from PySide6.QtGui import QColor
from PySide6.QtWidgets import QApplication, QWidget, QVBoxLayout, QLabel, QMainWindow, QFrame
from widgets import OutlinedLabel
class Lyric(QWidget):
def __init__(self):
super().__init__()
self.setLayout(QVBoxLayout())
self.lyrics = []
self.label_now = QLabel()
self.label_now.setObjectName("label_now")
self.label_now.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.label_next = QLabel()
self.label_next.setObjectName("label_next")
self.label_next.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.label_now.setStyleSheet("font-size: 30px; color: pink;")
self.label_next.setStyleSheet("font-size: 30px;")
self.layout().addWidget(self.label_now)
self.layout().addWidget(self.label_next)
self.setStyleSheet("background-color: rgba(255, 255, 255, 0);")
self.label_now.setText("asdasd")
self.label_next.setText("asdasd")
def set_lyrics(self, lyrics):
self.label_now.setText(lyrics[0])
self.label_next.setText(lyrics[1])
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.lyrics = Lyric()
self.frame = QFrame()
self.setCentralWidget(self.frame)
# self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, True)
self.setWindowFlag(Qt.WindowType.FramelessWindowHint, True)
self.setWindowFlag(Qt.WindowType.WindowStaysOnTopHint, True)
self.frame.setLayout(QVBoxLayout())
self.frame.layout().addWidget(self.lyrics)
self.frame.setStyleSheet("background-color: rgba(255, 255, 255, 50);")
if __name__ == '__main__':
app = QApplication(sys.argv)
window = Lyric()
window.show()
sys.exit(app.exec())