Search code examples
pythonwindowspython-2.7wxpython

WxPython - How to hide the X and expand button on window


Im making a python program and in some functions it needs to hide the X and expand window buttons, how would i do it? Im using WxPython, how would I put this in?


Solution

  • I wrote about Frame styles a while ago on my blog. To remove all the buttons, you could do this:

    import wx
    
    ########################################################################
    class NoSystemMenuFrame(wx.Frame):
        """
        There is no system menu, which means the title bar is there, but
        no buttons and no menu when clicking the top left hand corner
        of the frame
        """
    
        #----------------------------------------------------------------------
        def __init__(self):
            """Constructor"""
            no_sys_menu = wx.CAPTION
            wx.Frame.__init__(self, None, title="No System Menu", style=no_sys_menu)
            panel = wx.Panel(self)
            self.Show()
    
    #----------------------------------------------------------------------
    if __name__ == "__main__":
        app = wx.App(False)
        frame = NoSystemMenuFrame()
        app.MainLoop()
    

    I tried setting the style to wx.DEFAULT_FRAME_STYLE & (~wx.CLOSE_BOX) & (~wx.MAXIMIZE_BOX) and to wx.DEFAULT_FRAME_STYLE^(wx.CLOSE_BOX|wx.MAXIMIZE_BOX), but both of those seem to only remove the Close box. For some reason, the Maximize button is still there on my Xubuntu machine.