Search code examples
pythonplotly-dashbeeware

Dash-plotly deployed as an apk for android or IOS


Is there a way to create a dash-plotly app for android or IOS? I've read some of the Beeware documentation, but I still wouldn't know how to take my dashboard and include it into the app.py default file:

import toga
from toga.style import Pack
from toga.style.pack import COLUMN, ROW


class Matics(toga.App):

    def startup(self):
        """
        Construct and show the Toga application.

        Usually, you would add your application to a main content box.
        We then create a main window (with a name matching the app), and
        show the main window.
        """
        main_box = toga.Box()

        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = main_box
        self.main_window.show()


def main():
    return Matics()

The example they provide is a Hello world app with the following code:


class HelloWorld(toga.App):
    def startup(self):
        main_box = toga.Box(style=Pack(direction=COLUMN))

        name_label = toga.Label(
            'Your name: ',
            style=Pack(padding=(0, 5))
        )
        self.name_input = toga.TextInput(style=Pack(flex=1))

        name_box = toga.Box(style=Pack(direction=ROW, padding=5))
        name_box.add(name_label)
        name_box.add(self.name_input)

        button = toga.Button(
            'Say Hello!',
            on_press=self.say_hello,
            style=Pack(padding=5)
        )

        main_box.add(name_box)
        main_box.add(button)

        self.main_window = toga.MainWindow(title=self.formal_name)
        self.main_window.content = main_box
        self.main_window.show()

    def say_hello(self, widget):
        print("Hello", self.name_input.value)

I haven't found a way to include the dash-plotly code in the main_box.

My goal is to get the dashboard as an APK for android, so if beeware is not the solution I would be happy to see what the solution is.


Solution

  • To deploy your briefcase code into an apk, first open command prompt in the directory of your project and then in the command window type:

    briefcase create android
    

    And then after it completes all the work then type:

    briefcase build android
    

    And then it will take few minutes and then your apk will be created and to create an iOS app for this you need and Mac PC and the command are same but you have to just replace android by iOS.. Thanks