0

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?

Sunderam Dubey
  • 1
  • 11
  • 20
  • 40

1 Answers1

0

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.

  • Hey Matthieu! My enaml version is 0.15.0 and I'm using PyQt5. I just followed the steps from here: https://enaml.readthedocs.io/en/latest/get_started/installation.html . To run it I do python3 main.py from the command line. My OS is Ubuntu 20.04. – Nexttime Apr 25 '22 at 18:06
  • I tested on Windows. I will try to spin up a linux VM. What desktop are you using ? – Matthieu Dartiailh Apr 26 '22 at 20:17
  • Ubuntu 20.04.4 LTS. – Nexttime Apr 27 '22 at 23:59
  • Sorry for the delay. I am running into troubles getting VMs to work on my computer at the moment. I will try to test on a different machine but do not hesitate to ping me if I forget. – Matthieu Dartiailh May 23 '22 at 07:01