SetStatusText of MDIParentFrame from MDIChildFrame

Illy illy at otekno.biz
Mon Nov 21 14:21:16 EST 2011


Dear my friends....

I am stucked on a problem: I can't call a function of MDIParentFrame 
from MDIChildFrame: myturnonmenu and mystatusbar.SetStatusText()

Anybody would be so nice for telling me my mistakes? Please do me a favor.

Thank you very much in advance.

I created 3 files contain this sourcecode:
ceo at mefi:~/sementara/tes$ ls
jendelapos.py  jendelapos.pyc  myMDIChildFrameforLogin.py  
myMDIChildFrameforLogin.pyc  myMDIFrame.py
ceo at mefi:~/sementara/tes$
===========================================
ceo at mefi:~/sementara/tes$ cat myMDIFrame.py
#!/usr/bin/env python
import wx
import os

import jendelapos
import myMDIChildFrameforLogin

class myMDIParentFrame (wx.MDIParentFrame):
     def __init__(self):
         global mystatusbar, menuakuntan

         wx.MDIParentFrame.__init__(self, None, -1, "This is 
myMDIParentFrame", size=(1020,800))
         mystatusbar = self.CreateStatusBar()
         mystatusbar.SetStatusText("This is the StatusBar I want to put 
my message for the users in it")
         menuakuntan = wx.Menu()
         menuakuntan.Append(1000,  "Accounting - POS (&Point of Sale)")

         menuaplikasi = wx.Menu()
         menuaplikasi.Append(20000,  "&Login")
         menuaplikasi.Append(20001,  "E&xit")

         menubar = wx.MenuBar()
         menubar.Append(menuakuntan,  "&Accounting")
         menubar.Append(menuaplikasi,  "A&pplication")
         myturnoffmenu(self)

         self.SetMenuBar(menubar)

         self.Bind (wx.EVT_MENU,  self.jendelapos,  id=1000)

         self.Bind (wx.EVT_MENU,  self.myMDIChildFrameforLogin,  id=20000)
         self.Bind (wx.EVT_MENU,  self.OnExit,  id=20001)

     def OnExit(self,  evt):
         self.Close(True)

     jendelapos =  jendelapos.Show

     myMDIChildFrameforLogin = myMDIChildFrameforLogin.Show

def myturnoffmenu(self):
     menuakuntan.Enable(1000, False)

def myturnonmenu(self):
     menuakuntan.Enable(1000, True)

if __name__ == '__main__':
     app = wx.PySimpleApp()
     myMDIFrame = myMDIParentFrame()
     myMDIFrame.Show()
     app.MainLoop()
ceo at mefi:~/sementara/tes$
=================================================
ceo at mefi:~/sementara/tes$ cat ./myMDIChildFrameforLogin.py
import wx

def Show(self, evt):
     global pengguna, katakunci, jendela
     jendela = wx.MDIChildFrame(self, -1, "Login Form",  style= 
wx.DEFAULT_FRAME_STYLE | wx.HSCROLL | wx.VSCROLL)

     mystatusbar.SetStatusText("Login succeeded")
     myturnonmenu()

     jendela.Show(True)
ceo at mefi:~/sementara/tes$
=================================================
ceo at mefi:~/sementara/tes$ cat jendelapos.py
import wx

def Show (self, evt):
         win = wx.MDIChildFrame(self, -1,  "Accounting - POS")
         win.Show(True)
ceo at mefi:~/sementara/tes$
=================================================




More information about the Python-list mailing list