Zombeatle
Posts: 71
Joined: Wed Jun 03, 2020 8:43 pm

Need to find/make a SenseHAT GUI

Thu Jun 03, 2021 3:29 pm

Ok, its there in the title: I Need to find/make a SenseHAT GUI.

I found a discussion from 2017; that led me to an item called SenseHATGUI v1. Unfortunately, it was a bit buggy - I had to go through, finding this or that indent or tab or missing parentheses and so forth. Got done with that, and there were syntax errors, which with me not knowing anything about Python stopped me cold.

I'd like to have a GIU where it uses little graphic bars to indicate the results and the range, with a digital result also shown.

Okay, basically I'm trying to make a PiCorder, and I want the results to display like this:
63c140d9ef8f40d2cef6aef77d4c01f4.jpg
63c140d9ef8f40d2cef6aef77d4c01f4.jpg (76.29 KiB) Viewed 894 times
Only with SenseHAT info and titles rather than medical stuff.

SO, any idea where I could find something I could adapt to this, or find out how to just plain build it myself? Reminder, I know diddly about Python or PyGame, but I gather that one or the other might be helpful in this.

thanks

User avatar
B.Goode
Posts: 12308
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Need to find/make a SenseHAT GUI

Thu Jun 03, 2021 4:42 pm

Maybe use Raspberry Pi's own Sense Hat emulator?

https://www.raspberrypi.org/blog/deskto ... -emulator/

https://sense-emu.readthedocs.io/en/v1.1/


It is installed by default as part of the Full variant of the Raspberry Pi Buster [32] OS, or can trivially be added to the 'Desktop-only' version.

Zombeatle
Posts: 71
Joined: Wed Jun 03, 2020 8:43 pm

Re: Need to find/make a SenseHAT GUI

Sat Jun 19, 2021 9:11 pm

B.Goode wrote:
Thu Jun 03, 2021 4:42 pm
Maybe use Raspberry Pi's own Sense Hat emulator?

https://www.raspberrypi.org/blog/deskto ... -emulator/

https://sense-emu.readthedocs.io/en/v1.1/


It is installed by default as part of the Full variant of the Raspberry Pi Buster [32] OS, or can trivially be added to the 'Desktop-only' version.
I've used the emulator. All it seems to do is show what the LEDs on the device would show. That's not what I'm after.

I'm looking for something that will provide bar graphs of the senseHAT results, preferably with a digital notation at the bottom or top.

I thought I had found one with this file called SenseHatGUI, or at least a GUI of some sort, but the thing was loaded with bugs. The simplest, and the only one I could address, was spaces being in place of tabs and so forth. THen I ran into a syntax error, which I couldn't figure out.

here's the discussion in which I found it:

viewtopic.php?t=165834

and the gitHub link where it led

https://github.com/aerospike2/Fun-with-RaspberryPi

from the looks of things, the guy hasn't done anything with it or been around in years.

I was going to upload it as an attachment, but apparently this system doesn't much care for either Python files or text files.

Zombeatle
Posts: 71
Joined: Wed Jun 03, 2020 8:43 pm

Re: Need to find/make a SenseHAT GUI

Sat Jun 19, 2021 9:15 pm

Here's the text of the file, BTW -I'm including the part giving the syntax error before it starts, though in the file it's near the end. For some reason, the quotation marks are somehow the problem.

Anyway, if you or anyone else care to look at it, I'd be interested to see what you find out.

Traceback (most recent call last):
File "/home/pi/SenseHAT Stuff/SenseHAT GUI - Fun-with-RaspberryPi/SenseHatGUI_V1a.py", line 479

print "button: ", (posX+1), " ", (posY+1), " count: ", self.buttonClickCount[posX][posY]
____________ ^
SyntaxError: invalid syntax

Code: Select all

# --------------------------------------------------------------------------------------------- #
# ------------------- GUI INTERFACE FOR RASPBERRY PI : SENSE HAT MODULE ----------------------- #
# --------------------------------------------------------------------------------------------- #

