Плавания Python клавиатуры

Ваша переменная контроллера находится вне области видимости. Если вы отправите контроллер в функцию, я могу запустить код без ошибок:

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()
26
задан mskfisher 11 May 2012 в 15:03
поделиться

2 ответа

'%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.

43
ответ дан 28 November 2019 в 06:35
поделиться

Вы также можете использовать zfill.

str(3.3).zfill(5)
'003.3'
8
ответ дан 28 November 2019 в 06:35
поделиться
Другие вопросы по тегам:

Похожие вопросы: