Dashplotly部署为android或IOS的apk

2024-05-17 05:28:40 发布

您现在位置:Python中文网/ 问答频道 /正文

有没有办法为android或IOS创建dash plotly应用程序?我已经阅读了一些Beeware文档,但我仍然不知道如何使用仪表板并将其包含到app.py默认文件中:

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()

他们提供的示例是一个Hello world应用程序,其代码如下:


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)

我还没有找到在主框中包含破折号绘图代码的方法

我的目标是将仪表板作为android的APK,因此如果beeware不是解决方案,我很乐意看到解决方案是什么


Tags: thenameimportselfboxaddstylemain
1条回答
网友
1楼 · 发布于 2024-05-17 05:28:40

要将公文包代码部署到apk中,请首先在项目目录中打开命令提示符,然后在命令窗口中键入:

briefcase create android

然后在完成所有工作后,键入:

briefcase build android

然后这将需要几分钟,然后你的apk将被创建,要创建一个iOS应用程序,你需要Mac PC和命令是一样的,但你必须用iOS取代android。。 谢谢

相关问题 更多 >