# author       : Abhishek Sharma, BioMIP, Ruhr University, Bochum, Germany.
# email        : abhishek.sharma@rub.de
# started      : 11.11.2016
# last updated : 12.11.2016
# Comments     : Thanks to Ankit Izardar for lending me his Sense Hat, and I hope I'll never give
#                him back.

"""
  --- Description ---
  
	-> Creates a GUI interface for Sense Hat module of Raspberry Pi. 
	   Sense Hat consists of following sensors:

	     1. Temperature
	     2. Humidity
	     3. Pressure
	     4. Gyroscope
	     5. Accelerometer
	     6. Magnetometer
	     
	   and LEDMatrix with 8x8 RGB LED's.  
	
	-> Please look for python module: sense_hat API for further detials.   
  
"""

import sys
from time import sleep
import random
import Tkinter as Tk
import tkFont
import numpy as np

try:
	from sense_hat import SenseHat
	
except ImportError:
	raise ImportError('SenseHat NOT FOUND')

sense = SenseHat()
sense.clear()

def horns_LEDMatrix(X, O):
	
	""" Creates Bulls Head on LED Matrix  
       
              +              + 	
	        +           +
	        + + + + + + +
	          + + + + + 
	            + + + 
                    + + + 	
	              + 		
	
	"""
	
	LEDPixels = [O, O, X, O, O, O, X, O,
	             O, X, O, O, O, O, O, X,
	             O, X, X, X, X, X, X, X,
	             O, O, X, X, X, X, X, O,
	             O, O, O, X, X, X, O, O,
	             O, O, O, X, X, X, O, O, 
	             O, O, O, O, X, O, O, O,
	             O, O, O, O, O, O, O, O]
	sense.set_pixels(LEDPixels)
	sleep(0.5)
	sense.clear()
        

def run_LEDMatrix():        
	for i in range(10):
		
		X = (255, 0, 0)
		O = (0, 255, 0)
			                
		horns_LEDMatrix(X, O)
			
		X = (255, 0, 255)
		O = (255, 255, 0) 
				
		horns_LEDMatrix(X, O)
	
		X = (255, 255, 255)
		O = (0, 0, 0)
		
		horns_LEDMatrix(X, O)

	sense.show_message("In Metal, We Trust !!!", text_colour=[255, 0, 0], back_colour=[0, 0, 255])        
	sense.clear()

