Old 08-28-2014, 09:27 PM   #1
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default python issue

w7/64 pro, reaper4.721/64, sws/64 2.4.0 build 10, python 3.1.4/64

edit:
just realized one difference in systems. the laptop is w7 home premium, desktop is pro.
/edit

reaper detects the python dll in the windows32 folder (which seems a little odd for a 64 bit system). when i run the script test from the actions window the browser shows that python is present.

when i try to run the script below, nothing happens. all that should happen is that a point should be placed on a selected envelope. i notice that when i press the 'new/load' button in the actions window nothing happens there either. a file loading windows opens when i do the same on the laptop.

in reaper preferences 'enable reascript/python' IS checked and the paths seem correct. i tried reinstalling python. no luck.

tried running all of these checks in both limited user account (where i normally run) as well as the admin account. same behavior in each. file ownership also seems correct.

trying to run this and a bunch of variants on it, though, i don't think the code is the issue:
Code:
#!/usr/bin/env python

from reaper_python import *
from sws_python import *
import math

def msg(m): RPR_ShowConsoleMsg(str(m) + "\n")

cur_pos = RPR_GetCursorPositionEx(0)

envelope = RPR_GetSelectedEnvelope(0)

if envelope != 0:
    brEnv = BR_EnvAlloc(envelope, True)
    cur_automation_value = BR_EnvValueAtPos(brEnv, cur_pos)
    id = env_point_id_at_cursor = BR_EnvFind(brEnv, cur_pos, 0.0) # Returns envelope point id (zero-based) on success or -1 on failure.

    src_pos = .5               # reasurround x center

    if id > -1:
        BR_EnvSetPoint(brEnv, env_point_id_at_cursor, cur_pos, src_pos, 0, True, 0.0)
    if id == -1:
        RPR_Main_OnCommand(40915, 0) # insert new point
        BR_EnvSetPoint(brEnv, env_point_id_at_cursor, cur_pos, src_pos, 0, True, 0.0)

    BR_EnvFree(brEnv, True)
this just inserts a point into a reasurround envelope for an x coordinate. it seems to work fine on my laptop but not on the main desktop daw. i'm not a coder but i believe the 'import math' line is not needed here. it's used in some of the variant versions of the script. i believe the 'def msg' line is aalso a remnant of a test version. neither seem to affect the running of the script on the laptop.

any pointers as to what might be the issue are much appreciated. just started with this scripting on windows after coming over from running on the mac. mac started having memory issues with a large project. windows has been good but i need to run some python script now and this has just started to present itself as a problem.

thanks for any pointers. have tried to be thorough, here. hope it's not too much.

BabaG

Last edited by babag; 08-28-2014 at 10:46 PM.
babag is offline   Reply With Quote
Old 08-29-2014, 01:39 AM   #2
msmucr
Human being with feelings
 
Join Date: Jun 2009
Location: Praha, Czech republic
Posts: 595
Default

Hi BabaG,

I'm assuming 3.1.4 is typo and your Python version is latest 3.4.1 installed from official Python.org 64bit MSI package.

With that, settings for Reaper at ReaScript pane at preferences should be:
Custom path..: c:\Windows\System32
Force Python to use .dll: python34.dll

If that won't work, verify, if mentioned dll is present in that directory.
C:\Windows\System32 settings is correct for both 32 and 64bit applications.
In reality there are two folders on harddrive - C:\Windows\System32, for 64bit apps and C:\Windows\SysWow64 for 32bit apps and Windows transparently redirect applications to right folder. Mechanism is slightly confusing, but was introduced also for coexistence of two independent libraries with same filenames for each architecture.

And to your code.. there are some unnecessary variables, assignments and unused functions. It could be simplified for instance like this:
Code:
#!/usr/bin/env python

from reaper_python import *
from sws_python import *

new_value = 0.5
tolerance = 0.02 # time tolerance for cursor position in sec.

envelope = RPR_GetSelectedEnvelope(0)

if envelope:
	cur_pos = RPR_GetCursorPositionEx(0)
	
	RPR_Undo_BeginBlock2(0)
	
	brEnv = BR_EnvAlloc(envelope, True)
	id = BR_EnvFind(brEnv, cur_pos, tolerance)
	BR_EnvSetPoint(brEnv, id, cur_pos, new_value, 0, True, 0.0)
	BR_EnvFree(brEnv, True)
	
	RPR_Undo_EndBlock2(0, "Insert value at selected envelope", -1)
I've also added RPR_Undo_BeginBlock2 and RPR_Undo_BeginBlock2.. these two calls basically encloses part of your code, which is "doing" something and tells where starts and ends undo block for Reaper. Plus you can enter some meaningful name for that block, which will be displayed in Reaper's undo history.

UPDATE: Sorry, i actually didn't tried your script thoroughly. Two things. It seems, BR_EnvSetPoint inserts new point automatically, if id is -1 (non-existent previous point), so it isn't necessary care about that. Second, setting of value for existing point at cursor position doesn't seem to be working (eg. always inserting new points) for me unless it is increased delta value at BR_EnvFind. Delta is basically time tolerance for point id search around cursor.. So for instance, when it is set to 0.005, it will find closest point to cursor in range of +/- 5ms.
I modified script accordingly.

