从Python的IDLE控制的Paraview GUI

问题描述 投票:3回答:2

我试图控制的Paraview交互使用闲置。这将涉及从IDLE发送命令,看到发生的Paraview的变化。我宁可不使用in-的Paraview蟒蛇壳。

到目前为止,我已经成功地从IDLE进口的Paraview模块(简单,ServerManager的...等)。但是发送的命令不反映的Paraview。例如:

>>> from paraview.simple import *
>>> cone = Cone()
>>> Show()
>>> Render()

确实创造一个圆锥体。然而锥体输出到一个新的,独立的OpenGL窗口,而不是GUI的Paraview。

是否有可能控制的Paraview交互使用空闲?如果是如何做到这一点?谢谢

python python-2.7 python-idle paraview
2个回答
4
投票

你需要运行在多客户/服务器模式paraview包。在终端运行pvserver。

./bin/pvserver --multi-clients

在另一端,运行paraview包和连接到服务器

./bin/paraview
File->Connect
AddServer -> Choose a name -> Configure -> Save
Connect

在第三终端,运行pvpython(或您自己的配置蟒蛇)

./bin/pvpython
>> from paraview.simple import *
>> Connect("localhost")
>> Cone()
>> Show()

0
投票

我内置paraview包对我的系统蟒蛇,这样我可以使用ipython包等。我不得不为我设置PYTHONPATH指向paraview包python软件包和LD_LIBRARY_PATH指向paraview包lib目录。

export PYTHONPATH=/path/to/paraview/install/lib/python2.7/site-packages
export LD_LIBRARY_PATH=/path/to/paraview/install/lib
$ ipython 
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15) 
Type "copyright", "credits" or "license" for more information.

IPython 5.5.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: from paraview.simple import *

In [2]: Connect("localhost")
Out[2]: Connection (cs://localhost:11111) [2]

In [3]: Cone()
Out[3]: <paraview.servermanager.Cone at 0x7f30716cde10>

In [4]: Show()
Out[4]: <paraview.servermanager.GeometryRepresentation at 0x7f307167b210>

In [5]: GetSources()
Out[5]: {('Cone1', '8803'): <paraview.servermanager.Cone at 0x7f30716cde10>}

In [6]: GetActiveSource()
Out[6]: <paraview.servermanager.Cone at 0x7f30716cde10>

Screen shot of the rendered cone from the ipython paraview client

我paraview包版本是从master建在Ubuntu 18.04。

我唯一的问题是在Python站点__init__.py目录丢失packages/paraview/modules文件。

In [1]: from paraview.simple import *
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-cc11d49fb28b> in <module>()
----> 1 from paraview.simple import *

/home/dustin/repos/paraview_builds/master/install/lib/python2.7/site-packages/paraview/simple.py in <module>()
     39 
     40 import paraview
---> 41 from paraview import servermanager
     42 import paraview._backwardscompatibilityhelper
     43 

/home/dustin/repos/paraview_builds/master/install/lib/python2.7/site-packages/paraview/servermanager.py in <module>()
     54 from paraview import _backwardscompatibilityhelper as _bc
     55 
---> 56 from paraview.modules.vtkPVServerImplementationCore import *
     57 from paraview.modules.vtkPVClientServerCoreCore import *
     58 from paraview.modules.vtkPVServerManagerCore import *

ImportError: No module named modules.vtkPVServerImplementationCore

我周围这让刚刚通过创建在__init__.py目录中的文件paraview/modules

touch /path/to/paraview/install/lib/python2.7/site-packages/paraview/modules/__init__.py
© www.soinside.com 2019 - 2024. All rights reserved.