Archisman Panigrahi
Archisman Panigrahi

Reputation: 633

How to disable resizing in wx python widget?

I have already specified the size in wx python via

super(BrightnessController, self).__init__(parent, title=title, size=(330, 100)).

How to completely disable resizing?

Source: https://github.com/lordamit/Brightness/blob/master/src/brightness.py

Upvotes: 1

Views: 829

Answers (2)

MOREL Benoît
MOREL Benoît

Reputation: 284

Try with: super(BrightnessController, self).init(parent, title=title, size=(330, 100), style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER)

Upvotes: 1

Yoriz
Yoriz

Reputation: 3625

setting the minimum and maximum size will stop the frame from being resized past the sizes set for them.

import wx


class BrightnessController(wx.Frame):
    def __init__(self, parent, title):
        super(BrightnessController, self).__init__(parent, title=title,
                                                   size=(330, 100))
        self.SetMinSize((330, 100))
        self.SetMaxSize((330, 100))
        self.Show()


if __name__ == '__main__':
    app = wx.App()
    BrightnessController(None, title='Brightness Controller')
    app.MainLoop()

The other way is to set the style as a DEFAULT_DIALOG_STYLE and if you still want to minimize also MINIMIZE_BOX

import wx


class BrightnessController(wx.Frame):
    def __init__(self, parent, title):
        super(BrightnessController, self).__init__(parent, title=title,
            size=(330, 100), style=wx.DEFAULT_DIALOG_STYLE | wx.MINIMIZE_BOX)

        self.Show()


if __name__ == '__main__':
    app = wx.App()
    BrightnessController(None, title='Brightness Controller')
    app.MainLoop()

Upvotes: 1

Related Questions