display a variable in guizero app?
by RonHof from LinuxQuestions.org on (#4QYVP)
I have the following code the reads and decodes a string on serial port ttyUSB0:
Code:#!/usr/bin/env python
import time
import serial
import string
ser = serial.Serial(
port='/dev/ttyUSB0',
baudrate = 4800,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)
while 1:
Str = ser.readline(8)
Str = Str.decode('cp1252','strict')
print ("decoded string: ")
print (Str) # Print decoded stringand I have the following code to create a guizero app that displays the number 999.99 in this case. It works as expected.
Code:#!/usr/bin/env python
import time, serial, string
from guizero import App, Text
app = App(title="Video Scoreboard", height=300, width=400)
message = Text(app, text="999.99",
size=500,
font="Times New Roman",
color="white",
bg="black"
)
app.display() It works as expected. I'm trying to replace the "999.99" in the app with Str from Str.decode but so far no luck


Code:#!/usr/bin/env python
import time
import serial
import string
ser = serial.Serial(
port='/dev/ttyUSB0',
baudrate = 4800,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)
while 1:
Str = ser.readline(8)
Str = Str.decode('cp1252','strict')
print ("decoded string: ")
print (Str) # Print decoded stringand I have the following code to create a guizero app that displays the number 999.99 in this case. It works as expected.
Code:#!/usr/bin/env python
import time, serial, string
from guizero import App, Text
app = App(title="Video Scoreboard", height=300, width=400)
message = Text(app, text="999.99",
size=500,
font="Times New Roman",
color="white",
bg="black"
)
app.display() It works as expected. I'm trying to replace the "999.99" in the app with Str from Str.decode but so far no luck