Thanks for the interest. I'd managed to suss that, and also the x and y offsets, but have now fallen foul to another raspi/PC anomaly. Raspi does not like fg='red' or bg='yellow' to set foreground and background colours, when changing font properties, though the PC does.RogerW wrote:Try running the app and then stretching the window sideways. Tkinter seems to not expand the window to make the title visible.
Alternatively add the line
root.geometry('300x100')
Code: Select all
# create text display
self.textid = self.create_text(self.centrex
,self.centrey - 3*self.blobrad
,fill = 'red'
,font = tkf.Font(size = -int(2*self.majortick)))
Code: Select all
cd scripts
python3 vapour.py
Code: Select all
from tkinter import Tk, Label
import time
root = Tk()
root.title('dalVapour')
root.geometry("800x450+50+50")
stit=Label(root, text='Heat ON at 12:17')
stit.config(font=('Arial',20))
timing=Label(root, text='At 15:57')
timing.config(font=('Arial',20))
fist=Label(root,text='temperature now is')
fist.config(font= ('Arial', 20))
sayit = Label(root, text='96.3' + ' degrees Fahrenheit')
sayit.config(font=('times', 48, 'italic bold'), fg='red', bg='yellow')
# Font is a tuple of (font_family, size_in_points, style_modifier_string)
stit.pack(ipady=20)
timing.pack(ipady=20)
fist.pack(ipady=20)
sayit.pack(pady=20,ipadx=20,ipady=20)
root.after(15000,root.destroy)
root.mainloop()
Code: Select all
# ds18b20.py
# written by Roger Woollett
import os
import glob
import time
class DS18B20:
# much of this code is lifted from Adafruit web site
# This class can be used to access one or more DS18B20 temperature sensors
# It uses OS supplied drivers and one wire support must be enabled
# To do this add the line
# dtoverlay=w1-gpio
# to the end of /boot/config.txt
#
# The DS18B20 has three pins, looking at the flat side with the pins pointing
# down pin 1 is on the left
# connect pin 1 to GPIO ground
# connect pin 2 to GPIO 4 *and* GPIO 3.3V via a 4k8 (4800 ohm) pullup resistor
# connect pin 3 to GPIO 3.3V
# You can connect more than one sensor to the same set of pins
# Only one pullup resistor is required
def __init__(self):
# load required kernel modules
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')
# Find file names for the sensor(s)
base_dir = '/sys/bus/w1/devices/'
device_folder = glob.glob(base_dir + '28*')
self._num_devices = len(device_folder)
self._device_file = list()
i = 0
while i < self._num_devices:
self._device_file.append(device_folder[i] + '/w1_slave')
i += 1
def _read_temp(self,index):
# Issue one read to one sensor
# you should not call this directly
f = open(self._device_file[index],'r')
lines = f.readlines()
f.close()
return lines
def tempC(self,index = 0):
# call this to get the temperature in degrees C
# detected by a sensor
lines = self._read_temp(index)
retries = 5
while (lines[0].strip()[-3:] != 'YES') and (retries > 0):
# read failed so try again
time.sleep(0.1)
#print('Read Failed', retries)
lines = self._read_temp(index)
retries -= 1
if retries == 0:
return 998
equals_pos = lines[1].find('t=')
if equals_pos != -1:
temp = lines[1][equals_pos + 2:]
return float(temp)/1000
else:
# error
return 999
def device_count(self):
# call this to see how many sensors have been detected
return self._num_devices
Code: Select all
# Temp.py
from ds18b20 import DS18B20
# test temperature sensors
x = DS18B20()
count=x.device_count()
i = 0
while i < count:
print(x.tempC(i))
i += 1