three intern windows in one window

hi every body,
this is what I have written till now for my graphic interface:
from networkx import *
import pylab as P
import wx
from Simulateur import *
ID_OPEN=001
ID_ABOUT=101
ID_EXIT=110

class MainWindow(wx.Frame):
    def __init__(self, title):
        wx.Frame.__init__(self,None,wx.ID_ANY,'Construction reseau')
        self.CreateStatusBar()
        #setup du menu
        filemenu = wx.Menu()
        filemenu.Append(1000, "New", "New configuration")
        filemenu.Append(1100, "Open", "Open an existing configuration")
        filemenu.Append(1200, "Save", "Save configuration")
        filemenu.AppendSeparator()
        filemenu.Append(1300, "Exit", "Exit the programm")

        editmenu = wx.Menu()
        editmenu.Append(2000, "Ajouter Noeud", "Ajoute un noeud")
        editmenu.Append(2100, "Ajouter Lien", "Ajoute un lien")
        editmenu.Append(2200, "Mettre a jour", "Met a jour")

        helpmenu=wx.Menu()
        helpmenu.Append(3000, "HowTo", "What you should know")
        filemenu.AppendSeparator()
        helpmenu.Append(3100, "About", "Informations")

        #creation du menu
        menubar = wx.MenuBar()
        menubar.Append(filemenu, "&File")
        menubar.Append(editmenu, "&Edit")
        menubar.Append(helpmenu, "&Help")
        self.SetMenuBar(menubar)

       #Inside windows
        panel= wx.Panel(self, -1)

        #creation du sizer
        sizer = wx.GridBagSizer(hgap=4, vgap=4)

        #creation des fenetres
        status = wx.StaticText(panel, -1, 'Status')
        sizer.Add(status, pos=(19,0), flag=wx.BOTTOM, border=0)

        fen2 = wx.TextCtrl(panel, -1, style=wx.TE_MULTILINE)
        sizer.Add(fen2, (20,0), (5,35), wx.EXPAND, 0)

        envirTex = wx.StaticText(panel, -1, 'Environement')
        sizer.Add(envirTex, pos=(0,0), flag=wx.BOTTOM, border=0)

        envir=wx.StaticBox(panel, -1)
        sizer.Add(envir, (1, 0), (18,35), wx.EXPAND, 0)

        configTex = wx.StaticText(panel, -1, 'Configuration')
        sizer.Add(configTex, pos=(0,36), flag=wx.BOTTOM, border=0)

        config=wx.StaticBox(panel, -1)
        sizer.Add(config, (1, 36), (24,15), wx.EXPAND, 0)

        panel.SetSizerAndFit(sizer)

        self.Fit()

       #evenements
        wx.EVT_MENU(self,3100,self.OnAbout)
        wx.EVT_MENU(self,1100,self.OnOpen)
        wx.EVT_MENU(self,1300,self.OnExit)
        wx.EVT_MENU(self,2000,self.OnNode)
        wx.EVT_MENU(self,2100,self.OnLink)
        wx.EVT_MENU(self,2200,self.OnUpdate)
        self.Show(True)
        self.Centre()

    def OnOpen(self,event):
        #Open a file
        self.dirname = ''
        dlg = wx.FileDialog(self, "Choose a file", self.dirname, "", "*.*",
wx.OPEN)
        if dlg.ShowModal() == wx.ID_OK:
            self.filename=dlg.GetFilename()
            self.dirname=dlg.GetDirectory()
            f=open(os.path.join(self.dirname,self.filename),'r')
            self.control.SetValue(f.read())
            f.close()
        dlg.Destroy()

    def OnSave(selfself, event):
        pass

    def OnNew(selfself, event):
        pass

    def OnExit(self,event):
        self.Close(True)

    def OnAbout(self,event):
        d=wx.MessageDialog(self, "Simulateur de reseaux de machines en
Python \nAuteurs : Chollet Mathieu, Cladiere Pierre-Yves\nEl Gon Nouni
Abdessamaed \nProjet DEV 2008 \nTELECOM Bretagne", "A propos", wx.OK)
        d.ShowModal()
        d.Destroy()

    def OnNode(self,event):
        self.G.add_node(self.i)
        self.i=self.i+1

    def OnLink(self,event):
        self.G.add_edge(self.j,self.j+1)
        self.j=self.j+1

    def OnUpdate(self,event):
        #ajout de l'image
        if self.panel !=None:
            self.panel.Destroy()
        self.panel = wx.Panel(self, -1)
        sizerH= wx.BoxSizer(wx.HORIZONTAL)
        draw(self.G)
        P.savefig("construction.png")
        img= wx.Image('construction.png',wx.BITMAP_TYPE_PNG)
        bmp= wx.BitmapFromImage(img)
        staticBmp= wx.StaticBitmap(self,wx.ID_ANY,bmp)
        sizerH.Add(staticBmp)
        self.SetAutoLayout(1)
        sizerH.Fit(self)

        self.Center()
        self.Show(True)

class MonApp(wx.App):
    def OnInit(self):
         self.MainWindow = MainWindow(title='Simulateur reseau')
         self.MainWindow.Show()
         self.SetTopWindow(self.MainWindow)
         return True

app = MonApp()
app.MainLoop()

Now I have to add some fields in the staticBox "environement" but I tryied
without results. I didn't know how to pass the staticBox as a parent to
another static box a texCtrl or a button. any idea please?

Reading this will help I hope:

From the wxWidgets API found at

http://docs.wxwidgets.org/2.8.6/wx_wxstaticbox.html

wxStaticBox

A static box is a rectangle drawn around other panel items to denote a
logical grouping of items.

Please note that a static box should not be used as the parent for the
controls it contains, instead they should be siblings of each other.
Although using a static box as a parent might work in some versions of
wxWidgets, it results in a crash under, for example, wxGTK.

Also, please note that because of this, the order in which you create
new controls is important. Create your wxStaticBox control before any
siblings that are to appear inside the wxStaticBox in order to
preserve the correct Z-Order of controls.

···

On Fri, May 16, 2008 at 4:06 PM, Abdessamad EL GON-NOUNI <abdessamadg@gmail.com> wrote:

Hello. Unfortunately, I don't think there is any easy way to take a layout and
automatically convert it to a flexible layout. This is really the job
sizers do.
It is understandable that you may not want to change everything now, but if
you want an automatically resizing set of panels (what you are calling "intern
windows"), you have to.

I went through this resistance to learning sizers, too. But the consensus is
if you are going to make more than just this application, you are much better
off learning how to use sizers now and then always using them from then on.
Not only do they allow automatic resizing, but they allow your apps to look
good across platforms. And ultimately I think they save you work.

Here's the tutorial from the wxPython wiki:
http://wiki.wxpython.org/UsingSizers

As others have recently said, basically if you just start thinking in terms of
a group of (resizble) boxes within boxes, that is what sizers are. You can
do many things just using BoxSizer. And you can ask for help here, too.

Che
Che

···

On Sat, May 17, 2008 at 3:47 PM, EL GON NOUNI <abdessamadg@gmail.com> wrote:

C M a écrit :

Reading this will help I hope:

>From the wxWidgets API found at
http://docs.wxwidgets.org/2.8.6/wx_wxstaticbox.html

wxStaticBox

A static box is a rectangle drawn around other panel items to denote a
logical grouping of items.

Please note that a static box should not be used as the parent for the
controls it contains, instead they should be siblings of each other.
Although using a static box as a parent might work in some versions of
wxWidgets, it results in a crash under, for example, wxGTK.

Also, please note that because of this, the order in which you create
new controls is important. Create your wxStaticBox control before any
siblings that are to appear inside the wxStaticBox in order to
preserve the correct Z-Order of controls.
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

thank you very much C M, I know now how to use panels in order to organize
my window. here is my new code:

from networkx import *
import pylab as P
from Simulateur import *
ID_OPEN=001
ID_ABOUT=101
ID_EXIT=110
import wx

class InterfaceGraphique(wx.Frame):
  def __init__(self, titre):
      wx.Frame.__init__(self, None, -1, title = titre, size=(1100, 800))
      self.panel3 = wx.Panel(self, -1,pos=(0,550), size=(1100,200))
            self.etiquette3 = wx.StaticText(self.panel3, -1, "Status")
      self.etiquette31 = wx.TextCtrl(self.panel3, -1, pos=(0, 15),
size=(1100,145),style=wx.TE_MULTILINE)

            self.panel2 = wx.Panel(self, -1,pos=(700,0),size=(400,550))
      self.etiquette2 = wx.StaticText(self.panel2, -1, "Configuration")
      self.box2 = wx.StaticBox(self.panel2, -1, pos=(0,10), size=(400, 530))
      self.button1 = wx.Button(self.panel2, -1, pos=(0, 481), size=(190,30),
label='Apply changes')
      self.button2 = wx.Button(self.panel2, -1, pos=(0, 510), size=(200,30),
label='Change environement')
      self.button3 = wx.Button(self.panel2, -1, pos=(189, 481),
size=(210,30), label='Change connexion parameters')
      self.button4 = wx.Button(self.panel2, -1, pos=(199, 510),
size=(200,30), label='Start simulation')
            self.etiquette3 = wx.StaticText(self.panel2, -1, pos=(1,18),
label='Local data')
      self.box3 = wx.StaticBox(self.panel2, -1, pos=(0,10), size=(400, 100))
            self.etiquette4 = wx.StaticText(self.panel2, -1, pos=(1,115),
label='Node')
      self.box4 = wx.StaticBox(self.panel2, -1, pos=(0,105), size=(400,
180))
                  self.etiquette5 = wx.StaticText(self.panel2, -1,
pos=(1,288), label='Environement')
      self.box5 = wx.StaticBox(self.panel2, -1, pos=(0,280), size=(400,
200))

      self.panel1 = wx.Panel(self, -1,pos=(0,0),size=(700,550))
      self.etiquette2 = wx.StaticText(self.panel1, -1, "Environement state")
      self.box2 = wx.StaticBox(self.panel1, -1, pos=(0,10), size=(690, 530))

      """
      sizer = wx.GridBagSizer(0,0,vgap=4,hgap=4)
      sizer.Add(self.etiquette31,pos=(0,500), (500,800),
flag=wx.BOTTOM,0)"""

            filemenu = wx.Menu()
      filemenu.Append(1000, "New", "New configuration")
      filemenu.Append(1100, "Open", "Open an existing configuration")
      filemenu.Append(1200, "Save", "Save configuration")
      filemenu.AppendSeparator()
      filemenu.Append(1300, "Exit", "Exit the programm")
            editmenu = wx.Menu()
      editmenu.Append(2000, "Ajouter Noeud", "Ajoute un noeud")
      editmenu.Append(2100, "Ajouter Lien", "Ajoute un lien")
      editmenu.Append(2200, "Mettre a jour", "Met a jour")
            helpmenu=wx.Menu()
      helpmenu.Append(3000, "HowTo", "What you should know")
      filemenu.AppendSeparator()
      helpmenu.Append(3100, "About", "Informations")
            #creation du menu
      menubar = wx.MenuBar()
      menubar.Append(filemenu, "&File")
      menubar.Append(editmenu, "&Edit")
      menubar.Append(helpmenu, "&Help")
      self.SetMenuBar(menubar)

      #evenements
      wx.EVT_MENU(self,3100,self.OnAbout)
      wx.EVT_MENU(self,1100,self.OnOpen)
      wx.EVT_MENU(self,1300,self.OnExit)
      wx.EVT_MENU(self,2000,self.OnNode)
      wx.EVT_MENU(self,2100,self.OnLink)
      wx.EVT_MENU(self,2200,self.OnUpdate)
      self.Show(True)
      self.Centre()

  def OnOpen(self,event):
      #Open a file
          self.dirname = ''
          dlg = wx.FileDialog(self, "Choose a file", self.dirname, "",
"*.*", wx.OPEN)
          if dlg.ShowModal() == wx.ID_OK:
              self.filename=dlg.GetFilename()
              self.dirname=dlg.GetDirectory()
              f=open(os.path.join(self.dirname,self.filename),'r')
              self.control.SetValue(f.read())
              f.close()
          dlg.Destroy()

  def OnSave(selfself, event):
      pass
    def OnNew(selfself, event):
      pass
      def OnExit(self,event):
      self.Close(True)
        def OnAbout(self,event):
      d=wx.MessageDialog(self, "Simulateur de reseaux de machines en Python
\nAuteurs : Chollet Mathieu, Cladiere Pierre-Yves\nEl Gon Nouni Abdessamaed
\nProjet DEV 2008 \nTELECOM Bretagne", "A propos", wx.OK)
      d.ShowModal()
      d.Destroy()
    def OnNode(self,event):
      self.G.add_node(self.i)
      self.i=self.i+1
        def OnLink(self,event):
      self.G.add_edge(self.j,self.j+1)
      self.j=self.j+1
        def OnUpdate(self,event):
      #ajout de l'image
      if self.panel !=None:
          self.panel.Destroy()
      self.panel = wx.Panel(self, -1)
      sizerH= wx.BoxSizer(wx.HORIZONTAL)
      draw(self.G)
      P.savefig("construction.png")
      img= wx.Image('construction.png',wx.BITMAP_TYPE_PNG)
      bmp= wx.BitmapFromImage(img)
      staticBmp= wx.StaticBitmap(self,wx.ID_ANY,bmp)
      sizerH.Add(staticBmp)
      self.SetAutoLayout(1)
      sizerH.Fit(self)
            self.Center()
      self.Show(True)

class MonApp(wx.App):
  def OnInit(self):
      fen = InterfaceGraphique("Simulateur reseau")
      fen.Show(True)
      self.SetTopWindow(fen)
      return True

app = MonApp()
app.MainLoop()

the problem now is that I have to specify exactely the position and the size
of every thing in the window, and the size of the intern windows dont change
if I change the main window size. I know that I have to use sizers, but I
didn't understand how they work, and I dont want to change every thing now.
so if there is a simple way to make windows flexible, I'll be greatful to
hear it from you.
thanks