Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tkinter resize/Configure event error #586

Closed
rfiedorowicz opened this issue Mar 20, 2019 · 6 comments
Closed

Tkinter resize/Configure event error #586

rfiedorowicz opened this issue Mar 20, 2019 · 6 comments
Labels
Milestone

Comments

@rfiedorowicz
Copy link

I'm getting error when I'm trying resize tkinter window, where panda exists:

Fatal Python error: PyEval_RestoreThread: NULL tstate

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
AL lib: (EE) alc_cleanup: 1 device not closed

image

Panda 1.10.2
python 2.7
Config.prc : want-tk #t

Here is standalone example app:

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

def resize_event(event):
    print event.height, event.width


base = ShowBase(windowType='none')


base.startTk()

frame = base.tkRoot
frame.geometry('800x600')
frame.bind("<Configure>", resize_event)


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

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

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

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

base.run()
@rdb
Copy link
Member

rdb commented Mar 20, 2019

I looked into this recently and it seems to be caused by Panda sharing a message loop with Tkinter, but Tkinter assuming that its WinProc will only be invoked from its own message loop.

I'm not exactly sure how to solve this yet. Maybe Panda needs to ignore events in the message loop that don't match its own windows, or we need a setting for renderFrame not to release the GIL, or something like that.

@rdb rdb added the bug label Mar 20, 2019
@rfiedorowicz
Copy link
Author

@rdb
Hope I'm not annoying you, but is there change to resolve this issue?

On python 3.7 and panda 1.10 I have errors like this:

Fatal Python error: PyEval_RestoreThread: NULL tstate

Current thread 0x00002470 (most recent call first):
  File "C:\Users\busker\AppData\Local\Programs\Python\Python37-32\lib\site-packages\direct\showbase\ShowBase.py", line 2002 in __igLoop
  File "C:\Users\busker\AppData\Local\Programs\Python\Python37-32\lib\site-packages\direct\task\Task.py", line 485 in step
  File "C:\Users\busker\AppData\Local\Programs\Python\Python37-32\lib\site-packages\direct\showbase\ShowBase.py", line 3065 in __tkTimerCallback
  File "C:\Users\busker\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 749 in callit
  File "C:\Users\busker\AppData\Local\Programs\Python\Python37-32\lib\site-packages\Pmw\Pmw_2_0_1\lib\PmwBase.py", line 1776 in __call__
  File "C:\Users\busker\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1283 in mainloop
  File "C:\Users\busker\AppData\Local\Programs\Python\Python37-32\lib\site-packages\direct\showbase\ShowBase.py", line 3079 in tkRun
  File "c:/github/solar_panda/main copy.py", line 35 in <module>

@kostasmarkakis
Copy link

Hi, i am having the same problem but not when resizing. it happens in regular clicks as well.
@sheetcode did you had a ny luck solving it by the way?

@rdb rdb added this to the 1.10.5 milestone Nov 27, 2019
@rfiedorowicz
Copy link
Author

@kostasmarkakis
Unfortunately not :(
I was continuing using 2 separated windows

@kostasmarkakis
Copy link

kostasmarkakis commented Nov 27, 2019

@sheetcode
well as i said in the Panda3D forum discussion (https://discourse.panda3d.org/t/launch-a-panda3d-app-window-from-a-tkinter-based-python-app/25382/4)
the problem is not with resize but regular clicking as well. i have deactivated resizing for both Tkinter and Panda3D.

@rdb
Copy link
Member

rdb commented Dec 8, 2019

I decided to just do a hacky fix, since there may be no clean fix possible without risking side-effects in 1.10.5. Panda will now disable its own message pump entirely when Tk support is enabled, since Tcl's own main loop will happily handle Panda's events (but not vice versa).

A variable disable-message-loop true can be set by the user to force this if the standard mechanism of launching Tkinter is not used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants