Tkinter error opening directtools

I’m trying run the example, but I have errors:
I changed also Config.prc file:

    want-directtools  #t
    want-tk           #t

Does anybody know how to fix it?
Panda 1.10x64 , windows 10, python 2.7


Traceback (most recent call last):
  File "C:\Users\busker\PycharmProjects\solar_panda\tmp\TkinterManager.py", line 9, in <module>
    base.startTk()
  File "C:\Panda3D-1.10.0-x64\direct\showbase\ShowBase.py", line 2907, in startTk
    self.spawnTkLoop()
  File "C:\Panda3D-1.10.0-x64\direct\showbase\ShowBase.py", line 2926, in spawnTkLoop
    self.tkRoot = Pmw.initialise()
  File "C:\Panda3D-1.10.0-x64\Pmw\Pmw_1_3\lib\PmwLoader.py", line 134, in __getattr__
    self._initialise()
  File "C:\Panda3D-1.10.0-x64\Pmw\Pmw_1_3\lib\PmwLoader.py", line 88, in _initialise
    basemodule = self._getmodule(path + '.Pmw' + _BASEMODULE)
  File "C:\Panda3D-1.10.0-x64\Pmw\Pmw_1_3\lib\PmwLoader.py", line 71, in _getmodule
    __import__(modpath)
  File "C:\Panda3D-1.10.0-x64\Pmw\Pmw_1_3\lib\PmwBase.py", line 1182, in <module>
    forwardmethods(MegaToplevel, Tkinter.Toplevel, '_hull')
AttributeError: 'module' object has no attribute 'Toplevel'

I have moved your post to a new topic; please don’t add a new question to an existing 3-year-old thread.

Which precise version of Panda3D 1.10 are you using—1.10.0, 1.10.1, or 1.10.2? If you are not using 1.10.2, please update to the latest version.

Oh sorry, I added post there because I was using your example code

I’m using Panda3D-1.10.0-x64, ok so I will update and edit this post later

I updated to 1.10.2 and still getting same error message

I’m also tried run this with python 3.7.2

from direct.showbase.ShowBase import ShowBase
from panda3d.core import WindowProperties
# import Tkinter

# Start ShowBase, but don't open a Panda window yet
base = ShowBase(windowType='none')

# Start Tkinter integration, get the root window handle
base.startTk()

frame = base.tkRoot
frame.update()
id = frame.winfo_id()
width = frame.winfo_width()
height = frame.winfo_height()

props = WindowProperties()
props.setParentWindow(id)
props.setOrigin(0, 0)
props.setSize(width, height)

base.makeDefaultPipe()
base.openDefaultWindow(props=props)

scene = base.loader.loadModel("environment")
scene.reparentTo(base.render)

base.run()

but I got error:

PS C:\Panda3D-1.10.2-x64\python> .\python.exe .\tkinker_test.py
Traceback (most recent call last):
  File ".\tkinker_test.py", line 9, in <module>
    base.startTk()
  File "C:\Panda3D-1.10.2-x64\direct\showbase\ShowBase.py", line 2991, in startTk
    self.spawnTkLoop()
  File "C:\Panda3D-1.10.2-x64\direct\showbase\ShowBase.py", line 3006, in spawnTkLoop
    Pmw = importlib.import_module('Pmw')
  File "C:\Panda3D-1.10.2-x64\python\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Panda3D-1.10.2-x64\Pmw\__init__.py", line 30, in <module>
    _instdirs.sort()
AttributeError: 'filter' object has no attribute 'sort'

Download this file:

https://www.panda3d.org/download/panda3d-1.10.2/panda3d-1.10.2-tools-win64.zip

And take out the “thirdparty\Pmw” directory, and use it to replace “C:\Panda3D-1.10.2-x64\Pmw”

It’s working on python 3.7.2 :smiley:

I’m still getting this error on 2.7 :confused:

(Please don’t be confused with “C:\Panda3D-1.10.0-x64”, because I changed name of folder to not lose references in pycharm, yes it’s ugly dirty hack)

Python version: 2.7.13
Panda version: 1.10.2
Uncaught exception
Traceback (most recent call last):
  File "C:/Users/busker/PycharmProjects/solar_panda/main.py", line 28, in <module>
    panda.startTk()
  File "C:\Panda3D-1.10.0-x64\direct\showbase\ShowBase.py", line 2991, in startTk
    self.spawnTkLoop()
  File "C:\Panda3D-1.10.0-x64\direct\showbase\ShowBase.py", line 3010, in spawnTkLoop
    self.tkRoot = Pmw.initialise()
  File "C:\Panda3D-1.10.0-x64\Pmw\Pmw_1_3_3\lib\PmwLoader.py", line 134, in __getattr__
    self._initialise()
  File "C:\Panda3D-1.10.0-x64\Pmw\Pmw_1_3_3\lib\PmwLoader.py", line 88, in _initialise
    basemodule = self._getmodule(path + '.Pmw' + _BASEMODULE)
  File "C:\Panda3D-1.10.0-x64\Pmw\Pmw_1_3_3\lib\PmwLoader.py", line 71, in _getmodule
    __import__(modpath)
  File "C:\Panda3D-1.10.0-x64\Pmw\Pmw_1_3_3\lib\PmwBase.py", line 1188, in <module>
    forwardmethods(MegaToplevel, Tkinter.Toplevel, '_hull')
AttributeError: 'module' object has no attribute 'Toplevel'

You may have a module called Tkinter.py that is conflicting with Python’s built-in Tkinter module. Rename that module and the issue should go away.

Yeeees… I’m feel very stupid, but it’s working.

Thanks!