Looking for button to navigate to login page in python using justpy

37 views Asked by At

I'm using justpy to make a small scale management system, its a framework for developing web apps in python without css/html/js. The menu displays itself but none of the buttons work.The following is the code I have so far:

import justpy as jp

class LoginPage(jp.WebPage):
    def __init__(self):
        super().__init__()
        form_div = jp.Div(classes='w-64 mx-auto mt-10', a=self)
        self.username_input = jp.Input(placeholder='Username', classes='w-full mb-2 p-2', a=form_div)
        self.password_input = jp.Input(placeholder='Password', type='password', classes='w-full mb-2 p-2', a=form_div)
        self.login_button = jp.Button(text='Login', classes='w-full bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded', a=form_div)

class MenuPage(jp.BaseWebPage):
    def __init__(self):
        super().__init__()
        self.menu = jp.Div(classes='flex justify-around p-4 bg-blue-500 text-white', a=self)
        self.login_button = jp.Button(text='LOGIN', classes='p-2 hover:bg-blue-700', a=self.menu, click=self.go_to_login)
        self.home_button = jp.Button(text='HOME', classes='p-2 hover:bg-blue-700', a=self.menu)
        self.forums_button = jp.Button(text='FORUMS', classes='p-2 hover:bg-blue-700', a=self.menu)
        self.help_button = jp.Button(text='HELP', classes='p-2 hover:bg-blue-700', a=self.menu)

    

    def go_to_login(self, msg):
        self.delete()  # Remove the menu from the page
        a = LoginPage()
        a.show() # Add the login page to the page



jp.justpy(MenuPage)

I'm trying to create a dashboard with the menu options HOME, LOGIN, FORUMS, HELP. I have implemented the logic of the login button but can't get it to work. I can't get the LOGIN button to work, I tried making two different classes, one for the menu and the other for the login but still no luck. Open to all solutions

0

There are 0 answers