wx.TextCtrl not showing correctly

Hi all, sorry for the vague subject.

I have the below window, which should simple have two output fields. The main output field (.output), should fill up most of the screen at the top, with .entry, and it's associated label at the bottom.

Instead, what I am told is happening is that .output is sitting in the top left corner of the window, although my frame seems to be filling up the rest of the screen.

Any thoughts?

Here is the code I'm using. Bits have been chopped out, because it's quite a lot otherwise, but it's all under the hood stuff, properties and amenu bar, which shouldn't impact the layout.

def WorldFrame(wx.Frame):
  def __init__(self, filename = None):
   super(WorldFrame, self).__init__(None)
   self.panel = wx.Panel(self)
   s = wx.BoxSizer(wx.VERTICAL)
   self.output = TextCtrl(self.panel)
   self.statusBar = self.CreateStatusBar()
   s1 = wx.BoxSizer(wx.HORIZONTAL)
   self.prompt = wx.StaticText(self.panel, label = 'Entry')
   self.entry = wx.TextCtrl(self.panel, style = wx.TE_RICH|wx.TE_PROCESS_ENTER)
   self.entry.SetFocus()
   s1.Add(self.prompt, 0, wx.EXPAND)
   s1.Add(self.entry, 1, wx.EXPAND)
   s.Add(self.output, 1, wx.EXPAND)
   s.Add(s1, 0, wx.EXPAND)
   self.SetSizerAndFit(s)
   self.Maximize(True)
   self.Show(True)

Cheers in advance,

You are seting the sizer s to the frame in the line self.SetSizerAndFit(s), but not using a frame sizer, you need to set sizer s to the panel using self.panel.SetSizerAndFit(s) instead
Full runnable code

import wx

class WorldFrame(wx.Frame):

def __init__(self, filename=None):
    super(WorldFrame, self).__init__(None)
    self.panel = wx.Panel(self)
    s = wx.BoxSizer(wx.VERTICAL)
    self.output = wx.TextCtrl(self.panel)
    self.statusBar = self.CreateStatusBar()
    s1 = wx.BoxSizer(wx.HORIZONTAL)
    self.prompt = wx.StaticText(self.panel, label='Entry')
    self.entry = wx.TextCtrl(
        self.panel, style=wx.TE_RICH | wx.TE_PROCESS_ENTER)
    self.entry.SetFocus()
    s1.Add(self.prompt, 0, wx.EXPAND)
    s1.Add(self.entry, 1, wx.EXPAND)
    s.Add(self.output, 1, wx.EXPAND)
    s.Add(s1, 0, wx.EXPAND)
    self.panel.SetSizerAndFit(s)
    self.Maximize(True)
    self.Show(True)

if name == ‘main’:
app = wx.App(False)
WorldFrame(None)
app.MainLoop()

``

···

On Wednesday, December 24, 2014 12:27:06 PM UTC, Chris Norman wrote:

Hi all, sorry for the vague subject.

I have the below window, which should simple have two output fields. The
main output field (.output), should fill up most of the screen at the
top, with .entry, and it’s associated label at the bottom.

Instead, what I am told is happening is that .output is sitting in the
top left corner of the window, although my frame seems to be filling up
the rest of the screen.

Any thoughts?

Here is the code I’m using. Bits have been chopped out, because it’s
quite a lot otherwise, but it’s all under the hood stuff, properties
and amenu bar, which shouldn’t impact the layout.

def WorldFrame(wx.Frame):

def init(self, filename = None):

super(WorldFrame, self).init(None)

self.panel = wx.Panel(self)

s = wx.BoxSizer(wx.VERTICAL)

self.output = TextCtrl(self.panel)

self.statusBar = self.CreateStatusBar()

s1 = wx.BoxSizer(wx.HORIZONTAL)

self.prompt = wx.StaticText(self.panel, label = ‘Entry’)

self.entry = wx.TextCtrl(self.panel, style =
wx.TE_RICH|wx.TE_PROCESS_ENTER)

