Hello.
I built VTK 9.0.1 with tkinter Python 3.8.5 for Macos (Intel, Big Sur) on a Macbook Air, and built an app that visualizes dicom images. App works perfectly fine on Macbook Air. Tested it on multiple devices. However, on testing the app on Macbook Pro, the render window breaks down. It minimizes, leaves the set grid position, and overlaps other widgets on the tkinter window.
What could cause this difference in behaviour?
I assumed building on macos environment would work across all mac devices (air, pro, mini, imac).
Alternatively, are there any builds of VTK available anywhere with tkinter included? That would work consistently, like the ones on pypi, but with VTK included.
@ken-martin Could macbook pro and air on the same version of MacOS (Big Sur) have different tkinter versions? (Iām new to building apps in this environment)
The frozen app is built with tk8.6, that ships with python 3.8.
The render window itself still works, displays images, can be interacted with, on macbook pro. Just totally breaks down in terms of position and size.
I doubt that vtkTkRenderWidget will work on Retina displays. On my part, Iāve used tkinter on Windows and Linux recently, but I havenāt used tkinter on macOS for a couple years at least.
Fixing vtkTkRenderWidget for retina might be easy or might be hard.
I built VTK with Tkinter on Windows and Linux. The app works well on both platforms on multiple devices. It is only on MacOS that I have seen this issue.
@dgobbi What solution would you suggest? As the macbook pros I tested on definitely had retina displays.
A quick follow-up. I tried the old squadViewer.py example on Retina and the problem really does appear to be a scaling/positioning issue and nothing more:
Hi,
Following the info you mentioned earlier, that āVTK has been made to support Retina through Qt and Cocoaā¦ā
I decided to make a go of building the app on qt and have been largely successful.
However, I have noticed an offset between the mouse-click position on screen, and the relative position on the render window. See the screenshot below, where to get the handle of the Box Widget, I would have to click at the cursor position.
The QVTKRenderWindowInteractor in that example is quite old, try using the current one from the VTK master branch. Iām not sure if the retina support is complete, but the code is straightforward and should be easy to modify.
Also please note that QVTKRenderWindowInteractor.py is completely different from the QVTKOpenGLNativeWidget.cxx that is used by ParaView and other C++ applications. VTKās C++-Qt code is tested on a regular basis by Kitware, but QVTKRenderWindowInteractor.py is a community-supported class, so itās really only tested and patched by users such as yourself.
Would you mind sharing the build steps for VTK+tk support under Mac OS X? I brew installed python-tk@3.9 and tcl-tk, added the right path to $CPPFLAGS and $LDFLAGS but run into this:
cmake -DVTK_BUILD_TESTING=OFF\
-DVTK_WHEEL_BUILD=ON\
-DVTK_PYTHON_VERSION=3\
-DVTK_WRAP_PYTHON=ON\
-DPython3_EXECUTABLE=(which python3)\
-DVTK_USE_TK=ON\
..
-- Could NOT find Python3 (missing: Development.Module) (found version "3.9.10")
CMake Warning (dev) at /usr/local/Cellar/cmake/3.23.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
The package name passed to `find_package_handle_standard_args` (TCLTK) does
not match the name of the calling package (TCL). This can lead to problems
in calling code that expects `find_package` result variables (e.g.,
`_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
CMake/FindTCL.cmake:186 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
Rendering/Tk/CMakeLists.txt:2 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at /usr/local/Cellar/cmake/3.23.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
The package name passed to `find_package_handle_standard_args` (TK) does
not match the name of the calling package (TCL). This can lead to problems
in calling code that expects `find_package` result variables (e.g.,
`_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
CMake/FindTCL.cmake:189 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
Rendering/Tk/CMakeLists.txt:2 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Error at CMake/vtkModule.cmake:1473 (target_include_directories):
target_include_directories called with incorrect number of arguments
Call Stack (most recent call first):
Rendering/Tk/CMakeLists.txt:65 (vtk_module_include)
-- Configuring incomplete, errors occurred!
See also "/Users/nicoco/tmp/vtk/build/CMakeFiles/CMakeOutput.log".
See also "/Users/nicoco/tmp/vtk/build/CMakeFiles/CMakeError.log".
Didnāt you notice render window scaling issue? It seems the vtkviewport only occupies a quarter of the window. I am guessing it is HiDPI-relatedā¦ @dgobbi I hope it is OK if I ping you here, since you are the author of the tk related stuff.
The HiDPI stuff was never implemented in the vtkTkRenderWidget (search for āretinaā in this thread for previous posts on the subject). If anyone wants to dig into vtkTkRenderWidget.cxx and actually fix the issue, Iād be glad to assist.
@dgobbi Iāll definitely take a look, but I pretty much suck at any other language than python or JS. Might be a good opportunity to skill up though
@cmengich I see, you gave up on tkinter then! I know that using Qt is the most common option but I really enjoy tkinter to write GUIs rapidlyā¦ meh, maybe Iāll change my mind in the coming weeks and just rewrite all my stuff to use Qt instead.
to pick points on screen. This most probably does not work for non-retina display. Thought Iād share here anyway in case anybody also likes tkinter for quick GUI prototyping!