[wxpython-users] three intern windows in one window
Abdessamad EL GON-NOUNI
abdessamadg at gmail.com
Fri May 16 13:06:24 PDT 2008
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=3D001
ID_ABOUT=3D101
ID_EXIT=3D110
class MainWindow(wx.Frame):
def __init__(self, title):
wx.Frame.__init__(self,None,wx.ID_ANY,'Construction reseau')
self.CreateStatusBar()
#setup du menu
filemenu =3D 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 =3D 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=3Dwx.Menu()
helpmenu.Append(3000, "HowTo", "What you should know")
filemenu.AppendSeparator()
helpmenu.Append(3100, "About", "Informations")
#creation du menu
menubar =3D wx.MenuBar()
menubar.Append(filemenu, "&File")
menubar.Append(editmenu, "&Edit")
menubar.Append(helpmenu, "&Help")
self.SetMenuBar(menubar)
#Inside windows
panel=3D wx.Panel(self, -1)
#creation du sizer
sizer =3D wx.GridBagSizer(hgap=3D4, vgap=3D4)
#creation des fenetres
status =3D wx.StaticText(panel, -1, 'Status')
sizer.Add(status, pos=3D(19,0), flag=3Dwx.BOTTOM, border=3D0)
fen2 =3D wx.TextCtrl(panel, -1, style=3Dwx.TE_MULTILINE)
sizer.Add(fen2, (20,0), (5,35), wx.EXPAND, 0)
envirTex =3D wx.StaticText(panel, -1, 'Environement')
sizer.Add(envirTex, pos=3D(0,0), flag=3Dwx.BOTTOM, border=3D0)
envir=3Dwx.StaticBox(panel, -1)
sizer.Add(envir, (1, 0), (18,35), wx.EXPAND, 0)
configTex =3D wx.StaticText(panel, -1, 'Configuration')
sizer.Add(configTex, pos=3D(0,36), flag=3Dwx.BOTTOM, border=3D0)
config=3Dwx.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 =3D ''
dlg =3D wx.FileDialog(self, "Choose a file", self.dirname, "", "*.*=
",
wx.OPEN)
if dlg.ShowModal() =3D=3D wx.ID_OK:
self.filename=3Ddlg.GetFilename()
self.dirname=3Ddlg.GetDirectory()
f=3Dopen(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=3Dwx.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=3Dself.i+1
def OnLink(self,event):
self.G.add_edge(self.j,self.j+1)
self.j=3Dself.j+1
def OnUpdate(self,event):
#ajout de l'image
if self.panel !=3DNone:
self.panel.Destroy()
self.panel =3D wx.Panel(self, -1)
sizerH=3D wx.BoxSizer(wx.HORIZONTAL)
draw(self.G)
P.savefig("construction.png")
img=3D wx.Image('construction.png',wx.BITMAP_TYPE_PNG)
bmp=3D wx.BitmapFromImage(img)
staticBmp=3D 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 =3D MainWindow(title=3D'Simulateur reseau')
self.MainWindow.Show()
self.SetTopWindow(self.MainWindow)
return True
app =3D 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?
2008/5/5 C M <cmpython at gmail.com>:
> On Sun, May 4, 2008 at 7:33 PM, Abdessamad EL GON-NOUNI
> <abdessamadg at gmail.com> wrote:
> > hello,
> > I'm making a graphic interface with wxpython and I want to have thr=
ee
> > internal windows, one will display an image which changes every time, t=
he
> > second will contain other wibdows which have buttons and text fields and
> the
> > third one is for showing some messages. I'm struggling with too many
> > tutorials and I found that flixBoxSizer is the best one for me but I
> didn't
> > understand very well how it works. I would like to have some help from
> you
> > please.
>
> Do you mean BoxSizer or FlexGridSizer? In any case, maybe what might
> be good is to look at the sizers tutorial on the wiki, and then ask
> specific
> questions to the list about what you don't understand. That tutorial and
> the
> examples in it is found here:
> http://wiki.wxpython.org/UsingSizers
> _______________________________________________
> wxpython-users mailing list
> wxpython-users at lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200805=
16/01200c9a/attachment.htm
More information about the wxpython-users
mailing list