2

有没有办法为 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)

我还没有找到在 main_box 中包含破折号代码的方法。

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

4

1 回答 1

0

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

briefcase create android

然后在它完成所有工作后输入:

briefcase build android

然后这将需要几分钟,然后您的 apk 将被创建并为此创建一个您需要的 iOS 应用程序,Mac PC 和命令是相同的,但您只需将 android 替换为 iOS .. 谢谢

于 2020-10-21T10:49:15.283 回答