I am getting this error " TypeError: multipleApp.run() missing 1 required positional argument: 'self'"

Summary

I am getting the above error when I try to run my streamlit multiple pages app. Below are you code for my app.

import streamlit as st
from streamlit_option_menu import option_menu

st.set_page_config(
    page_title="My Online Store",
)

class multipleApp:
    def _init_(self):
        self.apps = []

    def add_app(self, title, function):
        self.apps.append({
            "title": title,
            "function": function
        })

    def run(self):

        with st.sidebar:
            app = option_menu(
                menu_title="My Online Store",
                options=["Home", "About"],
                icons=["house-fill", "person-circle"],
                menu_icon="chat-text-fill",
                default_index=1,
                styles={
                    "container": {"padding": "5!important", "background-color": "blue"},
                    "icon": {"color": "white", "font-size": "23px"},
                    "nav-link": {"color": "white", "font-size": "20px", "text-align": "left", "margin": "0px"},
                    "nav-link-selected": {"background-color": "#02ab21"}, }

            )
        if app == "Home":
            home.app()
        if app == "About":
            about.app()

    run()

Hi @Levis_Kerzuah ,

I didn’t understand the purpose of β€œself” here which is a class object.

Remove the β€œself” from the run function.

And in place of run() command use
multipleApp.run()

When I remove (self), it give me error.

Hello. Right before your run(), try this. Seems class is defined but not initialized.

runtime = multipleApp
runtime.run()

Not working. it gives error when I use it.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.