Hello all, trying to get my program working. The program is to take input from the user in a hh:mmx format (x being p or a, standing for PM and AM) and tell the user how many minutes from midnight that time is. I was able to make it so it would work in the Shell using the following code snippet:
def timedif(x): h = int(x[0:2]) m = int(x[3:5]) ampm = n[-1] if h != 12 and ampm == 'p': h = h + 12 time = h*60 + m print time n = raw_input('Input a time in hh:mmx format: ') timedif(n)
Now I am trying to make it work in a Tkinter format. The following snippet is what I have so far. Wondering if you all could help me figure out how to get it working. Thanks!
import Tkinter win = Tkinter.Tk() win.title('Time Clock') class Converter(): def __init__ (self,x): self.x = x def convert(self,x): h = int(x[0:2]) m = int(x[3:5]) ampm = n[-1] if h != 12 and ampm == 'p': h = h + 12 diff = h*60 + m conv = Converter(5) label = Tkinter.Label(win,text="Calculate Elapsed Time in Minutes",font=('Courier New',32,'bold')) label.pack() Row3 = Tkinter.Frame(win) mLabel = Tkinter.Label(Row3,text = "Enter Time (hh:mmx) With x = a or p",font=('Courier New',30)) mEntry = Tkinter.Entry(Row3,width=6,font=('Courier New',30)) mLabel.pack(side='left') mEntry.pack(side='right') Row3.pack() Row4 = Tkinter.Frame(win) vLabel = Tkinter.Label(Row4,text="Elapsed Minutes Since Midnight",font=('Courier New',30)) vLabel.pack() Row4.pack() Row5 = Tkinter.Frame(win) qb = Tkinter.Button(Row5,text='Quit',command=win.destroy,font=('Courier New',30)) cb = Tkinter.Button(Row5,text='Convert',font=('Courier New',30)) qb.pack(side='left') cb.pack(side='right') Row5.pack() win.mainloop()