1

I had a problem with tkinter. After several hours of research I found my bug, but don't understand why it happened.

If I write this snippet:

self.progressbar = ttk.Progressbar(self.frame_content, orient=HORIZONTAL, length=200, mode='determinate').grid(row = 2, column = 2)

instead of this one:

self.progressbar = ttk.Progressbar(self.frame_content, orient=HORIZONTAL, length=200, mode='determinate')
self.progressbar.grid(row = 2, column = 2)

I get this error:

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

I understand the error, but I do not understand why it occurs. Could someone explain it to me please?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
jmercier
  • 564
  • 2
  • 7
  • 17

1 Answers1

2

It occurs because grid(row = 2, column = 2) returns null by definition, i.e. its not a bug. Thus, in your first example, self.progressbar is null. This is not the case in your second example in which self.progressbar holds an instance of the ttk.Progressbar(). The same is for pack(), btw.

Marcin
  • 215,873
  • 14
  • 235
  • 294