class RPiSenseHat(Tk.Frame):
	
	def __init__(self, master):
		Tk.Frame.__init__(self, master)
		self.master = master

		# Setting colors for Sense Hat : RGB LEDs Matrix
		# [R, G, B, R+G, G+B, R+B, R+G+B] : Basic Colors 
		self.dark = (0, 0, 0)
		self.r = (255, 0, 0)
		self.g = (0, 255, 0)
		self.b = (0, 0, 255)
		self.rg = (255, 255, 0)
		self.gb = (0, 255, 255)
		self.rb = (255, 0, 255)
		self.rgb = (255, 255, 255)
		self.color = (0, 0, 0)
        		
		# Background : Dark : 0 / White : 1
		self.background = 0
		self.startGUI()
		self.running = False
		
	def startGUI(self):
		self.master.title("RPi SenseHat")
		self.master.grid_rowconfigure(1, weight=1)
		self.master.grid_columnconfigure(1, weight=1)
		
		self.frame = Tk.Frame(self.master)
		self.frame.pack(fill=Tk.X, padx=5, pady=5)
		
		# Setting font size and type
		helv12 = tkFont.Font(family='Helvetica', size=12, weight='bold') 
		
		# Button : Temperature Sensor
		self.button1 = Tk.Button(self.frame, bg = 'white', text="Temperature", height = 2, width = 20,
			command = lambda: self.senseTemperature(), font=helv12)
		self.button1.pack()
		
		# Button : Humidity Sensor
		self.button2 = Tk.Button(self.frame, bg = 'white', text="Humidity", height = 2, width = 20, 
			command = lambda: self.senseHumidity(), font=helv12)
		self.button2.pack()
		
		# Button : Pressure Sensor
		self.button3 = Tk.Button(self.frame, bg = 'white', text="Pressure", height = 2, width = 20,
			command = lambda: self.sensePressure(), font=helv12)
		self.button3.pack()
		
		# Button : Gyroscope
		self.button4 = Tk.Button(self.frame, bg = 'white', text="Gyroscope", height = 2, width = 20,
			command = lambda: self.senseGyro(), font=helv12)
		self.button4.pack()
		
		# Button : Accelerometer
		self.button5 = Tk.Button(self.frame, bg = 'white', text="Accelerometer", height = 2, width = 20,
			command = lambda: self.senseAcc(), font=helv12)
		self.button5.pack()
		
		# Button : Magnetometer
		self.button6 = Tk.Button(self.frame, bg = 'white', text="Magnetometer", height = 2, width = 20,
			command = lambda: self.senseMagF(), font=helv12)
		self.button6.pack()		
		
		# Button : LED Matrix
		self.button7 = Tk.Button(self.frame, bg = 'white', text="LEDMatrix", height = 2, width = 20,
			command = lambda: self.LEDMatrix(), font=helv12)
		self.button7.pack()	
		
	def senseTemperature(self):
		""" Senses Current Temperature """
		print ("Sensing Temperature")
		temp = sense.get_temperature()
		self.button1["bg"] = 'orange'
		self.button1["text"] = 'Temperature \n' + str("%.3f" %temp) + ' deg. C'
				
	def senseHumidity(self):
		""" Senses Current Humidity """
		print ("Sensing Humidity")
		humid = sense.get_humidity()
		self.button2["bg"] = 'orange'
		self.button2["text"] = 'Humidity \n' + str("%.3f" %humid) + ' %'
		
	def sensePressure(self):
		""" Senses Current Pressure """
		print ("Sensing Pressure")
		press = sense.get_pressure()
		self.button3["bg"] = 'orange'
		self.button3["text"] = 'Pressure \n' + str("%.3f" %press) + ' mBar'
	
	def senseGyro(self):
		""" Senses dynamic orientation """
		print ("Starting Gyroscope")
		
		helv12 = tkFont.Font(family='Helvetica', size=12, weight='bold') 
		self.Gyro = Tk.Toplevel(self.master)
		self.Gyro.title("Gyroscope")
		self.Gyro.grid_rowconfigure(1, weight=1)
		self.Gyro.grid_columnconfigure(1, weight=1)
		self.frame = Tk.Frame(self.Gyro)
		self.frame.pack(fill=Tk.X, padx=5, pady=5)

		self.l1 = Tk.Label(self.frame, text= "Pitch: ", font=helv12, height = 1, width = 10)
		self.l1.grid(row=1,column=0)
		
		self.l2 = Tk.Label(self.frame, text= "Roll: ", font=helv12, height = 1, width = 10)
		self.l2.grid(row=1,column=1)
		
		self.l3 = Tk.Label(self.frame, text= "Yaw: ", font=helv12, height = 1, width = 10)
		self.l3.grid(row=1,column=2)
		
		self.l4 = Tk.Label(self.frame, text="0", font=helv12, height = 1, width = 10)
		self.l4.grid(row=2,column=0)
		
		self.l5 = Tk.Label(self.frame, text="0", font=helv12, height = 1, width = 10)
		self.l5.grid(row=2,column=1)
		
		self.l6 = Tk.Label(self.frame, text="0", font=helv12, height = 1, width = 10)
		self.l6.grid(row=2,column=2)

		
		# Start button
		self.buttonStart = Tk.Button(self.frame, bg = 'white', text="Start", height = 1, width = 15,
			command = lambda: self.mGyro(1), font=helv12).grid(row=0,column=0)
		
		# Stop button
		self.buttonStop = Tk.Button(self.frame, bg = 'white', text="Stop", height = 1, width = 15,
			command = lambda: self.mGyro(0), font=helv12).grid(row=0,column=1)
		
	
	def mGyro(self, k):
		helv12 = tkFont.Font(family='Helvetica', size=12, weight='bold')
		if k == 1:
			self.running =  True
			while self.running == True:
				orientation = sense.get_orientation()
				pitch = orientation['pitch']
				roll = orientation['roll']
				yaw = orientation['yaw']
				self.l4['text'] = str("%.3f" %pitch)
				self.l5['text'] = str("%.3f" %roll)
				self.l6['text'] = str("%.3f" %yaw)
				root.update()			    
		else:
			self.running = False
			# sys.exit()		
						
		
	def senseAcc(self):
		""" Senses dynamic acceleration """
		print ("Sensing Acceleration")
		
		helv12 = tkFont.Font(family='Helvetica', size=12, weight='bold') 
		self.Acc = Tk.Toplevel(self.master)
		self.Acc.title("Accelerometer")
		self.Acc.grid_rowconfigure(1, weight=1)
		self.Acc.grid_columnconfigure(1, weight=1)
		self.frame = Tk.Frame(self.Acc)
		self.frame.pack(fill=Tk.X, padx=5, pady=5)

		self.l1 = Tk.Label(self.frame, text= "X: ", font=helv12, height = 1, width = 10)
		self.l1.grid(row=1,column=0)
		
		self.l2 = Tk.Label(self.frame, text= "Y: ", font=helv12, height = 1, width = 10)
		self.l2.grid(row=1,column=1)
		
		self.l3 = Tk.Label(self.frame, text= "Z: ", font=helv12, height = 1, width = 10)
		self.l3.grid(row=1,column=2)
		
		self.l4 = Tk.Label(self.frame, text="0", font=helv12, height = 1, width = 10)
		self.l4.grid(row=2,column=0)
		
		self.l5 = Tk.Label(self.frame, text="0", font=helv12, height = 1, width = 10)
		self.l5.grid(row=2,column=1)
		
		self.l6 = Tk.Label(self.frame, text="0", font=helv12, height = 1, width = 10)
		self.l6.grid(row=2,column=2)

		
		# Start button
		self.buttonStart = Tk.Button(self.frame, bg = 'white', text="Start", height = 1, width = 15,
			command = lambda: self.mAcc(1), font=helv12).grid(row=0,column=0)
		
		# Stop button
		self.buttonStop = Tk.Button(self.frame, bg = 'white', text="Stop", height = 1, width = 15,
			command = lambda: self.mAcc(0), font=helv12).grid(row=0,column=1)

	def mAcc(self, k):
		helv12 = tkFont.Font(family='Helvetica', size=12, weight='bold')
		if k == 1:
			self.running =  True
			while self.running == True:
				raw = sense.get_accelerometer_raw()
				self.l4['text'] = str("%.3f" %raw['x'])
				self.l5['text'] = str("%.3f" %raw['y'])
				self.l6['text'] = str("%.3f" %raw['z'])
				root.update()			    
		else:
			self.running = False
			# sys.exit()					
		
	def senseMagF(self):
		""" Senses dynamic magnetic field """
		print ("Sensing Magnetic Field")

		helv12 = tkFont.Font(family='Helvetica', size=12, weight='bold') 
		self.MagF = Tk.Toplevel(self.master)
		self.MagF.title("Magnetometer")
		self.MagF.grid_rowconfigure(1, weight=1)
		self.MagF.grid_columnconfigure(1, weight=1)
		self.frame = Tk.Frame(self.MagF)
		self.frame.pack(fill=Tk.X, padx=5, pady=5)

		self.l1 = Tk.Label(self.frame, text= "X: ", font=helv12, height = 1, width = 10)
		self.l1.grid(row=1,column=0)
		
		self.l2 = Tk.Label(self.frame, text= "Y: ", font=helv12, height = 1, width = 10)
		self.l2.grid(row=1,column=1)
		
		self.l3 = Tk.Label(self.frame, text= "Z: ", font=helv12, height = 1, width = 10)
		self.l3.grid(row=1,column=2)
		
		self.l4 = Tk.Label(self.frame, text="0", font=helv12, height = 1, width = 10)
		self.l4.grid(row=2,column=0)
		
		self.l5 = Tk.Label(self.frame, text="0", font=helv12, height = 1, width = 10)
		self.l5.grid(row=2,column=1)
		
		self.l6 = Tk.Label(self.frame, text="0", font=helv12, height = 1, width = 10)
		self.l6.grid(row=2,column=2)

		
		# Start button
		self.buttonStart = Tk.Button(self.frame, bg = 'white', text="Start", height = 1, width = 15,
			command = lambda: self.mMag(1), font=helv12).grid(row=0,column=0)
		
		# Stop button
		self.buttonStop = Tk.Button(self.frame, bg = 'white', text="Stop", height = 1, width = 15,
			command = lambda: self.mMag(0), font=helv12).grid(row=0,column=1)

	def mMag(self, k):
		helv12 = tkFont.Font(family='Helvetica', size=12, weight='bold')
		if k == 1:
			self.running =  True
			while self.running == True:
				raw = sense.get_compass_raw()
				self.l4['text'] = str("%.3f" %raw['x'])
				self.l5['text'] = str("%.3f" %raw['y'])
				self.l6['text'] = str("%.3f" %raw['z'])
				root.update()			    
		else:
			self.running = False
			# sys.exit()	

	def LEDMatrix(self):
		""" Creating new window for RGB LED matrix"""
		
		self.colorButtons()
		
		self.LEDMat = Tk.Toplevel(self.master)
		self.LEDMat.title("LED Matrix")
		self.LEDMat.grid_rowconfigure(1, weight=1)
		self.LEDMat.grid_columnconfigure(1, weight=1)
		
		self.frame = Tk.Frame(self.LEDMat)
		self.frame.pack(fill=Tk.X, padx=5, pady=5)
		
		self.frame2 = Tk.Frame(self.LEDMat)
		self.frame2.pack(fill=Tk.X, padx=5, pady=5)		
		
		
		# Creating Buttons : 8 x 8 Led Matrix
		self.dim = 8
		self.arr = np.zeros((self.dim, self.dim))
		
		self.buttonGrid = []
		self.buttonClickCount = np.zeros((self.dim, self.dim))
		
		# Setting font size and type
		helv10 = tkFont.Font(family='Helvetica', size=10, weight='bold') 
		
		for i in range(0, self.arr.shape[0]):
			row = []
			for j in range(0, self.arr.shape[1]):
				self.button = Tk.Button(self.frame, bg = 'gray', text = str(i+1)+ str(j+1), font=helv10, 
					command = lambda i=i, j=j: self.turnONLED(i, j), height = 2, width = 3)

				row.append(self.button)
				row[-1].grid(row=i,column=j)
			
			self.buttonGrid.append(row)
				
		# Starting LED Matrix 
		self.startLEDMatrix()
	
	def colorButtons(self):
				
		self.ColorList = Tk.Toplevel(self.master)
		self.ColorList.title("Colors")
		self.ColorList.grid_rowconfigure(1, weight=1)
		self.ColorList.grid_columnconfigure(1, weight=1)
		self.frame = Tk.Frame(self.ColorList)
		self.frame.pack(fill=Tk.X, padx=5, pady=5)
		
		# Button : Red
		self.buttonx1 = Tk.Button(self.frame, activebackground='Red', bg = 'Red', height = 2, width = 4,
			command = lambda: self.setColor(1))
		self.buttonx1.pack()
		
		# Button : Green
		self.buttonx2 = Tk.Button(self.frame, activebackground='Green', bg = 'Green', height = 2, width = 4, 
			command = lambda: self.setColor(2))
		self.buttonx2.pack()
		
		# Button : Blue
		self.buttonx3 = Tk.Button(self.frame, activebackground='Blue', bg = 'Blue', height = 2, width = 4,
			command = lambda: self.setColor(3))
		self.buttonx3.pack()
		
		# Button : Red + Green
		self.buttonx4 = Tk.Button(self.frame, activebackground='Yellow', bg = 'Yellow', height = 2, width = 4,
			command = lambda: self.setColor(4))
		self.buttonx4.pack()
		
		# Button : Green + Blue
		self.buttonx5 = Tk.Button(self.frame, activebackground='Cyan', bg = 'Cyan', height = 2, width = 4,
			command = lambda: self.setColor(5))
		self.buttonx5.pack()
		
		# Button : Red + Blue
		self.buttonx6 = Tk.Button(self.frame, activebackground='Magenta', bg = 'Magenta', height = 2, width = 4,
			command = lambda: self.setColor(6))
		self.buttonx6.pack()		
		
		# Button : Red + Green + Blue
		self.buttonx7 = Tk.Button(self.frame, activebackground='White', bg = 'White', height = 2, width = 4,
			command = lambda: self.setColor(7))
		self.buttonx7.pack()	

	def setColor(self, t):
		"""t= {1: Red}, {2: Green}, {3: Blue}, {4: Yellow}, {5: Cyan}, {6: Magenta}, {7: White} """
		if t==1:
			self.color = self.r
			self.colorname = 'Red'
			
		elif t==2:
			self.color = self.g
			self.colorname = 'Green'
			
		elif t==3:
			self.color = self.b
			self.colorname = 'Blue'
		
		elif t==4:
			self.color = self.rg
			self.colorname = 'Yellow'
			
		elif t==5:
			self.color = self.gb
			self.colorname = 'Cyan'
		
		elif t==6:
			self.color = self.rb
			self.colorname = 'Magenta'
			
		elif t==7:
			self.color = self.rgb
			self.colorname = 'White'
			
		else:
			print ("Wrong Color Argument, EXIT")
			sys.exit()
	
	
	def startLEDMatrix(self):
		
		for i in range(self.dim):
			for j in range(self.dim):
				if self.background == 0:
					sense.set_pixel(i, j, self.dark)
				else:
					sense.set_pixel(i, j, self.white)			

	def turnONLED(self, posX, posY):		
		
		print "button: ", (posX+1), " ", (posY+1), " count: ", self.buttonClickCount[posX][posY]
		self.buttonClickCount[posX][posY] += 1	
		
		if self.buttonClickCount[posX][posY]%2 == 1:
			self.buttonGrid[posX][posY]["bg"] = self.colorname
			sense.set_pixel(posX, posY, self.color)
		
		else:
			self.buttonGrid[posX][posY]["bg"] = 'Gray'
			sense.set_pixel(posX, posY, self.dark)
		
