-1

Is it possible to pass a Text widget to another file? I have a main.py file and a second file named fuction.py. Can I do the following?

in the main.py:

myText = Text(miFrame,width = 117, height = 18).place(x=20, y = 171)

function.some_function(myText)

And in the function.py:

def some_function(myText):
     myText.insert(END, "bla bla bla")

When I try to execute the above code I receive the following message:

AttributeError: 'NoneType' object has no attribute 'insert' 
Yevhen Kuzmovych
  • 10,940
  • 7
  • 28
  • 48
  • 2
    Does this answer your question? [Why do I get AttributeError: 'NoneType' object has no attribute 'something'?](https://stackoverflow.com/questions/8949252/why-do-i-get-attributeerror-nonetype-object-has-no-attribute-something) – astqx Jan 17 '21 at 15:39

1 Answers1

1

I think .place() method of the Text does not return anything. What you probably want in main.py is:

myText = Text(miFrame, width=117, height=18)
myText.place(x=20, y=171)

function.some_function(myText)
Yevhen Kuzmovych
  • 10,940
  • 7
  • 28
  • 48