在左边的第一张图片中,菜单很小且呈半圆形,而在第二张图片中(我的),随着进一步缩小,椭圆度丢失并frame变成了正方形,我该如何解决这个问题?
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'Apex.ui'
#
# Created by: PyQt5 UI code generator 5.15.2
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtGui import QColor, QIcon
from PyQt5.uic import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
self.menuvisible = 0
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1209, 747)
MainWindow.setStyleSheet("")
MainWindow.setAnimated(True)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setStyleSheet("background-color: rgb(34, 31, 46);")
self.centralwidget.setObjectName("centralwidget")
self.frame = QtWidgets.QFrame(self.centralwidget)
self.frame.setGeometry(QtCore.QRect(0, 160, 161, 591))
self.frame.setStyleSheet("background-color: rgb(46, 43, 63);")
self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame.setObjectName("frame")
self.weapon = QtWidgets.QPushButton(self.frame)
self.weapon.setGeometry(QtCore.QRect(40, 100, 121, 41))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.weapon.sizePolicy().hasHeightForWidth())
self.weapon.setSizePolicy(sizePolicy)
font = QtGui.QFont()
font.setFamily("Copperplate Gothic Bold")
font.setPointSize(14)
font.setBold(False)
font.setWeight(50)
self.weapon.setFont(font)
self.weapon.setStyleSheet("QPushButton {\n"
" ;\n"
" color: rgb(78, 75, 94); \n"
" background-color: rgba(255, 255, 255, 0);\n"
" padding: 5px;\n"
" }\n"
"\n"
"QPushButton:hover {\n"
" \n"
" \n"
" \n"
" color: rgb(168, 168, 168);\n"
" }\n"
"\n"
"QPushButton:pressed {\n"
" border-style: inset;\n"
" \n"
" \n"
" color: rgb(214, 214, 214);\n"
" }")
self.weapon.setInputMethodHints(QtCore.Qt.ImhNone)
self.weapon.setAutoExclusive(False)
self.weapon.setObjectName("weapon")
self.spravka = QtWidgets.QPushButton(self.frame)
self.spravka.setGeometry(QtCore.QRect(40, 540, 111, 41))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.spravka.sizePolicy().hasHeightForWidth())
self.spravka.setSizePolicy(sizePolicy)
font = QtGui.QFont()
font.setFamily("Copperplate Gothic Bold")
font.setPointSize(12)
font.setBold(False)
font.setWeight(50)
self.spravka.setFont(font)
self.spravka.setStyleSheet("QPushButton {\n"
" ;\n"
" \n"
" color: rgb(78, 75, 94);\n"
" background-color: rgba(255, 255, 255, 0);\n"
" padding: 5px;\n"
"\n"
" }\n"
"QPushButton:hover {\n"
" \n"
" \n"
" color: rgb(168, 168, 168);\n"
" }\n"
"\n"
"QPushButton:pressed {\n"
" border-style: inset;\n"
" \n"
" color: rgb(214, 214, 214);\n"
" }")
self.spravka.setInputMethodHints(QtCore.Qt.ImhNone)
self.spravka.setAutoExclusive(False)
self.spravka.setObjectName("spravka")
self.label_10 = QtWidgets.QLabel(self.frame)
self.label_10.setGeometry(QtCore.QRect(-20, 540, 61, 41))
self.label_10.setText("")
self.label_10.setPixmap(QtGui.QPixmap("Nikita_Pfeyfer4.png"))
self.label_10.setObjectName("label_10")
self.label_9 = QtWidgets.QLabel(self.frame)
self.label_9.setGeometry(QtCore.QRect(-30, 100, 81, 41))
self.label_9.setText("")
self.label_9.setPixmap(QtGui.QPixmap("Nikita_Pfeyfer2.png"))
self.label_9.setObjectName("label_9")
self.menu = QtWidgets.QPushButton(self.frame)
self.menu.clicked.connect(self.showmenu)
self.menu.setGeometry(QtCore.QRect(10, 20, 51, 51))
self.menu.setStyleSheet("background-image: url(:/menu/Изображения/back.png);\n"
"border: 1px solid rgba(255, 255, 255, 0);\n"
"")
self.menu.setText("")
self.menu.setObjectName("menu")
self.frame_2 = QtWidgets.QFrame(self.centralwidget)
self.frame_2.setGeometry(QtCore.QRect(0, 0, 1211, 21))
self.frame_2.setStyleSheet("background-color: rgb(46, 43, 63);")
self.frame_2.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_2.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame_2.setObjectName("frame_2")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(610, 90, 231, 41))
font = QtGui.QFont()
font.setFamily("Copperplate Gothic Bold")
font.setPointSize(28)
self.label.setFont(font)
self.label.setStyleSheet("color: rgb(253, 253, 253);")
self.label.setAlignment(QtCore.Qt.AlignCenter)
self.label.setObjectName("label")
self.line = QtWidgets.QFrame(self.centralwidget)
self.line.setGeometry(QtCore.QRect(600, 130, 241, 2))
self.line.setFrameShape(QtWidgets.QFrame.HLine)
self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line.setObjectName("line")
self.frame_3 = QtWidgets.QFrame(self.centralwidget)
self.frame_3.setGeometry(QtCore.QRect(260, 180, 261, 161))
self.frame_3.setStyleSheet("background-color: rgb(46, 43, 63);\n"
"border: 2px solid #2e2b3f;\n"
"border-radius: 10")
self.frame_3.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_3.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame_3.setObjectName("frame_3")
self.label_3 = QtWidgets.QLabel(self.frame_3)
self.label_3.setGeometry(QtCore.QRect(70, 0, 121, 41))
font = QtGui.QFont()
font.setFamily("Bahnschrift SemiBold")
font.setPointSize(22)
font.setBold(True)
font.setWeight(75)
self.label_3.setFont(font)
self.label_3.setStyleSheet("color: rgb(194, 194, 194);")
self.label_3.setAlignment(QtCore.Qt.AlignCenter)
self.label_3.setObjectName("label_3")
self.label_4 = QtWidgets.QLabel(self.frame_3)
self.label_4.setGeometry(QtCore.QRect(70, 60, 121, 61))
font = QtGui.QFont()
font.setFamily("Bahnschrift SemiBold")
font.setPointSize(22)
font.setBold(True)
font.setWeight(75)
self.label_4.setFont(font)
self.label_4.setStyleSheet("")
self.label_4.setAlignment(QtCore.Qt.AlignCenter)
self.label_4.setObjectName("label_4")
self.textBrowser = QtWidgets.QTextBrowser(self.centralwidget)
self.textBrowser.setGeometry(QtCore.QRect(570, 170, 256, 351))
self.textBrowser.setStyleSheet("background-color: rgb(46, 43, 63);\n"
"border: 2px solid #2e2b3f;\n"
"border-radius: 10")
self.textBrowser.setObjectName("textBrowser")
self.frame_4 = QtWidgets.QFrame(self.centralwidget)
self.frame_4.setGeometry(QtCore.QRect(560, 720, 201, 20))
self.frame_4.setStyleSheet("background-color: rgb(46, 43, 63);\n"
"border: 2px solid #2e2b3f;\n"
"border-radius: 10")
self.frame_4.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_4.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame_4.setObjectName("frame_4")
self.label_5 = QtWidgets.QLabel(self.frame_4)
self.label_5.setGeometry(QtCore.QRect(50, -2, 101, 21))
font = QtGui.QFont()
font.setFamily("Bahnschrift SemiBold SemiConden")
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.label_5.setFont(font)
self.label_5.setAlignment(QtCore.Qt.AlignCenter)
self.label_5.setObjectName("label_5")
self.textBrowser_2 = QtWidgets.QTextBrowser(self.centralwidget)
self.textBrowser_2.setGeometry(QtCore.QRect(260, 360, 261, 161))
self.textBrowser_2.setStyleSheet("background-color: rgb(46, 43, 63);\n"
"border: 2px solid #2e2b3f;\n"
"border-radius: 10")
self.textBrowser_2.setObjectName("textBrowser_2")
self.line_2 = QtWidgets.QFrame(self.centralwidget)
self.line_2.setGeometry(QtCore.QRect(309, 391, 161, 2))
self.line_2.setFrameShape(QtWidgets.QFrame.HLine)
self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_2.setObjectName("line_2")
self.line_3 = QtWidgets.QFrame(self.centralwidget)
self.line_3.setGeometry(QtCore.QRect(331, 219, 121, 2))
self.line_3.setFrameShape(QtWidgets.QFrame.HLine)
self.line_3.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_3.setObjectName("line_3")
self.textBrowser_3 = QtWidgets.QTextBrowser(self.centralwidget)
self.textBrowser_3.setGeometry(QtCore.QRect(870, 170, 256, 351))
self.textBrowser_3.setStyleSheet("background-color: rgb(46, 43, 63);\n"
"border: 2px solid #6c6c00;\n"
"border-radius: 10")
self.textBrowser_3.setObjectName("textBrowser_3")
self.line_4 = QtWidgets.QFrame(self.centralwidget)
self.line_4.setGeometry(QtCore.QRect(897, 200, 201, 2))
self.line_4.setFrameShape(QtWidgets.QFrame.HLine)
self.line_4.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_4.setObjectName("line_4")
self.frame_5 = QtWidgets.QFrame(self.centralwidget)
self.frame_5.setGeometry(QtCore.QRect(0, -1, 161, 170))
self.frame_5.setStyleSheet("background-color: rgb(46, 43, 63);")
self.frame_5.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_5.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame_5.setObjectName("frame_5")
self.mainmenu = QtWidgets.QPushButton(self.frame_5)
self.mainmenu.setGeometry(QtCore.QRect(0, 0, 161, 161))
self.mainmenu.setStyleSheet("background-image: url(:/Fone/Изображения/_Logotip_Proz3.png); \n"
"border: 1px solid rgba(255, 255, 255, 0);\n"
"")
self.mainmenu.setText("")
self.mainmenu.setObjectName("mainmenu")
self.frame_2.raise_()
self.frame.raise_()
self.label.raise_()
self.line.raise_()
self.frame_3.raise_()
self.textBrowser.raise_()
self.frame_4.raise_()
self.textBrowser_2.raise_()
self.line_2.raise_()
self.line_3.raise_()
self.textBrowser_3.raise_()
self.line_4.raise_()
self.frame_5.raise_()
MainWindow.setCentralWidget(self.centralwidget)
self.action = QtWidgets.QAction(MainWindow)
self.action.setObjectName("action")
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.weapon.setText(_translate("MainWindow", "Weapons"))
self.spravka.setText(_translate("MainWindow", "Reference"))
self.label.setText(_translate("MainWindow", "Main Menu"))
self.label_3.setText(_translate("MainWindow", "Версия"))
self.label_4.setText(_translate("MainWindow", "1.0 BETA"))
self.textBrowser.setHtml(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:12pt; font-weight:600; color:#c2c2c2;\">ApexHelper</span></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt; font-weight:600;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:12pt;\">Эта программа предназначена для того, чтобы помочь новичкам или опытным игрокам более лучше освоить игру</span></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:12pt; font-weight:600; color:#c2c2c2;\">_Apex Legends_</span></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt; font-weight:600; color:#c2c2c2;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:12pt;\">Тут ты найдёшь подробное описание каждого оружия,</span><span style=\" font-size:12pt; text-decoration: underline;\"> </span><span style=\" font-size:12pt;\">обвеса и прочих вещей.</span></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt;\"><br /></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:12pt; font-style:italic; color:#c2c2c2;\">С уважением, Разработчик </span><span style=\" font-size:12pt; font-weight:600; font-style:italic; color:#c2c2c2;\">ApexHelper</span><span style=\" font-size:12pt; color:#c2c2c2;\">.</span></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt;\"><br /></p></body></html>"))
self.label_5.setText(_translate("MainWindow", "Всё для вас!"))
self.textBrowser_2.setHtml(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:16pt; font-weight:600; color:#c2c2c2;\">Информация</span></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt; font-weight:600;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:12pt;\">Программа находится в разработке, поэтому, пока что присудствует не вся информация </span></p></body></html>"))
self.textBrowser_3.setHtml(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:16pt; color:#c2c2c2;\">Кому принадлежит</span></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:16pt;\">Все данные, изображения и прочее из программы, принадлежат компании</span></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:16pt;\"> </span></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:14pt; font-weight:600; color:#6f6f0a;\">Respawn Entertainment</span></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:14pt; font-weight:600;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:14pt;\">Никому более.</span></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:14pt;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:14pt;\">Их материал был повзаимствован для помощи игрокам.</span></p></body></html>"))
self.action.setText(_translate("MainWindow", "справка"))
def showmenu(self):
self.anim = QPropertyAnimation(self.frame, b'size')
self.anim.setDuration(250)
if self.menuvisible==0:
self.anim.setStartValue(QSize(50,751))
self.anim.setEndValue(QSize(161, 751))
self.menuvisible = 1
else:
self.anim.setStartValue(QSize(161,751))
self.anim.setEndValue(QSize(50, 751))
self.menuvisible = 0
#self.anim.finished.connect(self.hidemenu)
self.frame.show()
self.anim.start()
import ApexFone
import menu
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())


您的最大缺陷是您不使用布局管理器,而且我没有看到您的应用程序的整个窗口。
我更改了一些小部件样式的大小和颜色,这样图片对我来说更清晰,您可以更清楚地看到小部件在我的窗口中的位置。
据我了解,您想更改对象的外观
self.frame。查看此对象的样式。请注意border-radius我在代码中记录的其他更改。附上我使用的图片。立即与他们一起尝试,然后继续拍摄您的照片。
好的.png
球.png