XRC expand wxTextCtrl to available space

I am trying to get a wxTextCtrl to expand to the maximum available
space.Despite all my efforts I am rewarded with the minimum size!

I have attached the XRC file. I am trying to get it drawn with the
following code:

`class MyXRCPanel(wx.Panel):

def __init__(self,parent,uibase,state):

    self.params=(parent,uibase)

    wx.Panel.__init__(self, parent,

style=wx.TAB_TRAVERSAL|wx.NO_BORDER|wx.EXPAND)

    RESFILE="c:\\panel.xrc"

    self.res = xrc.XmlResource(RESFILE)

    print RESFILE,self.res

    sizer = wx.BoxSizer(wx.VERTICAL)

    self.panel = self.res.LoadPanel(self, "state%i"%state)

    if  self.panel==None:

        print "ERROR could not get state%i,

RESFILE=%s"%(state,RESFILE)

    self.buttonEvents={}

    sizer.Add(self.panel, 0, wx.EXPAND)

    self.SetSizer(sizer)

    self.Fit()

    self.Layout()

    def OnSize(evt, win=self):

        win.panel.SetSize(evt.GetSize())

`I think I have set everything to expand. What I am doing wrong?

Paul

panel.xrc (1.58 KB)

···
-- Paul Sijben tel: +31334566488
Eemvalley Systems & Technology fax: +31334557523
the Netherlands

http://eemvalley.com

I am trying to get a wxTextCtrl to expand to the maximum available
space.Despite all my efforts I am rewarded with the _/minimum /_size!

I have attached the XRC file. I am trying to get it drawn with the
following code:

class MyXRCPanel(wx.Panel):
    def __init__(self,parent,uibase,state):
        self.params=(parent,uibase)
        wx.Panel.__init__(self, parent,
style=wx.TAB_TRAVERSAL|wx.NO_BORDER|wx.EXPAND)
        RESFILE="c:\\panel.xrc"
        self.res = xrc.XmlResource(RESFILE)
        print RESFILE,self.res
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.panel = self.res.LoadPanel(self, "state%i"%state)
        if self.panel==None:
            print "ERROR could not get state%i, RESFILE=%s"%(state,RESFILE)
        self.buttonEvents={}
        sizer.Add(self.panel, 0, wx.EXPAND)
        self.SetSizer(sizer)
        self.Fit()
        self.Layout()
        def OnSize(evt, win=self):
            win.panel.SetSize(evt.GetSize())

I think I have set everything to expand. What I am doing wrong?

The wx.Panel.__init__(..., style=...|wx.EXPAND) won't do anything, or
may do something wrong (wx.EXPAND is not a valid style).

Get rid of the OnSize handler (which you didn't seem to bind in this
code), it is unnecessary. The size handling and layout will be handled
by the sizer.

If your text control is a multi-line text control (created with the
wx.TE_MULTILINE style), then you are going to need to pass a '1' to the
sizer.Add call:
    sizer.Add(self.panel, 1, wx.EXPAND)

Otherwise it will be as short as possible.

Another issue is the following...

        self.SetSizer(sizer)
        self.Fit()
        self.Layout()

The use of Fit(), generally speaking, reduces controls to their absolute
minimum size (and their containers, if applicable). Remove the .Fit()
call, because it does what you don't want it to do. You could also
remove the .Layout() call, as it is done automatically in the SetSizer
call.

- Josiah

···

Paul Sijben <sijben@eemvalley.com> wrote:

Josiah,

thanks for all the advice, unfortunately, if I do not call Fit() I get
a panel of approx 10x10 pixels. Should I call something else to get the
panel to appear at the correct size?

Paul

Josiah Carlson wrote:

···

sijben@eemvalley.comwxPython-users-unsubscribe@lists.wxwidgets.orgwxPython-users-help@lists.wxwidgets.org

-- Paul Sijben tel: +31334566488
Eemvalley Systems & Technology fax: +31334557523
the Netherlands

http://eemvalley.com

Could we see the code where you create/use MyXRCPanel?

- Josiah

···

Paul Sijben <sijben@eemvalley.com> wrote:

Josiah,

thanks for all the advice, unfortunately, if I do not call Fit() I get a
panel of approx 10x10 pixels. Should I call something else to get the
panel to appear at the correct size?

Paul

