Как правильно пользоваться менеджером компановки?
При попытке установить менеджер компоновки, все изображение меняют своё расположение (что логично).
Но я не понимаю как устанавливать Spacers, как их изменять, чтобы моя программа выглядела точно так же, как до менеджера компоновки.
Вот например слева, моё меню которое было овальным оно просто стало плоским и как вернуть его размер, я не понимаю. Не могли бы вы показать.
Не могли бы показать, как сделать моё окно динамичным, но при этом оставить объекты там где они были и как сохранить картинки внутри Frame, при этом сохранив выдвижение окна.
Прикрепляю .ui файл:
Apex.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1209</width>
<height>747</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="animated">
<bool>true</bool>
</property>
<widget class="QWidget" name="centralwidget">
<property name="styleSheet">
<string notr="true">background-color: rgb(34, 31, 46);</string>
</property>
<widget class="QFrame" name="frame">
<property name="geometry">
<rect>
<x>40</x>
<y>110</y>
<width>41</width>
<height>581</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(46, 43, 63);
border: 5px solid rgba(255, 255, 255, 0);
border-radius: 20px;
</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QLabel" name="label_10">
<property name="geometry">
<rect>
<x>-24</x>
<y>530</y>
<width>71</width>
<height>41</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(34, 31, 46);</string>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>../Nikita_Pfeyfer4.png</pixmap>
</property>
</widget>
<widget class="QPushButton" name="menu">
<property name="geometry">
<rect>
<x>5</x>
<y>4</y>
<width>31</width>
<height>31</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/menu/Изображения/3030.png);
border: 1px solid #a112fe;
border-radius: 10;
</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="spravka">
<property name="geometry">
<rect>
<x>30</x>
<y>530</y>
<width>141</width>
<height>41</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Copperplate Gothic Bold</family>
<pointsize>12</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">QPushButton {
;
color: rgb(78, 75, 94);
background-color: rgba(255, 255, 255, 0);
padding: 5px;
}
QPushButton:hover {
color: rgb(168, 168, 168);
}
QPushButton:pressed {
border-style: inset;
color: rgb(214, 214, 214);
}</string>
</property>
<property name="inputMethodHints">
<set>Qt::ImhNone</set>
</property>
<property name="text">
<string>Reference</string>
</property>
<property name="autoExclusive">
<bool>false</bool>
</property>
</widget>
<widget class="QLabel" name="label_9">
<property name="geometry">
<rect>
<x>-30</x>
<y>80</y>
<width>81</width>
<height>31</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(34, 31, 46);
border: 2px solid rgba(34, 31, 46, 0); ;
border-radius: 10</string>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>../Nikita_Pfeyfer2.png</pixmap>
</property>
</widget>
<widget class="QPushButton" name="weapon">
<property name="geometry">
<rect>
<x>50</x>
<y>70</y>
<width>121</width>
<height>41</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Copperplate Gothic Bold</family>
<pointsize>14</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">QPushButton {
;
color: rgb(78, 75, 94);
background-color: rgba(255, 255, 255, 0);
padding: 5px;
}
QPushButton:hover {
color: rgb(168, 168, 168);
}
QPushButton:pressed {
border-style: inset;
color: rgb(214, 214, 214);
}</string>
</property>
<property name="inputMethodHints">
<set>Qt::ImhNone</set>
</property>
<property name="text">
<string>Weapons</string>
</property>
<property name="autoExclusive">
<bool>false</bool>
</property>
</widget>
</widget>
<widget class="QFrame" name="frame_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1211</width>
<height>21</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(46, 43, 63);</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>590</x>
<y>90</y>
<width>231</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<family>Copperplate Gothic Bold</family>
<pointsize>28</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(253, 253, 253);</string>
</property>
<property name="text">
<string>Main Menu</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="Line" name="line">
<property name="geometry">
<rect>
<x>600</x>
<y>130</y>
<width>241</width>
<height>2</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QFrame" name="frame_3">
<property name="geometry">
<rect>
<x>260</x>
<y>180</y>
<width>261</width>
<height>161</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(46, 43, 63);
border: 2px solid #2e2b3f;
border-radius: 10</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>70</x>
<y>0</y>
<width>121</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<family>Bahnschrift SemiBold</family>
<pointsize>22</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(194, 194, 194);</string>
</property>
<property name="text">
<string>Версия</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>70</x>
<y>60</y>
<width>121</width>
<height>61</height>
</rect>
</property>
<property name="font">
<font>
<family>Bahnschrift SemiBold</family>
<pointsize>22</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>1.0 BETA</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</widget>
<widget class="QTextBrowser" name="textBrowser">
<property name="geometry">
<rect>
<x>570</x>
<y>170</y>
<width>256</width>
<height>351</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(46, 43, 63);
border: 2px solid #2e2b3f;
border-radius: 10</string>
</property>
<property name="html">
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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></string>
</property>
</widget>
<widget class="QFrame" name="frame_4">
<property name="geometry">
<rect>
<x>560</x>
<y>720</y>
<width>201</width>
<height>20</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(46, 43, 63);
border: 2px solid #2e2b3f;
border-radius: 10</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>50</x>
<y>-2</y>
<width>101</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<family>Bahnschrift SemiBold SemiConden</family>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Всё для вас!</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</widget>
<widget class="QTextBrowser" name="textBrowser_2">
<property name="geometry">
<rect>
<x>260</x>
<y>360</y>
<width>261</width>
<height>161</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(46, 43, 63);
border: 2px solid #2e2b3f;
border-radius: 10</string>
</property>
<property name="html">
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
<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>
<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>
<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></string>
</property>
</widget>
<widget class="Line" name="line_2">
<property name="geometry">
<rect>
<x>309</x>
<y>391</y>
<width>161</width>
<height>2</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="Line" name="line_3">
<property name="geometry">
<rect>
<x>331</x>
<y>219</y>
<width>121</width>
<height>2</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QTextBrowser" name="textBrowser_3">
<property name="geometry">
<rect>
<x>870</x>
<y>170</y>
<width>256</width>
<height>351</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(46, 43, 63);
border: 2px solid #6c6c00;
border-radius: 10</string>
</property>
<property name="html">
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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></string>
</property>
</widget>
<widget class="Line" name="line_4">
<property name="geometry">
<rect>
<x>897</x>
<y>200</y>
<width>201</width>
<height>2</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QPushButton" name="mainmenu">
<property name="geometry">
<rect>
<x>50</x>
<y>20</y>
<width>81</width>
<height>81</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-image: url(:/Fone/Изображения/_Logotip_Proz5.png);
border: 1px solid rgba(255, 255, 255, 0);
</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<zorder>label</zorder>
<zorder>frame_2</zorder>
<zorder>frame</zorder>
<zorder>line</zorder>
<zorder>frame_3</zorder>
<zorder>textBrowser</zorder>
<zorder>frame_4</zorder>
<zorder>textBrowser_2</zorder>
<zorder>line_2</zorder>
<zorder>line_3</zorder>
<zorder>textBrowser_3</zorder>
<zorder>line_4</zorder>
<zorder>mainmenu</zorder>
</widget>
<action name="action">
<property name="text">
<string>справка</string>
</property>
</action>
</widget>
<resources>
<include location="../our/ApexFone.qrc"/>
<include location="../our/menu.qrc"/>
</resources>
<connections/>
</ui>
Ответы (1 шт):
Автор решения: S. Nick
→ Ссылка
Попробуйте так
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.Qt import *
class ImageLabel(QtWidgets.QGraphicsView):
def __init__(self, *args, **kwargs):
super(ImageLabel, self).__init__(*args, **kwargs)
self.setScene(QtWidgets.QGraphicsScene())
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
def setImage(self, filename):
self.setPixmap(QtGui.QPixmap(filename))
def setPixmap(self, pixmap):
item = QtWidgets.QGraphicsPixmapItem(pixmap)
item.setTransformationMode(QtCore.Qt.SmoothTransformation)
self.scene().addItem(item)
def resizeEvent(self, event):
r = self.scene().itemsBoundingRect()
self.fitInView(r, QtCore.Qt.KeepAspectRatio)
super(ImageLabel, self).resizeEvent(event)
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(640, 480)
self.horizontalLayout = QtWidgets.QHBoxLayout(Form)
self.horizontalLayout.setObjectName("horizontalLayout")
self.horizontalLayout.setSpacing(0)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.frameLeft = QtWidgets.QFrame(Form)
self.frameLeft.setObjectName("frameLeft")
self.frameLeft.setStyleSheet(
"#frameLeft {background-color: #753422;}")
self.horizontalLayout.addWidget(self.frameLeft, 1)
self.frame = QtWidgets.QFrame(Form)
self.frame.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
self.frame.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
self.frame.setObjectName("frame")
self.frame.setMaximumHeight(0)
self.verticalLayout = QtWidgets.QVBoxLayout(self.frameLeft)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setObjectName("verticalLayout")
self.image = ImageLabel()
self.image.setObjectName("image")
self.image.setStyleSheet("background-color: #753422;")
self.verticalLayout.addWidget(self.image)
self.pushButton_2 = QtWidgets.QPushButton(self.frame)
self.pushButton_2.setObjectName("pushButton_2")
self.verticalLayout.addWidget(self.pushButton_2)
self.pushButton_3 = QtWidgets.QPushButton(self.frame)
self.pushButton_3.setObjectName("pushButton_3")
self.pushButton_3.setIcon(QtGui.QIcon('Ok.png'))
self.pushButton_3.setIconSize(QtCore.QSize(75, 75))
self.pushButton_3.setMinimumWidth(175)
font = QtGui.QFont()
font.setFamily("Bahnschrift SemiBold SemiConden")
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.pushButton_3.setFont(font)
self.verticalLayout.addWidget(self.pushButton_3)
spacerItem = QtWidgets.QSpacerItem(
20, 40,
QtWidgets.QSizePolicy.Policy.Minimum,
QtWidgets.QSizePolicy.Policy.Expanding
)
self.verticalLayout.addItem(spacerItem)
self.pushButton_4 = QtWidgets.QToolButton(self.frame)
self.pushButton_4.setObjectName("pushButton_4")
self.pushButton_4.setFixedSize(75, 75)
self.pushButton_4.setStyleSheet('''
#pushButton_4 {
border: none;
margin: 0px;
padding: 0px;
border-image: url(Ok.png);
}
''')
self.verticalLayout.addWidget(
self.pushButton_4, alignment=QtCore.Qt.AlignCenter)
self.frameRight = QtWidgets.QFrame(Form)
self.frameRight.setObjectName("frameRight")
self.frameRight.setStyleSheet("background-color: #D79771;")
self.horizontalLayout.addWidget(self.frameRight, 1)
self.frame_2 = QtWidgets.QFrame(Form)
self.frame_2.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
self.frame_2.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
self.frame_2.setObjectName("frame_2")
self.frame_2.setMaximumHeight(0)
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.frameRight)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.image_2 = ImageLabel()
self.image_2.setObjectName("image_2")
self.verticalLayout_2.addWidget(self.image_2)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.pushButton_2.setText(_translate("Form", "Нажми меня"))
self.pushButton_3.setText(_translate("Form", "Hello World"))
class DemoImageLabel(QWidget, Ui_Form):
def __init__(self):
super().__init__()
self.setupUi(self)
self.pushButton_3.setText("Hello World")
self.frameLeft.setMaximumWidth(75)
self.image.setImage("cat_png.png") # установите свое изображение !!!
self.image.setMaximumHeight(200)
self.image_2.setImage("heart.png") # установите свое изображение !!!
self.pushButton_2.clicked.connect(self.animate_frame_left)
self.animation1 = self.build_animation(self.frameLeft)
def build_animation(self, frameLeft):
animation = QPropertyAnimation(frameLeft, b"maximumWidth")
animation.setDuration(800)
animation.setEasingCurve(QEasingCurve.Type.Linear)
return animation
def start_animation(self, animation):
width = animation.targetObject().width()
animation.stop()
animation.setStartValue(width)
animation.setEndValue(75 if width != 75 else 200)
animation.start()
def animate_frame_left(self):
self.start_animation(self.animation1)
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
app.setStyle('fusion')
w = DemoImageLabel()
w.resize(800, 600)
w.show()
sys.exit(app.exec_())



