1

My class is,

 class MainFrame(wx.Frame):
     def __init__(self,parent,ID,title):
         wx.Frame.__init__(self, parent, ID, title, style=wx.DEFAULT_FRAME_STYLE ^   wx.RESIZE_BORDER ^ wx.MAXIMIZE_BOX,size=(600,500))
         wx.Frame.CenterOnScreen(self) 
         ..........
         ..........
         panel1 = wx.Panel(panel, wx.ID_ANY,size=(550,200),pos=(25,150))
         log = wx.TextCtrl(panel1, wx.ID_ANY, size=(550,200),style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)

     def PanelStatus(message):
         ...............

I want to call method Panel1 from function 'init' in the function 'PanelStatus' and later call this function in the other class.How to do that?? I am very new to programming language.Help me out.

2 Answers 2

1

First, you need to give your PanelStatus function a new first argument self. That's because it's a method, and methods will automatically get the instance they are called on passed as the first argument (the name self is a convention).

Then, you can call it from __init__ with self.PanelStatus("some message"). If other code in other parts of your program have a reference to a MainFrame instance, they can call myMainFrame.PanelStatus("some other message").

Sign up to request clarification or add additional context in comments.

Comments

0

I did something like this and it worked for me.

class MainFrame(wx.Frame):
    def __init__(self,parent,ID,title):
        wx.Frame.__init__(self, parent, ID, title, style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER ^ wx.MAXIMIZE_BOX,size=(600,500))
        .......
        .......
        panel1 = wx.Panel(panel, wx.ID_ANY,size=(550,200),pos=(25,150))
        self.log = wx.TextCtrl(panel1, wx.ID_ANY, size=(550,200),style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)


    def PanelStatus(self,message):
        self.log.AppendText(message)

and used self.PanelStatus("my text") in the other function.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.