SetMinSize not work?

In the code below, use initially can resize the frame to no smaller
than (200, 200) + the size of the button. But I want to make it
possible to resize the frame to a smaller size if the user press a
button. SetMinSize() here seems not work. How?

import wx

class MyPanel(wx.Panel):
    def __init__(self, *a, **kw):
        super(MyPanel, self).__init__(*a, **kw)
        self.SetBackgroundColour(wx.BLUE)

    def shrink(self):
        self.SetMinSize((100, 100)) # <-- here seems not work
        
class MyFrame(wx.Frame):
    def __init__(self, *a, **kw):
        super(MyFrame, self).__init__(*a, **kw)

        self.panel = MyPanel(self, size=(200, 200))
        self.btn = wx.Button(self, -1, 'Shrink MinSize')

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.panel, 1, wx.GROW)
        sizer.Add(self.btn, 0, wx.GROW)
        self.SetAutoLayout(True)
        self.SetSizerAndFit(sizer)

        self.btn.Bind(wx.EVT_BUTTON, self.on_button)

    def on_button(self, evt):
        self.panel.shrink()

if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = MyFrame(None)
    frame.Show()
    app.MainLoop()

···

--
Qiangning Hong

I'm usually annoyed by IDEs because, for instance, they don't use VIM
as an editor. Since I'm hooked to that, all IDEs I've used so far have
failed to impress me.
    -- Sybren Stuvel @ c.l.python

Get Firefox! <http://www.spreadfirefox.com/?q=affiliates&id=67907&t=1>

Try using SetSize

···

On 7/6/05, Qiangning Hong <hongqn@gmail.com> wrote:

In the code below, use initially can resize the frame to no smaller
than (200, 200) + the size of the button. But I want to make it
possible to resize the frame to a smaller size if the user press a
button. SetMinSize() here seems not work. How?

import wx

class MyPanel(wx.Panel):
    def __init__(self, *a, **kw):
        super(MyPanel, self).__init__(*a, **kw)
        self.SetBackgroundColour(wx.BLUE)

    def shrink(self):
        self.SetMinSize((100, 100)) # <-- here seems not work

class MyFrame(wx.Frame):
    def __init__(self, *a, **kw):
        super(MyFrame, self).__init__(*a, **kw)

        self.panel = MyPanel(self, size=(200, 200))
        self.btn = wx.Button(self, -1, 'Shrink MinSize')

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.panel, 1, wx.GROW)
        sizer.Add(self.btn, 0, wx.GROW)
        self.SetAutoLayout(True)
        self.SetSizerAndFit(sizer)

        self.btn.Bind(wx.EVT_BUTTON, self.on_button)

    def on_button(self, evt):
        self.panel.shrink()

if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = MyFrame(None)
    frame.Show()
    app.MainLoop()

--
Qiangning Hong

I'm usually annoyed by IDEs because, for instance, they don't use VIM
as an editor. Since I'm hooked to that, all IDEs I've used so far have
failed to impress me.
    -- Sybren Stuvel @ c.l.python

Get Firefox! <http://www.spreadfirefox.com/?q=affiliates&amp;id=67907&amp;t=1&gt;

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

--
Don't be a pioneeer. A pioneer is the guy with the arrow through his
chest. -- John J. Rakos

SetSize doesn't work, too.

What I want is make it possible to let user drag the border to resize
the frame to a smaller size. Using SetSize here only make the panel
smaller, while the frame still cannot be dragged to smaller than (200,
200).

···

On 7/7/05, Matt Kubilus <mattkubilus@gmail.com> wrote:

Try using SetSize

On 7/6/05, Qiangning Hong <hongqn@gmail.com> wrote:
> In the code below, use initially can resize the frame to no smaller
> than (200, 200) + the size of the button. But I want to make it
> possible to resize the frame to a smaller size if the user press a
> button. SetMinSize() here seems not work. How?
>
> import wx
>
> class MyPanel(wx.Panel):
> def __init__(self, *a, **kw):
> super(MyPanel, self).__init__(*a, **kw)
> self.SetBackgroundColour(wx.BLUE)
>
> def shrink(self):
> self.SetMinSize((100, 100)) # <-- here seems not work
>
>
> class MyFrame(wx.Frame):
> def __init__(self, *a, **kw):
> super(MyFrame, self).__init__(*a, **kw)
>
> self.panel = MyPanel(self, size=(200, 200))
> self.btn = wx.Button(self, -1, 'Shrink MinSize')
>
> sizer = wx.BoxSizer(wx.VERTICAL)
> sizer.Add(self.panel, 1, wx.GROW)
> sizer.Add(self.btn, 0, wx.GROW)
> self.SetAutoLayout(True)
> self.SetSizerAndFit(sizer)
>
> self.btn.Bind(wx.EVT_BUTTON, self.on_button)
>
> def on_button(self, evt):
> self.panel.shrink()
>
>
> if __name__ == '__main__':
> app = wx.PySimpleApp()
> frame = MyFrame(None)
> frame.Show()
> app.MainLoop()
>
> --
> Qiangning Hong
>
> I'm usually annoyed by IDEs because, for instance, they don't use VIM
> as an editor. Since I'm hooked to that, all IDEs I've used so far have
> failed to impress me.
> -- Sybren Stuvel @ c.l.python
>
> Get Firefox! <http://www.spreadfirefox.com/?q=affiliates&amp;id=67907&amp;t=1&gt;
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
>
>