if __name__ == "__main__":
	
	run_LEDMatrix()
	root = Tk.Tk()
	app = RPiSenseHat(root) 
	root.mainloop()				

# -------------------------------------------- end - of - file ----------------------------------------------------- #
[moderator added code tags, and deleted second copy of this long post]
Last edited by Zombeatle on Sun Jun 20, 2021 1:44 am, edited 1 time in total.

User avatar
Gavinmc42
Posts: 5884
Joined: Wed Aug 28, 2013 3:31 am

Re: Need to find/make a SenseHAT GUI

Sun Jun 20, 2021 1:10 am

I have done a LCARS style display but that was baremetal on Ultibo with OpenVG.

For a simple Python method Guizero is quick
https://lawsie.github.io/guizero/
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Zombeatle
Posts: 71
Joined: Wed Jun 03, 2020 8:43 pm

Re: Need to find/make a SenseHAT GUI

Sun Jun 20, 2021 2:23 am

Gavinmc42 wrote:
Sun Jun 20, 2021 1:10 am
I have done a LCARS style display but that was baremetal on Ultibo with OpenVG.

For a simple Python method Guizero is quick
https://lawsie.github.io/guizero/
I'm familiar with GuiZero, gave it a try not long ago. It's not bad, but not quite what I'm looking for.

