Hi,
So it seems my self-teaching experience isnt going as well as i hoped. Every time i think im starting to understand something new pops up that halts me in my tracks :-) lol
Was wondering if someone could just give me a quick pointer in the right direction of what to do here.
this is my code;
import wx
import os
class Main_Frame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title)
Icon = wx.Icon("icon.ico", wx.BITMAP_TYPE_ICO)
self.SetIcon(Icon)
self.Main_Panel = wx.Panel(self, -1)
self.Main_Panel.SetBackgroundColour((225,245,255))
self.Main_Sizer = wx.BoxSizer(wx.VERTICAL)
self.CreateMenuBar()
self.CreateStatusBar()
self.TitlePanel()
# This isnt in yet as the TitlePanel code seems to be a bit dodgy
# self.Main_Panel.Sizer.Add(self.Title_Panel, 1, wx.EXPAND)
self.Main_Panel.SetSizer(Main_Sizer)
self.Main_Panel.Layout()
### MENU CREATION ###
def MenuData(self):
return (("File",
("&New Tractor Wizard\tCtrl-N", "Start the New Tractor wizard", self.OnMenuNew_Wiz),
("&Save\tCtrl-S", "Save the current tractor configuration to file", self.OnMenuSave),
("&Load\tCtrl-L", "Open a tractor configuration from file", self.OnMenuLoad),
("E&xit\tAlt-F4", "Exit the program", self.OnMenuExit)),
("&Help",
("&Help\tF1", "Open the Help file", self.OnMenuHelp),
("&About", "About the program", self.OnMenuAbout)))
def CreateMenuBar(self):
MenuBar = wx.MenuBar()
for eachMenuData in self.MenuData():
menuLabel = eachMenuData[0]
menuItems = eachMenuData[1:]
MenuBar.Append(self.CreateMenu(menuItems), menuLabel)
self.SetMenuBar(MenuBar)
def CreateMenu(self, MenuData):
menu = wx.Menu()
for eachLabel, eachStatus, eachHandler in MenuData:
if not eachLabel:
menu.AppendSeparator()
continue
menuItem = menu.Append(-1, eachLabel, eachStatus)
self.Bind(wx.EVT_MENU, eachHandler, menuItem)
return menu
### Menu Events ###
def OnMenuNew_Wiz(self, event): pass
def OnMenuSave(self, event): pass
def OnMenuLoad(self, event): pass
def OnMenuExit(self, event): pass
def OnMenuHelp(self, event): pass
def OnMenuAbout(self, event): pass
def TitlePanel(self):
Title_Panel = CreatePanel(self.Main_Panel, (-1,-1), (0,0), wx.HORIZONTAL)
Title_Image = wx.Image("DPT.jpg", wx.BITMAP_TYPE_ANY)
Title_Bitmap = wx.StaticBitmap(Title_Panel, -1, wx.BitmapFromImage(Title_Image))
Title_Text = wx.StaticText(Title_Panel, -1, "DPT - Sequence Driven Controller" )
Title_Label.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, True))
Title_Label.SetForegroundColour('#00009F')
Title_Panel.Sizer.Add(Title_Bitmap, 1, wx.ALIGN_CENTER)
Title_Panel.Sizer.Add(TitleText, 4, wx.ALIGN_CENTER | wx.LEFT, 10)
class CreatePanel():
def __init__(self, parent, size, pos, Orientation):
self.Sizer = wx.BoxSizer(Orientation)
self.Panel = wx.Panel(parent)
#self.Panel.SetBackgroundColour(colour)
self.Panel.SetSize(size)
self.Panel.SetPosition(pos)
self.Panel.SetSizer(self.Sizer)
self.Panel.Layout()
class wxPyApp(wx.App):
def OnInit(self):
frame = Main_Frame(None, "DPT - Sequence Driven Controller")
self.SetTopWindow(frame)
frame.Show(True)
frame.Center(wx.BOTH)
return True
if __name__ == '__main__': # Only runs if program is being executed, not imported
app = wxPyApp(redirect=True)
app.MainLoop()
but i keep getting the error;
blah blah... Error on method 'new_StaticBitmap', expected arguemnt 1 of type 'wxWindow'
I think its got something to do with the way im calling / defining Title_Panel but i cant get it to work.
Any help would be greatly appreciated :-)
Mark