My middle-aged father (an electrical engineer is not a programmer by profession) is trying to teach my 13-year-old daughter electronics and programming. I still love Python. I am creating a program to display temperature throughout our home using the tkinter GUI and DS18B20 sensors.
We compiled the program below by reading books, online research and using Qaru to correct errors (this site is rocky!).
Now we are at a dead end, we continue to receive an intermittent error, when we run the program for the first time after loading inactivity on our raspberries, it works fine.
The second time and all subsequent moments we get this error message:
Traceback (most recent call last): File "/home/pi/Code-working-library/stackoverflow-paste.py", line 140, in <module> app.equipTemp.set(tempread) File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 203, in set return self._tk.globalsetvar(self._name, value) RuntimeError: main thread is not in main loop
Please note that we understand that in order to update the static window labels and updates, the updated rates read from our sensor (DS18B20), we needed to use a stream. The sample code we started with contains _init_ instructions with one underscore preceding and ending - I donβt know why, if I add a second underscore, I get error messages. The update window code that we used as the basis is obtained from the Raspberry Pi Forum
Here is our code:
from Tkinter import * import tkFont import os import glob import time import subprocess import re import sys import time import threading import Image import ImageTk os.system('modprobe w1-gpio') os.system('modprobe w1-therm')
source share