The idea is to have bar graphics displaying senseHAT data. GuiZero is mainly about interfaces, but has nothing for displaying data in a bar or line graph. Thanks anyway, though.

User avatar
Gavinmc42
Posts: 5884
Joined: Wed Aug 28, 2013 3:31 am

Re: Need to find/make a SenseHAT GUI

Sun Jun 20, 2021 9:17 am

You could try LVGL, it has charts.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
bensimmo
Posts: 5370
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Need to find/make a SenseHAT GUI

Sun Jun 20, 2021 10:45 am

Zombeatle wrote:
Sun Jun 20, 2021 2:23 am
Gavinmc42 wrote:
Sun Jun 20, 2021 1:10 am
I have done a LCARS style display but that was baremetal on Ultibo with OpenVG.

For a simple Python method Guizero is quick
https://lawsie.github.io/guizero/
I'm familiar with GuiZero, gave it a try not long ago. It's not bad, but not quite what I'm looking for.

The idea is to have bar graphics displaying senseHAT data. GuiZero is mainly about interfaces, but has nothing for displaying data in a bar or line graph. Thanks anyway, though.
GuiZero has the SenseHAT in the example code in their github ( I made it). But as you say not for graphs and things, you could look at add adding them in.

It may be easier to take something like Node-RED , it has SenseHAT plugins on the Pi and then use it's dashboards to create and interface.
Or look at PyGame etc if staying in python3.

