Skip to main content

Scrollable containers for Tkinter, wxPython, PyQt5 and PyQt6

Project description

Scrollable containers which just work!

If you have developed GUI applications, you probably know the pain of designing a clean front-end only to find that your application window is too large for your client's screen. Making the content scrollable is not straightforward (at least in Tkinter). Especially not after you have already written a lot of code to draw the content.

You can use ScrollableContainers to reduce headaches. It's available on PyPI!

pip install ScrollableContainers

Scrollable containers are currently available for the following GUI toolkits.

  • Tkinter
  • wxPython
  • PyQt5
  • PyQt6

This project is not sponsored or endorsed by, or connected with, any organisation or entity such as but not limited to: the Tcl Core Team, the Python Software Foundation, the wxWidgets Team, the wxPython Team, the Qt Company and Riverbank Computing.

Tkinter

ScrollableContainers.ScrollableFrameTk: a comprehensive implementation of a scrollable frame, and the flagship class of this project. (I wrote the other classes just for completeness.)

Usage

Add widgets to the frame attribute of a ScrollableFrameTk object. See examples.

Features

  • Handles resize events correctly.
  • Supports scrolling with the mouse wheel and touchpad.
    • Scrolling the mouse wheel or swiping vertically with two fingers on the touchpad triggers a vertical scroll.
    • Scrolling the mouse wheel while holding down Shift or swiping horizontally with two fingers on the touchpad triggers a horizontal scroll.
  • Horizontally centres the contents if the window is wider.

Notes

'<Button-4>', '<Button-5>' and '<MouseWheel>' are bound to all widgets using bind_all to handle mouse wheel scroll events. Do not unbind_all (or bind_all another function to) these three sequences!

wxPython

ScrollableContainers.ScrollablePanelWx: a thin wrapper around wx.lib.scrolledpanel.ScrolledPanel.

Usage

Add widgets to the panel attribute of a ScrollablePanelWx object. See examples.

Features

  • Does everything the wrapped class does.
  • Horizontally centres the contents if the window is wider.

PyQt5/PyQt6

ScrollableContainers.ScrollableAreaQt5/ScrollableContainers.Qt6.ScrollableAreaQt6: a thin wrapper around PyQt5.QtWidgets.QScrollArea/PyQt6.QtWidgets.QScrollArea.

Usage

Add widgets to the area attribute of a ScrollableAreaQt5/ScrollableAreaQt6 object. See examples.

Features

  • Does everything the wrapped class does.
  • Horizontally centres the contents if the window is wider.

In GTK, containers are widgets, so they can be aligned in other containers.

import gi; gi.require_version('Gtk', '3.0')
import gi.repository.Gtk as Gtk
import itertools

window = Gtk.Window()
window.connect('destroy', Gtk.main_quit)
window.set_default_size(256, 128)

scrolled_window = Gtk.ScrolledWindow()
window.add(scrolled_window)

grid = Gtk.Grid()
grid.set_halign(Gtk.Align.CENTER)
grid.set_row_spacing(20)
grid.set_column_spacing(20)
scrolled_window.add(grid)

dim = 10
for (i, j) in itertools.product(range(dim), repeat=2):
    label = Gtk.Label()
    label.set_label(f'Label\n({i}, {j})')
    grid.attach(label, j, i, 1, 1)

window.show_all()
Gtk.main()

Since horizontally centring the contents of a scrollable container is the primary function of this package, and GTK has built-in functionality to achieve the same, no submodule for PyGObject is implemented here.

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

ScrollableContainers-1.1.1.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

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

ScrollableContainers-1.1.1-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file ScrollableContainers-1.1.1.tar.gz.

File metadata

  • Download URL: ScrollableContainers-1.1.1.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for ScrollableContainers-1.1.1.tar.gz
Algorithm Hash digest
SHA256 9ce2f058b909d5d0fa0bf7196d049461762963efebd6138d4e9f89a58f817631
MD5 de8f02e4c2b15415d990b70f8ce832c1
BLAKE2b-256 f932acc9529015c862a548847fb87ffef7fb903a31f84916227ef2e2eeb78c34

See more details on using hashes here.

File details

Details for the file ScrollableContainers-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ScrollableContainers-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f790cf1429f7c18fd61ec2039847c393599067db04e698bcedcd8a3e51f5a850
MD5 2d264ca22a0e5d0514db1344fe626cff
BLAKE2b-256 138d7fba4b3e42879e6436e3d7e919d518b2b1b5b4598ebb48c42f661391b772

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