trame icon indicating copy to clipboard operation
trame copied to clipboard

Bug with exporting the plotter to an HTML file

Open Brandon-Xu opened this issue 3 months ago • 0 comments

I found a bug with exporting the plotter to an HTML file self.plotter.export_html(). When I open it in a browser, it works normally. However, when I open trame in desktop mode (using this line sys.argv.append('--app')), not only does the HTML file fail to export, but a strange dialog box also pops up.

I look forward to a resolution to this issue. Thanks.

Windows 11 Python 3.11 Trame 3.6.5 Pyvista 0.44.0

import sys
import pyvista as pv
from pyvista.trame import PyVistaLocalView

from trame.decorators import TrameApp
from trame_vtk.modules.vtk.serializers import encode_lut
from trame.app import get_server
from trame.widgets import vuetify3 as vuetify
from trame.ui.vuetify3 import SinglePageLayout

encode_lut(True)


@TrameApp()
class KlGModelApp:
    def __init__(self):
        self.view = None
        self.server = get_server(client_type="vue3")
        self.plotter = pv.Plotter(off_screen=True)

        sphere = pv.Sphere(center=(0, 0, 0))
        self.plotter.add_mesh(sphere)
        self.build_ui()

    @property
    def state(self):
        return self.server.state

    @property
    def ctrl(self):
        return self.server.controller

    def export_to_html(self):
        self.plotter.export_html("pv.html")

    def build_ui(self):
        with SinglePageLayout(_server=self.server) as layout:
            layout.title.set_text("(ο´・д・)??")

            with layout.toolbar:
                vuetify.VDivider(vertical=True, classes="mx-2")
                vuetify.VBtn(children="Export HTML", click=self.export_to_html)

            with layout.content:
                with vuetify.VContainer(fluid=True, classes="pa-0 fill-height"):
                    self.view = PyVistaLocalView(self.plotter)

# -----------------------------------------------------------------------------
# Main
# -----------------------------------------------------------------------------


if __name__ == "__main__":
    app = KlGModelApp()
    sys.argv.append('--app')
    app.server.start(width=1800, height=900, port=8081)

Brandon-Xu avatar Oct 28 '24 10:10 Brandon-Xu