Python TkInter: Creating a Window which runs my custom code

可紊 提交于 2020-06-17 09:27:50

问题


I am Creating a python custom code to Visualise scientific/medical data in 3D.

This code should be implemented in the GUI I am creating with TKInter, so as to visualise these data sets directly in the GUI.

If I already have the code written up is there a way I can run this code in my GUI and subsequently open and run the visualisation window directly in the TKInter GUI???

Is it possible to create custom windows inside with TKInter which contain more complex code and allow the user to visualise the image output of the code??

Additional info: The visualisation code for the 3d data is created with VTK (Visualisation ToolKit) and opens a custom Visualisation window.


回答1:


VTK should ship with the vtkTkRenderWindowInteractor functionality but is per default not built or included in most distributions like pypi or anaconda. You would then most likely have to build VTK manually with the VTK_USE_TK cmake flag, see for example this thread:

https://discourse.vtk.org/t/error-importing-vtktkrenderwindowinteractor-in-vtk-8-2-0/856/27




回答2:


Unless the VTK binding for Python contains a dedicated library for interaction with TKInter, no, you can't.

Every GUI toolkit contains it's own set of widgets designed to interact with each other in exactly the ways defined by the toolkit, so you generally can't simply mix widgets from two libraries in one window.

You can, of course, write a Python program that imports both libraries and then opens two windows, one from TKInter and one from VTK. By making it handle events from both windows, you can also provide some very basic interaction between them. This might be the closest to what you want.



来源:https://stackoverflow.com/questions/51268131/python-tkinter-creating-a-window-which-runs-my-custom-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!