def SQLQueriesExecution(queryString, informationData): printData = [] dataWindow = Window(app, title="Query Display", layout="grid") dataWindow.height = 1080 dataWindow.width = 400 dataWindow.bg = "Grey" dataRecord = connection.execute(queryString) printData.append(informationData) for row in dataRecord: printData.append(row) dataList = ListBox(dataWindow, items=printData, scrollbar=True, grid=[0, 0], align="top") dataList.height = 1080 dataList.width = 400 dataList.bg = "White"
first_name = TextBox(window_six, text="") enter_four = PushButton(window_six, text="Enter Values", command=custom_profiles_set) enter_three = PushButton(window_six, text="Save Profile", command=set) window_six.bg = "white" # Style block for the widgets within the custom profiles window. title_one.text_size = 3 title_two.text_size = 3 title_three.text_size = 3 title_four.text_size = 3 title_five.text_size = 3 enter_three.text_size = 3 enter_four.text_size = 3 enter_six.text_size = 3 listbox.width = 32 listbox.height = 4 n_up_two.text_color = (255, 30, 30) n_up_two.font = "verdana" n_up_two.text_size = 3 n_up_two.bg = "#6C0000" n_down_two.text_color = (255, 30, 30) n_down_two.font = "verdana" n_down_two.text_size = 3 n_down_two.bg = "#300000" t_up_two.text_color = (255, 30, 30) t_up_two.font = "verdana" t_up_two.text_size = 3 t_up_two.bg = "#6C0000" t_down_two.text_color = (255, 30, 30) t_down_two.font = "verdana" t_down_two.text_size = 3
def LiveCollection(cycles): printedData = [] liveTime = [] liveTemp = [] liveHumid = [] livePress = [] liveWindow = Window(app, title="Data Collection Window", layout="grid") liveWindow.width = 620 liveWindow.height = 920 try: localCycles = int(cycles) except: print("invalid variable") liveWindow.error("Error", "Invalid Variable") else: x = 0 localCycles = int(cycles) liveDataList = ListBox(liveWindow) imageContainer = Box(liveWindow, layout="grid", grid=[1, 0], align="top", border=True) imageContainer.border = 10 liveTempImage = Picture(imageContainer) liveHumidImage = Picture(imageContainer) livePressImage = Picture(imageContainer) while x < (localCycles): currentTemperature = (round(sense.get_temperature(), 2)) currentHumidity = round(sense.get_humidity(), 2) currentPressure = round(sense.get_pressure(), 2) currentTime = time.strftime("%H%M%S", time.localtime()) currentDate = time.strftime("%Y%m%d", gmtime()) ID = str(currentTime) + str(currentDate) liveTime.append(currentTime) liveTemp.append(currentTemperature) liveHumid.append(currentHumidity) livePress.append(currentPressure) printedData.append(("ID:", ID)) printedData.append(("Temp:", currentTemperature)) printedData.append(("Humidity:", currentHumidity)) printedData.append(("Pressure:", currentPressure)) printedData.append(("Time:", currentTime)) printedData.append(("Date:", currentDate)) printedData.append( ("Entry: {0} Out of: {1}".format(x + 1, localCycles))) printedData.append("") connection.execute( "INSERT INTO WeatherData (ID, Temp, Humid, Press, Time, Date) Values ({0}, {1}, {2}, {3}, {4}, {5});" .format(ID, currentTemperature, currentHumidity, currentPressure, currentTime, currentDate)) connection.commit() plt.clf() plt.plot(liveTime, liveTemp) plt.ylabel("Temperature") plt.xlabel("Time") plt.savefig("liveTemp.png") plt.clf() plt.plot(liveTime, liveHumid) plt.ylabel("Pressure") plt.xlabel("Time") plt.savefig("liveHumid.png") plt.clf() plt.plot(liveTime, livePress) plt.ylabel("Humidity") plt.xlabel("Time") plt.savefig("livePress.png") plt.clf() liveDataList.destroy() liveDataList = ListBox(liveWindow, items=printedData, grid=[0, 0], scrollbar=True) liveDataList.width = 200 liveDataList.height = 920 liveTempImage.destroy() liveTempImage = Picture(imageContainer, image="liveTemp.png", grid=[0, 0]) liveTempImage.width = 400 liveTempImage.height = 300 liveHumidImage.destroy() liveHumidImage = Picture(imageContainer, image="liveHumid.png", grid=[0, 1]) liveHumidImage.width = 400 liveHumidImage.height = 300 livePressImage.destroy() livePressImage = Picture(imageContainer, image="livePress.png", grid=[0, 2]) livePressImage.width = 400 livePressImage.height = 300 liveWindow.update() time.sleep(10) x += 1 liveWindow.focus()