I am glad to announce the release of MySimpleGUI version 1.1,6: GitHub <https://github.com/salabim/MySimpleGUI>salabim/MySimpleGUI <https://github.com/salabim/MySimpleGUI> Enhancement for PySimpleGUI as an addon module. Contribute to salabim/MySimpleGUI development by creating an account on GitHub. MySimpleGUI is an extension to the popular PySimpleGUI (see https://github.com/PySimpleGUI/PySimpleGUI) package, which adds functionality and significantly changes exception handling, making it more Pythonic and facilitates debugging of GUIs. Major additions: - Attribute notation to *Window* and the *values parameter as returned from Window.read()*, e.g. import MySimpleGUI as sg layout = [[sg.Text('Your typed chars appear here:'), sg.Text(size=(15,1), key='output')], [sg.Input(key='input')], [sg.Button('Show'), sg.Button('Exit')]] window = sg.Window('Pattern 2B', layout) while True: # Event Loop event, values = window.read() if event == sg.WIN_CLOSED or event == 'Exit': break if event == 'Show': window.output.update(values.in)window.close() - A Multiline element can now be used as a file. That means, a user program can use the write function, but more importantly, can also use the print builtin, like print("This is a test", file=window.mymultiline) Multiline elements can be closed and flushed as ordinary files. That also opens the door to more Pythonic redirections of stdout and stderr. - And Multiline files support ANSI colours, both for foreground and background colours. The escape sequences associated with the various colours can be used as such but also via the ansi dict like data structure. So, we can now do: import MySimpleGUI as sg from MySimpleGUI import ansi ... window = [[sg.Multiline, size=(80, 10), key="results"]] print(f"colour {ansi.red} red {ansi.onred}{ansi.white} red on white {ansi.reset}", file=window.results) print(f"still red on white {ansi.reset}{ansi.green} green", file=window.result) - ANSI colours are also supported as the initial contents of Multiline and PopupScrolled. - MySimpleGUI provided functions to get/set the globals that can be normally only be defined with SetOptions: The value of a global variable can be retrieved by calling the function without an argument, like current_message_box_line_with = sg.message_box_line_width() The value of a global variable can be set by calling the function with the new value as its argument, like sg.message_box_line_width(20) And it is possible to use the function with an argument as a context manager. In that case, the global variable will be restored after finishing the context manager: with sg.message_box_line_width(20): sg.Popup("Hey, this is much more narrow than usual!") sg.Popup("And now it's back to the usual 60 characters width, isn't it?") - MySimpleGUI can print Elements, Columns and Windows in a nice format, which can be very useful for debugging and just getting to know what MySimpleGUI/PySimpleGUI does internally. MySimpleGUI is implemented as an add-on that actually patches an existing PySimpleGUI installation (*source code injection*). This means that future versions of PySimpleGUI will be automatically supported.
participants (1)
-
Ruud van der Ham