Comments (6)
from guizero import *
arduinoData=[]
for i in range (1,25):
arduinoData.append(i*2)
print("Array: ",arduinoData) #Works OK
def read_sensor():
for i in range (0,24):
return arduinoData[i] # PRINTS ONLY FIRST LOOPING
#exchanged from original: return random.randrange(3200, 5310, 10) / 100
def update_label():
text.value = read_sensor()
recursive call
text.after(1000, update_label)
if name == 'main':
app = App(title='Sensor Display!',
height=200,
width=600,
layout='grid')
title = Text(app, 'Sensor value:', grid=[1, 1], size="50", color="blue")
text = Text(app, "xx", grid=[2, 1], size="50", color="red")
text.after(1000, update_label)
app.display()
from guizero.
The code is missing its indentation, could you update please.
I have edited the issues to format the code so its easier to read.
It isnt obvious to me what the program is trying to do.
Re this function:
def read_sensor():
for i in range (0,24):
return arduinoData[i] # PRINTS ONLY FIRST LOOPING
Regardless of how this function is called (via update
, repeat
, or call directly) it is only ever going to return the first value in the list. The for loop will start from 0 each time it is run.
This is not an issue with guizero so adding help wanted label.
from guizero.
I see the counter i in def read_sensor() loop will be reset for every call.
So counter has to be outside the loop and then i could not make it work. Where in code should the retreaving of values from the arduinoData() be placed to increment ?
from guizero.
Feel free to pop to https://forums.raspberrypi.com/viewforum.php?f=32 especially if you are then going to interface and Arduino physically.
Although actually displaying code on the RPi forum is not as good as here.
Simple method.
Create a global counter variable for i
Increment that either in update_ or read_ as you see best
Reset when it reaches its limit after the read_
from guizero.
Thanks bsimmo. I will try that. 👍
from guizero.
Closing due to inactivity.
from guizero.
Related Issues (20)
- Slider hide/show bug HOT 10
- Add options properties to Combo, ButtonGroup & ListBox HOT 1
- You cant programmatically add items to a ListBox that isn't enabled HOT 1
- Error (typo) on the book manual HOT 1
- Documentation Issue HOT 2
- Update installation documentation for Raspberry Pi 'bookworm' OS HOT 6
- An option in the question dialog to hide the input HOT 1
- effbot.org is dead (tk_event) HOT 1
- Uplift guizero to new Python versions
- Example in tutorial raises error HOT 1
- Migrate guizero build process HOT 6
- Showing and hiding large numbers of elements causes black screen HOT 1
- Theme Support HOT 1
- Updating Element Values of Method-Created Objects within a Drawing
- args for widgets that support command HOT 3
- app.box_color, feature! HOT 5
- Strange ordering of 2D-List in Tic-Tec-Toe program HOT 2
- Rename master to main HOT 2
- Add the ability to shape Waffles as a rectangle, not only as a square or dot
- When App is created visible=False, ButtonGroup radiobutton indicators are grey, not blue HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from guizero.