Pysimplegui: [ Enhancement/Bug/Question] My problem is...

Created on 21 Jun 2020  ·  4Comments  ·  Source: PySimpleGUI/PySimpleGUI

Type of Issues (Enhancement, Error, Bug, Question)

Question / Enhancement

Operating System

Win10, Raspian

Python version

3.7

PySimpleGUI Port and Version

tkinter Port, 4.20.0


4.20.0 Released 6-Jun-2020

Your Experience Levels In Months or Years

1 years_________ Python programming experience
45 years_________ Programming experience overall
yes_________ Have used another Python GUI Framework (tkinter, Qt, etc) previously (yes/no is fine)?

You have completed these steps:

  • [ x] Read instructions on how to file an Issue
  • [ x] Searched through main docs http://www.PySimpleGUI.org for your problem
  • [ x] Searched through the readme for your specific port if not PySimpleGUI (Qt, WX, Remi)
  • [ x] Looked for Demo Programs that are similar to your goal http://www.PySimpleGUI.com
  • [ x] Note that there are also Demo Programs under each port on GitHub
  • [ x] Run your program outside of your debugger (from a command line)
  • [ x] Searched through Issues (open and closed) to see if already reported
  • [ ]x Try again by upgrading your PySimpleGUI.py file to use the current one on GitHub. Your problem may have already been fixed but is not yet on PyPI.

Description of Problem / Question / Details

My app is for a GUI on raspberry with elements updating in real time (async window)
UPS2-GUI
. It's working fine, but some additional features in pysimplegui would be great:
Question1: Please provide a list with text element attributes that are updatable by window['xxkey'].update().

Question2: What is the purpose of the _f_ in window[f'xxkey'] appearing in some of your examples

Enhancement porposal: important for dynamic update me is e.g. 'border_width' on a text.

working examples:
window['K_BATT_STATE'].update('LOW')
window[f'K_BATT_V'].update(background_color='green')

not working example:
window[f'K_BATT_V'].update(border_width=2)

Most helpful comment

As I known

  • Options of Text element attributes shown in Update(value=None, background_color=None, text_color=None, font=None, visible=None).
  • The only one demo example use window[f'...] is Demo_Column_Elem_Swap_Entire_Window.py. f-string used for substring replacement by variable.

One sample for you.

import PySimpleGUI as sg

layout = [[sg.Text('Hello World !', font=('Courier New',20), key='TEXT1')],
          [sg.Text('dlroW olleH !', font=('Courier New',20), key='TEXT2')]]
window = sg.Window('Text', layout, finalize=True)
window['TEXT1'].Widget.configure(borderwidth=5, relief='solid')

while True:

    event, values = window.read()
    if event == sg.WINDOW_CLOSED:
        break

window.close()

All 4 comments

The documentation and the built-in doc strings tell you exactly what is available for each element's update method. Take a look at the detailed call reference.
http://calls.PySimpleGUI.org
If something's not there, then you have a couple of choices. You can directly manipulate the underlying Widget, or open an enhancement request.,

As I known

  • Options of Text element attributes shown in Update(value=None, background_color=None, text_color=None, font=None, visible=None).
  • The only one demo example use window[f'...] is Demo_Column_Elem_Swap_Entire_Window.py. f-string used for substring replacement by variable.

One sample for you.

import PySimpleGUI as sg

layout = [[sg.Text('Hello World !', font=('Courier New',20), key='TEXT1')],
          [sg.Text('dlroW olleH !', font=('Courier New',20), key='TEXT2')]]
window = sg.Window('Text', layout, finalize=True)
window['TEXT1'].Widget.configure(borderwidth=5, relief='solid')

while True:

    event, values = window.read()
    if event == sg.WINDOW_CLOSED:
        break

window.close()

Thanks much Jason!

When a feature of an underlying "widget" is not exposed through the PySimpleGUI APIs, then you can use the .Widget member variable to directly access the underlying GUI framework's widget. You lose the portability from one framework to another, but that's generally not an issue in these cases.

Glad you got a solution you're OK with.

Hi Jason, Hi Mike
Thanks a lot! Both answers are helpful ended my suffering :-) within minutes.
Pysimplegui is a great product with an incredible support!
As soon as my project is usable, I will publish it on my git account. It is an uninterruptable and high efficiency power supply for all raspberry models 3++ and pi zero and includes a complete hardware and software design.

Was this page helpful?
0 / 5 - 0 ratings