Comments (19)
My use case is very simple and I want to know if PysimpleGui can accommodate the use of dynamically updating a button’s text and color based on a changing status. No input(clicking a button) etc is involved.
Yessir!
If you use the call sg.write_event_value
then you can inject an event into your event loop and change the information there. It's the same call that you can use from a thread (the only call you can use from a thread).
from pysimplegui.
Excellent, I will look up the documentation on that call. Also, do you offer a box element to basically do what I need without having to formally use a button element with all the disabled=T/F etc attributes for a status box?
from pysimplegui.
Not sure what the expectation, but
Example Code here for you
from time import sleep
from random import randint
import PySimpleGUI as sg
def capture():
global running, temperature
while running:
temperature = (temperature + randint(-10, 10)) % 100
window.write_event_value("Update", temperature)
sleep(1)
settings = {
"Normal": {"disabled":True, "button_color":("white", "blue")},
"Alarm" : {"disabled":False, "button_color":("white", "red" )},
}
temperature, state = 25, "Normal"
layout = [
[sg.Push(), sg.Button("Alarm", font=("Courier New", 24, "bold"), **settings[state]), sg.Push()],
[sg.Text("Temperature:", justification='center', expand_x=True, key="TEMPERATURE")],
[sg.Text('', size=(50, 1), relief='sunken', font=('Courier', 11), text_color='yellow', background_color='black', key='TEXT')],
]
window = sg.Window("Demo", layout, enable_close_attempted_event=True, finalize=True)
running = True
window.perform_long_operation(capture, "Done")
while True:
event, values = window.read()
if event == sg.WINDOW_CLOSE_ATTEMPTED_EVENT:
running = False
elif event == "Update":
temperature = values[event]
window['TEXT'].update('█'*temperature)
window['TEMPERATURE'].update(f"Temeperature:{temperature}")
state = "Normal" if 15 <= temperature <= 35 else "Alarm"
window['Alarm'].update(**settings[state])
if event == "Done":
break
window.close()
from pysimplegui.
Most things are "clickable" so that you'll get an event. If you use an Image element to display an image and set enable_events=True, then you'll get an event when the image is clicked. Check the different elements for this capability.
I'm confident you'll be able to build something you'll like if you study the library for a short while. There are a lot of examples for you to see and run, and excellent documentation.
from pysimplegui.
from pysimplegui.
from pysimplegui.
I can't understand a mass of code and text.... a picture I can make sense of though. A sketch would even work.
from pysimplegui.
from pysimplegui.
I don't see anything. Replying to GitHub issues doesn't post images, format your code, etc. I'm happy to try and help. Determining if a library can do what your project needs is a good sized portion of the work, as I'm sure you've encountered in your long history of programming. A sketch usually answers the basic capability question, but even then if the specific desired approach isn't doable, there are often other approaches that can be taken.
from pysimplegui.
from pysimplegui.
from pysimplegui.
If you want to post a Visio diagram, export/save as a PNG/JPG, come to the GitHub issues on the web, drag and drop into a comment. Replying via email is not helpful.
from pysimplegui.
from pysimplegui.
Here is the diagram depicting the use case.
from pysimplegui.
You can change a PySimpleGUI window from any place in your code you want as long as it's the main thread. It cannot be another thread.
I don't see a problem with doing the kind of operation you're after. It's not a difficult operation to update an element.
from pysimplegui.
Since you're talking about a dashboard of sorts, there's a dashboard mock-up in the eCookbook you can run and look at the code if that would help you see that you don't need to do anything in order to change things in the GUI. When the program starts you don't need to do anything to "start" it.
https://docs.pysimplegui.com/en/latest/cookbook/ecookbook/elements/graph/dashboard-mockup/
from pysimplegui.
Got it thank you.. Greatly appreciate the patience. Thanks again..
You're welcome.... we're here to help... best of luck with your program! Come back when you're done and post a screenshot if you are able to.
from pysimplegui.
Thank you. I will look into the the link in the cookbook and check it out. I did look at the cookbooks old and the eCookbooks.
I just wanted to know if it was possible before going deeper into PySimpleGUI. I will definitely post a pic of the end result and again greatly appreciate the assistance.
from pysimplegui.
again greatly appreciate the assistance.
Thank you for the "thank you"! It's nice to know when we've helped. Have fun.... enjoy the ride!
from pysimplegui.
Related Issues (20)
- Flask click SystemError when used with pySimpleGUI output redirect HOT 1
- [Question] How to trap an event HOT 2
- [Enhancement] CI friendly handling for the first time installation dialog HOT 3
- [Question] How to update class parameter within inherited class HOT 4
- [Question] How To Re-Enter Data For A Specific Field - AND 'CR to act like TAB HOT 1
- [ Bug] sg.ColorChooserButton Unless Additional Tkinter Import HOT 1
- [Bug] Hitting the image-count limit [Fail to create pixmap with Tk_GetPixmap in TkImgPhotoInstanceSetSize] HOT 6
- [Question] Import error HOT 3
- [Question] Change focus highlight when tabbing to button HOT 8
- [ Enhancement/Bug/Question] NOTE - you can also call sg.main() or sg.main_open_github_issue() to post an issue HOT 1
- [ Question] Compiling Errors since License validation HOT 2
- [ Bug] Broken Doc Link HOT 2
- [Question] NOTE - Table get doesn't work HOT 6
- [ Enhancement] allow arrowheads for lines in tkinter graphs HOT 8
- [Question] Question of shortcut HOT 17
- [Question] How to Use PySimpleGui Programs on Other PCs HOT 1
- [ Question] How to detect when we manually enter a value in combo box in Pysimple GUI HOT 1
- [Bug] Table colored rows flashes when updating in 5.0, while they didn't in 4.x HOT 10
- [Question] No right_click_menu in Combo HOT 3
- [Enhancement] Reusing Context Menu 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 pysimplegui.