panels not resing help

Hi the code below attempts to added a second sub panel if buffer is
selected using the choice control. It sort of works but you need to drag
the frame a bit for the panels to expand to fill it.

1 How can I do this without dragging the frame.

2 Can I create and add sub panels entirely within the event function cos
I've got quite a few or do I have to add them all and hide them, and
just .Show() the ones I want?

Any help much appreciated!

<code>
#!/usr/bin/env python
import wx
import string

class MyDataStruct:
   def __init__(self, arg_1):
      self.arg_1 = arg_1

my_list = []

# the sizer stuff is not working here but does in dialog.py why?
# took all sizer stuff out and put it back and it worked? compiler seems
a bit flak
# this is for standard stuff
class MySubPanel_1(wx.Panel):
   def __init__(self, parent):
      wx.Panel.__init__(self, parent, id=-1)
      self.SetBackgroundColour("GREEN")

      # choice of set type control
      st_set_type = wx.StaticText(self, -1, 'set_type ')
      set_type_list = ['machine', 'buffer', 'fixed conveyor', 'free
conveyor', 'track_pt', 'vehicle',]
      #not safe so stick with unique ids
      choice_set_type = wx.Choice(self, 2, (85, 18),
choices=set_type_list)
      
      # this is all the sizers
      hbox_set_type = wx.BoxSizer(wx.HORIZONTAL)
      hbox_set_type.Add(st_set_type, 0, wx.LEFT, 30)
      hbox_set_type.Add(choice_set_type, 0, 50 )

      vbox = wx.BoxSizer(wx.VERTICAL) #all controls positioned
in here
      vbox.Add(hbox_set_type, 0, wx.TOP, 10)
      self.vbox = vbox

# this is for custom stuff
class MySubPanel_2(wx.Panel):
   def __init__(self, parent):
      wx.Panel.__init__(self, parent, id=-1)
      self.SetBackgroundColour("RED")

      # this is all the sizers
      hbox_cust_1 = wx.BoxSizer(wx.HORIZONTAL)
      hbox_cust_2 = wx.BoxSizer(wx.HORIZONTAL)

      st_cust_1 = wx.StaticText(self, -1, 'custom stuff')
      hbox_cust_1.Add(st_cust_1, 0, wx.LEFT, 30)

      vbox = wx.BoxSizer(wx.VERTICAL) #all controls positioned
in here
      vbox.Add(hbox_cust_1, 0, wx.TOP, 10)

#this is a panel that, itself, contains 2 child panels
class MyPanel(wx.Panel):
   def __init__(self, parent):
      wx.Panel.__init__(self, parent, id=-1)
     
      #create some members
      self.parent = parent
      self.mydatastruct = MyDataStruct(3)
      self.my_ctr = 0

      #create sub_panels
      panel1 = MySubPanel_1(self) #self passes this object as parent
      panel2 = MySubPanel_2(self)

      # button to create set
      button_create_set = wx.Button(self, 1, 'create set')
      self.Bind(wx.EVT_BUTTON, self.create_set, id=1) #how does this
know which button? Is it by id=1 ?

      #always stick with a unique id
      self.Bind(wx.EVT_CHOICE, self.OnSetTypeChoice, id=2)

      sizer = wx.BoxSizer(wx.VERTICAL) #replaced by sizer
      sizer.Add(panel1, 1, wx.EXPAND)
      sizer.Add(panel2, 1, wx.EXPAND)
      sizer.Add(button_create_set, 0, wx.ALIGN_CENTER | wx.TOP |
wx.BOTTOM, 20)
      sizer.Hide(panel2, recursive=True)

      self.SetSizer(sizer)
      self.SetAutoLayout(1)
      sizer.Fit(self)
      sizer.SetSizeHints(self)
      
      self.panel2 = panel2
      self.sizer = sizer

   #this adds the custom ctrls dependent upon what type of set you
choose via the set type choice ctrl
   def OnSetTypeChoice(self, event):
      choice = event.GetString()
      if choice == "machine":
         self.parent.SetTitle(choice) #test
      if choice == "buffer":
         #i think i need a frame sizer and that this would do it ie this
needs to be in the frame
         self.parent.SetTitle(choice)
         self.sizer.Show(self.panel2, recursive=True)
         self.SetSizer(self.sizer)
         self.SetAutoLayout(1)
         self.sizer.Fit(self)
      if choice == "fixed conveyor":
         self.parent.SetTitle(choice)
      if choice == "free conveyor":
         self.parent.SetTitle(choice)
      if choice == "track_pt":
         self.parent.SetTitle(choice)
      if choice == "vehicle":
         self.parent.SetTitle(choice)

   # event for button that creates set
   #this button needs to be at a higher level cos it needs to get stuff
from all panels - ie move it
   def create_set(self, event):
      if self.mydatastruct.arg_1 == 3:
         self.my_ctr = self.my_ctr + 1
         obj = MyDataStruct(self.my_ctr)
         my_list.append(obj)
         my_str = "good"
         for x in my_list:
            my_str = my_str + str(x.arg_1 * 2) + ","
         self.parent.SetTitle(my_str)
      else:
         self.parent.SetTitle("bad")
          
class MyFrame(wx.Frame):
   def __init__(self):
      wx.Frame.__init__(self, None, -1, 'Sizer Demo', size=(400,200))
      panel = MyPanel(self)
      panel.SetBackgroundColour("BLACK")

class MyApp(wx.App):
   def OnInit(self):
      frame = MyFrame()
      frame.Show(1)
      return 1

if __name__ == '__main__':
      app = MyApp(0)
      app.MainLoop()

</code>

Hi all,
As I reading through WxPython In Action, there is a whole chapter talking
about PyCrust, that looks like exactly what I need, after being pretty
frustrated by Pythonwin. So I downloaded the Demo and Tool kit from WxPython
and started PyCrust but I can't open anyfile 'cause all the buttons except
for "save" and "exit" are greyed out.

Is this the right thing I downloaded? How to start the PyCrust properly, for
a new design, for example?

Thanks in advance,
Song

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.15/848 - Release Date: 13/06/2007
12:50 PM

Hi,

Song Cao wrote:

Hi all,
As I reading through WxPython In Action, there is a whole chapter talking
about PyCrust, that looks like exactly what I need, after being pretty
frustrated by Pythonwin. So I downloaded the Demo and Tool kit from WxPython
and started PyCrust but I can't open anyfile 'cause all the buttons except
for "save" and "exit" are greyed out.

Is this the right thing I downloaded? How to start the PyCrust properly, for
a new design, for example?
  

PyCrust is "just" a shell, maybe you want to try PyAlaMode which is included with the demo too.

You might also want to look at other editors and IDE's (check this wiki page: http://wiki.wxpython.org/wxPythonPit_Apps#head-fe56252572360991069b3a7a15d1a4a26fcbd026 )

Werner

Song,

I have used SciTE with great success to edit many different languages
(it is even great for taking notes). If you go that route, there are
also some lines you can add to your code to redirect simple output to
the SciTE output Window to help in troubleshooting.

thom

···

-----Original Message-----
From: Werner F. Bruhin [mailto:werner.bruhin@free.fr]
Sent: Thursday, June 14, 2007 9:27 AM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] How to start PyCrust?

