article

Thursday, October 20, 2022

Python Desktop App Admin using python eel

Python Desktop App Admin using python eel

Eel is a little Python library for making simple Electron-like offline HTML/JS GUI apps, with full access to Python capabilities and libraries.
https://github.com/ChrisKnott/Eel

Install
pip install eel
C:\python_dev\crud>pip install eel

Install PyAutoGUI
https://pypi.org/project/PyAutoGUI/
pip install PyAutoGUI
C:\python_dev\crud>pip install PyAutoGUI

Download 
Bootstrap admin 
https://startbootstrap.com/

main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#main.py
import eel
  
eel.init('views')
     
@eel.expose
def new_window(target: str):
    eel.show(f"html/{target}")
     
eel.start(
    'templates/index.html',
    size=pyautogui.size(),
    jinja_templates='templates'
)
#C:\python_dev\admin> python -m eel main.py views --onefile --icon=logo.ico --noconsole
Make your Front-end HTML CSS and Javascript
admin\views\templates\index.html
1
2
3
4
5
6
7
8
//admin\views\templates\index.html
{% extends "base.html" %}
 
{% block content %}
    <div id="wrapper">
        {% include "sidebar.html" %}
    </div>  
{% endblock %}
admin\views\templates\base.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//admin\views\templates\base.html
<!DOCTYPE html>
<html lang="pt-br">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script type="text/javascript" src="/eel.js"></script>
     
    <link href="../vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
     
    <link rel="stylesheet" href="../css/sb-admin-2.min.css">
    <link rel="icon" href="../img/myglogo.png">
    <title>Python Admin</title>
</head>
<body>
  {% block content %}
  {% endblock %}
 
    <!-- Bootstrap core JavaScript-->
    <script src="../vendor/jquery/jquery.min.js"></script>
    <script src="../vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
 
    <!-- Core plugin JavaScript-->
    <script src="../vendor/jquery-easing/jquery.easing.min.js"></script>
 
    <!-- Custom scripts for all pages-->
    <script src="../js/sb-admin-2.min.js"></script>
 
    <!-- Page level plugins -->
    <script src="../vendor/chart.js/Chart.min.js"></script>
 
    <!-- Page level custom scripts -->
    <script src="../js/demo/chart-area-demo.js"></script>
    <script src="../js/demo/chart-pie-demo.js"></script>   
    <script>
        function link(target) {
            window.location.href=target;
        }
    </script>
</body>
</html>
admin\views\templates\buttons.html
1
2
3
4
5
6
//admin\views\templates\buttons.html
{% extends "base.html" %}
 
{% block content %}
    buttons.html
{% endblock %}
admin\views\templates\sidebar.html Run : C:\python_dev\crud>python main.py

pytinstaller exe file
C:\python_dev\admin> python -m eel main.py views --onefile --icon=logo.ico --noconsole

Related Post