Josiah Carlson wrote:
> Paul Sijben <sijben@eemvalley.com> wrote:
>
>> I am trying to get a wxTextCtrl to expand to the maximum available
>> space.Despite all my efforts I am rewarded with the _/minimum /_size!
>>
>> I have attached the XRC file. I am trying to get it drawn with the
>> following code:
>>
>> class MyXRCPanel(wx.Panel):
>> def __init__(self,parent,uibase,state):
>> self.params=(parent,uibase)
>> wx.Panel.__init__(self, parent,
>> style=wx.TAB_TRAVERSAL|wx.NO_BORDER|wx.EXPAND)
>> RESFILE="c:\\panel.xrc"
>> self.res = xrc.XmlResource(RESFILE)
>> print RESFILE,self.res
>> sizer = wx.BoxSizer(wx.VERTICAL)
>> self.panel = self.res.LoadPanel(self, "state%i"%state)
>> if self.panel==None:
>> print "ERROR could not get state%i, RESFILE=%s"%(state,RESFILE)
>> self.buttonEvents={}
>> sizer.Add(self.panel, 0, wx.EXPAND)
>> self.SetSizer(sizer)
>> self.Fit()
>> self.Layout()
>> def OnSize(evt, win=self):
>> win.panel.SetSize(evt.GetSize())
>>
>> I think I have set everything to expand. What I am doing wrong?
>>
>
> The wx.Panel.__init__(..., style=...|wx.EXPAND) won't do anything, or
> may do something wrong (wx.EXPAND is not a valid style).
>
> Get rid of the OnSize handler (which you didn't seem to bind in this
> code), it is unnecessary. The size handling and layout will be handled
> by the sizer.
>
> If your text control is a multi-line text control (created with the
> wx.TE_MULTILINE style), then you are going to need to pass a '1' to the
> sizer.Add call:
> sizer.Add(self.panel, 1, wx.EXPAND)
>
> Otherwise it will be as short as possible.
>
>
> Another issue is the following...
>
>> self.SetSizer(sizer)
>> self.Fit()
>> self.Layout()
>>
>
> The use of Fit(), generally speaking, reduces controls to their absolute
> minimum size (and their containers, if applicable). Remove the .Fit()
> call, because it does what you don't want it to do. You could also
> remove the .Layout() call, as it is done automatically in the SetSizer
> call.
>
> - Josiah
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
>

--
Paul Sijben tel: +31334566488
Eemvalley Systems & Technology fax: +31334557523
the Netherlands http://eemvalley.com

sure, I believe I cut and pasted everything below:

class Frame(wx.Frame):
    def __init__(self, parent=None, id=-1,
            pos=wx.DefaultPosition, title='my window'):
        size = (800,600)
        wx.Frame.__init__(self, parent, id, title, pos, size)
        self.nb = Notebook(self, -1, None)

class App(wx.App):
    def OnInit(self):
        self.semaphone=threading.Semaphore()
        self.frame = Frame()
        self.frame.Show()
        self.SetTopWindow(self.frame)
       
        w=self.frame
        bp=MyXRCPanel(w,"",10)
       
        w.Layout()
        w.Fit()

···

#
        return True

Josiah Carlson wrote:

Could we see the code where you create/use MyXRCPanel?

- Josiah

Paul Sijben <sijben@eemvalley.com> wrote:
  

Josiah,

thanks for all the advice, unfortunately, if I do not call Fit() I get a
panel of approx 10x10 pixels. Should I call something else to get the
panel to appear at the correct size?

Paul

Josiah Carlson wrote:
    

Paul Sijben <sijben@eemvalley.com> wrote:
  

I am trying to get a wxTextCtrl to expand to the maximum available
space.Despite all my efforts I am rewarded with the _/minimum /_size!

I have attached the XRC file. I am trying to get it drawn with the
following code:

class MyXRCPanel(wx.Panel):
    def __init__(self,parent,uibase,state):
        self.params=(parent,uibase)
        wx.Panel.__init__(self, parent,
style=wx.TAB_TRAVERSAL|wx.NO_BORDER|wx.EXPAND)
        RESFILE="c:\\panel.xrc"
        self.res = xrc.XmlResource(RESFILE)
        print RESFILE,self.res
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.panel = self.res.LoadPanel(self, "state%i"%state)
        if self.panel==None:
            print "ERROR could not get state%i, RESFILE=%s"%(state,RESFILE)
        self.buttonEvents={}
        sizer.Add(self.panel, 0, wx.EXPAND)
        self.SetSizer(sizer)
        self.Fit()
        self.Layout()
        def OnSize(evt, win=self):
            win.panel.SetSize(evt.GetSize())

I think I have set everything to expand. What I am doing wrong?
    

The wx.Panel.__init__(..., style=...|wx.EXPAND) won't do anything, or
may do something wrong (wx.EXPAND is not a valid style).

Get rid of the OnSize handler (which you didn't seem to bind in this
code), it is unnecessary. The size handling and layout will be handled
by the sizer.

If your text control is a multi-line text control (created with the
wx.TE_MULTILINE style), then you are going to need to pass a '1' to the
sizer.Add call:
    sizer.Add(self.panel, 1, wx.EXPAND)

Otherwise it will be as short as possible.

Another issue is the following...
  

        self.SetSizer(sizer)
        self.Fit()
        self.Layout()
    

The use of Fit(), generally speaking, reduces controls to their absolute
minimum size (and their containers, if applicable). Remove the .Fit()
call, because it does what you don't want it to do. You could also
remove the .Layout() call, as it is done automatically in the SetSizer
call.

- Josiah

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

--
Paul Sijben tel: +31334566488
Eemvalley Systems & Technology fax: +31334557523
the Netherlands http://eemvalley.com

--
Paul Sijben tel: +31334566488
Eemvalley Systems & Technology fax: +31334557523
the Netherlands http://eemvalley.com