Quoting James Bigler <bigler (AT) cs (DOT) utah.edu>:
I still can\'t make it smaller than the initial size, however. I even
tried to change the minimum size after the window was shown, but that
didn\'t have an effect.
def Size(self, event):
if (not self.panel.minSizeSet):
self.panel.SetMinSize(wx.Size(20,20))
self.panel.minSizeSet = True
self.SetStatusText(\"Size = %s\" % (self.panel.GetSize(),) )
event.Skip(True)
So I want the panel to be a certain initial size, but I want to be able
to make it bigger or smaller afterwards.
Hi James,
way is to set the frame to a default size and don\'t do the:
self.SetSizerAndFit(box)
See code below:
import wx
class MyApp(wx.App):
def Init(self):
frame = Frame(parent=None, title=\'Resize Panel\')
frame.Show()
self.SetTopWindow(frame)
return True
class Frame(wx.Frame):
def __init__(self, parent, title):
wx.Frameinit__(self, parent=parent, title=title, size=(300,400))
# Setup menu bar
menuBar = wx.MenuBar()
menu1 = wx.Menu()
self.Bind(wx.EVT_MENU, Quit, menu1.Append(wx.NewId(),
\"&Quit\"))
menuBar.Append(menu1, \"&File\")
menu2 = wx.Menu()
self.Bind(wx.EVT_MENU, About, menu2.Append(wx.NewId(),
\"About Me\"))
menuBar.Append(menu2, \"&Help\")
self.SetMenuBar(menuBar)
# Create status bar
self.CreateStatusBar()
self.SetStatusText(\"Welcome to wxPython!\")
# Create the panel
self.panel = wx.Panel(self, -1)
self.panel.SetBackgroundColour(\"green\")
box = wx.BoxSizer(wx.HRIZNTAL)
box.Add(self.panel, 1, wx.EXPAND)
# !!! This resizes the frame !!!
#self.SetSizerAndFit(box)
print \"Min Size = %s\" % self.panel.GetMinSize()
print \"Max Size = %s\" % self.panel.GetMaxSize()
print \"Best Size = %s\" % self.panel.GetBestSize()
def Quit(self, event):
self.Close()
def About(self, event):
wx.MessageBox(\"This is a test program to show how to resize
the main panel. I want the green panel to change size when the screen
is resized bigger and smaller than the original. \",
\"About Me\", K | wx.ICN_INFRMATIN, self)
if __name__ == \'__main__\':
app = MyApp(False)
app.MainLoop()
Regards,
Ray Smith
http://RaymondSmith.com
To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org