Michal

Last edited by msmucr; 08-29-2014 at 06:25 AM. Reason: updated script
msmucr is offline   Reply With Quote
Old 08-29-2014, 11:15 AM   #3
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default

thanks for the reply, msmucr.

it's not a typo on the python version, although, i've since tested further. when i originally installed python, 3.1.4 was the only version i could get reaper to work with on this end so i've stuck with it. this issue, however, has been more vexing and in trying to debug it i've uninstalled and tried 3.2, 3.3, as well as 3.4. 3.4 did not work but the others said they were recognized by reaper. i currently have 3.2 installed and it says it is recognized. same behavior in all versions that reaper recognized.

i saved and tried to run your code but i'm unable to load it. in the actions window, when i press the 'new/load' button, nothing happens. i get no file browser window that would allow me to load the script.

another point regarding all of this is that, when i originally imported my own script, the one posted above, i was only able to do so via the importing of a keymap. i exported a keymap from the laptop, where all of my scripts load and run fine. i was unable to load the scripts directly using 'new/load' and imported the keymap, which also brought in the scripts.

i'm thinking the 'new/load' issue is some kind of tipoff as to what's going on.

anxious to try your test but dead in the water right now.

thanks again,
BabaG
babag is offline   Reply With Quote
Old 08-29-2014, 11:49 AM   #4
msmucr
Human being with feelings
 
Join Date: Jun 2009
Location: Praha, Czech republic
Posts: 595
Default

I'm not sure about all things you've mentioned, but there is something weird..
Lets assume, that 3.4 is working and try to resolve issues with it before swapping wildly swapping Python versions and adding possible other variables to issue.

Steps, i would try to do:

- uninstall every Python
- remove possible remaining directories (eg. C:\Python32, C:\Python33..)
- delete possible remaining registry key HKEY_LOCAL_MACHINE\SOFTWARE\Python
- install latest 3.4.1 from official repository (all installation options to default)
https://www.python.org/ftp/python/3.....4.1.amd64.msi

- start Reaper
- go to Preferences/Plug-ins/ReaScript
- check Enable ReaScript/Python
- manually enter c:\Windows\System32 to "Custom path to dll directory" field
- manually enter python34.dll to "Force Python to use .dll" field
- OK and restart Reaper
- at same configuration pane should be now "Python: python34.dll is installed"

- open Action list
- press Reascript New/load.. button
(in that file requester, there should be file type "Python Script (*.py)".. this is another hint, Python in Reaper is working.. if not, there is just built-in EEL)
- save new file like pythontest.py
- new custom action is added
- press edit button from Action list menu
- copy/paste following lines to opened editor with script
Code:
#!/usr/bin/env python

RPR_APITest()
- run script via button

Finally there should be popup window saying "Test OK"
This should be proof of working Python interpreter inside Reaper. We could probably don't move without it.

Good luck,

Michal
msmucr is offline   Reply With Quote
Old 08-29-2014, 12:15 PM   #5
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default

i'll get to your suggestions next, msmucr. first, though, here's something new. before you'd posted, i had a thought to try 32bit reaper to see if there were any differences in behaviors. there were.

i installed 32bit reaper. i also went back to python 3.1 32bit. i figured there could be an issue with installing both 32 and 64bit versions of same python version(3.2) as they both wanted the same install folder of c:\python32.

i pointed reaper to it and configured reaper further. opening the actions window i find that the 'new/load' button now works. i was able to load your test script. i was also able to load my scripts.

on running your test script, i got the following error:
Code:
Script execution error

Traceback (most recent call last):
  File "msmucr_test.py", line 16, in <module>
    brEnv = BR_EnvAlloc(envelope, True)
NameError: name 'BR_EnvAlloc' is not defined
my scripts also do not execute but i find the reaper behavior differences interesting.

lastly, i might not have been quite as wild as it may seem. i was actually pretty methodical about uninstalling/reinstalling successive versions of python for testing. i've been through this before. it's one of the reasons, the main one, actually, that i advocate getting things wrapped into sws where possible. i seem to have nothing but problems with this add-on stuff like scripting. eel seems like it may be better as it seems more tightly integrated into reaper. can't use some of these things in eel, though, unfortunately.

i have a few things i have to get done now and will come back to follow through with your suggestions.

thanks again,
BabaG
babag is offline   Reply With Quote
Old 08-29-2014, 12:20 PM   #6
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default

i will add that, in re-reading your instructions, that's pretty much how i did everything. the hangup has always been with the actions window and the 'new/load' button, which has not worked, not in 64bit anyway. no browse window opens, even when reaper says it is correctly detecting python. it does work in 32bit reaper.

BabaG
babag is offline   Reply With Quote
Old 08-29-2014, 12:38 PM   #7
msmucr
Human being with feelings
 
Join Date: Jun 2009
Location: Praha, Czech republic
Posts: 595
Default

Quote:
Originally Posted by babag View Post
Code:
Script execution error

Traceback (most recent call last):
  File "msmucr_test.py", line 16, in <module>
    brEnv = BR_EnvAlloc(envelope, True)
