And now, a ScrolledPanel sizing question

I wrote up something on linux to deal with scrolled panels. It looked
a lot like this:

class scrolledTextFrame( wx.Frame ):
  def updateText( self, text ):
    self.text.SetLabel( text )
    self.scroll.FitInside()
    self.Layout()
    self.scroll.SetupScrolling()

  def __init__( self, *args, **kwargs ):
    wx.Frame.__init__( self, *args, **kwargs )
    self.scroll = wx.lib.scrolledpanel.ScrolledPanel( parent=self, id=-1 )
    self.text = wx.StaticText( self.scroll, -1, "UNITIALIZED" )
    self.sizer = wx.BoxSizer( wx.VERTICAL )
    self.sizer.Add( self.text, wx.EXPAND, 0 )
    self.scroll.SetupScrolling()
    self.scroll.SetSizer( self.sizer )
    self.scroll.Layout()
    self.Show()

On linux, I would call it with a size=(400,800) argument, and I would
get a sized area for my text that worked perfectly.

When I tried this on my mac, the text acted like it was inside a tiny
box even though the window was sized just right for what I was doing.
In other words, instead of seeing "This is a line of text". I'd see
something like "This is a \nline of te\nxt" inside a 400 by 800
window.

-- Schlake

Please make a runnable, small as possible, sample application that demonstrates the problem and let us know the platform and wx version. MakingSampleApps - wxPyWiki

···

On 5/13/11 9:03 PM, William D. Colburn (Schlake) wrote:

I wrote up something on linux to deal with scrolled panels. It looked
a lot like this:

class scrolledTextFrame( wx.Frame ):
   def updateText( self, text ):
     self.text.SetLabel( text )
     self.scroll.FitInside()
     self.Layout()
     self.scroll.SetupScrolling()

   def __init__( self, *args, **kwargs ):
     wx.Frame.__init__( self, *args, **kwargs )
     self.scroll = wx.lib.scrolledpanel.ScrolledPanel( parent=self, id=-1 )
     self.text = wx.StaticText( self.scroll, -1, "UNITIALIZED" )
     self.sizer = wx.BoxSizer( wx.VERTICAL )
     self.sizer.Add( self.text, wx.EXPAND, 0 )
     self.scroll.SetupScrolling()
     self.scroll.SetSizer( self.sizer )
     self.scroll.Layout()
     self.Show()

On linux, I would call it with a size=(400,800) argument, and I would
get a sized area for my text that worked perfectly.

When I tried this on my mac, the text acted like it was inside a tiny
box even though the window was sized just right for what I was doing.
In other words, instead of seeing "This is a line of text". I'd see
something like "This is a \nline of te\nxt" inside a 400 by 800
window.

--
Robin Dunn
Software Craftsman

Ok, here it is with an App() and a MainWindow():

import wx
import wx.lib.scrolledpanel
class scrolledTextFrame( wx.Frame ):
def updateText( self, text ):
   self.text.SetLabel( text )
   self.scroll.FitInside()
   self.Layout()
   self.scroll.SetupScrolling()

def __init__( self, *args, **kwargs ):
   wx.Frame.__init__( self, *args, **kwargs )
   self.scroll = wx.lib.scrolledpanel.ScrolledPanel( parent=self, id=-1 )
   self.text = wx.StaticText( self.scroll, -1, "UNITIALIZED" )
   self.sizer = wx.BoxSizer( wx.VERTICAL )
   self.sizer.Add( self.text, wx.EXPAND, 0 )
   self.scroll.SetupScrolling()
   self.scroll.SetSizer( self.sizer )
   self.scroll.Layout()
   self.Show()

app = wx.App( 0 )
frame = scrolledTextFrame( None )
frame.updateText( 'This is some text that is longer than ten characters.' )
app.MainLoop()

As stated before, it works under linux, not under MacOS.

···

--
-- Schlake

Which version? It's working fine here.

···

On 5/16/11 10:01 AM, William D. Colburn (Schlake) wrote:

Ok, here it is with an App() and a MainWindow():

import wx
import wx.lib.scrolledpanel
class scrolledTextFrame( wx.Frame ):
  def updateText( self, text ):
    self.text.SetLabel( text )
    self.scroll.FitInside()
    self.Layout()
    self.scroll.SetupScrolling()

  def __init__( self, *args, **kwargs ):
    wx.Frame.__init__( self, *args, **kwargs )
    self.scroll = wx.lib.scrolledpanel.ScrolledPanel( parent=self, id=-1 )
    self.text = wx.StaticText( self.scroll, -1, "UNITIALIZED" )
    self.sizer = wx.BoxSizer( wx.VERTICAL )
    self.sizer.Add( self.text, wx.EXPAND, 0 )
    self.scroll.SetupScrolling()
    self.scroll.SetSizer( self.sizer )
    self.scroll.Layout()
    self.Show()

app = wx.App( 0 )
frame = scrolledTextFrame( None )
frame.updateText( 'This is some text that is longer than ten characters.' )
app.MainLoop()

As stated before, it works under linux, not under MacOS.

--
Robin Dunn
Software Craftsman

Python says 2.7.1, wx says 2.8.

···

On Mon, May 16, 2011 at 11:40 AM, Robin Dunn <robin@alldunn.com> wrote:

Which version? It's working fine here.

--
-- Schlake

Which 2.8? ("print wx.version()" will tell you.) It has been 4+ years and 17 releases since the first 2.8.x release and the current one. If you're not using 2.8.12.0 then please try it with that release.

Regardless, your issue sounds like it is something to do with a widget not being the expected size at the time that the text is changed and so the static text is compensating by wrapping itself. That hint should help you focus your debugging efforts. Using the WIT will help too. http://wiki.wxpython.org/Widget_Inspection_Tool

···

On 5/16/11 10:43 AM, William D. Colburn (Schlake) wrote:

On Mon, May 16, 2011 at 11:40 AM, Robin Dunn<robin@alldunn.com> wrote:

Which version? It's working fine here.

Python says 2.7.1, wx says 2.8.

--
Robin Dunn
Software Craftsman