mininterface 0.7.4__tar.gz → 0.8.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mininterface-0.8.0/LICENSE +165 -0
- mininterface-0.8.0/PKG-INFO +265 -0
- mininterface-0.7.4/PKG-INFO → mininterface-0.8.0/README.md +88 -83
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/__init__.py +30 -14
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/__main__.py +16 -21
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/auxiliary.py +33 -2
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/cli_parser.py +52 -16
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/experimental.py +0 -4
- mininterface-0.7.4/mininterface/facet.py → mininterface-0.8.0/mininterface/facet/__init__.py +13 -54
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/form_dict.py +2 -2
- mininterface-0.8.0/mininterface/interfaces.py +106 -0
- mininterface-0.7.4/mininterface/mininterface.py → mininterface-0.8.0/mininterface/mininterface/__init__.py +55 -89
- mininterface-0.8.0/mininterface/mininterface/adaptor.py +59 -0
- mininterface-0.8.0/mininterface/options.py +55 -0
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/showcase.py +27 -9
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/start.py +3 -3
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/tag.py +140 -72
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/tag_factory.py +17 -15
- mininterface-0.8.0/mininterface/text_interface/__init__.py +161 -0
- mininterface-0.8.0/mininterface/text_interface/adaptor.py +158 -0
- mininterface-0.8.0/mininterface/text_interface/facet.py +29 -0
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/textual_interface/__init__.py +20 -8
- mininterface-0.8.0/mininterface/textual_interface/adaptor.py +91 -0
- mininterface-0.7.4/mininterface/textual_interface/textual_facet.py → mininterface-0.8.0/mininterface/textual_interface/facet.py +2 -3
- mininterface-0.8.0/mininterface/textual_interface/file_picker_input.py +399 -0
- mininterface-0.8.0/mininterface/textual_interface/textual_app.py +180 -0
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/textual_interface/textual_button_app.py +1 -2
- mininterface-0.8.0/mininterface/textual_interface/widgets.py +154 -0
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/tk_interface/__init__.py +11 -12
- mininterface-0.7.4/mininterface/tk_interface/tk_window.py → mininterface-0.8.0/mininterface/tk_interface/adaptor.py +42 -12
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/tk_interface/date_entry.py +4 -5
- mininterface-0.7.4/mininterface/tk_interface/tk_facet.py → mininterface-0.8.0/mininterface/tk_interface/facet.py +2 -2
- mininterface-0.8.0/mininterface/tk_interface/secret_entry.py +36 -0
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/tk_interface/utils.py +83 -64
- mininterface-0.8.0/mininterface/types/__init__.py +4 -0
- mininterface-0.8.0/mininterface/types/alias.py +29 -0
- mininterface-0.8.0/mininterface/types/flags.py +69 -0
- mininterface-0.8.0/mininterface/types/internal.py +7 -0
- mininterface-0.8.0/mininterface/types/rich_tags.py +440 -0
- mininterface-0.8.0/mininterface/web_interface/__init__.py +87 -0
- mininterface-0.8.0/mininterface/web_interface/app.py +24 -0
- mininterface-0.8.0/mininterface/web_interface/child_adaptor.py +68 -0
- mininterface-0.8.0/mininterface/web_interface/parent_adaptor.py +69 -0
- mininterface-0.8.0/pyproject.toml +65 -0
- mininterface-0.7.4/LICENSE +0 -674
- mininterface-0.7.4/README.md +0 -196
- mininterface-0.7.4/mininterface/interfaces.py +0 -58
- mininterface-0.7.4/mininterface/text_interface.py +0 -135
- mininterface-0.7.4/mininterface/textual_interface/textual_adaptor.py +0 -100
- mininterface-0.7.4/mininterface/textual_interface/textual_app.py +0 -114
- mininterface-0.7.4/mininterface/textual_interface/widgets.py +0 -67
- mininterface-0.7.4/mininterface/types.py +0 -231
- mininterface-0.7.4/pyproject.toml +0 -40
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/ValidationFail.py +0 -0
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/exceptions.py +0 -0
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/redirectable.py +0 -0
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/subcommands.py +0 -0
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/tk_interface/external_fix.py +0 -0
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/tk_interface/redirect_text_tkinter.py +0 -0
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/type_stubs.py +0 -0
- {mininterface-0.7.4 → mininterface-0.8.0}/mininterface/validators.py +0 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: mininterface
|
|
3
|
+
Version: 0.8.0
|
|
4
|
+
Summary: A minimal access to GUI, TUI, CLI and config
|
|
5
|
+
License: LGPL-3.0-or-later
|
|
6
|
+
Author: Edvard Rejthar
|
|
7
|
+
Author-email: edvard.rejthar@nic.cz
|
|
8
|
+
Requires-Python: >=3.10,<4.0
|
|
9
|
+
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Provides-Extra: all
|
|
16
|
+
Provides-Extra: gui
|
|
17
|
+
Provides-Extra: img
|
|
18
|
+
Provides-Extra: tui
|
|
19
|
+
Provides-Extra: ui
|
|
20
|
+
Provides-Extra: web
|
|
21
|
+
Requires-Dist: autocombobox (==1.4.2) ; extra == "gui" or extra == "ui" or extra == "all"
|
|
22
|
+
Requires-Dist: humanize
|
|
23
|
+
Requires-Dist: pillow ; extra == "img" or extra == "gui" or extra == "ui" or extra == "all"
|
|
24
|
+
Requires-Dist: pyyaml
|
|
25
|
+
Requires-Dist: simple_term_menu
|
|
26
|
+
Requires-Dist: textual (<2.0.0)
|
|
27
|
+
Requires-Dist: textual-serve ; extra == "web" or extra == "ui" or extra == "all"
|
|
28
|
+
Requires-Dist: textual_imageview ; extra == "img" or extra == "tui" or extra == "ui" or extra == "all"
|
|
29
|
+
Requires-Dist: tkcalendar ; extra == "gui" or extra == "ui" or extra == "all"
|
|
30
|
+
Requires-Dist: tkinter-tooltip
|
|
31
|
+
Requires-Dist: tkinter_form (==0.2.1)
|
|
32
|
+
Requires-Dist: tkscrollableframe
|
|
33
|
+
Requires-Dist: typing_extensions
|
|
34
|
+
Requires-Dist: tyro (>=0.9,<0.10)
|
|
35
|
+
Project-URL: Homepage, https://github.com/CZ-NIC/mininterface
|
|
36
|
+
Description-Content-Type: text/markdown
|
|
37
|
+
|
|
38
|
+
# Mininterface – access to GUI, TUI, CLI and config files
|
|
39
|
+
[](https://github.com/CZ-NIC/mininterface/actions)
|
|
40
|
+
[](https://pepy.tech/project/mininterface)
|
|
41
|
+
|
|
42
|
+
Write the program core, do not bother with the input/output.
|
|
43
|
+
|
|
44
|
+

|
|
45
|
+

|
|
46
|
+
|
|
47
|
+
Check out the code, which is surprisingly short, that displays such a window or its textual fallback.
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from dataclasses import dataclass
|
|
51
|
+
from mininterface import run
|
|
52
|
+
|
|
53
|
+
@dataclass
|
|
54
|
+
class Env:
|
|
55
|
+
""" This calculates something. """
|
|
56
|
+
|
|
57
|
+
my_flag: bool = False
|
|
58
|
+
""" This switches the functionality """
|
|
59
|
+
|
|
60
|
+
my_number: int = 4
|
|
61
|
+
""" This number is very important """
|
|
62
|
+
|
|
63
|
+
if __name__ == "__main__":
|
|
64
|
+
m = run(Env, prog="My application")
|
|
65
|
+
m.form()
|
|
66
|
+
# Attributes are suggested by the IDE
|
|
67
|
+
# along with the hint text 'This number is very important'.
|
|
68
|
+
print(m.env.my_number)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
# Contents
|
|
72
|
+
- [You got CLI](#you-got-cli)
|
|
73
|
+
- [You got config file management](#you-got-config-file-management)
|
|
74
|
+
- [You got dialogues](#you-got-dialogues)
|
|
75
|
+
- [Background](#background)
|
|
76
|
+
- [Installation](#installation)
|
|
77
|
+
- [Docs](#docs)
|
|
78
|
+
- [Gallery](#gallery)
|
|
79
|
+
- [Hello world](#hello-world)
|
|
80
|
+
|
|
81
|
+
## You got CLI
|
|
82
|
+
It was all the code you need. No lengthy blocks of code imposed by an external dependency. Besides the GUI/TUI, you receive powerful YAML-configurable CLI parsing.
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
$ ./program.py --help
|
|
87
|
+
usage: My application [-h] [-v] [--my-flag | --no-my-flag] [--my-number INT]
|
|
88
|
+
|
|
89
|
+
This calculates something.
|
|
90
|
+
|
|
91
|
+
╭─ options ───────────────────────────────────────────────────────────────╮
|
|
92
|
+
│ -h, --help show this help message and exit │
|
|
93
|
+
│ -v, --verbose Verbosity level. Can be used twice to increase. │
|
|
94
|
+
│ --my-flag, --no-my-flag │
|
|
95
|
+
│ This switches the functionality (default: False) │
|
|
96
|
+
│ --my-number INT This number is very important (default: 4) │
|
|
97
|
+
╰─────────────────────────────────────────────────────────────────────────╯
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## You got config file management
|
|
101
|
+
Loading config file is a piece of cake. Alongside `program.py`, put `program.yaml` and put there some of the arguments. They are seamlessly taken as defaults.
|
|
102
|
+
|
|
103
|
+
```yaml
|
|
104
|
+
my_number: 555
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
$ program.py --help
|
|
109
|
+
...
|
|
110
|
+
│ --my-number INT This number is very important (default: 555) │
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## You got dialogues
|
|
114
|
+
Check out several useful methods to handle user dialogues. Here we bound the interface to a `with` statement that redirects stdout directly to the window.
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
with run(Env) as m:
|
|
118
|
+
print(f"Your important number is {m.env.my_number}")
|
|
119
|
+
boolean = m.is_yes("Is that alright?")
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+

|
|
123
|
+

|
|
124
|
+
|
|
125
|
+
# Background
|
|
126
|
+
|
|
127
|
+
Wrapper between various libraries that provide a user interface.
|
|
128
|
+
|
|
129
|
+
Writing a small and useful program might be a task that takes fifteen minutes. Adding a CLI to specify the parameters is not so much overhead. But building a simple GUI around it? HOURS! Hours spent on researching GUI libraries, wondering why the Python desktop app ecosystem lags so far behind the web world. All you need is a few input fields validated through a clickable window... You do not deserve to add hundred of lines of the code just to define some editable fields. `Mininterface` is here to help.
|
|
130
|
+
|
|
131
|
+
The config variables needed by your program are kept in cozy dataclasses. Write less! The syntax of [tyro](https://github.com/brentyi/tyro) does not require any overhead (as its `argparse` alternatives do). You just annotate a class attribute, append a simple docstring and get a fully functional application:
|
|
132
|
+
|
|
133
|
+
* Call it as `program.py --help` to display full help.
|
|
134
|
+
* Use any flag in CLI: `program.py --my-flag` causes `env.my_flag` be set to `True`.
|
|
135
|
+
* The main benefit: Launch it without parameters as `program.py` to get a full working window with all the flags ready to be edited.
|
|
136
|
+
* Running on a remote machine? Automatic regression to the text interface.
|
|
137
|
+
* Or access your program via [web browser](http://127.0.0.1:8000/Interfaces/#webinterface-or-web).
|
|
138
|
+
|
|
139
|
+
# Installation
|
|
140
|
+
|
|
141
|
+
Install with a single command from [PyPi](https://pypi.org/project/mininterface/).
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
pip install mininterface[all] # GPLv3 and compatible
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Bundles
|
|
148
|
+
|
|
149
|
+
There are various bundles. We mark the bundles with GPL3 dependencies.
|
|
150
|
+
|
|
151
|
+
| bundle | size | licence | description |
|
|
152
|
+
| ------ | ---- | ----------- | ---- |
|
|
153
|
+
| mininterface | 30 MB | LGPL | standard (GUI, TUI) |
|
|
154
|
+
| mininterface | 36 MB | LGPL | standard (GUI, TUI) |
|
|
155
|
+
| mininterface[web] | 36 MB | | including [WebInterface](Interfaces.md#webinterface-or-web) |
|
|
156
|
+
| mininterface[img] | | | images |
|
|
157
|
+
| mininterface[tui] | | | images |
|
|
158
|
+
| mininterface[gui] | | GPL | images, combobox, calendar |
|
|
159
|
+
| mininterface[ui] | 100 MB | GPL | full installation |
|
|
160
|
+
| mininterface[all] | 100 MB | GPL | full installation, same as `ui`, reserved for future use (big dependencies, optional interfaces) |
|
|
161
|
+
|
|
162
|
+
## Minimal installation
|
|
163
|
+
|
|
164
|
+
Should you need just the CLI part and you are happy with basic text dialogs, use these commands instead:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
pip install --no-dependencies mininterface
|
|
168
|
+
pip install tyro typing_extensions pyyaml simple_term_menu
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## MacOS GUI
|
|
172
|
+
|
|
173
|
+
If the GUI does not work on MacOS, you might need to launch: `brew install python-tk`
|
|
174
|
+
|
|
175
|
+
# Docs
|
|
176
|
+
See the docs overview at [https://cz-nic.github.io/mininterface/](https://cz-nic.github.io/mininterface/Overview/).
|
|
177
|
+
|
|
178
|
+
# Gallery
|
|
179
|
+
|
|
180
|
+
These projects have the code base reduced thanks to the mininterface:
|
|
181
|
+
|
|
182
|
+
* **[deduplidog](https://github.com/CZ-NIC/deduplidog/)** – Find duplicates in a scattered directory structure
|
|
183
|
+
* **[touch-timestamp](https://github.com/CZ-NIC/touch-timestamp/)** – A powerful dialog to change the files' timestamp
|
|
184
|
+
|
|
185
|
+
# Hello world
|
|
186
|
+
|
|
187
|
+
Take a look at the following example.
|
|
188
|
+
1. We define any Env class.
|
|
189
|
+
2. Then, we initialize mininterface with [`run(Env)`][mininterface.run] – the missing fields will be prompter for
|
|
190
|
+
3. Then, we use various dialog methods, like [`is_yes`][mininterface.Mininterface.is_yes], [`choice`][mininterface.Mininterface.choice] or [`form`][mininterface.Mininterface.form].
|
|
191
|
+
|
|
192
|
+
Below, you find the screenshots how the program looks in various environments ([graphic](Interfaces.md#guiinterface-or-tkinterface-or-gui) interface, [web](Interfaces.md#webinterface-or-web) interface...).
|
|
193
|
+
|
|
194
|
+
```python3
|
|
195
|
+
from dataclasses import dataclass
|
|
196
|
+
from pathlib import Path
|
|
197
|
+
from mininterface import run
|
|
198
|
+
|
|
199
|
+
@dataclass
|
|
200
|
+
class Env:
|
|
201
|
+
my_file: Path # This is my help text
|
|
202
|
+
my_flag: bool = False
|
|
203
|
+
my_number: int = 4
|
|
204
|
+
|
|
205
|
+
if __name__ == "__main__":
|
|
206
|
+
# Here, the user will be prompted
|
|
207
|
+
# for missing parameters (`my_file`) automatically
|
|
208
|
+
with run(Env) as m:
|
|
209
|
+
|
|
210
|
+
# You can lean on the typing
|
|
211
|
+
# Ex. directly read from the file object:
|
|
212
|
+
print("The file contents:", m.env.my_file.read_text())
|
|
213
|
+
|
|
214
|
+
# You can use various dialog methods,
|
|
215
|
+
# like `is_yes` for bool
|
|
216
|
+
if m.is_yes("Do you want to continue?"):
|
|
217
|
+
|
|
218
|
+
# or `choice` for choosing a value
|
|
219
|
+
fruit = m.choice(("apple", "banana", "sirup"), "Choose a fruit")
|
|
220
|
+
|
|
221
|
+
if fruit == "apple":
|
|
222
|
+
# or `form` for an arbitrary values
|
|
223
|
+
m.form({
|
|
224
|
+
"How many": 0,
|
|
225
|
+
"Choose another file": m.env.my_file
|
|
226
|
+
})
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Launch with `./program.py`:
|
|
230
|
+
|
|
231
|
+

|
|
232
|
+

|
|
233
|
+

|
|
234
|
+

|
|
235
|
+
|
|
236
|
+
Or at the remote machine `MININTERFACE_INTERFACE=tui ./program.py`:
|
|
237
|
+
|
|
238
|
+

|
|
239
|
+

|
|
240
|
+

|
|
241
|
+

|
|
242
|
+
|
|
243
|
+
Or via the plain text `MININTERFACE_INTERFACE=text ./program.py`:
|
|
244
|
+
|
|
245
|
+

|
|
246
|
+
|
|
247
|
+
Or via web browser `MININTERFACE_INTERFACE=web ./program.py`:
|
|
248
|
+
|
|
249
|
+

|
|
250
|
+
|
|
251
|
+
You can always set Env via CLI or a config file:
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
$ MININTERFACE_INTERFACE=gui ./program.py --help
|
|
255
|
+
usage: program.py [-h] [OPTIONS]
|
|
256
|
+
|
|
257
|
+
╭─ options ──────────────────────────────────────────────────────────────╮
|
|
258
|
+
│ -h, --help show this help message and exit │
|
|
259
|
+
│ -v, --verbose Verbosity level. Can be used twice to increase. │
|
|
260
|
+
│ --my-file PATH This is my help text (required) │
|
|
261
|
+
│ --my-flag, --no-my-flag │
|
|
262
|
+
│ (default: False) │
|
|
263
|
+
│ --my-number INT (default: 4) │
|
|
264
|
+
╰────────────────────────────────────────────────────────────────────────╯
|
|
265
|
+
```
|
|
@@ -1,31 +1,4 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: mininterface
|
|
3
|
-
Version: 0.7.4
|
|
4
|
-
Summary: A minimal access to GUI, TUI, CLI and config
|
|
5
|
-
License: GPL-3.0-or-later
|
|
6
|
-
Author: Edvard Rejthar
|
|
7
|
-
Author-email: edvard.rejthar@nic.cz
|
|
8
|
-
Requires-Python: >=3.10,<4.0
|
|
9
|
-
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
|
10
|
-
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
-
Requires-Dist: autocombobox (==1.4.2)
|
|
16
|
-
Requires-Dist: humanize
|
|
17
|
-
Requires-Dist: pyyaml
|
|
18
|
-
Requires-Dist: textual (>=0.84,<0.85)
|
|
19
|
-
Requires-Dist: tkinter-tooltip
|
|
20
|
-
Requires-Dist: tkinter_form (==0.2.1)
|
|
21
|
-
Requires-Dist: tkscrollableframe
|
|
22
|
-
Requires-Dist: typing_extensions
|
|
23
|
-
Requires-Dist: tyro (>=0.9,<0.10)
|
|
24
|
-
Project-URL: Homepage, https://github.com/CZ-NIC/mininterface
|
|
25
|
-
Description-Content-Type: text/markdown
|
|
26
|
-
|
|
27
1
|
# Mininterface – access to GUI, TUI, CLI and config files
|
|
28
|
-
[](https://www.gnu.org/licenses/gpl-3.0)
|
|
29
2
|
[](https://github.com/CZ-NIC/mininterface/actions)
|
|
30
3
|
[](https://pepy.tech/project/mininterface)
|
|
31
4
|
|
|
@@ -65,7 +38,8 @@ if __name__ == "__main__":
|
|
|
65
38
|
- [Background](#background)
|
|
66
39
|
- [Installation](#installation)
|
|
67
40
|
- [Docs](#docs)
|
|
68
|
-
- [
|
|
41
|
+
- [Gallery](#gallery)
|
|
42
|
+
- [Hello world](#hello-world)
|
|
69
43
|
|
|
70
44
|
## You got CLI
|
|
71
45
|
It was all the code you need. No lengthy blocks of code imposed by an external dependency. Besides the GUI/TUI, you receive powerful YAML-configurable CLI parsing.
|
|
@@ -113,15 +87,17 @@ with run(Env) as m:
|
|
|
113
87
|
|
|
114
88
|
# Background
|
|
115
89
|
|
|
116
|
-
Wrapper between
|
|
90
|
+
Wrapper between various libraries that provide a user interface.
|
|
117
91
|
|
|
118
92
|
Writing a small and useful program might be a task that takes fifteen minutes. Adding a CLI to specify the parameters is not so much overhead. But building a simple GUI around it? HOURS! Hours spent on researching GUI libraries, wondering why the Python desktop app ecosystem lags so far behind the web world. All you need is a few input fields validated through a clickable window... You do not deserve to add hundred of lines of the code just to define some editable fields. `Mininterface` is here to help.
|
|
119
93
|
|
|
120
94
|
The config variables needed by your program are kept in cozy dataclasses. Write less! The syntax of [tyro](https://github.com/brentyi/tyro) does not require any overhead (as its `argparse` alternatives do). You just annotate a class attribute, append a simple docstring and get a fully functional application:
|
|
95
|
+
|
|
121
96
|
* Call it as `program.py --help` to display full help.
|
|
122
97
|
* Use any flag in CLI: `program.py --my-flag` causes `env.my_flag` be set to `True`.
|
|
123
98
|
* The main benefit: Launch it without parameters as `program.py` to get a full working window with all the flags ready to be edited.
|
|
124
99
|
* Running on a remote machine? Automatic regression to the text interface.
|
|
100
|
+
* Or access your program via [web browser](http://127.0.0.1:8000/Interfaces/#webinterface-or-web).
|
|
125
101
|
|
|
126
102
|
# Installation
|
|
127
103
|
|
|
@@ -131,13 +107,28 @@ Install with a single command from [PyPi](https://pypi.org/project/mininterface/
|
|
|
131
107
|
pip install mininterface[all] # GPLv3 and compatible
|
|
132
108
|
```
|
|
133
109
|
|
|
110
|
+
## Bundles
|
|
111
|
+
|
|
112
|
+
There are various bundles. We mark the bundles with GPL3 dependencies.
|
|
113
|
+
|
|
114
|
+
| bundle | size | licence | description |
|
|
115
|
+
| ------ | ---- | ----------- | ---- |
|
|
116
|
+
| mininterface | 30 MB | LGPL | standard (GUI, TUI) |
|
|
117
|
+
| mininterface | 36 MB | LGPL | standard (GUI, TUI) |
|
|
118
|
+
| mininterface[web] | 36 MB | | including [WebInterface](Interfaces.md#webinterface-or-web) |
|
|
119
|
+
| mininterface[img] | | | images |
|
|
120
|
+
| mininterface[tui] | | | images |
|
|
121
|
+
| mininterface[gui] | | GPL | images, combobox, calendar |
|
|
122
|
+
| mininterface[ui] | 100 MB | GPL | full installation |
|
|
123
|
+
| mininterface[all] | 100 MB | GPL | full installation, same as `ui`, reserved for future use (big dependencies, optional interfaces) |
|
|
124
|
+
|
|
134
125
|
## Minimal installation
|
|
135
126
|
|
|
136
127
|
Should you need just the CLI part and you are happy with basic text dialogs, use these commands instead:
|
|
137
128
|
|
|
138
129
|
```bash
|
|
139
130
|
pip install --no-dependencies mininterface
|
|
140
|
-
pip install tyro typing_extensions pyyaml
|
|
131
|
+
pip install tyro typing_extensions pyyaml simple_term_menu
|
|
141
132
|
```
|
|
142
133
|
|
|
143
134
|
## MacOS GUI
|
|
@@ -147,77 +138,91 @@ If the GUI does not work on MacOS, you might need to launch: `brew install pytho
|
|
|
147
138
|
# Docs
|
|
148
139
|
See the docs overview at [https://cz-nic.github.io/mininterface/](https://cz-nic.github.io/mininterface/Overview/).
|
|
149
140
|
|
|
150
|
-
#
|
|
141
|
+
# Gallery
|
|
142
|
+
|
|
143
|
+
These projects have the code base reduced thanks to the mininterface:
|
|
151
144
|
|
|
152
|
-
|
|
145
|
+
* **[deduplidog](https://github.com/CZ-NIC/deduplidog/)** – Find duplicates in a scattered directory structure
|
|
146
|
+
* **[touch-timestamp](https://github.com/CZ-NIC/touch-timestamp/)** – A powerful dialog to change the files' timestamp
|
|
153
147
|
|
|
154
|
-
|
|
148
|
+
# Hello world
|
|
149
|
+
|
|
150
|
+
Take a look at the following example.
|
|
151
|
+
1. We define any Env class.
|
|
152
|
+
2. Then, we initialize mininterface with [`run(Env)`][mininterface.run] – the missing fields will be prompter for
|
|
153
|
+
3. Then, we use various dialog methods, like [`is_yes`][mininterface.Mininterface.is_yes], [`choice`][mininterface.Mininterface.choice] or [`form`][mininterface.Mininterface.form].
|
|
154
|
+
|
|
155
|
+
Below, you find the screenshots how the program looks in various environments ([graphic](Interfaces.md#guiinterface-or-tkinterface-or-gui) interface, [web](Interfaces.md#webinterface-or-web) interface...).
|
|
155
156
|
|
|
156
157
|
```python3
|
|
157
|
-
from typing import Annotated
|
|
158
158
|
from dataclasses import dataclass
|
|
159
|
-
from
|
|
160
|
-
from mininterface import run
|
|
161
|
-
|
|
162
|
-
@dataclass
|
|
163
|
-
class NestedEnv:
|
|
164
|
-
another_number: int = 7
|
|
165
|
-
""" This field is nested """
|
|
159
|
+
from pathlib import Path
|
|
160
|
+
from mininterface import run
|
|
166
161
|
|
|
167
162
|
@dataclass
|
|
168
163
|
class Env:
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
mandatory_str: str
|
|
172
|
-
""" As there is no default value, you will be prompted automatically to fill up the field """
|
|
173
|
-
|
|
174
|
-
my_number: int | None = None
|
|
175
|
-
""" This is not just a dummy number, if left empty, it is None. """
|
|
176
|
-
|
|
177
|
-
my_string: str = "Hello"
|
|
178
|
-
""" A dummy string """
|
|
179
|
-
|
|
164
|
+
my_file: Path # This is my help text
|
|
180
165
|
my_flag: bool = False
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
my_validated: Annotated[str, Validation(not_empty)] = "hello"
|
|
184
|
-
""" A validated field """
|
|
185
|
-
|
|
186
|
-
m = run(Env, title="My program")
|
|
187
|
-
# See some values
|
|
188
|
-
print(m.env.nested_config.another_number) # 7
|
|
189
|
-
print(m.env)
|
|
190
|
-
# Env(nested_config=NestedEnv(another_number=7), my_number=5, my_string='Hello', my_flag=False, my_validated='hello')
|
|
166
|
+
my_number: int = 4
|
|
191
167
|
|
|
192
|
-
|
|
193
|
-
|
|
168
|
+
if __name__ == "__main__":
|
|
169
|
+
# Here, the user will be prompted
|
|
170
|
+
# for missing parameters (`my_file`) automatically
|
|
171
|
+
with run(Env) as m:
|
|
172
|
+
|
|
173
|
+
# You can lean on the typing
|
|
174
|
+
# Ex. directly read from the file object:
|
|
175
|
+
print("The file contents:", m.env.my_file.read_text())
|
|
176
|
+
|
|
177
|
+
# You can use various dialog methods,
|
|
178
|
+
# like `is_yes` for bool
|
|
179
|
+
if m.is_yes("Do you want to continue?"):
|
|
180
|
+
|
|
181
|
+
# or `choice` for choosing a value
|
|
182
|
+
fruit = m.choice(("apple", "banana", "sirup"), "Choose a fruit")
|
|
183
|
+
|
|
184
|
+
if fruit == "apple":
|
|
185
|
+
# or `form` for an arbitrary values
|
|
186
|
+
m.form({
|
|
187
|
+
"How many": 0,
|
|
188
|
+
"Choose another file": m.env.my_file
|
|
189
|
+
})
|
|
194
190
|
```
|
|
195
191
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-

|
|
192
|
+
Launch with `./program.py`:
|
|
199
193
|
|
|
200
|
-
|
|
194
|
+

|
|
195
|
+

|
|
196
|
+

|
|
197
|
+

|
|
201
198
|
|
|
202
|
-
|
|
199
|
+
Or at the remote machine `MININTERFACE_INTERFACE=tui ./program.py`:
|
|
203
200
|
|
|
204
|
-
|
|
201
|
+

|
|
202
|
+

|
|
203
|
+

|
|
204
|
+

|
|
205
205
|
|
|
206
|
-
|
|
206
|
+
Or via the plain text `MININTERFACE_INTERFACE=text ./program.py`:
|
|
207
207
|
|
|
208
|
-
|
|
209
|
-
from pathlib import Path
|
|
210
|
-
from mininterface import run, Tag
|
|
208
|
+

|
|
211
209
|
|
|
212
|
-
|
|
213
|
-
my_dictionary = {
|
|
214
|
-
"paths": Tag("", annotation=list[Path]),
|
|
215
|
-
"default_paths": Tag([Path("/tmp"), Path("/usr")], annotation=list[Path])
|
|
216
|
-
}
|
|
210
|
+
Or via web browser `MININTERFACE_INTERFACE=web ./program.py`:
|
|
217
211
|
|
|
218
|
-
|
|
219
|
-
m.form(my_dictionary)
|
|
220
|
-
```
|
|
212
|
+

|
|
221
213
|
|
|
222
|
-
|
|
214
|
+
You can always set Env via CLI or a config file:
|
|
223
215
|
|
|
216
|
+
```bash
|
|
217
|
+
$ MININTERFACE_INTERFACE=gui ./program.py --help
|
|
218
|
+
usage: program.py [-h] [OPTIONS]
|
|
219
|
+
|
|
220
|
+
╭─ options ──────────────────────────────────────────────────────────────╮
|
|
221
|
+
│ -h, --help show this help message and exit │
|
|
222
|
+
│ -v, --verbose Verbosity level. Can be used twice to increase. │
|
|
223
|
+
│ --my-file PATH This is my help text (required) │
|
|
224
|
+
│ --my-flag, --no-my-flag │
|
|
225
|
+
│ (default: False) │
|
|
226
|
+
│ --my-number INT (default: 4) │
|
|
227
|
+
╰────────────────────────────────────────────────────────────────────────╯
|
|
228
|
+
```
|