I've just started learning all programming thing and came across this python library "eel" where you can create a decent GUI out of HTML. However, there are not many tutorials available or decent example projects available out there to study from. Here's what I want to do but I don't know how to achieve it. If you guys can help me out, it'd be greatly appreciated.
- I have (currently 2) HTML pages one used as a landing page for login (index.html) and one use as a man application (main.html).
- A main.py where I import and connect eel.
- A login.py where I create a list of login credentials: username and password
Basically, when I open the main.py, the index.html will open up, and enter the correct login credential (let's say username: user1 | password: 12345) and hit the button, the main application (main.html) will appear, otherwise it shows "incorrect username or password".
So, the code looks like this in my index.html
<script type="text/javascript">
$(function() {
eel.expose(open_vwmain);
function open_vwmain_js(x){
$(window.location = ".../web/main.html")
}
<!-- upon button click, html eel sends out the user and pw entered in this index.html to python -->
$("#btn").click(function() {
eel.login($("#username").val(), $("#password").val());
});
});
</script>
And in my main.py it looks like this:
eel.init('web')
@eel.expose
def login(username, password):
# logic -> Check for right user/ login suceeded
if username == check_data.USER and password == check_data.PW:
eel.open_vwmain_js(open_vwmain)
else:
eel.open_vwmain_js(error)
eel.start('index.html',size=(800,600), port=8080)
Note, I have not added the popup error message yet because it isn't that important for now. I just have no idea how to make this first step to work yet.
Thanks a lot guys!