Hi Doni,
I succeed to get your code. It seems you are new to the
wxPython club.
Like you I was a vb (3 to 6) user, one day I switched to
Python and wxPython, I never regret this step. Python is
a clean language and wxPython give you a complete
transparency of your code. This is certainly not the case
in vb.
I will not code your interface, but I can give you some
tips about wxPython.
- wxPython is not vb! Do not try to have a clone of your
vb interface. Try to have something similar.
- In vb, when you drag and drop a control, (button,...)
you create a class or an instance of a class. Of course,
you can not do this in an editor, but you can divide
your code in small pieces, a class for a button,
for a tree control, for an application, ...That's much
easier to debug.
- wxPython has the concept of Layout and LayoutConstraints.
These are not existing in
vb. There are not so easy to understand. For a
first application, I suggest to work with constant sizes.
- If you are new in wxPython, avoid to use wxGlade,
Boa, ...Create everything by yourself, this is a very good
exercise, then later you will be happy to understand what
these (very good) tools are doing.
- wxPython is changing. Use the new programming
style: import wx instead of from wxPython.wx import *
- Look at the demo and the code (when I was speaking
of transparency...) Robin has done a very good work.
Below the (or a) skeleton of your application.
Have fun.
···
#----------------------------
#doni2.py
#win98, py2.2.3, wxpy 2.4.0.1
#----------------------------
import wx
#----------------------------
class MyDataPanel(wx.Panel):
def __init__(self, parent, id, pos, size, style):
wx.Panel.__init__(self, parent, id, pos, size,
style)
self.SetBackgroundColour(wx.CYAN)
#----------------------------
class MyLeftTopTree(wx.TreeCtrl):
def __init__(self, parent, id, pos, size, style):
wx.TreeCtrl.__init__(self, parent, id, pos, size,
style)
self.SetBackgroundColour(wx.GREEN)
self.AddRoot("Lefttop TreeCtrl")
#----------------------------
class MyLeftBottomTree(wx.TreeCtrl):
def __init__(self, parent, id, pos, size, style):
wx.TreeCtrl.__init__(self, parent, id, pos, size,
style)
self.AddRoot("Leftbottom TreeCtrl")
self.SetBackgroundColour(wx.RED)
#----------------------------
class MyPanel(wx.Panel):
def __init__(self, parent, id):
cwi, che = parent.GetClientSizeTuple()
wx.Panel.__init__(self, parent, id, wx.Point(0, 0),
wx.Size(cwi, che), wx.SUNKEN_BORDER)
lefttopwi, lefttophe = 300, 400
self.ltt = MyLeftTopTree(self, -1, wx.Point(0, 0),
wx.Size(lefttopwi, lefttophe),
wx.TR_HAS_VARIABLE_ROW_HEIGHT)
self.lbt = MyLeftBottomTree(self, -1, wx.Point(0,
lefttophe), wx.Size(lefttopwi, che - lefttophe),
wx.TR_HAS_VARIABLE_ROW_HEIGHT)
self.dp = MyDataPanel(self, -1, wx.Point(lefttopwi,
0), wx.Size(cwi - lefttopwi, che), wx.NO_BORDER)
#----------------------------
class MyFrame(wx.Frame):
def __init__(self, parent, id):
style = wx.SYSTEM_MENU | wx.CAPTION |
wx.MINIMIZE_BOX
wx.Frame.__init__(self, parent, id, 'Accattatevi
illo', wx.Point(20, 20), \
wx.Size(800, 600), style)
#create menus
menu = wx.Menu()
menu.Append(1001, "&New Window")
menu.AppendSeparator()
menu.Append(1002, "E&xit")
menubar = wx.MenuBar()
menubar.Append(menu, "&File")
self.SetMenuBar(menubar)
#create the statusbar here
#create the Toolbar here
#add a panel
panel = MyPanel(self, -1)
wx.EVT_MENU(self, 1001, self.OnNewWindow)
wx.EVT_MENU(self, 1002, self.OnCloseWindow)
wx.EVT_CLOSE(self, self.OnCloseWindow)
def OnNewWindow(self, event):
print 'OnNewWindow'
def OnCloseWindow(self, event):
self.Destroy()
#----------------------------
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, -1)
frame.Show(True)
self.SetTopWindow(frame)
return True
#----------------------------
def main():
print 'main is running...'
app = MyApp(0)
app.MainLoop()
#----------------------------
if __name__ == '__main__':
main()
#eof----------------------------
Ciao
Jean-Michel Fauth, Switzerland