![]() ![]() Using Constructor: This simply involves using the Float class construct that accepts string parameter as input and returns a float.This returns a primitive float value, unlike the valueOf () method, which returns a Float object. Using Float.parseFloat(): This is also a built-in static method of Float class which accepts a given string that is to be converted into float and returns a float value corresponding to the passed input string.This returns a primitive object of the Float class. This method can throw NumberFormatException if the passed string is not a valid number and NullPointerException if null is passed as input. Using Float.valueOf(): This is a built-in static method of Float class that accepts a given string which is to be converted into float and returns a float value corresponding to the passed input string.There are mainly four different ways to convert string to float in java: Web development, programming languages, Software testing & others How to Convert String to Float in Java? Root.after(int(interval_ms), DisplayTemp)īuttonClear.Start Your Free Software Development Course Root.after(int(interval_ms), DisplayTime) ![]() Then in the tkinter callback just grab last value and take this for the chart.īut I apologize profusely, here I have tried what I can, but maybe because I really don't really understand coding yet, so the results are still not correct and here what happened was that there was no error written after the program was run, but it became like this Here threading could be used: spin off a thread which reads temperature in background and stores in variables. Remove all the threads in code by this pattern.Īnd perhaps a change in Interval() is needed to ensure that returned values are > 0.įurther improvements: having the GetTemp() method in the tkinter callback could be a problem as these callbacks should be fast. Sorry in advance, I’m not very familiar with coding, please help Plotting = threading.Thread(name='graphPlotting',target=PlotGraph,daemon=True) ShowTime = threading.Thread(name='showTime', target=DisplayTime, daemon=True) ShowTemp = threading.Thread(name='showTemp', target=DisplayTemp, daemon=True) Logging = threading.Thread(name='logging',target=LogData, daemon=True) TimeEnd = time.strptime(timeEndEntry.get(),"%H:%M:%S")īuttonLog = Button(root,text='Start Logging',font=('times',16),command=LogFunction)īid(row=6,column=0,padx=5,pady=5)īuttonClear = Button(root,text='Clear',font=('times',16),command=ClearPlot)īid(row=6,column=1,padx=5,pady=5) TimeStart = time.strptime(timeStartEntry.get(),"%H:%M:%S") TimeNow = time.strptime(timeNowTuple,'%H:%M:%S') Temp2 = round(sensor2.get_temperature(),2) Temp1 = round(sensor1.get_temperature(),2) id(row=0,column=2, rowspan=7,pady=5,padx=5, sticky=W+E)Ĭanvas = FigureCanvasTkAgg(figure,master=root)Ĭanvas.get_tk_widget().grid(row=7,column=0,columnspan=3, padx=5, pady=5) LogListBox = Listbox(root, font=('times',16), width=30) ![]() TimeEndEntry = Entry(root, font=('times',16),width=8, textvariable=defaultEndTime) TimeEndLabel = Label(root, text='End time', font=('times',16)) TimeStartEntry = Entry(root, font=('times',16),width=8, textvariable =defaultStartTime) TimeStartLabel = Label(root, text='Start time', font=('times',16)) IntervalLabel = Label(root, text='Interval (min)', font=('times',16)) Sensor2Display = Label(root, font=('times',20)) Sensor2Label = Label(root, text='Sensor 2:',font=('times',16)) Sensor1Display = Label(root, font=('times',20)) Sensor1Label = Label(root, text='Sensor 1:',font=('times',16)) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |