Я хочу создать заставку в своем пользовательском интерфейсе Fluent, но в этом окне пользовательского интерфейса есть кнопка заголовка. Я не хочу этого. Я новичок, поэтому помогите мне, пожалуйста. Я пытаюсь исправить этот код, но мне это не удалось, поэтому скажите мне, как я могу это исправить. когда я запускаю это окно кода, оно открывается успешно, но значок виден. Ошибок нет, скажите, как это исправитьimport sys
from PyQt5.QtWidgets import QMainWindow, QApplication,QStackedWidget,QVBoxLayout
from PyQt5.QtCore import Qt,QSize,QEventLoop,QTimer
from PyQt5.QtGui import QIcon
from temp import First_page,Second_page,Third_page
from qfluentwidgets import SplashScreen
from qframelesswindow import FramelessWindow
class Mainwindow(QMainWindow):
def __init__(self):
super().__init__()
self.initwindow()
self.initUi()
self.window()
def initUi(self):
self.resize(700, 600)
self.setWindowTitle('WhatsApp')
self.setWindowIcon(QIcon('C:\\Users\\NSG\\Desktop\\qfluent widget\\whatsapp3-removebg-preview.png'))
self.splashScreen = SplashScreen(self.windowIcon(), self)
self.splashScreen.setIconSize(QSize(333, 333))
self.show()
# create other subinterfaces
self.createSubInterface()
# close splash screen
self.splashScreen.finish()
def createSubInterface(self):
loop = QEventLoop(self)
QTimer.singleShot(4000,loop.quit)
loop.exec()
def initwindow(self):
self.resize(900,400)
self.setWindowTitle('WhatsApp')
self.setWindowIcon(QIcon('C:\\Users\\NSG\\Desktop\\qfluent widget\\whatsapp_logo.png'))
desktop = QApplication.desktop().availableGeometry()
w,h = desktop.width(),desktop.height()
self.move(w//2 - self.width(), h//2 - self.height())
def window(self):
self.central_widget = QStackedWidget(self)
self.setCentralWidget(self.central_widget)
self.first_page = First_page(self)
self.central_widget.addWidget(self.first_page)
self.second_page = Second_page(self)
self.central_widget.addWidget(self.second_page)
self.third_page = Third_page(self)
self.central_widget.addWidget(self.third_page)
def show_first_page(self):
self.central_widget.setCurrentWidget(self.first_page)
def show_second_page(self):
self.central_widget.setCurrentWidget(self.second_page)
def show_third_page(self):
self.central_widget.setCurrentWidget(self.third_page)
if __name__=='__main__':
QApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
app = QApplication(sys.argv)
window = Mainwindow()
window.show()
sys.exit(app.exec_())
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QMainWindow, QApplication, QWidget,QStyle,QVBoxLayout,QToolButton,QLabel, QFrame,QSizePolicy,QSpacerItem,QHBoxLayout
from PyQt5.QtGui import QFont, QPixmap
from qfluentwidgets import BodyLabel,PrimaryPushButton,PushButton,DropDownPushButton,FluentIcon,Action,RoundMenu
class First_page(QWidget):
def __init__(self,parent):
super().__init__()
self.pixmap = QPixmap("whatsapp3_logo-removebg-preview.png")
self.init_ui(parent)
def init_ui(self,parant):
layout1 = QVBoxLayout(self)
layout1.addStretch(1)
self.image_label = QLabel(self)
self.update_image_size(200,200)
layout1.setAlignment(Qt.AlignCenter)
layout1.addWidget(self.image_label)
layout1.addStretch(0)
label1 = QLabel("Welcome to WhatsApp")
label1.setFont(QFont("Arial",15, QFont.Bold))
label1.setAlignment(Qt.AlignCenter)
layout1.addWidget(label1)
layout1.addSpacing(17)
label2 = QLabel("A simpal,reliable and private way to use WhatsApp on your computer")
label2.setFont(QFont("Arial",10))
label2.setAlignment(Qt.AlignCenter)
layout1.addWidget(label2)
layout1.addSpacing(20)
button = PrimaryPushButton("Get started")
button.setFixedSize(180,30)
button.clicked.connect(parant.show_second_page)
layout1.addWidget(button,alignment=Qt.AlignCenter)
layout1.addSpacing(20)
label3 = QLabel("Version 2.2440.9.0")
label3.setFont(QFont("Arial",10))
label3.setAlignment(Qt.AlignCenter)
layout1.addWidget(label3)
layout1.addStretch(1)
def update_image_size(self,width,height):
scaled_Pixmap = self.pixmap.scaled(width,height, Qt.KeepAspectRatio, Qt.SmoothTransformation)
self.image_label.setPixmap(scaled_Pixmap)
def resizeEvent(self,event):
new_width = self.width() * 0.5
new_height = self.height() * 0.5
self.update_image_size(int(new_width),int(new_height))
super().resizeEvent(event)
class Second_page(QWidget):
def __init__(self, parent):
super().__init__()
self.init_ui(parent)
def init_ui(self, parent):
layout = QVBoxLayout()
layout.setContentsMargins(32, 32, 32, 32)
layout.setAlignment(Qt.AlignCenter)
central_frame = QFrame(self)
central_frame.setStyleSheet("background-color: white; border-radius: 10px")
central_frame.setMinimumSize(900, 600)
central_frame.setMaximumWidth(500)
central_layout = QVBoxLayout(central_frame)
instruction = BodyLabel(
"To set up WhatsApp on your computer
"
"1. Open WhatsApp on your phone
"
"2. Tap Menu on Android, or Settings on iPhone
"
"3. Tap Linked devices and then Link a device
"
"4. Point your phone at this screen to capture the QR code
"
)
instruction.setAlignment(Qt.AlignLeft)
instruction.setFont(QFont("Arial", 11))
instruction.setStyleSheet("padding-left: 100px; line-height: 100px;padding-top:100px;")
instruction.setWordWrap(True)
qr_label = QLabel(self)
pixmap = QPixmap("qr2.png")
qr_label.setPixmap(pixmap)
qr_label.setStyleSheet("padding-top:100px; padding-right:100px;")
qr_label.setAlignment(Qt.AlignRight)
line_layout = QHBoxLayout()
line_layout.addWidget(instruction)
line_layout.addWidget(qr_label)
central_layout.addLayout(line_layout)
link_label = BodyLabel("Link with phone number")
link_label.setAlignment(Qt.AlignLeft)
link_label.linkActivated.connect(parent.show_third_page)
link_label.setFont(QFont("Arial", 9, QFont.Bold))
link_label.setStyleSheet("padding-left: 100px;padding-bottom: 100px")
central_layout.addWidget(link_label)
layout.addWidget(central_frame)
back_button = QToolButton(self)
back_button.setIcon(self.style().standardIcon(QStyle.SP_ArrowBack))
back_button.clicked.connect(parent.show_first_page)
layout.addWidget(back_button, alignment=Qt.AlignLeft | Qt.AlignTop)
self.setLayout(layout)
class Third_page(QWidget):
def __init__(self,parant):
super().__init__()
self.init_ui(parant)
def init_ui(self,parant):
layout2 = QVBoxLayout()
layout2.setContentsMargins(1,10,10,10)
layout2.setAlignment(Qt.AlignCenter)
central_frame = QFrame(self)
central_frame.setStyleSheet("background-color: white")
central_frame.setFixedSize(888,500)
# central_frame.setM(500)
central_layout = QVBoxLayout(central_frame)
label = BodyLabel("Enter phone number")
label.setFont(QFont("Arial",14))
label.setAlignment(Qt.AlignCenter)
central_layout.addWidget(label)
label2 = BodyLabel("Select a country and add your phone number")
label2.setStyleSheet("padding-bottom: 100px;")
label2.setAlignment(Qt.AlignCenter)
central_layout.addWidget(label2)
central_layout.setContentsMargins(0,0,0,290)
button2 = DropDownPushButton(FluentIcon.MAIL, 'Email')
# Create menu
menu = RoundMenu(parent=button2)
menu.addAction(Action(FluentIcon.BASKETBALL, 'Basketball', triggered=lambda: print("What are you doing?")))
menu.addAction(Action(FluentIcon.ALBUM, 'Sing', triggered=lambda: print("I like singing, rapping, and dancing")))
menu.addAction(Action(FluentIcon.MUSIC, 'Music', triggered=lambda: print("Just because you are so beautiful")))
# Add menu
button2.setMenu(menu)
central_layout.setAlignment(Qt.AlignCenter)
central_layout.addWidget(button2)
layout2.addWidget(central_frame, alignment= Qt.AlignCenter)
self.setLayout(layout2)
Подробнее здесь: https://stackoverflow.com/questions/791 ... there-is-t
В pyqt5 я хочу создать экран-заставку в своем проекте WhatsApp Ui, но создано два окна, как его решить. ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение