mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-02 14:51:15 +00:00
Python: Replace import magic with an auto-loader
As discussed on Reddit, the magic import logic is not very tool friendly and a little too magic perhaps. Instead, this patch introduces an automatic loader (`slint.loader`), which can traverse `sys.path` and lazily load `.slint` files by attribute lookup. Closes #4856
This commit is contained in:
parent
93307707cd
commit
f86f4993fa
6 changed files with 48 additions and 52 deletions
|
@ -1,18 +1,15 @@
|
|||
# Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# autopep8: off
|
||||
from slint import Color, ListModel, Timer, TimerMode
|
||||
import slint
|
||||
from datetime import timedelta, datetime
|
||||
import os
|
||||
import sys
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "ui"))
|
||||
import slint
|
||||
from slint import Color, ListModel, Timer, TimerMode
|
||||
import printerdemo_slint
|
||||
# autopep8: on
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
|
||||
|
||||
|
||||
class MainWindow(printerdemo_slint.MainWindow):
|
||||
class MainWindow(slint.loader.ui.printerdemo.MainWindow):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.ink_levels = ListModel([
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue