Ваша переменная контроллера находится вне области видимости. Если вы отправите контроллер в функцию, я могу запустить код без ошибок:
class ViewBezettingBoven(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
label = tk.Label(self, text="Page One!!!")
self.parent = parent
self.window = FrameBovenverdieping(self)
label.pack(pady=10,padx=10)
#send controller to function
self.widgets(controller)
def widgets(self,controller):
button1 = tk.Button(self, text="Back to Home",
command=lambda: controller.show_frame(StartPage))
button1.pack()
button2 = tk.Button(self, text="Page Two",
command=lambda: controller.show_frame(PageTwo))
button2.pack()
'%03.1f' works (1 could be any number, or empty string):
>>> "%06.2f"%3.3
'003.30'
>>> "%04.f"%3.2
'0003'
Note that the field width includes the decimal and fractional digits.
Вы также можете использовать zfill.
str(3.3).zfill(5)
'003.3'