Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7986781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:57:05+00:00 2026-06-04T11:57:05+00:00

How could I customize the Title Bar (including: close, maximize, minimize buttons, title) and

  • 0

How could I customize the Title Bar (including: close, maximize, minimize buttons, title) and the Frame of desktop application written in PyQt so that it looks like the below image?. I need a way to specify the colors I want to use for title bar elements (buttons, text title and background-color of bar and buttons). Nokia Ovi Suite

the code which I need to change its window:

import sys
from PyQt5 import QtCore, uic
from PyQt5.QtWidgets import QApplication, QDialog

class MainWindow(QDialog):
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)

        self.setWindowFlags(QtCore.Qt.FramelessWindowHint)


        self.resize(500, 600)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = MainWindow()
    sys.exit(app.exec_())

Is there any way to do that? I appreciate any suggestion and idea to doing this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:57:07+00:00Added an answer on June 4, 2026 at 11:57 am
    #########################################################
    ## customize Title bar
    ## dotpy.ir
    ## iraj.jelo@gmail.com
    #########################################################
    import sys
    from PyQt4 import QtGui
    from PyQt4 import QtCore
    from PyQt4.QtCore import Qt
    
    class TitleBar(QtGui.QDialog):
        def __init__(self, parent=None):
            QtGui.QWidget.__init__(self, parent)
            self.setWindowFlags(Qt.FramelessWindowHint);
            css = """
            QWidget{
                Background: #AA00AA;
                color:white;
                font:12px bold;
                font-weight:bold;
                border-radius: 1px;
                height: 11px;
            }
            QDialog{
                Background-image:url('img/titlebar bg.png');
                font-size:12px;
                color: black;
    
            }
            QToolButton{
                Background:#AA00AA;
                font-size:11px;
            }
            QToolButton:hover{
                Background: #FF00FF;
                font-size:11px;
            }
            """
            self.setAutoFillBackground(True)
            self.setBackgroundRole(QtGui.QPalette.Highlight)
            self.setStyleSheet(css) 
            self.minimize=QtGui.QToolButton(self);
            self.minimize.setIcon(QtGui.QIcon('img/min.png'));
            self.maximize=QtGui.QToolButton(self);
            self.maximize.setIcon(QtGui.QIcon('img/max.png'));
            close=QtGui.QToolButton(self);
            close.setIcon(QtGui.QIcon('img/close.png'));
            self.minimize.setMinimumHeight(10);
            close.setMinimumHeight(10);
            self.maximize.setMinimumHeight(10);
            label=QtGui.QLabel(self);
            label.setText("Window Title");
            self.setWindowTitle("Window Title");
            hbox=QtGui.QHBoxLayout(self);
            hbox.addWidget(label);
            hbox.addWidget(self.minimize);
            hbox.addWidget(self.maximize);
            hbox.addWidget(close);
            hbox.insertStretch(1,500);
            hbox.setSpacing(0);
            self.setSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Fixed);
            self.maxNormal=False;
            close.clicked.connect(self.close);
            self.minimize.clicked.connect(self.showSmall);
            self.maximize.clicked.connect(self.showMaxRestore);
    
        def showSmall(self):
            box.showMinimized();
    
        def showMaxRestore(self):
            if(self.maxNormal):
                box.showNormal();
                self.maxNormal= False;
                self.maximize.setIcon(QtGui.QIcon('img/max.png'));
                print '1'
            else:
                box.showMaximized();
                self.maxNormal=  True;
                print '2'
                self.maximize.setIcon(QtGui.QIcon('img/max2.png'));
    
        def close(self):
            box.close()
    
        def mousePressEvent(self,event):
            if event.button() == Qt.LeftButton:
                box.moving = True; box.offset = event.pos()
    
        def mouseMoveEvent(self,event):
            if box.moving: box.move(event.globalPos()-box.offset)
    
    
    class Frame(QtGui.QFrame):
        def __init__(self, parent=None):
            QtGui.QFrame.__init__(self, parent)
            self.m_mouse_down= False;
            self.setFrameShape(QtGui.QFrame.StyledPanel)
            css = """
            QFrame{
                Background:  #D700D7;
                color:white;
                font:13px ;
                font-weight:bold;
                }
            """
            self.setStyleSheet(css) 
            self.setWindowFlags(Qt.FramelessWindowHint);
            self.setMouseTracking(True);
            self.m_titleBar= TitleBar(self);
            self.m_content= QtGui.QWidget(self);
            vbox=QtGui.QVBoxLayout(self);
            vbox.addWidget(self.m_titleBar);
            vbox.setMargin(0);
            vbox.setSpacing(0);
            layout=QtGui.QVBoxLayout(self);
            layout.addWidget(self.m_content);
            layout.setMargin(5);
            layout.setSpacing(0);
            vbox.addLayout(layout);
            # Allows you to access the content area of the frame
            # where widgets and layouts can be added
    
        def contentWidget(self):
            return self.m_content
    
        def titleBar(self):
            return self.m_titleBar
    
        def mousePressEvent(self,event):
            self.m_old_pos = event.pos();
            self.m_mouse_down = event.button()== Qt.LeftButton;
    
        def mouseMoveEvent(self,event):
            x=event.x();
            y=event.y();
    
        def mouseReleaseEvent(self,event):
            m_mouse_down=False;
    
    if __name__ == '__main__':
        app = QtGui.QApplication(sys.argv);
        box = Frame()
        box.move(60,60);
        l=QtGui.QVBoxLayout(box.contentWidget());
        l.setMargin(0);
        edit=QtGui.QLabel("""I would've did anything for you to show you how much I adored you
    But it's over now, it's too late to save our loveJust promise me you'll think of me
    Every time you look up in the sky and see a star 'cuz I'm  your star.""");
        l.addWidget(edit)
        box.show()
        app.exec_()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to customize my titlebar, minimize-, maximize- and the close-button. So I
I've implemented a resource dictionary so that I could customize my tooltip on a
I am going to create a new web application that is very customized. It
Customized Title Bar More and more, professional software are customizing their title bars, whether
How could I customize placeholders in my .rst file with actual values? For example,
Could someone explain how does Union in LINQ work? It is told that it
I noticed that once you customize the settings of a zone in Internet Explorer,
Suppose that I want to customize the indentation rules of the foton document editor,
I'm trying to customize form labels that are generated in subforms. I want to
I'm using jQuery to customize my own dropbox but was wondering how I could

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.