0

Somewhere in my code I import this module:

import sModule as s

And initialize my main Tkinter window like this:

base = tk.Tk()

mw = MainWindow(base).grid()
s.parent = sys.modules[__name__]

base.mainloop()

And MainWindow class is something like this:

class MainWindow(tk.Frame): 
  def __init__(self, parent):
    self.info1 = tk.StringVar()
    self.info2 = tk.StringVar()

What I'm trying to do is accessing info1 and info2 in sModule like this:

parent.mw.info1.set(str1)

And I'm getting this error:

AttributeError: 'NoneType' object has no attribute 'info1'

Which part is wrong?

1 Answer 1

3

Replace following line:

mw = MainWindow(base).grid()

with:

mw = MainWindow(base)
mv.grid()

Why? grid() does not return anything; implicitly return None.

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

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.