A flexible toolset to improve QML coding experience for PySide6 development.
Project description
LK QtQuick Scaffold
Using Python and Qt QML to build desktop applications from a series of predefined tools.
How to Install
pip install lk-qtquick-scaffold
Python 3.8 is the minimum required version.
Highlights
- A layout engine to extend QML layouts.
- Integrate qt logging with python console (no need to enable "emulate terminal in output console" in PyCharm).
- Executing Python snippet in QML, and vice versa.
- Easy-to-use register handler for registering Python functions to QML side.
- Hot loader for testing target layout.
- Assets manager to thoroughly control application appearance (color, motion, shape, typograph, and so on).
- A built-in theme to quickly produce elegant user interface. For example,
use
LCButton
orLCGhostButton
to replace the normalButton
.- Currently (v1.x) there's only one theme (LightClean Theme) provided.
Feature Quickview
Layout Engine
import QtQuick
Item {
Rectangle {
Component.onCompleted: {
LKLayoutHelper.quick_anchors(this, parent, {
'reclines': [1, 1, 0, 1], // left, top, right, bottom
'margins': [12, 4, 12, 4] // left, top, right, bottom
})
}
}
}
import QtQuick
Row {
spacing: 4
Rectangle {
width: 0.5 // 50% of parent.width (respect parent.spacing)
height: parent.height
}
Rectangle {
width: 0.2 // 20% of parent.width (respect parent.spacing)
height: parent.height
}
Rectangle {
width: 0 // fill the rest (30% of parent.width) (respect parent.spacing)
height: parent.height
}
Component.onCompleted: {
LKLayoutHelper.hadjust_children_size(this)
}
}
TODO:MoreExamples
Integrate qt logging with python console
Executing Python snippet in QML, and vice versa
from lk_qtquick_scaffold import eval_js
def foo(a: QObject, b: QObject):
eval_js('''
{0}.anchors.left = Qt.binding(() => {{
return {1}.anchors.left
}})
''', a, b)
import QtQuick
ListView {
model: pyside.eval(`
import os
files = os.listdir(input('target folder: '))
return files
`)
}
Register Python functions to QML side
There're two ways to register:
from lk_qtquick_scaffold import reg
@reg()
def foo(*args, **kwargs):
print(args, kwargs)
return True
from lk_qtquick_scaffold import pyside
def foo(*args, **kwargs):
print(args, kwargs)
return True
pyside.register(foo)
Then call it by function name in QML side:
import QtQuick
Item {
Component.onCompleted: {
var result = pyside.call('foo', [1, 2, 3], {'aaa': 4, 'bbb': 5})
}
}
Hot Loader
from lk_qtquick_scaffold import app, hot_loader
# Just replace `app.start` with `hot_loader.start`
# app.start('view.qml')
hot_loader.start('view.qml')
Assets Manager
TODO:AssetsManagerExample
LightClean Theme
See also code_examples/eg01_viscous_indicator_anim:
import QtQuick
import LightClean
import LightClean.LCComplex
LCWindow {
width: 280
height: 360
LCSideBar {
anchors.fill: parent
// icon from: https://iconduck.com/sets/bubblecons-nations-icon-set
p_model: [
{m_title: 'Sprint', m_icon: 'file:stopwatch.svg'},
{m_title: 'Boomerang', m_icon: 'file:boomerang.svg'},
{m_title: 'Football', m_icon: 'file:football-spain.svg'},
]
}
}
In this example, LCSideBar
uses a simple model struct to generate items. Each
item has apperance in different status (hovered, selected, etc.), an indicator
moves when selection changed.
More screenshots
TODO:AddMoreWidgetsDemo
Working in Progress
- The documentation is far away to ready status.
- LightClean Theme is found in Sept. 2020, but it is under refactoring in recent
months.
- The documentation is not provided. You have to check its source code for more infomation.
- Some old widgets have bugs unfixed.
- The registered functions by
@reg()
orpyside.register()
are not Slot functions. So it may cause GUI latency on doing heavy task. (It will be resolved in future releases.)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lk-qtquick-scaffold-1.2.2.tar.gz
(42.5 kB
view hashes)
Built Distribution
Close
Hashes for lk-qtquick-scaffold-1.2.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24ed917ff8aa34f490f8646bf5418a2ffe6f632a67d00e48c85d101b88a5881d |
|
MD5 | 6943980436157c666c367f8bbe8db7d7 |
|
BLAKE2b-256 | 269876125dac09d037453ec0632e6b996a3906573974e5b9d6b9dd3f7307e5c7 |
Close
Hashes for lk_qtquick_scaffold-1.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29e6f872d7191eec21248dcf9199a57be5cbf0d3f9db8547d641b45e6aa10edc |
|
MD5 | a172828a6c59fa5a9b720d407cf3756f |
|
BLAKE2b-256 | b2023dba8192f8c9722a46f4d329d8eb08221ddf6bd52903302810a6e3e2f650 |