Sunday, November 21, 2010

Importing values in Python

Programmer Question

I have a little module that creates a window (program1). I've imported this into another python program of mine (program2).



How do I make program 2 get self.x and x that's in program1?



This is program1.



import Tkinter

class Class(Tkinter.Tk):

def __init__(self, parent):

Tkinter.Tk.__init__(self, parent)
self.parent = parent

self.Main()

def Main(self):
self.button= Tkinter.Button(self,text='hello')
self.button.pack()

self.x = 34
x = 62





def run():
app = Class(None)
app.mainloop()

if __name__ == "__main__":
run()


Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails