Yet another GUI lib, looks and performs better than tkinter.
Project description
Suzaku 朱雀
Advanced UI module based on skia-python, pyopengl and glfw.
Still under developing...
versions under dev are provided for evaluation purposes.
Basic Example
python3 -m suzaku
The Latest Snapshot
0.1.9
0.1.1
Installation
Using pip
pip install suzaku
From source
git clone https://github.com/yourusername/suzaku.git
cd suzaku
pip install -e .
Features
- Modern UI: Beautiful, modern UI components with customizable themes
- Easy Layout: Simple box-based layout system, similar to tkinter
- Cross-platform: Works on Windows, macOS, and Linux
- Hardware Accelerated: Uses OpenGL for rendering via skia-python
- Event-driven: Comprehensive event handling system
- Themable: Supports custom themes and built-in light/dark themes
- Rich Component Set: Wide range of UI components available
Components
| Component | Description | Status |
|---|---|---|
| SkApp | Application base | ✅ |
| SkWindow | Main window | ✅ |
| SkButton | Clickable button | ✅ |
| SkCard | Card container | ✅ |
| SkCheckBox | Checkbox | ✅ |
| SkCheckItem | Checkable menu item | ✅ |
| SkComboBox | Dropdown menu | ✅ |
| SkContainer | Base container | ✅ |
| SkEmpty | Empty placeholder | ✅ |
| SkEntry | Single-line input | ✅ |
| SkFrame | Frame container | ✅ |
| SkImage | Image display with color processing | ✅ |
| SkLabel | Text label | ✅ |
| SkLineInput | Line input | ✅ |
| SkListBox | List container | ✅ |
| SkListItem | List item | ✅ |
| SkMenu | Menu | ✅ |
| SkMenuBar | Menu bar | ✅ |
| SkMenuItem | Menu item | ✅ |
| SkMessageBox | Message box | ✅ |
| SkMultiLineInput | Multi-line input | ⛔ |
| SkPopup | Popup window | ✅ |
| SkPopupMenu | Popup menu | ✅ |
| SkRadioBox | Radio button group | ✅ |
| SkRadioItem | Radio button | ✅ |
| SkSeparator | Separator line | ✅ |
| SkSizeGrip | Window resize grip | ✅ |
| SkSlider | Slider control | ✅ |
| SkStack | Stack container | ✅ |
| SkSwitch | Toggle switch | ✅ |
| SkSwitchBox | Switch group | ✅ |
| SkTabBar | Tab bar | ✅ |
| SkTabButton | Tab button | ✅ |
| SkTabs | Tab container | ✅ |
| SkText | Text display | ✅ |
| SkTextButton | Text button | ✅ |
| SkTitleBar | Window title bar | ✅ |
| SkTreeView | Tree view | ⛔ |
| SkWidget | Base widget | ✅ |
Layout
Each component can use layout methods to arrange itself using, for instance, widget.box(), which is similar to how things work in tkinter. Comparing to other solutions used in Qt or other UI frameworks, we believe this approach is more simple and user-friendly.
每个组件都可以使用布局方法来布局自己,例如widget.box(),类似于tkinter,我觉得这样更简洁易用点。
Box Layout
It can be considered a simplified version of tkinter.pack—with side, expand, padx, pady, ipadx, and ipady attributes.
Each container can only choose one layout direction. For example,
you cannot use both widget.box(side="left") and widget.box(side="right") simultaneously.
可以被称为tkinter.pack的简易版,包含side、expand、padx、pady、ipadx和ipady属性。
每个容器只能选择一种布局方向,例如,不能同时使用widget.box(side="left")和widget.box(side="right")。
Vertical layout / 垂直布局
The default layout is vertical.
默认为垂直方向布局。
widget.box()
Horizontal layout / 水平布局
widget.box(side="left")
widget2.box(side="right")
Layout with padding
widget.box(padx=10, pady=5, ipadx=2, ipady=2)
Expanding widgets
widget.box(expand=True)
Grid Layout
Grid layout allows you to arrange widgets in a grid pattern.
widget.grid(row=0, column=0)
widget2.grid(row=0, column=1)
widget3.grid(row=1, column=0, columnspan=2)
Fixed Layout
Fixed layout allows you to position widgets at specific coordinates.
widget.fixed(x=10, y=10, width=100, height=30)
How it Works / 原理
Basic Principles / 基础原理
- Uses
glfwas window management library - Uses
pyopenglas rendering backend - Uses
skia-pythonfor 2D graphics rendering - Event-driven architecture for handling user interactions
使用glfw作为窗口管理库,使用pyopengl作为渲染后端,使用skia-python作为2D图形渲染库,采用事件驱动架构处理用户交互。
Themes
Suzaku supports multiple themes, including:
- Light theme
- Dark theme
- Special themes (SV Light, SV Dark)
Applying Themes
from suzaku.styles.theme import SkTheme
# Load a theme
theme = SkTheme.load("path/to/theme.json")
# Apply theme to window
window.apply_theme(theme)
Events
Basic Event Handling
# Bind a function to a widget event
widget.bind("click", lambda evt: print("Clicked!"))
# Bind to keyboard events
window.bind("key_press", lambda evt: print(f"Key pressed: {evt['key']}"))
# Bind to mouse events
widget.bind("mouse_enter", lambda evt: print("Mouse entered!"))
widget.bind("mouse_leave", lambda evt: print("Mouse left!"))
Available Events
click: Mouse clickdouble_click: Double clickmouse_enter: Mouse enters widgetmouse_leave: Mouse leaves widgetmouse_press: Mouse button pressedmouse_release: Mouse button releasedkey_press: Key pressedkey_release: Key releasedfocus_gain: Widget gains focusfocus_loss: Widget loses focusresize: Widget resizedconfigure: Widget configuredupdate: Widget updatedscroll: Mouse wheel scrolled
Examples
Basic Application
from suzaku import *
app = SkApp()
window = SkWindow(title="My App", size=(400, 300))
# Create a button
button = SkButton(window, text="Click Me")
button.box(padx=10, pady=10)
button.bind("click", lambda evt: print("Button clicked!"))
# Create a label
label = SkLabel(window, text="Hello, Suzaku!")
label.box(padx=10, pady=5)
window.update_layout()
app.run()
Naming / 取名
Suzaku is one of the four mythical beasts in ancient China, representing the south and the element of fire. It symbolizes vitality, growth, and transformation.
suzaku是中国古代的四大神兽之一,代表南方和火元素,象征着生命力、成长和变革。
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License
Plans / 计划
- Support for more frameworks (SDL2)
- Additional UI components
- Improved layout system
- Enhanced theme support
- Documentation improvements
- More examples and tutorials
Credits
- skia-python - Skia Python bindings
- glfw - Window management
- pyopengl - OpenGL bindings for Python
Support
If you encounter any issues or have questions, please open an issue on the GitHub repository.
Enjoy using Suzaku!
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file suzaku-0.2.1.tar.gz.
File metadata
- Download URL: suzaku-0.2.1.tar.gz
- Upload date:
- Size: 89.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.13.5 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33bcdd8b32c28656d60130b27efab9b9ddd800fbf399404caa8ac2aabbe1dce3
|
|
| MD5 |
4e494994f383f1b40e4c1229b6551654
|
|
| BLAKE2b-256 |
72340f3b467c6970dc98209dd6c632490878caa2896ccc6d602ba83aaa745925
|
File details
Details for the file suzaku-0.2.1-py3-none-any.whl.
File metadata
- Download URL: suzaku-0.2.1-py3-none-any.whl
- Upload date:
- Size: 115.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.13.5 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf99fc88ae5f0ff7c7c2b2d43c120d3526758e3c7e3c06a57a9b1992fe99d989
|
|
| MD5 |
531c74519d325bfe3ba7b14a9c183ad4
|
|
| BLAKE2b-256 |
6c446ab220235c007ccac183e8a501c85a87c5dcccf48ac989315840d05be5de
|