On Tue, Aug 25, 2015 at 5:26 AM, <[email protected]> wrote:
> May be this is a stupid question:
>
There are no stupid questions, only stupid answers :-)
> I'm trying to import a large Qt application into Leo. For testing, I
> created a script in a single node with the headline '
>
> @clean QtTest.pyw)' and the following body:
>
> @language python
> @tabwidth -4
>
>
> import sys
>
> from PyQt5.QtCore import QObject
> from PyQt5.QtWidgets import QApplication, QWidget
>
> class Application(QWidget):
>
> def __init__(self):
>
> QObject.__init__(self)
> self.setGeometry(100, 100, 400, 300)
> self.setWindowTitle('QtTest')
>
> if __name__ == '__main__':
> app = QApplication([])
> form = Application()
> form.show()
> sys.exit(app.exec_())
>
> From the command line, this script runs without problems (using 'python
> QtTest.pyw').
> But if I try to execute the script in the node (using Ctrl-B), Leo
> disappears, the Qt window is opened and immediately closed. I want Leo stay
> visibly in the background and the Qt window in the foreground until it is
> closed explicitly.
>
> What do I miss?
>
Leo is already a QApplication, so you don't want another copy.
Whenever something weird happens, be sure you run Leo from a console
window. Here is what I see (and all I see) when I run your program:
QCoreApplication::exec: The event loop is already running
If you want to run an application from within Leo, use g.app.gui.qtApp
instead of creating another app. Depending on how complex the app is, this
may take some doing.
The other alternative is to run the original code in an external process,
completely separate from Leo. Here is one way:
path = r'c:\users\edreamleo\test\QtTest.py'
assert g.os_path_exists(path)
g.executeFile(path)
HTH.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.