0

I am trying to write a python tkinter program that calculates time in seconds of a set number of beats at a certain bpm. Anyways i am having a hard time using the tkinter enters as float variables. I am wanting some suggestions on how to make my code work. I am an beginner programmer so my code is prolly kinda shaky, Thanks. Here is my code...

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()
  • Welcome to Stack Overflow! You can learn [How to Ask a good question](http://stackoverflow.com/help/how-to-ask) and create a [Minimal, Complete, and Verifiable](http://stackoverflow.com/help/mcve) example. That makes it easier for us to help you. – Stephen Rauch Jan 23 '17 at 00:52
  • 1
    It looks like you need to do a lot more studying, not to mention copy and paste more carefully (I have absolutely no idea how `from tkinter import *` managed to migrate from the top of the file to the end of an arbitrary line in the middle of the code). – TigerhawkT3 Jan 23 '17 at 00:56
  • 1
    @TigerhawkT3 I do not believe that this question is a duplicate. The problem is that OP is creating a new Label (and not packing it) instead of configuring an existing Label. As well as performing `* 0` to their result. – Steven Summers Jan 23 '17 at 00:58
  • @StevenSummers - As you suggest, this code has many problems, and "debug my program's many issues" is too broad for this site. The next best option as I saw it was to answer the specific question given. – TigerhawkT3 Jan 23 '17 at 01:00
  • @TigerhawkT3 well this question should probably be closed as OP is already correctly using the Entry widgets to get a value and convert it to a float. Their real question should be _"Changing the text on a label"_ which they should be able to find the answer to. – Steven Summers Jan 23 '17 at 01:05
  • @StevenSummers - So, it could also be closed as unclear what they're asking? What a quality question... :P – TigerhawkT3 Jan 23 '17 at 01:06
  • Your problem is not `float()` but `Label` - `timeOut['text'] = 'Time: {}'.format(time1)` - and `min = 0` so you have `time1 = 0 * perc` – furas Jan 23 '17 at 01:27

0 Answers0