Hi,

Song Cao wrote:

Hi all,
As I reading through WxPython In Action, there is a whole chapter
talking about PyCrust, that looks like exactly what I need, after
being pretty frustrated by Pythonwin. So I downloaded the Demo and
Tool kit from WxPython and started PyCrust but I can't open anyfile
'cause all the buttons except for "save" and "exit" are greyed out.

Is this the right thing I downloaded? How to start the PyCrust
properly, for a new design, for example?
  

PyCrust is "just" a shell, maybe you want to try PyAlaMode which is
included with the demo too.

You might also want to look at other editors and IDE's (check this wiki
page:
http://wiki.wxpython.org/wxPythonPit_Apps#head-fe56252572360991069b3a7a1
5d1a4a26fcbd026
)

Werner

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

me wrote:

Hi the code below attempts to added a second sub panel if buffer is
selected using the choice control. It sort of works but you need to drag
the frame a bit for the panels to expand to fill it.

1 How can I do this without dragging the frame.

In this code:

       if choice == "buffer":
          #i think i need a frame sizer and that this would do it ie this needs to be in the frame
          self.parent.SetTitle(choice)
          self.sizer.Show(self.panel2, recursive=True)
          self.SetSizer(self.sizer)
          self.SetAutoLayout(1)
          self.sizer.Fit(self)