NameError: name 'BR_EnvAlloc' is not defined
my scripts also do not execute but i find the reaper behavior differences interesting.
This error means, that there is probably missing latest beta of SWS extensions in your 32bit Reaper installation. These new Breeder's functions were added for last version.

There is possible to install both 32 and 64bit versions of Python to same computer, but you have to pay attention for destination directory during its setup.. Eg. choose something like C:\Python34_64 for installation of former one. This shouldn't be problem for Reaper as i described in my first post, that 32 and 64bit apps are pointed to different C:\Windows\System32 directories where each version places its own python3x.dll file.
There is only one restriction and this is default system Python interpreter..(this is the interpreter which runs *.py files from explorer and command line). It could be only one in system.. there is entry in Python setup options, where you can choose, if version, you're installing will be registered as default one.
Generally after you'll proceed initial tests and choose working version, i'll advise to keep that version across all Reaper installations and platforms to avoid possible problems at Python level due to possible differences among interpreter versions.

Maybe i'm just lucky, but i haven't any significant issues, which i wasn't possible to resolve, with Python and ReaScript.

Michal
msmucr is offline   Reply With Quote
Old 08-29-2014, 12:48 PM   #8
msmucr
Human being with feelings
 
Join Date: Jun 2009
Location: Praha, Czech republic
Posts: 595
Default

Quote:
Originally Posted by babag View Post
i will add that, in re-reading your instructions, that's pretty much how i did everything. the hangup has always been with the actions window and the 'new/load' button, which has not worked, not in 64bit anyway. no browse window opens, even when reaper says it is correctly detecting python. it does work in 32bit reaper.

BabaG
Hmm file requester for load isn't working.. Never seen it before. Sorry, it can sound silly, but isn't there some issue with multimonitor setup and window popping outside of screen area. After requester invocation, can you then normally click to Reaper main window, menus? In case of that offscreen Window, this will be symptom.

Anyway.. if you move nowhere with that strange issue, i would try reset Reaper to factory defaults - eg. start menu shortcut "REAPER (x64) (reset configuration to factory defaults)".

Michal

P.S.: instructions how to restore offscreen window/dialog for most Windows applications:
You are stucked at place with hidden window.. and assuming window is in focus
press alt+space
press m (shortcut for move)
press any keyboard cursor key (eg. right arrow)
move your mouse around.. you should have evil window attached on your mouse cursor and you can place it wherever you want

remark.. This is working only for English version of Windows as m shortcut could be different for other languages

Last edited by msmucr; 08-29-2014 at 12:54 PM. Reason: Added instruction for window move
msmucr is offline   Reply With Quote
Old 08-29-2014, 01:12 PM   #9
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default

good thought about the off-screen window but, no, other menus open normally. seems nothing happens when 'new/load' pressed. i think there was a post long ago by tod about something like this but i think he abandoned the issue. i'll search for it later.

edit>
http://forum.cockos.com/showthread.p...ghlight=python

seems he had a typo or something. i don't. paths are all correct here.
/edit>

Last edited by babag; 08-29-2014 at 01:25 PM.
babag is offline   Reply With Quote
Old 08-29-2014, 01:33 PM   #10
msmucr
Human being with feelings
 
Join Date: Jun 2009
Location: Praha, Czech republic
Posts: 595
Default

I don't know, but main problem i can see in linked thread is incorrect path to dll.
It should be C:\Windows\System32. File in C:\Python3x\DLLs is not right one. Correct dll from windows directory is actually whole Python interpreter and has size around 3.8MB.

I would reset Reaper settings ;-)

Michal
msmucr is offline   Reply With Quote
Old 08-29-2014, 06:49 PM   #11
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default

Quote:
Anyway.. if you move nowhere with that strange issue, i would try reset Reaper to factory defaults - eg. start menu shortcut "REAPER (x64) (reset configuration to factory defaults)".
do you know how to get at this with a portable install?

i did notice the wrong path in Tod's post. tried it just out of desperation to no avail. getting to the end of my rope here. i may post this in another forum, tips, as a more general reaper question. i'm thinking, after all the various versions of python all doing the same thing, that the bad button is symptomatic of something more reaper/windows related than python related. wonder if anyone else has seen this.

thinking maybe it could have to do with anti-malware in windows? that would seem like something that could shut down script execution. wonder where to look for that. firing up the daw now to start in again.

BabaG
babag is offline   Reply With Quote
Old 08-29-2014, 07:10 PM   #12
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default

but wait! there's more! these scripts DO run. will post in multi parts as the second i think gets a little long for the forum. it's two scripts, the first which copies the attributes of an item, and a second which opens a tcl/tk gui to allow the user to select which parameters to paste into multple selected items.

copy item attributes:
Code:
#!/usr/bin/env python3

# Save first selected item's volume only if at least one item is selected
if RPR_CountSelectedMediaItems(0) != 0:
    activeTake =        RPR_GetActiveTake(RPR_GetSelectedMediaItem(0, 0))
    takeVol =           RPR_GetMediaItemTakeInfo_Value(activeTake, "D_VOL")
    takePan =           RPR_GetMediaItemTakeInfo_Value(activeTake, "D_PAN")
    takePlayrate =      RPR_GetMediaItemTakeInfo_Value(activeTake, "D_PLAYRATE")
    takePitch =         RPR_GetMediaItemTakeInfo_Value(activeTake, "D_PITCH")
    takeChannelmode =   RPR_GetMediaItemTakeInfo_Value(activeTake, "I_CHANMODE")
    envelopePointer =   RPR_GetTakeEnvelopeByName(activeTake, "Volume")
    takeVolEnv =        RPR_GetSetEnvelopeState(envelopePointer, "", 1024*1024*4)
    envelopePointer =   RPR_GetTakeEnvelopeByName(activeTake, "Pan")
    takePanEnv =        RPR_GetSetEnvelopeState(envelopePointer, "", 1024*1024*4)
    envelopePointer =   RPR_GetTakeEnvelopeByName(activeTake, "Mute")
    takeMuteEnv =       RPR_GetSetEnvelopeState(envelopePointer, "", 1024*1024*4)
    envelopePointer =   RPR_GetTakeEnvelopeByName(activeTake, "Pitch")
    takePitchEnv =      RPR_GetSetEnvelopeState(envelopePointer, "", 1024*1024*4)
    itemVol =           RPR_GetMediaItemInfo_Value(RPR_GetSelectedMediaItem(0, 0), "D_VOL")
    itemMute =          RPR_GetMediaItemInfo_Value(RPR_GetSelectedMediaItem(0, 0), "B_MUTE")
    itemLock =          RPR_GetMediaItemInfo_Value(RPR_GetSelectedMediaItem(0, 0), "C_LOCK")
    itemLoopsrc =       RPR_GetMediaItemInfo_Value(RPR_GetSelectedMediaItem(0, 0), "B_LOOPSRC")
    itemFadeinshape =   RPR_GetMediaItemInfo_Value(RPR_GetSelectedMediaItem(0, 0), "C_FADEINSHAPE")
    itemFadeoutshape =  RPR_GetMediaItemInfo_Value(RPR_GetSelectedMediaItem(0, 0), "C_FADEOUTSHAPE")
    RPR_SetExtState("babaG", "takeVol", takeVol, 0)
    RPR_SetExtState("babaG", "takePan", takePan, 0)
    RPR_SetExtState("babaG", "takePlayrate", takePlayrate, 0)
    RPR_SetExtState("babaG", "takePitch", takePitch, 0)
    RPR_SetExtState("babaG", "takeChannelmode", takeChannelmode, 0)
    RPR_SetExtState("babaG", "takeVolEnvelope", takeVolEnv[2], 0)
    RPR_SetExtState("babaG", "takePanEnvelope", takePanEnv[2], 0)
    RPR_SetExtState("babaG", "takeMuteEnvelope", takeMuteEnv[2], 0)
    RPR_SetExtState("babaG", "takePitchEnvelope", takePitchEnv[2], 0)
    RPR_SetExtState("babaG", "itemVol", itemVol, 0)
    RPR_SetExtState("babaG", "itemMute", itemMute, 0)
    RPR_SetExtState("babaG", "itemLock", itemLock, 0)
    RPR_SetExtState("babaG", "itemLoopsrc", itemLoopsrc, 0)
    RPR_SetExtState("babaG", "itemFadeinshape", itemFadeinshape, 0)
    RPR_SetExtState("babaG", "itemFadeoutshape", itemFadeoutshape, 0)
    RPR_Main_OnCommand(54069, 0)                                        # Copy FX Chain

# If no items are selected inform the user
else:
    RPR_ShowMessageBox("Please select an item.", "No item selected", 0)
paste attributes (part 1):
Code:
#!/usr/bin/env python3


import sys
import tkinter
from tkinter import *
sys.argv=["Main"]


## Main function executed when OK is pressed ##
###############################################
def Foo ():

	# Since copy script copies everything it is enough to test for one variable to see if copy script was used
	if not RPR_HasExtState("babaG", "takeVol"):
		RPR_ShowMessageBox("Nothing to paste", "Error", 0)
		return

	# Get saved values
	takeVol = 		RPR_GetExtState("babaG", "takeVol")
	takePan = 		RPR_GetExtState("babaG", "takePan")
	takePlayrate = 		RPR_GetExtState("babaG", "takePlayrate")
	takePitch = 		RPR_GetExtState("babaG", "takePitch")
	takeChannelmode = 	RPR_GetExtState("babaG", "takeChannelmode")
	takeVolEnv = 		RPR_GetExtState("babaG", "takeVolEnvelope")
	takePanEnv = 		RPR_GetExtState("babaG", "takePanEnvelope")
	takeMuteEnv = 		RPR_GetExtState("babaG", "takeMuteEnvelope")
	takePitchEnv = 		RPR_GetExtState("babaG", "takePitchEnvelope")
	itemVol = 		RPR_GetExtState("babaG", "itemVol")
	itemMute = 		RPR_GetExtState("babaG", "itemMute")
	itemLock = 		RPR_GetExtState("babaG", "itemLock")
	itemLoopsrc = 		RPR_GetExtState("babaG", "itemLoopsrc")
	itemFadeinshape = 	RPR_GetExtState("babaG", "itemFadeinshape")
	itemFadeoutshape = 	RPR_GetExtState("babaG", "itemFadeoutshape")

	# Show take envelopes if pasting them
	if var6.get():
		RPR_Main_OnCommand(RPR_NamedCommandLookup("_S&M_TAKEENV1"), 0)
	if var7.get():
		RPR_Main_OnCommand(RPR_NamedCommandLookup("_S&M_TAKEENV2"), 0)
	if var8.get():
		RPR_Main_OnCommand(RPR_NamedCommandLookup("_S&M_TAKEENV3"), 0)
	if var9.get():
		RPR_Main_OnCommand(RPR_NamedCommandLookup("_S&M_TAKEENV10"), 0)

	# Loop through selected items and paste values
	RPR_Undo_BeginBlock2(0)
	for i in range(RPR_CountSelectedMediaItems(0)):
	
		# Get item currently in the loop and it's active take
		item = RPR_GetSelectedMediaItem(0, i)
		take = RPR_GetActiveTake(item)
	
		# Take volume
		if var1.get():	
			RPR_SetMediaItemTakeInfo_Value(take, "D_VOL", float(takeVol))
	
		# Take Pan
		if var2.get():
			RPR_SetMediaItemTakeInfo_Value(take, "D_PAN", float(takePan))

		# Take Playrate
		if var3.get():	
			RPR_SetMediaItemTakeInfo_Value(take, "D_PLAYRATE", float(takePlayrate))
	
		# Take Pitch
		if var4.get():
			RPR_SetMediaItemTakeInfo_Value(take, "D_PITCH", float(takePitch))

		# Take Channelmode
		if var5.get():	
			RPR_SetMediaItemTakeInfo_Value(take, "I_CHANMODE", float(takeChannelmode))
	
		# Take Volume Envelope
		if var6.get():
			envelopePointer = RPR_GetTakeEnvelopeByName(take, "Volume")
			RPR_GetSetEnvelopeState(envelopePointer, takeVolEnv, 1024*1024*4)

		# Take Pan Envelope
		if var7.get():
			envelopePointer = RPR_GetTakeEnvelopeByName(take, "Pan")
			RPR_GetSetEnvelopeState(envelopePointer, takePanEnv, 1024*1024*4)

		# Take Mute Envelope
		if var8.get():
			envelopePointer = RPR_GetTakeEnvelopeByName(take, "Mute")
			RPR_GetSetEnvelopeState(envelopePointer, takeMuteEnv, 1024*1024*4)

		# Take Pitch Envelope
		if var9.get():
			envelopePointer = RPR_GetTakeEnvelopeByName(take, "Pitch")
			RPR_GetSetEnvelopeState(envelopePointer, takePitchEnv, 1024*1024*4)

		# Item Volume
		if var10.get():
			RPR_SetMediaItemInfo_Value(item, "D_VOL", float(itemVol))

		# Item Mute
		if var11.get():	
			RPR_SetMediaItemInfo_Value(item, "B_MUTE", float(itemMute))
	
		# Item Lock
		if var12.get():
			RPR_SetMediaItemInfo_Value(item, "C_LOCK", float(itemLock))

		# Item Loop Source
		if var13.get():	
			RPR_SetMediaItemInfo_Value(item, "B_LOOPSRC", float(itemLoopsrc))
	
		# Item Fade In Shape
		if var14.get():
			RPR_SetMediaItemInfo_Value(item, "C_FADEINSHAPE", float(itemFadeinshape))

		# Item Fade Out Shape
		if var15.get():	
			RPR_SetMediaItemInfo_Value(item, "C_FADEOUTSHAPE", float(itemFadeoutshape))	
		
		# Item Fade Out Shape
		if var16.get():	
			RPR_Main_OnCommand(54071, 0)	# Paste FX Chain to selected items

		RPR_UpdateArrange()

	RPR_Undo_EndBlock2(0,"Item_Paste_Attributes",0)
babag is offline   Reply With Quote
Old 08-29-2014, 07:12 PM   #13
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default

paste attributes (part 2):
Code:
## Dialog functions for closing, saving dialog state (position, size, checkboxes) ##
####################################################################################

def Close ():
	
	# Save dialog state
	GetSetDlgState(1)

	# Kill dialog
	dialog.destroy()

def GetSetDlgState (save):

	# Save state
	if save:

		# Get current position of the dialog
		x = re.findall(r'\d+', dialog.geometry())[2]
		y = re.findall(r'\d+', dialog.geometry())[3]
		
		# Save dialog position
		RPR_SetExtState("babaG", "dlg1_x", x, 0)
		RPR_SetExtState("babaG", "dlg1_y", y, 0)

		# Save checkboxes
		state = list()
		for i in checkboxes:
			state.append(i.get())	
		RPR_SetExtState("babaG", "dlg1_state", state, 0)			

	# Restore state
	else:
		
		# Get current dimensions
		width = dialog.minsize()[0]
		height = dialog.minsize()[1]
		
		# Restore dialog position (if not found, position in the middle of the screen)
		if RPR_HasExtState("babaG", "dlg1_x"):
			x = RPR_GetExtState("babaG", "dlg1_x")
			y = RPR_GetExtState("babaG", "dlg1_y")
			dialog.geometry('%dx%d+%d+%d' % (width, height, int(x), int(y)))
		else:	
			w = dialog.winfo_screenwidth()		# Get screen width and height
			h = dialog.winfo_screenheight()		
			x = (w/2) - (width/2)			# Calculate center position
			y = (h/2) - (height/2)
			dialog.geometry('%dx%d+%d+%d' % (width, height, x, y))

		# Restore checkboxes
		if RPR_HasExtState("babaG", "dlg1_state"):
			state = eval(RPR_GetExtState("babaG", "dlg1_state"))
			for i in checkboxes:
				try:
					i.set(state[checkboxes.index(i)]) 
				except IndexError:		# in case new checkboxes are added
					pass


## Create dialog and set it's properties ##
###########################################

dialog = tkinter.Tk()					# Create root widget (main dialog) which will contain additional widgets
dialog.title('Item/Take Paste Attributes')		# Name it
dialog.minsize(380, 310)				# Set dialog size
dialog.resizable(0, 0)					# Disable resizing
dialog.attributes('-topmost', 1)			# Make window topmost (so it stays visible even when focus is lost)
dialog.protocol("WM_DELETE_WINDOW", Close)		# Set function which gets executed on dialog close
checkboxes = []						# Holds all checkboxes so their state can be saved/restored

# Variables that hold checkboxes values - store them in a list
var1  = IntVar();  checkboxes.append(var1);
var2  = IntVar();  checkboxes.append(var2);
var3  = IntVar();  checkboxes.append(var3);
var4  = IntVar();  checkboxes.append(var4);
var5  = IntVar();  checkboxes.append(var5);
var6  = IntVar();  checkboxes.append(var6);
var7  = IntVar();  checkboxes.append(var7);
var8  = IntVar();  checkboxes.append(var8);
var9  = IntVar();  checkboxes.append(var9);
var10 = IntVar();  checkboxes.append(var10);
var11 = IntVar();  checkboxes.append(var11);
var12 = IntVar();  checkboxes.append(var12);
var13 = IntVar();  checkboxes.append(var13);
var14 = IntVar();  checkboxes.append(var14);
var15 = IntVar();  checkboxes.append(var15);
var16 = IntVar();  checkboxes.append(var16);

# Add checkboxes
Checkbutton(dialog, text="Take Volume", variable=var1).grid(row=1, sticky=W)
Checkbutton(dialog, text="Take Pan", variable=var2).grid(row=2, sticky=W)
Checkbutton(dialog, text="Take Playrate", variable=var3).grid(row=3, sticky=W)
Checkbutton(dialog, text="Take Pitch", variable=var4).grid(row=4, sticky=W)
Checkbutton(dialog, text="Take Channel Mode", variable=var5).grid(row=5, sticky=W)
Checkbutton(dialog, text="Take Volume Envelope", variable=var6).grid(row=6, sticky=W)
Checkbutton(dialog, text="Take Pan Envelope", variable=var7).grid(row=7, sticky=W)
Checkbutton(dialog, text="Take Mute Envelope", variable=var8).grid(row=8, sticky=W)
Checkbutton(dialog, text="Take Pitch Envelope", variable=var9).grid(row=9, sticky=W)
Checkbutton(dialog, text="Item Volume", variable=var10).grid(column=2, row=1, sticky=W)
Checkbutton(dialog, text="Item Mute", variable=var11).grid(column=2, row=2, sticky=W)
Checkbutton(dialog, text="Item Lock", variable=var12).grid(column=2, row=3, sticky=W)
Checkbutton(dialog, text="Item Loop Source", variable=var13).grid(column=2, row=4, sticky=W)
Checkbutton(dialog, text="Item Fade In Shape", variable=var14).grid(column=2, row=5, sticky=W)
Checkbutton(dialog, text="Item Fade Out Shape", variable=var15).grid(column=2, row=6, sticky=W)
Checkbutton(dialog, text="Item FX Chain", variable=var16).grid(column=2, row=7, sticky=W)

# Add buttons
button1 = Button(dialog, text="OK", command=Foo) 		# Run Foo() when pressing OK
button2 = Button(dialog, text="Cancel", command=Close)		# Run Close() when pressing Cancel
button1.place(height=25, width=70, x=75, y=270)
button2.place(height=25, width=70, x=235, y=270)

# Load dialog state (position and checkboxes)
GetSetDlgState(0)

# Start and run dialog loop
dialog.mainloop()
no idea why this would run and the others don't. maybe they never loaded correctly?

i notice that the very first line in these says 'python3' as opposed to 'python' but changing that did nothing to solve the issue.

BabaG
babag is offline   Reply With Quote
Old 08-29-2014, 08:06 PM   #14
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default

Quote:
This error means, that there is probably missing latest beta of SWS extensions in your 32bit Reaper installation. These new Breeder's functions were added for last version.
latest, build 10, sws is installed but throws the above described error.
babag is offline   Reply With Quote
Old 08-30-2014, 01:31 AM   #15
msmucr
Human being with feelings
 
