[PyQt] Skinning the title bar and window border

Devon Rueckner devon.rueckner at temboo.com
Fri Sep 24 05:45:50 BST 2010


Hi -

>From a usability perspective, you definitely end up with something that feels and behaves .. different.  This sort of thing is probably more appropriate for smaller pop-ups and dialogs than a main window.

For implementation, you can make a subclass of QDialog which implements the chrome and event handling in a standard grid layout, with a big empty widget in the center.  Then over-ride some of the standard methods like setLayout to operate on the inner content widget, and you've created a custom window that's somewhat API-compatible with the standard QDialog.  It's not pretty but it gets the job done.

~ Devon



> -----Original Message-----
> From: pyqt-bounces at riverbankcomputing.com [mailto:pyqt-
> bounces at riverbankcomputing.com] On Behalf Of Yao Ko
> Sent: Thursday, September 23, 2010 12:54 PM
> To: Hans-Peter Jansen
> Cc: pyqt at riverbankcomputing.com
> Subject: Re: [PyQt] Skinning the title bar and window border
> 
> Hi,
> 
> Just note that if you go down the route of implementing a custom chrome
> with custom title bar (with the typical minimize, maximize, close
> butons), you may end up losing some Window Manager specific features.
> This is particularly noticeable on Mac and Win7 (with Aero).  On Mac,
> you can no longer click the title bar and move the app to another
> virtual desktop.  On Win7, you can no longer "shake" the app and have
> all other apps minimize automatically.  Nor you can auto "snap" the app
> to the desktop borders.
> 
> 
> So in the end, it's a tradeoff of user experiences, so you may want to
> choose carefully before diving into having custom chrome.
> 
> Yao
> 
> On Thu, Sep 23, 2010 at 3:51 AM, Hans-Peter Jansen <hpj at urpla.net>
> wrote:
> 
> 
> 	On Thursday 23 September 2010, 10:06:01 pard wrote:
> 	> Thanks Devon
> 	>
> 	> I will be looking at an example that Vincent Vande Vyvre
> suggested.
> 
> 
> 	Well that example let you play with the flags, and the flag that
> is needed
> 	is named QtCore.Qt.FramelessWindowHint, as Devon already
> mentioned. The
> 	matter is recreating the behavior of the window manager, which
> will always
> 	be a proximity, of course.
> 
> 	Pete
> 
> 
> 	> Would
> 	> you mind if I contacted you for pointers if I get stuck, since
> you have
> 	> some experience in this?
> 	>
> 	> Pard
> 	>
> 	> On 22 September 2010 18:18, Devon Rueckner
> 	<devon.rueckner at temboo.com>wrote:
> 	> > Hi -
> 	> >
> 	> > We had the same requirement.  Our solution was to use a
> frameless
> 	> > window (FramelessWindowHint) and implement our own chrome
> with event
> 	> > handling for title-bar moving, edge resizing, etc.
> 	> >
> 	> > Regards
> 	> > ~ Devon
> 	> >
> 	> > > -----Original Message-----
> 	> > > From: pyqt-bounces at riverbankcomputing.com [mailto:pyqt-
> 	> > > bounces at riverbankcomputing.com] On Behalf Of pard
> 	> > > Sent: Wednesday, September 22, 2010 6:48 AM
> 	> > > To: Hans-Peter Jansen
> 	> > > Cc: pyqt at riverbankcomputing.com
> 	> > > Subject: Re: [PyQt] Skinning the title bar and window
> border
> 	> > >
> 	> > > Hi Pete
> 	> > >
> 	> > > I understand why it is not popular. However, this is a
> requirement
> 	> > > for work purposes.
> 	> > > I had created a working program using wxpython for the gui,
> but the
> 	> > > client required a specific colour scheme, fonts, etc. I
> found that
> 	> > > wxpython was very restrictive when it comes to theming.
> 	> > >
> 	> > > PyQt uses stylesheets which make it much simpler to theme
> an
> 	> > > application. The only outstanding requirement is that the
> frame must
> 	> > > be the same theme as the application.
> 	> > > Marketing is quite adamant about this.
> 	> > >
> 	> > > I also understand that it would be better to start with the
> basics,
> 	> > > however, the deadline is also tight. If there are any
> resources which
> 	> > > would give pointers as to how to reconstruct the work of
> window
> 	> > > managers for my app it would be much appreciated.
> 	> > >
> 	> > > Pard
> 	> > >
> 	> > >
> 	> > > On 22 September 2010 12:32, Hans-Peter Jansen
> <hpj at urpla.net> wrote:
> 	> > >
> 	> > >       On Wednesday 22 September 2010, 11:36:41 pard wrote:
> 	> > >       > Hi David
> 	> > >       >
> 	> > >       > Thanks for your response. Do you have any resources
> that
> 	> > >       > would
> 	> > >
> 	> > > show how
> 	> > >
> 	> > >       > to do this? Tutorials, examples, etc.
> 	> > >       > I do need to change the style of the window frame.
> 	> > >
> 	> > >       Doing that is not so popular, as it usually confuses
> your users
> 	> > > more than it
> 	> > >       is buying you. There's a reason, why all graphical
> operating
> 	> > > systems
> 	> > >       (including Windows, although their application
> developers
> 	> > > usually doesn't
> 	> > >       care a whit) try to provide an consistent user
> interface.
> 	> > >
> 	> > >       > I am new to pyqt.
> 	> > >
> 	> > >       Hmm, do you enter cars, when they move at 100 mph? If
> yes, how?
> 	> > >
> 	> > >       Seriously, start with the basics. If you master them,
> nothing
> 	> > > will stop you
> 	> > >       to reconstruct the work of window managers for you
> own
> 	> > > application.
> 	> > >
> 	> > >       Cheers,
> 	> > >       Pete
> 	> > >
> 	> > >       _______________________________________________
> 	> > >       PyQt mailing list    PyQt at riverbankcomputing.com
> 	> > >
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> 
> 	_______________________________________________
> 	PyQt mailing list    PyQt at riverbankcomputing.com
> 	http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> 



More information about the PyQt mailing list