Skip to content

Provides convenience functions for easier layout of PyQt and PySide widgets

License

Notifications You must be signed in to change notification settings

brakedust/qtlayout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

qtlayout module

Intro

This module makes it easier to programatically layout widgets for PyQt and PySide applications in Python. There are several helper functions which wrap commonly used layouts.

qtlayout uses the qtpy module to support PyQt4, PyQt5, and PySide.

The following layouts are currently handled:

  • hbox - QHBoxLayout
  • vbox - QVBoxLayout
  • stack - QStackWidget
  • grid - QGridLayout
  • hsplit - QSplitter (with horizontal orientation)
  • vsplit - QSplitter (with vetical orientation)
  • flow - custom flow layout container

Example

To layout a few widgets in a QHBoxLayout:

# the necessary imports
from qtlayout import QtWidgets, hbox

# must create a QApplication first
qapp = QtWidgets.QApplication(['test'])

# define our controls
label = QtWidgets.QLabel('A label')
btn = QtWidgets.QPushButton('Push me')
editor = QtWidgets.QLineEdit('editing')

# lay them out in an hbox layout.  This takes care
# of creating a parent widget, creating a layout,
# setting the layout of the parent widget, and (finally)
# adding all of the controls to the layout.
# The parent widget is returned.
w = hbox(label, btn, editor)

# create the main window and go
mw = QtWidgets.QMainWindow()
mw.setCentralWidget(w)
mw.show()
qapp.exec_()

Links to External Documentation

About

Provides convenience functions for easier layout of PyQt and PySide widgets

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages