Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 10-01-2018, 08:33 PM   #1
meta
Human being with feelings
 
Join Date: Sep 2018
Posts: 33
Default PyQt4 script runs once successfully then wont again until Reaper is restarted.

I was trying to get a PyQt4 script to run in Reaper and it worked! But only the first time. Every time after that I was greeted with this error:
Code:
from PyQt4 import QtGui
RuntimeError: the sip module has already registered a module called PyQt4.QtCore
The issue resets every time Reaper is restarted. Runs once, then keeps failing.
Anyone got any idea what this means or how to solve it?

Here's the test script:
Code:
import sys
from PyQt4 import QtGui

def main():
    sys.argv = []

    app = QtGui.QApplication(sys.argv)
    widget = QtGui.QWidget()
    layout = QtGui.QGridLayout()

    buttons = {}

    for i in range(16):
        for j in range(16):
            # keep a reference to the buttons
            buttons[i, j] = QtGui.QPushButton('row %d, col %d' % (i, j))
            # add to the layout
            layout.addWidget(buttons[(i, j)], i, j)

    widget.setLayout(layout)
    widget.show()
    app.exit(app.exec_())

if __name__ == '__main__':
    RPR_defer('main()')
PyQt4 wheel found here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4

Last edited by meta; 10-01-2018 at 08:47 PM.
meta is offline   Reply With Quote
Old 10-02-2018, 02:49 AM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,900
Default

All I know is that it seems that running GUI Python framework from REAPER like Tkinter isn't stable at all: the action list may become unclickable, and some other artifacts like this.


https://forum.cockos.com/showthread.php?p=1888983



It is better to use the beyond.reaper bridge and run the script outside REAPER. Though, it is less performant if you have a lot of REAPER API function calls.


https://github.com/ReaTeam/ReaScript...nd%20reaper.py

Just curious: can you show us a screenshot of your GUI ?

FOr simple GUi script, you may prefer use Lua and GFX function, with Lokasenna template GUI for eg.
X-Raym is offline   Reply With Quote
Old 10-04-2018, 04:53 AM   #3
meta
Human being with feelings
 
Join Date: Sep 2018
Posts: 33
Default

Quote:
Originally Posted by X-Raym View Post
All I know is that it seems that running GUI Python framework from REAPER like Tkinter isn't stable at all: the action list may become unclickable, and some other artifacts like this.


https://forum.cockos.com/showthread.php?p=1888983



It is better to use the beyond.reaper bridge and run the script outside REAPER. Though, it is less performant if you have a lot of REAPER API function calls.


https://github.com/ReaTeam/ReaScript...nd%20reaper.py

Just curious: can you show us a screenshot of your GUI ?

FOr simple GUi script, you may prefer use Lua and GFX function, with Lokasenna template GUI for eg.
That's a shame. I thought Tkinter was at least safe, but it makes sense that it would block the event loop now thinking about it.

I'm aware of both beyond.reaper and Lokasenna's GUI library. For my purposes I need to draw and control two separate windows, which, as far as I'm aware, the current Lua GUI functionality doesn't seem to allow in one script.

Yesterday I wrote a more user friendly (and possibly faster, havent run any tests yet) alternative to beyond.reaper which is a simple TCP server running inside Reaper. In addition to this, a method that goes through reaper_python and sws_python at import and replaces all API functions with remote calls to this server and returns its response. It works pretty well so far, unless there are multiple instances of Reaper. When there are 3-4 Reaper instances at the same time this occurs: https://forum.cockos.com/showthread.php?p=2041861

I will release it after some more testing and when this bug is solved.
meta is offline   Reply With Quote
Old 10-04-2018, 05:19 AM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,900
Default

Quote:
Yesterday I wrote a more user friendly
Intersting, beyond reaper is cool but quite complex to set up, so we'll keep on eye on what you have to propose.
X-Raym is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 06:30 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.