wx Beginner Layout

Hi !

1.)
I want to create a from with 3 panels.
The two top panels is have fixed size. Height is as needed by inner
content, Width is expand with form.
The Bottom panel is AlClient (Delphi) -> it is fill the free area.

What I do wrong in the resizer ?

2.)
I want to disable some buttons, but the
self.btn_close.Enabled=False is not working.
What I must do to disable it ?

Hi and thx:
KK

from wxPython.wx import *

ID_START = wxNewId()
ID_STOP = wxNewId()
ID_CLOSE = wxNewId()
ID_SPINW = wxNewId()
ID_SPINS = wxNewId()
ID_SPINB = wxNewId()

class MyApp(wxApp):
def OnInit(self):
   # Frame + panels
   self.frame = wxFrame(NULL, -1, 'NeuroLotto',wxDefaultPosition, (400,
400))
   optpanel=wxPanel(self.frame,-1,wxDefaultPosition, wxDefaultSize)
   optpanel.Height=120
   toppanel=wxPanel(self.frame,-1,wxDefaultPosition, wxDefaultSize)
   toppanel.Height=24
   clientpanel=wxPanel(self.frame,-1,wxDefaultPosition, wxDefaultSize)
   panelbox = wxBoxSizer(wxVERTICAL)
   panelbox.Add(optpanel, 1, wxTOP|wxEXPAND|wxALL)
   panelbox.Add(toppanel, 1, wxTOP|wxALL)
   panelbox.Add(clientpanel, 1, wxEXPAND|wxALL)
   # Options
   self.optiongroup=wxPanel(optpanel,-1)
   box_group=wxBoxSizer(wxHORIZONTAL)
   box_group.Add(self.optiongroup,1,wxEXPAND|wxALL,8)
   optpanel.SetSizer(box_group)
   txt1=wxStaticText(self.optiongroup,-1,'Week count')
   txt2=wxStaticText(self.optiongroup,-1,'Succ count')
   txt3=wxStaticText(self.optiongroup,-1,'Break count')
   self.spin_w=wxSpinCtrl(self.optiongroup,-1,"1")
   self.spin_w.SetRange(1, 100);
   self.spin_w.SetValue(1)

   self.spin_s=wxSpinCtrl(self.optiongroup,-1,"1")
   self.spin_s.SetRange(1,5);
   self.spin_s.SetValue(1)

   self.spin_b=wxSpinCtrl(self.optiongroup,-1,"1000000")
   self.spin_b.SetRange(1, 1000000);
   self.spin_b.SetValue(1)

   box_igrp=wxGridSizer(3,2)
   box_igrp.AddMany([
    (txt1,1,wxEXPAND|wxALL,4),
    (self.spin_w,1,wxEXPAND|wxALL,4),
    (txt2,1,wxEXPAND|wxALL,4),
    (self.spin_s,1,wxEXPAND|wxALL,4),
    (txt3,1,wxEXPAND|wxALL,4),
    (self.spin_b,1,wxEXPAND|wxALL,4)])

   self.optiongroup.SetSizer(box_igrp)
   # Buttons
   self.btn_start = wxButton(toppanel, ID_START, 'Start')
   EVT_BUTTON(self, ID_START, self.onStartClick)
   self.btn_stop = wxButton(toppanel, ID_STOP, 'Stop')
   #self.btn_stop.Show(False)
   EVT_BUTTON(self, ID_STOP, self.onStopClick)
   self.btn_close = wxButton(toppanel, ID_CLOSE, 'Close')
   EVT_BUTTON(self, ID_CLOSE, self.onCloseClick)
   box_btns=wxBoxSizer(wxHORIZONTAL)
   box_btns.Add(self.btn_start,1,wxEXPAND|wxALL,8)
   box_btns.Add(self.btn_stop,1,wxEXPAND|wxALL,8)
   box_btns.Add(self.btn_close,1,wxEXPAND|wxALL,8)
   toppanel.SetSizer(box_btns)
   self.memo=wxTextCtrl(clientpanel,-1,size=(200, 100),
style=wxTE_MULTILINE)
   box_mem=wxBoxSizer(wxVERTICAL)
   box_mem.Add(self.memo,1,wxEXPAND|wxALL,8)
   clientpanel.SetSizer(box_mem)

   # Layout
   self.frame.SetAutoLayout(true)
   self.frame.SetSizer(panelbox)
   self.frame.Show(true)
   self.SetTopWindow(self.frame)
   return true
def onStartClick(self, event):
   print 'Hello!', event.GetId()
def onStopClick(self, event):
   print 'Hello!', event.GetId()
def onCloseClick(self, event):
   self.frame.Show(false)
def OnSpinW(self, event):
   self.text_w.SetValue(str(event.GetPosition()))
def OnSpinS(self, event):
   self.text_s.SetValue(str(event.GetPosition()))
def OnSpinB(self, event):
   self.text_b.SetValue(str(event.GetPosition()))

app = MyApp(0)
app.MainLoop()

Krisztian Kepes wrote:

Hi !

1.)
I want to create a from with 3 panels.
The two top panels is have fixed size. Height is as needed by inner
content, Width is expand with form.
The Bottom panel is AlClient (Delphi) -> it is fill the free area.

What I do wrong in the resizer ?

You need to tell the sizer what to do about the size of toppanel. You can either give it either the WXEXPAND ot wxADJUST_MINSIZE flag when adding it to the panelbox sizer, or you can ensure that the sizer knows what it's minimal size should be, like this:

panelbox.SetItemMinSize(toppanel, box_btns.GetMinSize())

2.)
I want to disable some buttons, but the
self.btn_close.Enabled=False is not working.
What I must do to disable it ?

self.btn_close.Enable(False) (or just self.btn_close.Disable())

You need to call the methods, not just assume that there are properties that can be set.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!