Join Date: Jun 2009
Location: Praha, Czech republic
Posts: 595
Default

Quote:
Originally Posted by babag View Post
do you know how to get at this with a portable install?
Reset shortcut runs:
"reaper.exe -resetconfig"
But i've never tried it with portable version.


Quote:
Originally Posted by babag View Post
latest, build 10, sws is installed but throws the above described error.
It has to be something with version, error says, that there is no function BR_* from sws_python module.
BR_* functions were added to last beta versions. If there will be problem with completely missing SWS extensions, exception would be
something like "ImportError: No module named 'sws_python'".

To manually check for SWS extension look at REAPER plugins directory
(eg. C:\Program Files (x86)\REAPER\Plugins in case of normal install)
necessary files:
reaper_sws.dll
sws_python.py

if you right click at dll file, and hit properties and details tab, it should tell you its version.. so for latest one it is 2.4.0.10

Quote:
Originally Posted by babag View Post
no idea why this would run and the others don't. maybe they never loaded correctly?
i notice that the very first line in these says 'python3' as opposed to 'python' but changing that did nothing to solve the issue.
First line is called shebang and says which Python interpreter should be called for execution of script. It is bit redundant for Reaper as there is only one interpreter at time and every file with .py extensions is executed with it. I generally add this, because i'm used to it from general python programming and some source editors checks that for syntax highlighting. But here it shouldn't matter, you can easily omit whole line and result will be the same.

Quote:
Originally Posted by babag View Post
i did notice the wrong path in Tod's post. tried it just out of desperation to no avail. getting to the end of my rope here. i may post this in another forum, tips, as a more general reaper question. i'm thinking, after all the various versions of python all doing the same thing, that the bad button is symptomatic of something more reaper/windows related than python related. wonder if anyone else has seen this.

thinking maybe it could have to do with anti-malware in windows? that would seem like something that could shut down script execution. wonder where to look for that. firing up the daw now to start in again.
Frankly, by all tests you've done, it progressively became super convoluted kind of snowball issue to me.
I'm not sure, which version has which problem.. I thought, that main issue is no action after invocation of New/Load button. For that i would try either reset Reaper or at case with portable version, which can be completely backed up and allows clean installation of standard 64bit Reaper to Windows without any harm to your setup. This is alternative to reset.

Then i assume you've got somewhat mixed results with different scripts. If New/Load button isn't working, I assumed, you've probably imported it from another Reaper installation.
Generally running Python all scripts, you've posted here, should be pretty consistent, i'm not commenting scripts itself, but there is no latest language construction or functions, which will work only on specific Python version. Only requirements are working interpreter and right version of SWS module as i wrote earlier.
Only tricky part is Tkinter GUI toolkit, which sometimes needs few hacks to work.

If you manage to run following simple script, you will be able to use all of your required features (eg. Reaper API functions, latest SWS and Tkinter.).

Code:
#!/usr/bin/env python

from sws_python import *
import sys
import tkinter

#following line is necessary for initialisation of Tkinter
sys.argv=["Main"]

RPR_APITest()
RPR_MB("Test SWS", str(BR_PositionAtMouseCursor(True)), 0)

dialog = tkinter.Tk()
dialog.title('Test of Tkinter')
dialog.mainloop()
That is probably all, what came to my mind :-)

Michal
msmucr is offline   Reply With Quote
Old 08-30-2014, 11:16 AM   #16
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default

Michal,

interesting development:

after running your instruction to reset to defaults, the 'new/load' button regained its functionality. the newer py scripts do import but don't run. i noticed that reaper, in spite of its ability to have parallel installs, seems a bit confused about some things.

i ran the RPR_APITest() you suggested but when i saved it, it was crossing the save location with one of the other installs. there were other examples like this. i'm thinking i should get rid of ALL reaper installs at this point and make a fresh one, just one, in order to try to make things as simple for reaper as possible. i think sws is maybe crossed up with one of the other installs.

for the standard installs that are on my system, i assume it's sufficient to run the w7 'control panel' to uninstall. do you know how to uninstall a portable install? is it as simple as deleting the folder?

lastly, you made some suggestions earlier regarding the registry. it would seem to me, at this point, that that might be something worth doing now to rid the system of all things reaper before i reinstall. any instructions on how to go about this? think it's necessary?

thanks for all your interest and help. this looks promising.
BabaG
babag is offline   Reply With Quote
Old 08-30-2014, 11:40 AM   #17
msmucr
Human being with feelings
 
Join Date: Jun 2009
Location: Praha, Czech republic
Posts: 595
Default

Hi BabaG,

good to hear about some progress.
- yes for portable install, everything should be inside Reaper folder.
- if you are going to install everything from scratch.. i would do only one preferred version of Reaper (eg. 64bit) and use normal installation instead of portable one, if you really don't require it. Also i would try to install latest 3.4.1 version of Python.
- regarding cleaning of registry entries.. I don't usually use any auto cleaner, but always trying to find particular culprit or leftover.
After normal uninstallation of programs open start menu and type "regedit" to search field. Run application.
You'll see tree structure at left side of application. Navigate to following locations:

