Есть ли способ заменить self.panel1 на Vispy Canvas? или встроить Vispy Canvas в self.panel1 (холст Tkinter). В этом коде выходные данные дают мне два отдельных окна.
Код: Выделить всё
def init_panels(self):
self.panel1 = self.create_panel("3D", "white", "white")
self.panel2 = self.create_panel("XY", "magenta", "yellow")
self.panel3 = self.create_panel("YZ", "blue", "magenta")
self.panel4 = self.create_panel("XZ", "blue", "yellow")
self.panel1.grid(row=0, column=0, sticky="nsew", padx=1, pady=1)
self.panel2.grid(row=0, column=1, sticky="nsew", padx=1, pady=1)
self.panel3.grid(row=1, column=0, sticky="nsew", padx=1, pady=1)
self.panel4.grid(row=1, column=1, sticky="nsew", padx=1, pady=1)
self.content_frame.grid_columnconfigure(0, weight=1, minsize=512)
self.content_frame.grid_columnconfigure(1, weight=1, minsize=512)
self.content_frame.grid_rowconfigure(0, weight=1, minsize=512)
self.content_frame.grid_rowconfigure(1, weight=1, minsize=512)
self.panels.extend([self.panel1, self.panel2, self.panel3, self.panel4])
# Initial axes
self.update_panel_images()
def create_panel(self, label_text, x_color, y_color):
panel = Frame(self.content_frame, bg="black", width=512, height=512)
panel.pack_propagate(False) # Prevent the panel from resizing to fit its contents
panel.canvas = Canvas(panel, bg="black")
panel.canvas.pack(fill="both", expand=True, anchor="center")
panel.bind("", self.on_panel_resize)
return panel
def visualize_vispy(self, volume3d):
canvas = scene.SceneCanvas(keys='interactive', show=True)
view = canvas.central_widget.add_view()
volume = scene.visuals.Volume(volume3d, parent=view.scene, threshold=0.225)
view.camera = scene.cameras.TurntableCamera(parent=view.scene, fov=60)
view.camera.set_range()
canvas.native.master = self.panel1
canvas.native.pack(side=TOP, fill=BOTH, expand=1)
AttributeError: у объекта «CanvasBackendDesktop» нет атрибута «pack».
Я ожидаю, что визуализировать 3D-модель из Vispy в self.panel1
Возможно ли это?
Подробнее здесь: https://stackoverflow.com/questions/786 ... ter-canvas