Question

In: Computer Science

Design the Python GUI to display the temperature & humidity on two gauges. - Use the...

Design the Python GUI to display the temperature & humidity on two gauges.

- Use the Tkinter Canvas Widget.

- The gauge should be in a separate file and can be integrated using the import directive.

- The gauge should have at least two parameters; e.g. the range (scale: min-max) and the fill color of the moving arc. You are free to add more.

You have to design the gauge and not import it

****PYTHON code*****

Solutions

Expert Solution

Python GUI to display the temperature & humidity on two gauges:

import csv
import requests
from scipy import interpolate
from scipy.interpolate import UnivariateSpline
import numpy as np
import matplotlib.pyplot as plt
from tkinter import *
import tkinter.font
from tkinter import messagebox

'''
data retrieve and prediction
'''

CSV_URL = 'https://thingspeak.com/channels/357788/feed.csv'

data1=[]
x = np.arange(0,100)
y=[]
z=[]
with requests.Session() as s:
download = s.get(CSV_URL)

decoded_content = download.content.decode('utf-8')

cr = csv.reader(decoded_content.splitlines(), delimiter=',')
my_list = list(cr)
for row in my_list[1:74]:
# print(row)
data1.append(row)
for data in data1:
y.append(float(data[2]))
z.append(float(data[3]))
#print(len(y))
#print(len(x))
#print(y)

def interpcurve():
spl = UnivariateSpline(x,y)
xs = np.linspace(0, 200, 10)
plt.plot(xs, spl(xs), 'r')
plt.xlabel('x points')
plt.ylabel('temperature')
plt.show()
def tomtemp():
spl= UnivariateSpline(x,y)
t1=spl(120)
messagebox.showinfo("PREDICTED TEMPERATURE", "The temperature will be approximately\n\n\t %.2fºC"%t1)
def humcurve():
spl = UnivariateSpline(x,z)
xs = np.linspace(0, 200, 10)
plt.plot(xs, spl(xs), 'g')
plt.xlabel('x points')
plt.ylabel('humidity')
plt.show()
def tomhum():
spl=UnivariateSpline(x,z)
t1=spl(120)
messagebox.showinfo("PREDICTED HUMIDITY", "The humidity will be approximately\n\n\t %.2f%%"%t1)


#tomtemp(x,y)
'''
GUI PART
'''

root=Tk()

#frame setup
root.title('NUMERRICAL PROJECT')
root.geometry('350x500')
root.focus_set()
topFrame=Frame(root,bg='#C2C4B9')
topFrame.pack()
bottomFrame=Frame(root,bg='#C2C4B9')
bottomFrame.pack(side='bottom')

#fonts,
helv36 = tkinter.font.Font(family='Helvetica', size=10, weight=tkinter.font.BOLD)
gar=tkinter.font.Font(family='Garamond', size=20, weight=tkinter.font.BOLD)
gar1=tkinter.font.Font(family='Garamond', size=10)
gar2=tkinter.font.Font(family='Garamond', size=8, weight=tkinter.font.BOLD)

#images
img = PhotoImage(file=" ") #add button image path


#elements
root.configure(background='#C2C4B9')

label=Label(topFrame,text='NUMERICAL\nWEATHER PREDICTOR',font=gar,fg= "#2D42AE",bg='#C2C4B9')
label1=Label(bottomFrame,text="Made by RAKESH SEAL",font=gar1,bg='#C2C4B9')
label2=Label(bottomFrame,text='SELECT DATE FOR GETTING PREVIOUS DATA',font=gar2,bg='#C2C4B9')

button1=Button(topFrame,image=img,text="TEMPERATURE\nGRAPH",command=interpcurve,compound=CENTER)
button1.config( height = '60', width = '120',font=helv36,borderwidth='5')

button4=Button(root,text="TOMORROWS \n HUMIDITY",image=img,compound=CENTER,command=tomhum)
button4.config( height = '60', width = '120',font=helv36,borderwidth='5')

button5=Button(root,text="HUMIDITY\n GPH ",image=img,compound=CENTER,command=humcurve)
button5.config( height = '60', width = '120',font=helv36,borderwidth='5')

button2=Button(topFrame,image=img,text=" TOMMORROWS \nTEMPRETURE",command=tomtemp,compound=CENTER)
button2.config( height = '60', width = '120',font=helv36,borderwidth='5.5')


sp=Spinbox(bottomFrame,from_=0,to=10)
sp.config(width='40',borderwidth='5')

#function for previous datas
def spn():
spl = UnivariateSpline(x,y)
spl1=UnivariateSpline(x,z)
a=sp.get()
if ((float(a)<=10.0) and (float(a)>=0)):
b=(spl((10.0)*float(a)))
c=(spl1((10.0)*float(a)))
messagebox.showinfo("PAST DATA", "\tRequested "+str(a)+"\n"+"--------------------------------"+"\n"+"Temperature:"+str(np.round(b,2))+"ºC"+"\n\n"+"Huidity: "+str(np.round(c,2)))+'%%'
else:
messagebox.showinfo("PAST DATA"," INVALID REQUEST")


  

button3=Button(bottomFrame,text='get previous\ndata',fg='#121C09',font=helv36,borderwidth='5.5',command=spn)

