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.2.1.tar.gz (147.3 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.2.1-py3-none-any.whl (79.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for wxutils-2026.2.1.tar.gz
Algorithm Hash digest
SHA256 1ea04d747c67b8be34242a7970a05010f32cc71c3387f7c5a7fbec11df318ef9
MD5 dc0c09d1807ca462fbffef38c8b67cac
BLAKE2b-256 b6341b7b21024d5831f15e40e95261144d88fa101f2c9e9476d80efa4008b159

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for wxutils-2026.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c56715994ab4d01ae7fca4b5671c9d0fc9cba36b5a9bc9179c99609bb0de74c4
MD5 1e3f7c5a22773039005545753344f8a1
BLAKE2b-256 0f21b66689b12b221d4f4cb1aedc80a781aaed9da7c1c842d5985e01d4c7745b

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