ok below code is v rough but first implementation in python.
i get the error
name error name self is not defined in relation to teh first use of self.panelL in the layout function?
it was working then i tried adding a button and it stopped I removed the button code and I got a different error?
the error message is less than useful. self is called in at the function start and my example code still works?
id like to know what the problem is so i can fix it in future?
"""
portable menu application written in python.
"""
__author__ = "adam Buxton"
__version__ = "0.1"
#imports
from wxPython.wx import * #import the GUI
import wx
from win32gui import GetDesktopWindow,GetWindowRect # windows methods to find desktop dimensions.
from calcMem import * #import python script for memory function
import os
TITLE = "python portable menu"
ID_ABOUT = wx.NewId()
ID_EXIT = wx.NewId()
class menuFrame(wxFrame):
def __init__(self, parent, ID, title):
hDesk = GetDesktopWindow()
(dL,dT,dR,dB) = GetWindowRect(hDesk)
wxFrame.__init__(self, parent, ID, title,(dR-(dR/3),dB-(dB/3)*2),wx.Size(dR/3, ((dB/3)*2)-30))
self.CreateStatusBar()
self.SetStatusText(compFreeSpace()+' Free Space of '+compTotalSpace())
FileMenu = wx.Menu()
FileMenu.Append(ID_EXIT,
"E&xit",
"Terminate the program")
HelpMenu = wx.Menu()
HelpMenu.Append(ID_ABOUT,"&About","Portable menu developed in python")
menuBar = wx.MenuBar()
menuBar.Append(FileMenu, "&File")
menuBar.Append(HelpMenu, "&Help")
self.SetMenuBar(menuBar)
#panels for layout
panelL = wx.Panel(self)
panelRt = wx.Panel(self)
panelRb = wx.Panel(self)
self.__do_layout()
def __do_layout(self):
sizer = wx.BoxSizer(wx.VERTICAL)
grid_sizer = wx.GridSizer(1, 2, 0, 0)
grid_sizerR = wx.GridSizer(2, 1, 0, 0)
grid_sizer.Add(self.panelL, 1, wx.EXPAND, 0)
grid_sizerR.Add(self.panelRt, 1, wx.EXPAND, 0)
grid_sizerR.Add(self.panelRb, 1, wx.EXPAND, 0)
grid_sizer.Add(grid_sizerR, 1, wx.EXPAND, 0)
sizer.Add(grid_sizer, 1, wx.EXPAND, 0)
self.SetSizer(sizer)
sizer_1.Fit(self)
self.Layout()
class menuApp(wxApp):
#menu app its self with constrcutors
def OnInit(self):
frame = menuFrame(NULL, -1, TITLE)
frame.Show(true)
self.SetTopWindow(frame)
return true
#main looop to run program
app = menuApp(0)
app.MainLoop()