self.entry.SetFocus()

s1.Add(self.prompt, 0, wx.EXPAND)

s1.Add(self.entry, 1, wx.EXPAND)

s.Add(self.output, 1, wx.EXPAND)

s.Add(s1, 0, wx.EXPAND)

self.SetSizerAndFit(s)

self.Maximize(True)

self.Show(True)

Cheers in advance,

Thank you very much.

I've made the chage, but no clue as it's worked or not, since the

control has always reported the right size to my screen reader.

Thank you very much for the help.

Take care, and merry christmas to all,
···

On 24/12/2014 14:30, Yoriz wrote:

    On Wednesday, December 24, 2014 12:27:06 PM UTC, Chris Norman

wrote:

      Hi all,

sorry for the vague subject.

      I have the below window, which should simple have two output

fields. The

      main output field (.output), should fill up most of the screen

at the

      top, with .entry, and it's associated label at the bottom.




      Instead, what I am told is happening is that .output is

sitting in the

      top left corner of the window, although my frame seems to be

filling up

      the rest of the screen.




      Any thoughts?




      Here is the code I'm using. Bits have been chopped out,

because it’s

      quite a lot otherwise, but it's all under the hood stuff,

properties

      and  amenu bar, which shouldn't impact the layout.




      def WorldFrame(wx.Frame):


        def __init__(self, filename = None):


         super(WorldFrame, self).__init__(None)


         self.panel = wx.Panel(self)


         s = wx.BoxSizer(wx.VERTICAL)


         self.output = TextCtrl(self.panel)


         self.statusBar = self.CreateStatusBar()


         s1 = wx.BoxSizer(wx.HORIZONTAL)


         self.prompt = wx.StaticText(self.panel, label = 'Entry')


         self.entry = wx.TextCtrl(self.panel, style =

      wx.TE_RICH|wx.TE_PROCESS_          ENTER)


         self.entry.SetFocus()


         s1.Add(self.prompt, 0, wx.EXPAND)


         s1.Add(self.entry, 1, wx.EXPAND)


         s.Add(self.output, 1, wx.EXPAND)


         s.Add(s1, 0, wx.EXPAND)


         self.SetSizerAndFit(s)


         self.Maximize(True)


         self.Show(True)






      Cheers in advance,

You are seting the sizer s to the frame in the line self.SetSizerAndFit(s) ,
but not using a frame sizer, you need to set sizer s to the
panel using self.panel.SetSizerAndFit(s) instead

      Full *runnable* code

import wx

            class WorldFrame(wx.Frame):



                  def
              __init__(self,
              filename=None):

                      super(WorldFrame, self).__init__(None)

                      self.                panel

= wx.Panel(self)

                      s = wx.BoxSizer(wx.VERTICAL)

                      self.                output

= wx.TextCtrl(self.panel)

                      self.                statusBar

= self.CreateStatusBar()

                      s1 = wx.BoxSizer(wx.HORIZONTAL)

                      self.                prompt

= wx.StaticText(self.panel, label=‘Entry’)

                      self.                entry

= wx.TextCtrl(

                          self.panel, style=wx.                TE_RICH

| wx.TE_PROCESS_ENTER)

                      self.entry.SetFocus()

                      s1.Add(self.prompt, 0, wx.EXPAND)

                      s1.Add(self.entry, 1, wx.EXPAND)

                      s.Add(self.output, 1, wx.EXPAND)

                      s.Add(s1, 0, wx.EXPAND)

                      self.panel.SetSizerAndFit(s)

                      self.Maximize(True)

                      self.Show(True)





            if
              __name__ == '__main__':

                  app = wx.App(False)

                  WorldFrame(None)

                  app.MainLoop()

``

  You received this message because you are subscribed to the Google

Groups “wxPython-users” group.

  To unsubscribe from this group and stop receiving emails from it,

send an email to wxpython-users+unsubscribe@googlegroups.com.

  For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).