changing windows

  • aitchs

    I have a project with two wxfames, ie wxFrame1, and wxFrame2.  I can open the second frame from the first, but I cant work out how to pass and return data to it. Is there an easy way? As a newbie to python I think Im missing something here. At present Im lookat at wrinting some data to disk then reading it in .
    Thanks for any advice.

    • This is really more a Python or wxPython question, so you would probably get more/better suggestions on e.g. this list:

      Now I am in no way an expert but there are several methods much better then a file.

      - Hand over data when you init the second frame (e.g. a parameter called mydata)

      - Have a GetData function/method in your frame1 and in your frame2 call it frame1.GetData()

      - In your frame1 declare variable as self.somedata1, self.somedata2 and in your frame2 you can get to them using frame1.somedata1, frame1.somedata2

      Hope this helps, by the way I am sure there are other methods I haven't figured out.

      See you

    • aitchs

      I have worked it out.
      The best way That I can get going is to define a variable in  wxApp1 , then if I import wxApp1 into every other file I can access the variable as wxApp1.somevariable

      To send info when opening a new frame,

      use the following code in frame1 to open wxFrame2

      self.main2 = wxFrame2.create(self,"heyyy")

      and in wxFrame2 have the following

      global n1

      def create(parent,txt):
          return wxFrame2(parent)

      This isnt very pretty, but I am a complete newbie, and this seems to work.


      • I don't see why you need to import wxApp1 in all other modules?  You can reference it without that.

        If you want I have a look at it, send the files as an ATTACHMENT on the following newsgroup.


        See you