How to minimize windows by clicking on an image (wxPython)

Post here if you need help with creating a Graphical User Interface in Python.

How to minimize windows by clicking on an image (wxPython)

Postby mitma » Wed Oct 23, 2013 10:34 pm

Hello,
I would like to hide the title bar and substitute the minimization button with an image, to minimize the app's windows on the task bar, by clicking with left mouse button on the image.

I found some topics about this:
http://www.blog.pythonlibrary.org/2013/ ... stem-tray/
http://zetcode.com/wxpython/menustoolbars/
http://bytes.com/topic/python/answers/4 ... ize-button

...so, my code is:

    1) To hide the title bar:

    Code: Select all
    wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = '', pos = wx.DefaultPosition, size = wx.Size( 640,400 ), style = wx.NO_BORDER )


    2) To create the bitmap:

    Code: Select all
    self.minimize = wx.BitmapButton( self, wx.ID_ANY, wx.Bitmap( u"minimize20x20.png", wx.BITMAP_TYPE_ANY ), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW|wx.NO_BORDER )
    self.minimize.SetFont( wx.Font( 8, 74, 90, 92, False, "Segoe UI" ) )
    self.minimize.SetForegroundColour( wx.Colour( 21, 180, 255 ) )
    self.minimize.SetBackgroundColour( wx.Colour( 15, 15, 15 ) )
    self.minimize.SetToolTipString( u"minimizza" )

    3) Then I bound a function to the image in this way:

    Code: Select all
    self.minimize.Bind( wx.EVT_ICONIZE, self.OnIconify )

    4) and finally I defined the OnIconify() function in this way:

    Code: Select all
    def OnIconify(self, event):
                 self.Iconize( True )

but nothing happens... what is wrong?

Thanks a lot,

Riccardo
User avatar
mitma
 
Posts: 3
Joined: Mon Oct 21, 2013 12:00 am
Location: Pisa (Italy)

Re: How to minimize windows by clicking on an image (wxPytho

Postby Yoriz » Thu Oct 24, 2013 11:55 am

I think your binding to the wrong event.
Code: Select all
self.minimize.Bind(wx.EVT_ICONIZE, self.OnIconify)

try binding to wx.EVT_BUTTON instead.
Code: Select all
self.minimize.Bind(wx.EVT_BUTTON, self.OnIconify)
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Image
User avatar
Yoriz
 
Posts: 998
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Re: How to minimize windows by clicking on an image (wxPytho

Postby mitma » Tue Dec 03, 2013 1:08 am

Thanks! Yes, that was the problem! I read only now your answer,

I solved it,
thanks again
User avatar
mitma
 
Posts: 3
Joined: Mon Oct 21, 2013 12:00 am
Location: Pisa (Italy)


Return to GUI

Who is online

Users browsing this forum: No registered users and 2 guests