dars-framework 1.2.3__py3-none-any.whl
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.
- dars/__init__.py +0 -0
- dars/all.py +69 -0
- dars/cli/__init__.py +0 -0
- dars/cli/doctor/__init__.py +1 -0
- dars/cli/doctor/detect.py +154 -0
- dars/cli/doctor/doctor.py +176 -0
- dars/cli/doctor/installers.py +100 -0
- dars/cli/doctor/persist.py +62 -0
- dars/cli/doctor/preflight.py +33 -0
- dars/cli/doctor/ui.py +54 -0
- dars/cli/hot_reload.py +33 -0
- dars/cli/main.py +1107 -0
- dars/cli/preview.py +448 -0
- dars/cli/translations.py +531 -0
- dars/components/__init__.py +0 -0
- dars/components/advanced/__init__.py +8 -0
- dars/components/advanced/accordion.py +26 -0
- dars/components/advanced/card.py +33 -0
- dars/components/advanced/modal.py +45 -0
- dars/components/advanced/navbar.py +44 -0
- dars/components/advanced/table.py +25 -0
- dars/components/advanced/tabs.py +31 -0
- dars/components/basic/__init__.py +34 -0
- dars/components/basic/button.py +55 -0
- dars/components/basic/checkbox.py +35 -0
- dars/components/basic/container.py +29 -0
- dars/components/basic/datepicker.py +139 -0
- dars/components/basic/image.py +36 -0
- dars/components/basic/input.py +57 -0
- dars/components/basic/link.py +31 -0
- dars/components/basic/markdown.py +86 -0
- dars/components/basic/page.py +20 -0
- dars/components/basic/progressbar.py +18 -0
- dars/components/basic/radiobutton.py +35 -0
- dars/components/basic/select.py +82 -0
- dars/components/basic/slider.py +63 -0
- dars/components/basic/spinner.py +12 -0
- dars/components/basic/text.py +23 -0
- dars/components/basic/textarea.py +46 -0
- dars/components/basic/tooltip.py +19 -0
- dars/components/layout/__init__.py +0 -0
- dars/components/layout/anchor.py +13 -0
- dars/components/layout/flex.py +26 -0
- dars/components/layout/grid.py +45 -0
- dars/config.py +134 -0
- dars/core/__init__.py +0 -0
- dars/core/app.py +957 -0
- dars/core/component.py +284 -0
- dars/core/events.py +102 -0
- dars/core/js_bridge.py +99 -0
- dars/core/properties.py +127 -0
- dars/core/state.py +309 -0
- dars/dars_tests/apps_test/health_check.py +56 -0
- dars/dars_tests/run_tests.py +275 -0
- dars/dars_tests/tests/test_advanced_components.py +69 -0
- dars/dars_tests/tests/test_basic_components.py +88 -0
- dars/dars_tests/tests/test_core_and_cli.py +17 -0
- dars/dars_tests/tests/test_layout_components.py +58 -0
- dars/dars_tests/tests/test_version_check.py +21 -0
- dars/docs/__init__.py +0 -0
- dars/docs/app.md +290 -0
- dars/docs/cli.md +80 -0
- dars/docs/components.md +1679 -0
- dars/docs/custom_components.md +30 -0
- dars/docs/events.md +45 -0
- dars/docs/exporters.md +162 -0
- dars/docs/getting_started.md +79 -0
- dars/docs/index.md +18 -0
- dars/docs/scripts.md +593 -0
- dars/docs/state_management.md +57 -0
- dars/exporters/__init__.py +0 -0
- dars/exporters/base.py +96 -0
- dars/exporters/web/OLD/html_css_js_OLD4.py +1538 -0
- dars/exporters/web/OLD/html_css_js_old.py +1406 -0
- dars/exporters/web/OLD/html_css_js_old2.py +1406 -0
- dars/exporters/web/__init__.py +0 -0
- dars/exporters/web/html_css_js.py +2675 -0
- dars/exporters/web/vdom.py +251 -0
- dars/js_lib.py +206 -0
- dars/scripts/__init__.py +0 -0
- dars/scripts/dscript.py +26 -0
- dars/scripts/script.py +39 -0
- dars/security.py +195 -0
- dars/templates/__init__.py +0 -0
- dars/templates/__pycache__/__init__.cpython-311.pyc +0 -0
- dars/templates/examples/README.md +4 -0
- dars/templates/examples/__pycache__/dynamic_event_demo.cpython-311.pyc +0 -0
- dars/templates/examples/advanced/Modal_Demo/advanced_modal_demo.py +275 -0
- dars/templates/examples/advanced/SimpleDashboard/dashboard.py +437 -0
- dars/templates/examples/advanced/SimpleModermWeb/modern_web_app.py +452 -0
- dars/templates/examples/advanced/VariousComponents/all_components_demo.py +87 -0
- dars/templates/examples/advanced/__init__.py +0 -0
- dars/templates/examples/advanced/dState/state_mods_demo.py +68 -0
- dars/templates/examples/basic/Forms/form_components.py +516 -0
- dars/templates/examples/basic/Forms/simple_form.py +379 -0
- dars/templates/examples/basic/HelloWorld/hello_world.py +56 -0
- dars/templates/examples/basic/Layouts/flex_layout_responsive.py +13 -0
- dars/templates/examples/basic/Layouts/grid_layout_responsive.py +12 -0
- dars/templates/examples/basic/Layouts/layout_multipage_demo.py +23 -0
- dars/templates/examples/basic/Multipage/multipage_example.py +67 -0
- dars/templates/examples/basic/PWA/icon-192x192.png +0 -0
- dars/templates/examples/basic/PWA/icon-512x512.png +0 -0
- dars/templates/examples/basic/PWA/pwa_custom_icons.py +33 -0
- dars/templates/examples/basic/__init__.py +0 -0
- dars/templates/examples/demo/__pycache__/complete_app.cpython-311.pyc +0 -0
- dars/templates/examples/demo/complete_app.py +21 -0
- dars/templates/examples/markdown/MarkdownTemplate/README.md +159 -0
- dars/templates/examples/markdown/MarkdownTemplate/markdown_template.py +21 -0
- dars/templates/examples/markdown/MarkdownTemplate/other_docs.md +1 -0
- dars/templates/examples/markdown/__init__.py +0 -0
- dars/templates/html/__init__.py +0 -0
- dars/version.py +2 -0
- dars_framework-1.2.3.dist-info/METADATA +15 -0
- dars_framework-1.2.3.dist-info/RECORD +118 -0
- dars_framework-1.2.3.dist-info/WHEEL +5 -0
- dars_framework-1.2.3.dist-info/entry_points.txt +2 -0
- dars_framework-1.2.3.dist-info/licenses/LICENSE +21 -0
- dars_framework-1.2.3.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
This is an example of how to create a custom component in Dars. The `Button` class inherits from `Component` and defines its own initialization and rendering logic. You can use `self.set_event` to attach event handlers to components.
|
|
2
|
+
|
|
3
|
+
> Note: when you instance a CustomComponent you need to do it like this CustomComponent(id="") <-- with parentesis
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
from dars.all import *
|
|
7
|
+
from dars.core.component import Component
|
|
8
|
+
from dars.exporters.web.html_css_js import *
|
|
9
|
+
|
|
10
|
+
class CustomComponent(Component):
|
|
11
|
+
def __init__(self, title: str, id: str = None, **props):
|
|
12
|
+
super().__init__(**props)
|
|
13
|
+
|
|
14
|
+
self.title = title
|
|
15
|
+
self.id = id
|
|
16
|
+
self.set_event(EventTypes.CLICK, dScript("console.log('click')"))
|
|
17
|
+
def render(self, exporter: 'Exporter') -> str:
|
|
18
|
+
# Use the exporter to consistently render children
|
|
19
|
+
children_html = self.render_children(exporter)
|
|
20
|
+
return f'''
|
|
21
|
+
<div class="my-component" id="{self.id}">
|
|
22
|
+
<h2>{self.title}</h2>
|
|
23
|
+
<div class="content">
|
|
24
|
+
{children_html}
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
'''
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
|
dars/docs/events.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
## Event Calling System
|
|
2
|
+
|
|
3
|
+
Custom components in Dars can have events associated with them. You can set an event on a custom component using the `set_event` method.
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
self.set_event(EventTypes.CLICK, dScript("console.log('click')"))
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
### Available Event Types
|
|
10
|
+
|
|
11
|
+
To use the event types, you need to import them from `dars.core.events`:
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from dars.core.events import EventTypes
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Here are the different event types available:
|
|
18
|
+
|
|
19
|
+
- **Mouse Events:**
|
|
20
|
+
- `CLICK = "click"`
|
|
21
|
+
- `DOUBLE_CLICK = "dblclick"`
|
|
22
|
+
- `MOUSE_DOWN = "mousedown"`
|
|
23
|
+
- `MOUSE_UP = "mouseup"`
|
|
24
|
+
- `MOUSE_ENTER = "mouseenter"`
|
|
25
|
+
- `MOUSE_LEAVE = "mouseleave"`
|
|
26
|
+
- `MOUSE_MOVE = "mousemove"`
|
|
27
|
+
|
|
28
|
+
- **Keyboard Events:**
|
|
29
|
+
- `KEY_DOWN = "keydown"`
|
|
30
|
+
- `KEY_UP = "keyup"`
|
|
31
|
+
- `KEY_PRESS = "keypress"`
|
|
32
|
+
|
|
33
|
+
- **Form Events:**
|
|
34
|
+
- `CHANGE = "change"`
|
|
35
|
+
- `INPUT = "input"`
|
|
36
|
+
- `SUBMIT = "submit"`
|
|
37
|
+
- `FOCUS = "focus"`
|
|
38
|
+
- `BLUR = "blur"`
|
|
39
|
+
|
|
40
|
+
- **Load Events:**
|
|
41
|
+
- `LOAD = "load"`
|
|
42
|
+
- `ERROR = "error"`
|
|
43
|
+
- `RESIZE = "resize"`
|
|
44
|
+
|
|
45
|
+
|
dars/docs/exporters.md
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# Dars - Exporter Documentation
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
Exporters are the heart of Dars that allow transforming applications written in Python to different technologies and platforms. Each exporter translates Dars components, styles, and scripts to the native code of the target platform.
|
|
6
|
+
|
|
7
|
+
## Exporter Architecture
|
|
8
|
+
|
|
9
|
+
### Base Exporter Class
|
|
10
|
+
|
|
11
|
+
All exporters inherit from the base `Exporter` class:
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from abc import ABC, abstractmethod
|
|
15
|
+
|
|
16
|
+
class Exporter(ABC):
|
|
17
|
+
def __init__(self):
|
|
18
|
+
self.templates_path = "templates/"
|
|
19
|
+
|
|
20
|
+
@abstractmethod
|
|
21
|
+
def export(self, app: App, output_path: str) -> bool:
|
|
22
|
+
"""Exports the application to the specific format"""
|
|
23
|
+
pass
|
|
24
|
+
|
|
25
|
+
@abstractmethod
|
|
26
|
+
def render_component(self, component: Component) -> str:
|
|
27
|
+
"""Renders an individual component"""
|
|
28
|
+
pass
|
|
29
|
+
|
|
30
|
+
@abstractmethod
|
|
31
|
+
def get_platform(self) -> str:
|
|
32
|
+
"""Returns the name of the platform"""
|
|
33
|
+
pass
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Exportation Flow
|
|
37
|
+
|
|
38
|
+
1. **Validation**: Verify that the application is valid
|
|
39
|
+
2. **Preparation**: Create directory structure
|
|
40
|
+
3. **Rendering**: Convert components to the target format
|
|
41
|
+
4. **Generation**: Create configuration and dependency files
|
|
42
|
+
5. **Finalization**: Write files to the system
|
|
43
|
+
|
|
44
|
+
## Web Exporters
|
|
45
|
+
|
|
46
|
+
### HTML/CSS/JavaScript
|
|
47
|
+
|
|
48
|
+
The HTML exporter generates standard web applications that can run in any browser.
|
|
49
|
+
|
|
50
|
+
#### Features
|
|
51
|
+
|
|
52
|
+
- **Compatibility**: Works in all modern browsers
|
|
53
|
+
- **Simplicity**: No requires build tools
|
|
54
|
+
- **Performance**: Fast loading and efficient execution
|
|
55
|
+
- **SEO**: Content indexable by search engines
|
|
56
|
+
|
|
57
|
+
#### Usage
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
dars export my_app.py --format html --output ./dist
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
By default, the `dars export` command generates a production bundle (no hot-reload). See Bundling vs Dev Preview below.
|
|
64
|
+
|
|
65
|
+
#### Generated Structure
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
dist/
|
|
69
|
+
├── index.html # Main page
|
|
70
|
+
├── styles.css # CSS styles
|
|
71
|
+
├── script.js # JavaScript logic
|
|
72
|
+
└── runtime_dars.js # Dars runtime
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
#### Example Output
|
|
76
|
+
|
|
77
|
+
**index.html**
|
|
78
|
+
```html
|
|
79
|
+
<!DOCTYPE html>
|
|
80
|
+
<html lang="en">
|
|
81
|
+
<head>
|
|
82
|
+
<meta charset="UTF-8">
|
|
83
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
84
|
+
<title>My Application</title>
|
|
85
|
+
<link rel="stylesheet" href="styles.css">
|
|
86
|
+
</head>
|
|
87
|
+
<body>
|
|
88
|
+
<div id="container_123" class="dars-container" style="display: flex; flex-direction: column; padding: 20px;">
|
|
89
|
+
<span id="text_456" class="dars-text" style="font-size: 24px; color: #333;">Hello Dars!</span>
|
|
90
|
+
<button id="button_789" class="dars-button" style="background-color: #007bff; color: white;">Click</button>
|
|
91
|
+
</div>
|
|
92
|
+
<script src="script.js"></script>
|
|
93
|
+
<script src="runtime_dars.js"></script>
|
|
94
|
+
</body>
|
|
95
|
+
</html>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**styles.css**
|
|
99
|
+
```css
|
|
100
|
+
/* Base Dars styles */
|
|
101
|
+
* {
|
|
102
|
+
box-sizing: border-box;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
body {
|
|
106
|
+
margin: 0;
|
|
107
|
+
padding: 0;
|
|
108
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.dars-button {
|
|
112
|
+
display: inline-block;
|
|
113
|
+
padding: 8px 16px;
|
|
114
|
+
border: 1px solid #ccc;
|
|
115
|
+
background-color: #f8f9fa;
|
|
116
|
+
color: #333;
|
|
117
|
+
cursor: pointer;
|
|
118
|
+
border-radius: 4px;
|
|
119
|
+
font-size: 14px;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.dars-button:hover {
|
|
123
|
+
background-color: #e9ecef;
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### Advantages
|
|
128
|
+
|
|
129
|
+
- **Universality**: Works in any web server
|
|
130
|
+
- **Debugging**: Easy to debug with browser tools
|
|
131
|
+
- **Personalization**: CSS and JavaScript completely modifiable
|
|
132
|
+
- **Hosting**: Can be hosted on any static hosting service
|
|
133
|
+
|
|
134
|
+
#### Use Cases
|
|
135
|
+
|
|
136
|
+
- Corporate websites
|
|
137
|
+
- Landing pages
|
|
138
|
+
- Simple web applications
|
|
139
|
+
- Quick prototypes
|
|
140
|
+
- Interactive documentation
|
|
141
|
+
|
|
142
|
+
## Exporter Personalization
|
|
143
|
+
|
|
144
|
+
### Extending Existing Exporters
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
from dars.exporters.base import Exporter
|
|
148
|
+
|
|
149
|
+
class MyCustomExporter(Exporter):
|
|
150
|
+
def get_platform(self):
|
|
151
|
+
return "my_custom_platform"
|
|
152
|
+
|
|
153
|
+
def export(self, app, output_path):
|
|
154
|
+
# Implement custom export logic
|
|
155
|
+
return True
|
|
156
|
+
|
|
157
|
+
def render_component(self, component):
|
|
158
|
+
# Implement custom component rendering
|
|
159
|
+
return "generated_code"
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
The documentstion of dars is moving to the documentation official website please visit https://ztamdev.github.io/Dars-Framework/documentation.html because this documents will be deprecated in some time...
|
|
2
|
+
# Getting Started with Dars
|
|
3
|
+
|
|
4
|
+
Welcome to Dars, a modern Python framework for building web applications with reusable UI components.
|
|
5
|
+
|
|
6
|
+
## Quick Start
|
|
7
|
+
|
|
8
|
+
1. **Install Dars**
|
|
9
|
+
See [INSTALL.md](../../INSTALL.md) for installation instructions.
|
|
10
|
+
|
|
11
|
+
2. **Project Structure**
|
|
12
|
+
Learn about the framework internal project layout in [STRUCTURE.md](../../STRUCTURE.md).
|
|
13
|
+
|
|
14
|
+
3. **Explore Components**
|
|
15
|
+
Discover all available UI components in [components.md](components.md).
|
|
16
|
+
|
|
17
|
+
4. **Command-Line Usage**
|
|
18
|
+
Find CLI commands, options, and workflows in [cli.md](cli.md).
|
|
19
|
+
|
|
20
|
+
5. **App Class**
|
|
21
|
+
Learn how to create an app class in [App Documentation](app.md).
|
|
22
|
+
|
|
23
|
+
6. **Component Search and Modification**
|
|
24
|
+
All components in Dars now support a powerful search and modification system:
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from dars.all import *
|
|
28
|
+
|
|
29
|
+
app = App(title="Search Demo")
|
|
30
|
+
|
|
31
|
+
# Create a page with nested components
|
|
32
|
+
page = Page(
|
|
33
|
+
Container(
|
|
34
|
+
Text(text="Welcome!", id="welcome-text"),
|
|
35
|
+
Container(
|
|
36
|
+
Button(text="Click me", class_name="action-btn"),
|
|
37
|
+
Button(text="Cancel", class_name="action-btn"),
|
|
38
|
+
id="buttons-container"
|
|
39
|
+
),
|
|
40
|
+
id="main-container"
|
|
41
|
+
)
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
# Find and modify components
|
|
45
|
+
page.find(id="welcome-text")\
|
|
46
|
+
.attr(text="Welcome to Dars!", style={"color": "blue"})
|
|
47
|
+
|
|
48
|
+
# Chain searches to find nested components
|
|
49
|
+
page.find(id="buttons-container")\
|
|
50
|
+
.find(class_name="action-btn")\
|
|
51
|
+
.attr(style={"padding": "10px"})
|
|
52
|
+
|
|
53
|
+
app.add_page(name="main", root=page)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
7. **Adding Custom File Types**
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
app.rTimeCompile().add_file_types = ".js,.css"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
* Include any extension your project uses beyond default Python files.
|
|
63
|
+
|
|
64
|
+
## Need More Help?
|
|
65
|
+
|
|
66
|
+
### Project Structure
|
|
67
|
+
Learn about the recommended project layout in [STRUCTURE.md](../../STRUCTURE.md).
|
|
68
|
+
|
|
69
|
+
### Explore Components
|
|
70
|
+
Discover all available UI components in [components.md](components.md).
|
|
71
|
+
|
|
72
|
+
### Command-Line Usage
|
|
73
|
+
Find CLI commands, options, and workflows in [cli.md](cli.md).
|
|
74
|
+
|
|
75
|
+
### Need More Help?
|
|
76
|
+
- For advanced topics, see the full documentation and examples in the referenced files above.
|
|
77
|
+
- If you have questions or need support, check the official repository or community channels.
|
|
78
|
+
|
|
79
|
+
Start building with Dars...
|
dars/docs/index.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Dars Framework Documentation
|
|
2
|
+
|
|
3
|
+
The documentstion of dars is moving to the documentation official website please visit https://ztamdev.github.io/Dars-Framework/documentation.html because this documents will be deprecated in some time...
|
|
4
|
+
|
|
5
|
+
Welcome to the official Dars Framework documentation. Here you will find detailed guides and references to help you build modern web applications with Python.
|
|
6
|
+
|
|
7
|
+
## Main Guides
|
|
8
|
+
|
|
9
|
+
- [Getting Started with Dars](getting_started.md)
|
|
10
|
+
- [App class](app.md)
|
|
11
|
+
- [Components](components.md)
|
|
12
|
+
- [Custom Components](custom_components.md)
|
|
13
|
+
- [Event Handling](events.md)
|
|
14
|
+
- [Exporters](exporters.md)
|
|
15
|
+
- [Scripts System](scripts.md)
|
|
16
|
+
- [CLI Usage and Commands](cli.md)
|
|
17
|
+
|
|
18
|
+
|