我正在尝试编写一个python tkinter程序,用于计算某个bpm下一定数量节拍的时间(以秒为单位)。无论如何,我很难使用tkinter作为浮点变量输入。我想要一些关于如何使我的代码工作的建议。我是一名初学程序员,所以我的代码有点不稳定,谢谢。这是我的代码......
window = Tk()
window.title( 'Bpm Timeslicer' )
intro = Label(window, text='Enter a Bpm and enter a number of beats, and the program will calculate sample time in seconds')
bpmL = Label(window, text='BPM')
bpmIn = Entry(window)
beatsL = Label(window, text='Number of beats')
beatsIn = Entry(window)
timeOut = Label(window, text='Time:')
def run():
bpm = bpmIn.get()
beats = beatsIn.get()
bpm = float(bpm)from tkinter import *
beats = float(beats)
time1 = float(0)
min = 0
perc = 0
perc = beats / bpm
time1 = min * perc
timeOut = Label(window, time1)
btn_run = Button( window, text = 'Run', command=run )
btn_end = Button( window , text = 'Close', command=exit )
intro.pack()
bpmL.pack()
bpmIn.pack()
beatsL.pack()
beatsIn.pack()
timeOut.pack()
btn_run.pack()
btn_end.pack()
window.mainloop()