Skip to main content

utilities and convenience functions for wxPython

Project description

wxutils

wxutils is a Python library with a collection utilities and convenience functions for wxPython. It is by no means comprehensive, but aims to simplify wxPython code, reduce boiler-plate, make wxPython coding a bit more python-like.

convenience functions

A large share of the classes in wxutils are simplified versions of wxPython widgets with common programming attributes and patterns. For example, a commmon pattern to create a Button in wxPython

import wx
btn = wx.Button(parent, label=label, **kws)
btn.Bind(wx.EVT_BUTTON, onButtonPress)

becomes

import wxutils
btn = wxutils.Button(parent, label,  action=onButtonPress, **kws)

While this can be viewed as merely a convenience, and not a completely general solution. But it is a very common pattern, and the wxutils version hides the ugliest parts of wxPython.

There are several similar convenience widgets, including Check, Choice, and SimpleText (a simplified variant of StaticText), MenuItem, Font, HLine, OkCancel, HyperText.

In addition, there are more complex widgets:

  • FloatCtrl a wx.TextCrtl that allows numerical input only. Precision, upper bound, and lower bound can be set, and a callback can be bound to the control.

  • NumericCombo wx.ComboBox with a FloatCtrl

  • EditableListBox a list box with a built-in popup menu to arrange order of the items with "move up/down, to top, to bottom"

  • YesNo a wx.Choice of only 'No' and 'Yes'

  • GridPanel a combined GridBagSizer and Panel that simplifies adding widgets to a GridBagSizer.

  • FileOpen, FileSave wrappers (supporting wildcards) to FileDialog.

colors and dark mode

wxPython supports switching between Dark Mode and Light Mode, and will automatically make this switch when the system setting changes. While a nice development, this means that any code that explicitly sets colors of some widget properties would either have to set colors for everything attribute (ignoring the system mode) or select and change colors based on the mode.

The wxutils.color module tries to help with this in a few ways. First, it uses the darkdetect module to identify Dark mode, and to allow callbacks to run when the mode changes. Second, it provides dictionaryes colors for both dark and light mode (COLORS_DARK and COLORS_LIGHT) using names for their usage ('text', 'text_bg', 'nb_text', and so on) that can be used as DARK-mode aware values. The wxutils.colors.COLORS attribute will be either wxutils.colors.COLORS_DARK or wxutils.colors.COLORS_LIGHT depending on the mode. All the wxutils classes and functions will use these, and so respond to changes in the dark mode. A number of utility functions in wxutils.colors are provided:

  • add_named_color(name, light, dark) to add a named color to both COLORS_LIGHT and COLORS_DARK, using either RGB or RGBA tuples.
  • set_color(widget, colorname, bg=None) to set the foreground (and optionally background) color by name in the COLORS dictionaries.
  • get_color(name) to get the color value by name.
  • register_darkdetect(callback) to define a callback to be run when a change in Dark mode is detected.

dedicated widgets for working with passwords

The wxutils.passwords module has dedicated code and wx widgets for dealing with Password dialogs, including 'show and hide password' icons. These methods can enforce common password rules like length and number of specials and can generate a "password hash" (which includes a salt and a number of iterations for the pbkdf2 algorithm) which is safe to store on disk, and methods to check the password against an existing hash. Methods in this module include

  • hash_password() to convert a password into a safe-to-store hash.bimum number of lowercase, upper case, digits, special characters.
  • PasswordPanel which includes a Password TextCtrl that can be toggled to show or hide plain text password.
  • PasswordCheckDialog a dialog to challenge for a password to match an existing hash.
  • PasswordSetDialog a dialog to set a Password, checking that password rules are satisfied.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wxutils-2026.1.0.tar.gz (145.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wxutils-2026.1.0-py3-none-any.whl (77.9 kB view details)

Uploaded Python 3

File details

Details for the file wxutils-2026.1.0.tar.gz.

File metadata

  • Download URL: wxutils-2026.1.0.tar.gz
  • Upload date:
  • Size: 145.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.10

File hashes

Hashes for wxutils-2026.1.0.tar.gz
Algorithm Hash digest
SHA256 e9bb225937e57a8b567c660eb73d8a03f04fa4f21cfe36ca443590a0760f5476
MD5 93e77bb64a398af3ae03011022d5477e
BLAKE2b-256 194a385fb1c290378d8d62c9bf8b1b126f5ed1bd46fe55dfd8eb3204cc95317d

See more details on using hashes here.

File details

Details for the file wxutils-2026.1.0-py3-none-any.whl.

File metadata

  • Download URL: wxutils-2026.1.0-py3-none-any.whl
  • Upload date:
  • Size: 77.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.10

File hashes

Hashes for wxutils-2026.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7dbede53d53d1bf76d790154364e32e1a37a379772a2f82b011d86e03d94d399
MD5 8b4b6bfc954a581d873e8e9adcd4f5d2
BLAKE2b-256 633807c6784433feaebc651e481c0a42c189713f957e4ac8990b9b7f427fa69f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page