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

You are right, Title_Panel is not recognized as a wxPython object. For some odd reason my brain is comatose today.

If you want other folks to help you with your code, I encourage you to follow the recommended Python naming convention.

Class names start with a capital letter, something like 'MainFrame', 'Employee' or 'CreatePanel'.

Functions, methods, instances, variables should not start with a capital letter! There you can use the Pascal naming like 'mainFrame' or the C type naming like 'main_frame', but if you mix them like 'main_Frame' it distracts. 'Mister Python' himself actually wrote a small set of guidelines and it is hidden somewhere at the www.python.org site.

Ah, I found it:
http://www.python.org/peps/pep-0008.html

Noted and taken on board :-) lol

I cant face coding with a hangover so i will go through and change that lot later (read as: Tomorrow)


Thanks for tip

Mark

To have it recognized as a wx.Window class, change your class CreatePanel to this ...

class CreatePanel(wx.Panel):
    def __init__(self, parent, size, pos, Orientation):
        wx.Panel.__init__(self, parent, -1)
        self.Sizer = wx.BoxSizer(Orientation)
        #self.SetBackgroundColour(colour)
        self.SetSize(size)
        self.SetPosition(pos)
        self.SetSizer(self.Sizer)
        self.Layout()

The next error is a missing Title_Label (title_label) creation.

GUI programming is not an easy thing to work with! You have come a remarkable distance though!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.