-
-
Save itarozzi/c757a46f031e81e6d4d269202864f9f8 to your computer and use it in GitHub Desktop.
Frame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PySide2.QtWidgets import (QApplication, QWidget, QPushButton, QMainWindow, QSizePolicy, | |
QFrame, QLabel, QLineEdit, QHBoxLayout, QVBoxLayout) | |
from PySide2.QtGui import QIcon, QFont | |
from PySide2 import QtCore, QtGui, QtWidgets | |
from PySide2.QtCore import (QCoreApplication, QPropertyAnimation, QDate, QDateTime, QMetaObject, QObject, QPoint, QRect, QSize, QTime, QUrl, Qt, QEvent) | |
import sys | |
class MyWidget(QtWidgets.QWidget): | |
def __init__(self): | |
super().__init__() | |
self.setWindowTitle("Conversor de arquivos") | |
self.setGeometry(300, 100, 900, 600) # x, y, w, h -> esquerda, topo, largura, altura | |
self.setMinimumHeight(500) | |
self.setMinimumWidth(700) | |
self.vbox_main = QVBoxLayout() | |
self.hbox_main = QHBoxLayout() | |
self.hbox_main.setContentsMargins(0, 0, 0, 0) | |
self.hbox_main.stretch(1) | |
self.vbox_menu_left = QVBoxLayout() | |
self.vbox_menu_left.setSpacing(5) | |
self.button_toggle = QPushButton("TOGGLE") | |
self.button_toggle.setMaximumSize(100,40) | |
self.button_toggle.clicked.connect(self.toggle) | |
self.button1 = QPushButton("BTN1") | |
self.button2 = QPushButton("BTN2") | |
self.button3 = QPushButton("BTN3") | |
self.frame_left_menu = QFrame() | |
self.frame_left_menu.setStyleSheet('background-color: green') | |
self.frame_left_menu.setMaximumSize(QSize(70, 16777215)) | |
self.frame = QFrame() | |
self.frame.setStyleSheet('background-color: yellow') | |
self.frame.setMinimumWidth(16777215) | |
# Add objects to layouts | |
self.vbox_menu_left.addWidget(self.button1) | |
self.vbox_menu_left.addWidget(self.button2) | |
self.vbox_menu_left.addWidget(self.button3) | |
self.frame_left_menu.setLayout(self.vbox_menu_left) | |
self.hbox_main.addWidget(self.frame_left_menu) | |
self.hbox_main.addWidget(self.frame) | |
self.vbox_main.addWidget(self.button_toggle) | |
self.vbox_main.addLayout(self.hbox_main) | |
self.setLayout(self.vbox_main) | |
def toggle(self): | |
width = self.frame_left_menu.width() | |
if (width == 70): | |
widthExtended = 200 | |
else: | |
widthExtended = 70 | |
# use simple assignement | |
#self.frame_left_menu.setMinimumWidth(widthExtended) | |
# or use fancy ANIMATION | |
self.animation = QPropertyAnimation(self.frame_left_menu, b"minimumWidth") | |
self.animation.setDuration(400) | |
self.animation.setStartValue(width) | |
self.animation.setEndValue(widthExtended) | |
self.animation.setEasingCurve(QtCore.QEasingCurve.InOutQuart) | |
self.animation.start() | |
if __name__ == "__main__": | |
app = QtWidgets.QApplication([]) | |
widget = MyWidget() | |
widget.resize(400, 300) | |
widget.show() | |
sys.exit(app.exec_()) |
You are welcome ;)
Il mer 27 gen 2021, 23:58 Elias Coutinho <[email protected]> ha
scritto:
… ***@***.**** commented on this gist.
------------------------------
Thank you!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://gist.github.com/c757a46f031e81e6d4d269202864f9f8#gistcomment-3610324>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANWUZO325WIZEHOHM2W2NLS4CK7PANCNFSM4WWCII5A>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!