I am trying to print a string to the terminal while displaying a plot figure on my enaml gui and it doesn't seem to respond. Listed below are my two scripts:
main_view.enaml
from enaml.widgets.api import Window, Container, MPLCanvas, Label, PushButton
from enaml.layout.api import vbox
from matplotlib.figure import Figure
fig1 = Figure()
ax1 = fig1.add_subplot(111)
ax1.plot([1,2,3])
enamldef MainView(Window):
title = 'Main View'
Container:
constraints = [
vbox(
label,
canvas,
pb
)
]
MPLCanvas: canvas:
figure << fig1
Label:
text = 'MyApp'
PushButton: pb:
text = 'My button'
clicked ::
print('hello')
main.py
import enaml
from enaml.qt.qt_application import QtApplication
if __name__ == '__main__':
with enaml.imports():
from main_view import MainView
app = QtApplication()
view = MainView()
view.show()
app.start()
While running the terminal outputs the following:
QBasicTimer::start: QBasicTimer can only be used with threads started with QThread
QBasicTimer::start: QBasicTimer can only be used with threads started with QThread
QBasicTimer::start: QBasicTimer can only be used with threads started with QThread
When I hit the pushbutton the following gets outputted:
QObject::startTimer: Timers cannot be started from another thread
QObject::killTimer: Timers cannot be stopped from another thread
When I remove the figure the print statement gets triggered. Any idea as to what I am missing?
I cannot reproduce locally (using PyQt5 and PyQt6). Could you share the enaml version you are using the Qt bindings and how you invoke your script ?
There should not be multiple threads at work here. Are you by any chance running things through an IDE and if yes can you try running directly through the command line.