--
Don't be a pioneeer. A pioneer is the guy with the arrow through his
chest. -- John J. Rakos

--
Qiangning Hong

I'm usually annoyed by IDEs because, for instance, they don't use VIM
as an editor. Since I'm hooked to that, all IDEs I've used so far have
failed to impress me.
   -- Sybren Stuvel @ c.l.python

Get Firefox! <http://www.spreadfirefox.com/?q=affiliates&amp;id=67907&amp;t=1&gt;

I haven't set the default size for my frame. It is expand to that
size because of the initial size of the *panel*. So specify a smaller
default size for the frame is meaningless.

The panel in my example code is just an example to easy to understand.
In the real code, it is a subclass of wx.Panel with some dynamically
generated controls on it. When the number and size of these controls
changed, I want my user *can* change the size of the frame to a proper
value.

I just want to know how to change the min size of a frame at runtime.

···

On 7/7/05, Matt Kubilus <mattkubilus@gmail.com> wrote:

Specify a smaller default size for your frame and then set the size
explicitly after the frame is created. The size you set when the
frame is created is the minimum size that frame will occupy.

--Matt

On 7/6/05, Qiangning Hong <hongqn@gmail.com> wrote:
> SetSize doesn't work, too.
>
> What I want is make it possible to let user drag the border to resize
> the frame to a smaller size. Using SetSize here only make the panel
> smaller, while the frame still cannot be dragged to smaller than (200,
> 200).
>
> On 7/7/05, Matt Kubilus <mattkubilus@gmail.com> wrote:
> > Try using SetSize
> >
> > On 7/6/05, Qiangning Hong <hongqn@gmail.com> wrote:
> > > In the code below, use initially can resize the frame to no smaller
> > > than (200, 200) + the size of the button. But I want to make it
> > > possible to resize the frame to a smaller size if the user press a
> > > button. SetMinSize() here seems not work. How?
> > >
> > > import wx
> > >
> > > class MyPanel(wx.Panel):
> > > def __init__(self, *a, **kw):
> > > super(MyPanel, self).__init__(*a, **kw)
> > > self.SetBackgroundColour(wx.BLUE)
> > >
> > > def shrink(self):
> > > self.SetMinSize((100, 100)) # <-- here seems not work
> > >
> > >
> > > class MyFrame(wx.Frame):
> > > def __init__(self, *a, **kw):
> > > super(MyFrame, self).__init__(*a, **kw)
> > >
> > > self.panel = MyPanel(self, size=(200, 200))
> > > self.btn = wx.Button(self, -1, 'Shrink MinSize')
> > >
> > > sizer = wx.BoxSizer(wx.VERTICAL)
> > > sizer.Add(self.panel, 1, wx.GROW)
> > > sizer.Add(self.btn, 0, wx.GROW)
> > > self.SetAutoLayout(True)
> > > self.SetSizerAndFit(sizer)
> > >
> > > self.btn.Bind(wx.EVT_BUTTON, self.on_button)
> > >
> > > def on_button(self, evt):
> > > self.panel.shrink()
> > >
> > >
> > > if __name__ == '__main__':
> > > app = wx.PySimpleApp()
> > > frame = MyFrame(None)
> > > frame.Show()
> > > app.MainLoop()
> > >
> > > --
> > > Qiangning Hong
> > >
> > > I'm usually annoyed by IDEs because, for instance, they don't use VIM
> > > as an editor. Since I'm hooked to that, all IDEs I've used so far have
> > > failed to impress me.
> > > -- Sybren Stuvel @ c.l.python
> > >
> > > Get Firefox! <http://www.spreadfirefox.com/?q=affiliates&amp;id=67907&amp;t=1&gt;
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
> > > For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
> > >
> > >
> >
> >
> > --
> > Don't be a pioneeer. A pioneer is the guy with the arrow through his
> > chest. -- John J. Rakos
> >
>
>
> --
> Qiangning Hong
>
> I'm usually annoyed by IDEs because, for instance, they don't use VIM
> as an editor. Since I'm hooked to that, all IDEs I've used so far have
> failed to impress me.
> -- Sybren Stuvel @ c.l.python
>
> Get Firefox! <http://www.spreadfirefox.com/?q=affiliates&amp;id=67907&amp;t=1&gt;
>

--
Don't be a pioneeer. A pioneer is the guy with the arrow through his
chest. -- John J. Rakos

--
Qiangning Hong

I'm usually annoyed by IDEs because, for instance, they don't use VIM
as an editor. Since I'm hooked to that, all IDEs I've used so far have
failed to impress me.
   -- Sybren Stuvel @ c.l.python

Get Firefox! <http://www.spreadfirefox.com/?q=affiliates&amp;id=67907&amp;t=1&gt;

Qiangning Hong wrote:

I just want to know how to change the min size of a frame at runtime.

wx.Window.SetSizeHints may help you here.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov