display a variable in guizero app?
I have the following code the reads and decodes a string on serial port ttyUSB0:
Code:
#!/usr/bin/env python Code:
#!/usr/bin/env python |
Exactly what did you try and what was the error message?
|
I have no familiarity with guizero, even so it is difficult to understand the question without needing to know that detail.
What does this produce, exactly? Is it what you expected? Code:
while 1: If it is correct then how are you passing it to your app object? We can see no attempt to set that value in the code you have posted. Please review the Site FAQ for guidance in posting your questions and general forum usage. Especially, read the link in that page, How To Ask Questions The Smart Way. The more effort you put into understanding your problem and framing your questions, the better others can help! |
OK I have a legacy hardware device, a timer, that sends a floating point number between 0.00 and 999.99 as a coded stream. I have this device connected to the usb port on my Raspberry Pi. The first snippet of code reads and decodes the serial stream and displays the floating point number on the command line as I hoped it would. I want to display this number in the App. So far I haven't figured out how to do this. The app as posted displays the text 999.99 without any error messages. I only posted the code that I had working so you might see where I am trying to go. I tried putting the serial read and decode inside the app, that is between the app= and app.display, but all I get is a blank app window. No error messages. I also tried the TextBox widget but it would only read inputs from the keyboard. I have seen lots of windows displaying text and number data from outside sources so I assume there is some straight forward way to do this but I don't know how to proceed.
Thanks for your help |
guizero uses the Tkinter library and is supposed to be make it easier to create GUI applications.
It was my suggestion in another thread by the OP to use guizero as a way to display the decoded value received on the serial port in a window. The OP wants to incorporate the code from their command line python script into the GUI script. Unfortunately, I might of implied there was nothing to it... However, it is bit more complicated then the provided tutorials. Maybe I can find some decent code examples. |
still looking and reading... currently pursuing tkinter 'listbox' and tkinter.listvariable. Does this seem to be a useful direction?
|
display a string in Tkinter?
I have the following code that gets a string from ttyUSB0.
Code:
#!/usr/bin/env python I am also trying to create a GUI to display it. So far I have the following code that works in so far as it does display the word TEST and the QUIT button works Code:
#!/usr/bin/env python I think I need to get the decoded string into dtime.set. If so, how do I do that? or is there a better easier way to do it? |
You can’t use infinite loops with a GUI, there’s an explanation why here:
https://lawsie.github.io/guizero/blocking/ Here is a guizero example of how to read data from a sensor (in the example the sensor is just simulated by generating a random number) https://github.com/lawsie/guizero/bl...ate_example.py |
Anchor text in widget?
I have made up a GUI with the following code. I believe I have a problem with anchoring the text in the label_time widget. The text is not always in the same location. Sometimes it is even wrapped onto two lines. I'm trying to get the text to always display centered in the label_time widget. I would also like to adjust the size of the font, but I think that is a problem to be addressed in another thread. There are no error messages when I execute the code.
Code:
#!/usr/bin/env python3 |
All times are GMT -5. The time now is 04:50 AM. |