User avatar
bensimmo
Posts: 5370
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Need to find/make a SenseHAT GUI

Mon Jun 21, 2021 6:30 am

You need to start putting Code tags around code, it keeps its formatting then.
It a choice in the toolbar or click on the BBcode link just near it for help.


That error is probably you using Python3 (Thonny, Mu) as I would expect, but trying to use proper old Python2 code.

Mainly as that print statement has not () around it and it tkinter now not Tkinter (lowercase t)
You can have a go at fixing it, but other bits and Bobs may not work.

Thonny can try and give help in it's side help box and Mu tends to give layout help.

Zombeatle
Posts: 71
Joined: Wed Jun 03, 2020 8:43 pm

Re: Need to find/make a SenseHAT GUI

Tue Jun 22, 2021 11:57 am

bensimmo wrote:
Mon Jun 21, 2021 6:30 am
You need to start putting Code tags around code, it keeps its formatting then.
It a choice in the toolbar or click on the BBcode link just near it for help.


That error is probably you using Python3 (Thonny, Mu) as I would expect, but trying to use proper old Python2 code.

Mainly as that print statement has not () around it and it tkinter now not Tkinter (lowercase t)
You can have a go at fixing it, but other bits and Bobs may not work.

Thonny can try and give help in it's side help box and Mu tends to give layout help.
Thanks - Wasn't aware of Code Tags before, but I'll know to include them next time.

Yeah, it turns out that it's that Python 2 v Python 3 difference making things crazy, like you said. Throwing in the parentheses fixed it quick. A few other problems cropped ups, like Tkinter and others being referred to differently as you mentioned, but a quick online search and knowing of the disparity between the two made it easy to correct.

As it turns out, it's only graphical in the "dialog boxes with buttons" sense, but I gather its possible to get graphical readouts - bar/line graphs and such - either in Python or by other means. So I'll be looking into that.

Thanks again.

Return to “Astro Pi”