0

Hello, I am working on a project, and I cant seem to get around a part of it, which is really crucial to the program.. I am using WX btw for GUI, but unfortunately, I want when a button clicked, to open a new Miniframe and take the values and use them in the main Frame which is in another class...

Is there a way to have multiple miniframes under one class, or a way to return the variables from a class to another for example:

class window():
     def main():
          x=10
          return x

class frame():
     def fn():

I want to use the "x" in window in the "fn"....
Please help project deadline is so near...

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Nassarofficial
1

Generally speaking you open a new frame, not a new mainframe. There is no way to tell how the class is called from the sample, but you would access variables the same way as with any other class.

##--- Not tested
class Window_Test():
     def __init__(self):
          x=10
          ## instance of the class
          fr = Frame_Test()
          ## call the function
          y = fr.fn(x)
          print "y =", y
          print fr.var
          return x

class Frame_Test():
     def __init__(self):
         self.var = "class Frame_Test variable"

     def fn(self, x):
         print "fn called -->", x
         return x + 1

W=Window_Test()

Edited by woooee: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.