Skip to content

v0.11.0 - The "Files and functions"-update

Latest

Choose a tag to compare

@CheesecakeTV CheesecakeTV released this 10 Jan 13:13
· 66 commits to main since this release
1b63f7b

The "Files and functions"-update

This update brings a ton of functional additions from many different topics.

File-system

There is a basic tutorial on most of these additions, the others follow shortly.

Program directory

SwiftGUI just made working with a program-directory a lot easier.

You can define a program-directory that fits pretty much any operating system.
There is an easy function to generate paths inside that directory without even knowing where it is exactly.

This way, you can save files to a separate location without little to no effort.

Configuration-files

It's easy to create configuration-options through "configuration-files" for the user now.

Additionally, SwiftGUI offers two new elements to integrate editing these files in the GUI-Application.
These also work great as popups.

Dict-files

(Not sure what to call these otherwise)

SwiftGUI offers two new classes that function like a dict, but save their content to a file automatically (can be turned off).
This makes it easy to save and load values.

Currently, json and pickle is supported.
If you'd like to use a different encoding, you can easily create your own file-handler, by overwriting only two methods.

Saving values

It's possible to save and load the user-inputs of your layout now.

Reapplying these values is as easy as saving them, literally a single function-call.
However, this only works for elements with a key right now.

But on the other hand, it is downward-compatible.
If you update the application, old saves will still work fine without breaking the whole program.

Dynamically changing the layout

  • Elements and rows of elements can be deleted now
  • Elements and rows of elements can be added now
  • Elements can be hidden and shown now (experimental)
  • New methods to find out in which row a certain element is

(Most of these functionalities do not work for sg.GridFrame yet)

There is an advanced tutorial explaining how to do this.

Non-blocking popups

Since the popup-structure can be used well to implement full sub-windows, there is sg.BasePopupNonBlocking as an alternative.

Works the same as sg.BasePopup, but doesn't block the code.
It also returns itself upon creation instead of the "return-value".

Read the tutorial on additional windows for further infos.

New elements

  • sg.Matplot: shows a matplot figure. This has to be installed through another package though: https://github.com/CheesecakeTV/SwiftGUI-Matplot
  • sg.Files.ConfigSectionEditor: A combined element that lets the user edit one section of a configuration
  • sg.Files.ConfigFileEditor: A combination out of multiple sg.Files.ConfigSectionEditor in an sg.Notebook to edit a whole configuration-file a single layout

Combined elements can be popups now

Since combined elements and popups are already pretty similar, you can choose what's it gonna be now.
Just create the combined element and call .popup(), or .popup_nonblocking() on it.

Use .done() inside a combined element to support return-values when it is opened as a popup.

Other changes / bugfixes

  • preview_all_themes now accepts a popup that gets previewed instead of the default preview_all_elements. Helpful when trying to decide on a theme
  • Major performance-boost to global options. Literally 10-50 times faster now
  • Timeout-option is available for key-handlers now. If the event-loop doesn't execute for x seconds, it throws an event to execute it once
  • call_periodically-decorator to call functions periodically while a window exists
  • Windows and subwindows can call a function when being closed by the user now
  • It is possible to disable the default-event of buttons now
  • Improvements to sg.Notebook
  • Improvements to combined elements
  • sg.Combobox has a properly colored slider now
  • Improvements to sg.Radiobutton
  • Improvements to sg.Button
  • Improved typehinting
  • Overall naming-consistency improved
    • Corrected element-categorization
  • Basically all bugs from GlobalOptions are fixed
  • sg.Spinbox works properly now (it didn't before...)
  • sg.Themes.Thematic.Hacker and sg.Themes.Thematic.FacebookMom finally completed
  • Renamed two themes to not risk copyright problems
  • Added the option hide_headings to sg.Table for more flexibility