Git Product home page Git Product logo

Comments (5)

zhiyiYo avatar zhiyiYo commented on June 12, 2024

You can't use frameless window in designer

from pyqt-frameless-window.

ZouaouiB avatar ZouaouiB commented on June 12, 2024

Hello, appreciate your response! I'm looking to integrate the custom title bar developed in your code, not within the designer itself but in the main.py file, Can you assist me with this implementation?

class MainWindow(QMainWindow):
def init(self):
super().init()

# Initialize the UI
self.ui = Ui_MainWindow()
self.ui.setupUi(self)

from pyqt-frameless-window.

ZouaouiB avatar ZouaouiB commented on June 12, 2024

@YouKnow-sys
I need you assistance please

from pyqt-frameless-window.

zhiyiYo avatar zhiyiYo commented on June 12, 2024

Please check this demo: https://pyqt-frameless-window.readthedocs.io/en/latest/usage.html#work-with-qt-designer

from pyqt-frameless-window.

msalmonw avatar msalmonw commented on June 12, 2024

Hello, appreciate your response! I'm looking to integrate the custom title bar developed in your code, not within the designer itself but in the main.py file, Can you assist me with this implementation?

class MainWindow(QMainWindow): def init(self): super().init()

# Initialize the UI
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
  1. Create your UI inside a QWidget parent, not a QMainWindow parent. Compile the UI to .py.
  2. Create a new class that inherits from the FramelessWindow/AcrylicWindow class and the UI class.
from qframelesswindow import AcrylicWindow, TitleBar
from UI.DDCApp import Ui_DDCApp

class DDCApplication(Ui_DDCApp, AcrylicWindow):
    themeChangedSignal = QtCore.Signal(str)
    def __init__(self):
        super().__init__()
        self.setupUi(self)
  1. Create a custom titlebar inherited from the TitleBar class of qframelesswindow. Like I did here.
class CustomTitleBar(TitleBar):
    """ Custom title bar """

    def __init__(self, parent):
        super().__init__(parent)
        self.maxBtn.setStyleSheet("""
            TitleBarButton {
                qproperty-normalColor: rgba(255, 255, 255, 255);
                qproperty-normalBackgroundColor: transparent;
                qproperty-hoverColor: white;
                qproperty-hoverBackgroundColor: rgb(0, 100, 182);
                qproperty-pressedColor: white;
                qproperty-pressedBackgroundColor: rgb(54, 57, 65);
            }
        """)
        self.minBtn.setStyleSheet("""
            TitleBarButton {
                qproperty-normalColor: rgba(255, 255, 255, 255);
                qproperty-normalBackgroundColor: transparent;
                qproperty-hoverColor: white;
                qproperty-hoverBackgroundColor: rgb(0, 100, 182);
                qproperty-pressedColor: white;
                qproperty-pressedBackgroundColor: rgb(54, 57, 65);
                height: 4px;
            }
        """)
        self.closeBtn.setStyleSheet("""
            TitleBarButton {
                qproperty-normalColor: rgba(255, 255, 255, 255);
                qproperty-normalBackgroundColor: transparent;
            }
        """)
    
    def dark(self):
        self.maxBtn.setStyleSheet("""
            TitleBarButton {
                qproperty-normalColor: rgba(255, 255, 255, 255);
                qproperty-normalBackgroundColor: transparent;
                qproperty-hoverColor: white;
                qproperty-hoverBackgroundColor: rgb(0, 100, 182);
                qproperty-pressedColor: white;
                qproperty-pressedBackgroundColor: rgb(54, 57, 65);
            }
        """)
        self.minBtn.setStyleSheet("""
            TitleBarButton {
                qproperty-normalColor: rgba(255, 255, 255, 255);
                qproperty-normalBackgroundColor: transparent;
                qproperty-hoverColor: white;
                qproperty-hoverBackgroundColor: rgb(0, 100, 182);
                qproperty-pressedColor: white;
                qproperty-pressedBackgroundColor: rgb(54, 57, 65);
                height: 4px;
            }
        """)
        self.closeBtn.setStyleSheet("""
            TitleBarButton {
                qproperty-normalColor: rgba(255, 255, 255, 255);
                qproperty-normalBackgroundColor: transparent;
            }
        """)

    
    def light(self):
        self.maxBtn.setStyleSheet("""
            TitleBarButton {
                qproperty-normalColor: rgba(0, 0, 0, 255);
                qproperty-normalBackgroundColor: transparent;
                qproperty-hoverColor: white;
                qproperty-hoverBackgroundColor: rgba(0, 0, 0, 128);
                qproperty-pressedColor: white;
                qproperty-pressedBackgroundColor: rgba(0, 0, 0, 128);
            }
        """)
        self.minBtn.setStyleSheet("""
            TitleBarButton {
                qproperty-normalColor: rgba(0, 0, 0, 255);
                qproperty-normalBackgroundColor: transparent;
                qproperty-hoverColor: white;
                qproperty-hoverBackgroundColor: rgba(0, 0, 0, 128);
                qproperty-pressedColor: white;
                qproperty-pressedBackgroundColor: rgba(0, 0, 0, 128);
                height: 4px;
            }
        """)
        self.closeBtn.setStyleSheet("""
            TitleBarButton {
                qproperty-normalColor: rgba(0, 0, 0, 255);
                qproperty-normalBackgroundColor: transparent;
            }
        """)
  1. Assign the titlebar to your main application class. You can add more widgets to it as well like I did.
class DDCApplication(Ui_DDCApp, AcrylicWindow):
    themeChangedSignal = QtCore.Signal(str)
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        self.setTitleBar(CustomTitleBar(self))
        #self.windowEffect.setMicaEffect(self.winId(), isDarkMode=True, isAlt=False)
        

        self.title = QLabel(self.titleBar)
        self.title.setText('    DDC Desktop 2')

        self.connectionStatusLabel = QPushButton(self.titleBar)
        self.connectionStatusLabel.setText('  BLE not Connected')
        self.connectionStatusLabel.setIcon(QPixmap('UI/resources/redlight.png'))
        
        self.titleBar.layout().insertWidget(0, self.title, 0, QtCore.Qt.AlignLeft)
        self.titleBar.layout().insertWidget(1, self.connectionStatusLabel, 4, QtCore.Qt.AlignCenter)
        self.titleBar.layout().insertStretch(1, 1)

        self.titleBar.raise_()

from pyqt-frameless-window.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.