root@minto-Lenovo-V145-14AST:/home/minto/belajar/pysidepro/pyframe# python3 main.py
Traceback (most recent call last):
File "/home/minto/belajar/pysidepro/pyframe/main.py", line 8, in <module>
from qframelesswindow import FramelessWindow, TitleBar
File "/usr/local/lib/python3.10/dist-packages/qframelesswindow/__init__.py", line 9, in <module>
from .titlebar import UnixTitleBar as TitleBar
File "/usr/local/lib/python3.10/dist-packages/qframelesswindow/titlebar/__init__.py", line 13, in <module>
from ..utils.linux_utils import LinuxMoveResize
File "/usr/local/lib/python3.10/dist-packages/qframelesswindow/utils/linux_utils.py", line 5, in <module>
from PySide6 import sip
ImportError: cannot import name 'sip' from 'PySide6' (/usr/local/lib/python3.10/dist-packages/PySide6/__init__.py)
my code
# coding:utf-8
import sys
from PySide6.QtCore import Qt
from PySide6.QtGui import QColor, QPixmap
from PySide6.QtWidgets import QApplication, QLabel
from qframelesswindow import FramelessWindow, TitleBar
class CustomTitleBar(TitleBar):
""" Custom title bar """
def __init__(self, parent):
super().__init__(parent)
# add title label
self.titleLabel = QLabel(self)
self.titleLabel.setStyleSheet("QLabel{font: 13px 'Segoe UI'; margin: 9px}")
self.window().windowTitleChanged.connect(self.setTitle)
# customize the style of title bar button
self.minBtn.setHoverColor(Qt.white)
self.minBtn.setHoverBackgroundColor(QColor(0, 100, 182))
self.minBtn.setPressedColor(Qt.white)
self.minBtn.setPressedBackgroundColor(QColor(54, 57, 65))
# use qss to customize title bar button
self.maxBtn.setStyleSheet("""
TitleBarButton {
qproperty-hoverColor: white;
qproperty-hoverBackgroundColor: rgb(0, 100, 182);
qproperty-pressedColor: white;
qproperty-pressedBackgroundColor: rgb(54, 57, 65);
}
""")
def setTitle(self, title):
self.titleLabel.setText(title)
self.titleLabel.adjustSize()
class Window(FramelessWindow):
def __init__(self, parent=None):
super().__init__(parent=parent)
# change the default title bar if you like
self.setTitleBar(CustomTitleBar(self))
self.label = QLabel(self)
self.label.setScaledContents(True)
self.label.setPixmap(QPixmap("screenshot/shoko.png"))
self.setWindowTitle("PyQt Frameless Window")
self.setStyleSheet("background:white")
self.titleBar.raise_()
def resizeEvent(self, e):
# don't forget to call the resizeEvent() of super class
super().resizeEvent(e)
length = min(self.width(), self.height())
self.label.resize(length, length)
self.label.move(
self.width() // 2 - length // 2,
self.height() // 2 - length // 2
)
if __name__ == "__main__":
# enable dpi scale
QApplication.setHighDpiScaleFactorRoundingPolicy(
Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
# run app
app = QApplication(sys.argv)
demo = Window()
demo.show()
sys.exit(app.exec_())
error message
my code