HKEY_LOCAL_MACHINE\SOFTWARE\REAPER
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\REAPER
HKEY_LOCAL_MACHINE\SOFTWARE\Python
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python

And via right-click context menu delete whole key (folder icon). Maybe, you won't find it, that is fine and uninstaller correctly removed it.
Also from previous installation there can be some leftovers in Reaper's resource folder.. so open Windows explorer window, paste this %appdata%\REAPER to address field and press enter. Here you can wipe possible previous user settings, scripts etc.
But be sure, that you've backed up previous scripts, keysets, actions.. elsewhere before uninstallation.

Finally for normal installations i put all scripts to default %appdata%\REAPER\Scripts directory.
And as i wrote in my previous post.. i'm not sure about all of your previous scripts and possible other variables, but if you proceed through running of this combined test of Python, SWS and Tkinter.. you will be probably fine with everything.

Michal
msmucr is offline   Reply With Quote
Old 08-30-2014, 11:45 AM   #18
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default

thanks, Michal. i guess i know what i'm doing today. this has me hopeful.

BabaG
babag is offline   Reply With Quote
Old 08-30-2014, 12:21 PM   #19
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default

EUREKA! first test success!

python 3.2.5 was the most recent version this system would recognize but the apitest script imported/ran correctly, then my first test of placing a point on an envelope also worked. now i have a LOT of reconfiguring to do.

thanks so much for all your help! hopefully we won't hear from me for a while now ;-)

thanks again,
BabaG
babag is offline   Reply With Quote
Old 08-30-2014, 12:49 PM   #20
msmucr
Human being with feelings
 
Join Date: Jun 2009
Location: Praha, Czech republic
Posts: 595
Default

Quote:
Originally Posted by babag View Post
EUREKA! first test success!

python 3.2.5 was the most recent version this system would recognize but the apitest script imported/ran correctly, then my first test of placing a point on an envelope also worked. now i have a LOT of reconfiguring to do.

thanks so much for all your help! hopefully we won't hear from me for a while now ;-)

thanks again,
BabaG
You're welcome and i'm glad you sorted out basic issues.
What do you you mean by system would recognize.. you mean Reaper doesn't say python34.dll is installed after you've filled that two fields?.. I'm just curious about it and it doesn't mean, you had to do further tests, if 3.2.5 is working for you. I recently tried to install 3.4.1 to two different computers with Reaper and it was flawless (eg. attached screenshot), so that is, why i'm asking.

Just last hint.. as you proceed with your setup, you can efficiently use of Reaper's import/export configuration function.. It is right on top of configuration menu. That way you can always return to your working configuration without resorting to factory default reset.

And of course good luck with your movie.

Michal
Attached Images
File Type: png python34.png (53.0 KB, 272 views)
msmucr is offline   Reply With Quote
Old 08-30-2014, 01:38 PM   #21
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default

yes. reaper says no compatible python found until i got down to 3.2.5. what your posted image shows did not work here.

i used 'export configuration' to back up and copy the actions and scripts i made to move them from the laptop to the main daw. it seems that may actually be the problem.

i've been methodically doing installs and uninstalls of this reaper setup on the main daw, with each successive install selecting a different checkbox from the 'import configuration' window.

some import without issue, while others cause the 'new/load' and python issues. the first checkbox for configuration caused it. also reascripts checkbox as well as menus and keybindings. looks like i'm going to lose and have to rebuild by hand a bunch of these. i may try exporting only those from the laptop but, if i have to rebuild by hand, so be it. i'm just happy that it looks like i may actually be able to do some work again!

thanks,
BabaG
babag is offline   Reply With Quote
Old 08-30-2014, 01:56 PM   #22
msmucr
Human being with feelings
 
Join Date: Jun 2009
Location: Praha, Czech republic
Posts: 595
Default

Quote:
Originally Posted by babag View Post
yes. reaper says no compatible python found until i got down to 3.2.5. what your posted image shows did not work here.
I see.


Quote:
Originally Posted by babag View Post
i used 'export configuration' to back up and copy the actions and scripts i made to move them from the laptop to the main daw. it seems that may actually be the problem.

i've been methodically doing installs and uninstalls of this reaper setup on the main daw, with each successive install selecting a different checkbox from the 'import configuration' window.

some import without issue, while others cause the 'new/load' and python issues. the first checkbox for configuration caused it. also reascripts checkbox as well as menus and keybindings. looks like i'm going to lose and have to rebuild by hand a bunch of these. i may try exporting only those from the laptop but, if i have to rebuild by hand, so be it. i'm just happy that it looks like i may actually be able to do some work again!
BabaG
Hmm, it looks like there is issue with main Reaper configuration file according to your description.
First checkbox basically means "everything". If you are concerned only about custom actions, menus and keymappings, it is possible to export only menus and keybindings from your notebook. But as you wrote, it is also causing that 'new/load', which is very stange.. Hmm, maybe some action is incorrectly interpreted from notebook configuration and because it is also mapped to key and have its entry in menu... it is causing some troubles.

Anyway, thanks for further info and good luck!

Michal
msmucr 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 03:10 PM.


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