#final packing
button4.place(rely=0.6,relx=0.464, x=0, y=0, anchor=SE)
button5.place(rely=0.6,relx=0.927, x=0, y=0,anchor=SE)

label2.pack(side='top')
label1.pack(side='bottom')
label.pack(side='top')
button1.pack(side='right',padx='10',pady='50')
button2.pack(side='left',padx='10',pady='50')
button3.pack(side='bottom',pady='15')
sp.pack(pady='5',side='bottom')

root.mainloop()


Related Solutions

Cupcakes are sensitive to temperature and humidity. Cupcakes must be cooked at a consistent temperature. To...
Cupcakes are sensitive to temperature and humidity. Cupcakes must be cooked at a consistent temperature. To test the oven before using it to bake Cupcakes, we took temperature samples at regular intervals. The following measurements, in degrees Celsius, are the results. Sample X1 X2 X3 X4 X5 X6 X7 X8 1 172 163 164 175 168 161 168 160 2 172 162 163 173 172 174 172 176 3 165 179 179 178 160 169 165 172 4 163 174...
I did the complete programming in python , just want to use tkinter for GUI. please...
I did the complete programming in python , just want to use tkinter for GUI. please look at the 2nd part . i did some part of this program using tkinter but could not finis it. Thank you. import random image = 'w' # modified functions which accepts two numbers each and returns the respective # output def add(a, b): return a + b def subtract(a, b): return a - b def multiply(a, b): return a * b def kidCalc():...
Python Create a tkinter GUI application that has two buttons on it. The first button should...
Python Create a tkinter GUI application that has two buttons on it. The first button should have in red text the word "Red" on it and the second button should have in blue text the word "Blue" on it. When the red button is clicked you should change the background color of the application window to red and when the blue button is pressed you should change the background color of the application window to blue. You should place your...
USE EXCEL OR MATLAB IF YOU NEED Given the dry-bulb temperature, Tdb and relative humidity, Φ,...
USE EXCEL OR MATLAB IF YOU NEED Given the dry-bulb temperature, Tdb and relative humidity, Φ, the wet-bulb, Twb temperature may be calculated from the psychrometric equation (Jones, 1994): PvsΦ – Pss = PatmA (Twb -Tdb )                                              (1) Use your input from the Table below. The input Twb and Tdb are in oC (used in Eqs. (2) and (3) in Kelvin).    Pss = saturated vapor pressure at Twb (kPa) Pvs = saturated vapor pressure at Tdb (kPa)    Pss =...
Use the psychrometric chart to estimate (1) the absolute humidity, wet bulb temperature, humid volume, dew...
Use the psychrometric chart to estimate (1) the absolute humidity, wet bulb temperature, humid volume, dew point, and specific enthalpy of humid air at T =30 oC and 40 % relative humidity, and (2) the amount of water in 150 m3 or air at these conditions. Students must sketch the psychrometric chart and draw the path of determining the parameters of (1).
On a particular summer day, the temperature is 30 degrees Celsius and the relative humidity is...
On a particular summer day, the temperature is 30 degrees Celsius and the relative humidity is 80% (which means that the partial pressure of water vapor in the ambient air is 80% of the equilibrium vapor pressure of water). A sample of this air is placed in a 1 Liter flask which is then closed and cooled to 5 degrees Celsius. What is the mass in grams of water that still exists as vapor in the flask? How much liquid...
We need to code an LCD with a temperature and humidity sensor for the arduino UNO...
We need to code an LCD with a temperature and humidity sensor for the arduino UNO board. The LCD should simply display the temperature and humidity reading from the DHT11 sensor. We must do this without the use of arduino or lcd libraries, and only use raw c code. For example we need to use PORTD |= (1<<5); to set the pin to 5. The LCD is connected to pins A0 and A1, and it is using I2C. The temperature...
Using Python, use the following list (Temperature = [56.2,31.8,81.7,45.6,71.3,62.9,59.0,92.5,95.0,19.2,15.0]) to: - Create a loop to iterate...
Using Python, use the following list (Temperature = [56.2,31.8,81.7,45.6,71.3,62.9,59.0,92.5,95.0,19.2,15.0]) to: - Create a loop to iterate through each of the elements in the temperature list. - Convert each element of this list to a Celsius temperature and then, for each valid temperature in the list, print out both the original Fahrenheit temperature and the Celsius equivalent in this format: "32 degrees Fahrenheit is equivalent with 0 degrees Celsius."
what are some technical challenges will one face for building a temperature and humidity system with...
what are some technical challenges will one face for building a temperature and humidity system with arduino to display to app and how will they overcome these challenges to solve that problem?
A kinesiologist wanted to investigate the effect of temperature and humidity on human performance. He found...
A kinesiologist wanted to investigate the effect of temperature and humidity on human performance. He found 28 college students and randomly assigned them to four different conditions, during which they were to walk at their normal pace on a treadmill for 60 minutes. He measured how far, in miles, they walked. The conditions varied in temperature (normal temperature/high temperature) and humidity (normal humidity/high humidity). The data are presented below, and SSwithin = 1.58. Do all hypothesis testing steps and compute...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT