[PyQt] GUI Designing query

Hans-Peter Jansen hpj at urpla.net
Mon Jan 13 13:13:54 GMT 2014


On Samstag, 11. Januar 2014 18:17:22 Tomas Sobota wrote:
> Hi Pankaj,
> 
> What I do is capture the close event in the MainWindow class. Like this:
> 
> class Main(QMainWindow):
>     def __init__(self):
>         QMainWindow.__init__(self)
>     .
>     .
>     .
>     def closeEvent(self, event):
>         if QMessageBox.question(
>             self,
>             "My App Name",
>             self.trUtf8("Do you really want to exit the program?"),
>             QMessageBox.Yes|QMessageBox.No) == QMessageBox.No:
>             event.ignore()
> 
> In your case the logic will be different but this is the event that you
> need.
> 
> Tom
> 
> On Sat, Jan 11, 2014 at 2:18 PM, Pankaj Gupta <pankaj at gaurishiv.org> wrote:
> > Hi all,
> > 
> > I am very new to PyQt.

A choice of taste ;)

> > As per the requirement I have to disable panel
> > close button appears on the GUI at right top most corner. the user must
> > close the GUI by clicking the push button available on the GUI.

Removing the close button might be possible by providing some window flags.

Check out examples/widgets/windowflags.py.

Unfortunately, this is highly window manager dependent, and needs to be tested 
literally in any OS/windowmanager (version(!)) combination, that you aim for. 
Another option is using a frameless window (that option should do everywhere), 
and do you own window movement/resize/whatever handling.. This can be 
interesting with multiple screens and workspaces, though..

Good luck,
Pete


More information about the PyQt mailing list