Remove the last two lines and add this one:

          self.Layout()

2 Can I create and add sub panels entirely within the event function cos
I've got quite a few or do I have to add them all and hide them, and
just .Show() the ones I want?

They can be created on the fly if you need to. You'll also have to manage adding the new panels to the sizer, etc. You can get rid of the old panels by calling their Destroy() method.

···

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

Try SPE Python IDE from subversion, it contains the pycrust shell:

Stani

···

--

Song Cao schreef:

Hi all,
As I reading through WxPython In Action, there is a whole chapter talking
about PyCrust, that looks like exactly what I need, after being pretty
frustrated by Pythonwin. So I downloaded the Demo and Tool kit from WxPython
and started PyCrust but I can't open anyfile 'cause all the buttons except
for "save" and "exit" are greyed out.

Is this the right thing I downloaded? How to start the PyCrust properly, for
a new design, for example?

Thanks in advance,
Song

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.15/848 - Release Date: 13/06/2007
12:50 PM

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

Hi Stani,
I tried the SPE but it seems having problem running scripts with long path
name (with [Space] .or. ['] in the path). Here is an example of error
message:

""C:\Documents and Settings\Song\My
Documents\PythonTutorial\FrameWithImage.py""
C:\Python24\python.exe: can't open file 'C:\Documents': [Errno 2] No such
file or directory
Script terminated.

Song

···

-----Original Message-----
From: Stani's Python Editor [mailto:spe.stani.be@gmail.com]
Sent: June 14, 2007 8:34 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] How to start PyCrust?

Try SPE Python IDE from subversion, it contains the pycrust shell:
http://pythonide.blogspot.com/2007/02/how-to-download-latest-spe-from_26.htm
l

Stani
--

Song Cao schreef:

Hi all,
As I reading through WxPython In Action, there is a whole chapter talking
about PyCrust, that looks like exactly what I need, after being pretty
frustrated by Pythonwin. So I downloaded the Demo and Tool kit from

WxPython

and started PyCrust but I can't open anyfile 'cause all the buttons except
for "save" and "exit" are greyed out.

Is this the right thing I downloaded? How to start the PyCrust properly,

for

a new design, for example?

Thanks in advance,
Song

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.15/848 - Release Date: 13/06/2007
12:50 PM

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

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

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.15/848 - Release Date: 13/06/2007
12:50 PM

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.17/850 - Release Date: 15/06/2007
11:31 AM

I'll look at it.

Stani

Song Cao schreef:

···

Hi Stani,
I tried the SPE but it seems having problem running scripts with long path
name (with [Space] .or. ['] in the path). Here is an example of error
message:

""C:\Documents and Settings\Song\My
Documents\PythonTutorial\FrameWithImage.py""
C:\Python24\python.exe: can't open file 'C:\Documents': [Errno 2] No such
file or directory
Script terminated.

Song

-----Original Message-----
From: Stani's Python Editor [mailto:spe.stani.be@gmail.com]
Sent: June 14, 2007 8:34 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] How to start PyCrust?

Try SPE Python IDE from subversion, it contains the pycrust shell:
http://pythonide.blogspot.com/2007/02/how-to-download-latest-spe-from_26.htm
l

Stani
--
http://pythonide.stani.be

Song Cao schreef:

Hi all,
As I reading through WxPython In Action, there is a whole chapter talking
about PyCrust, that looks like exactly what I need, after being pretty
frustrated by Pythonwin. So I downloaded the Demo and Tool kit from

WxPython

and started PyCrust but I can't open anyfile 'cause all the buttons except
for "save" and "exit" are greyed out.

Is this the right thing I downloaded? How to start the PyCrust properly,

for

a new design, for example?

Thanks in advance,
Song

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.15/848 - Release Date: 13/06/2007
12:50 PM

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

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

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.15/848 - Release Date: 13/06/2007
12:50 PM

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.17/850 - Release Date: 15/06/2007
11:31 AM

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