- Posts: 25
- Joined: Mon Jun 24, 2019 4:36 pm
- Real Name: Brendon Rathbone
I have a small script to set a still label. The simple version of the script that works is here:
If I run this in a resolve gui I am unable to succesfully set the label but running that code by itself will set the label(preventing me from getting user input).
This is code that will not work. I am also running this on Resolve 17.4.2 on Windows 10.
Does anyone have any ideas on why it wouldn't work when spawning a gui window?
- Code: Select all
label="test"
projectManager=resolve.GetProjectManager()
project=projectManager.GetCurrentProject()
gallery=project.GetGallery()
current_album=gallery.GetCurrentStillAlbum()
still=timeline.GrabStill()
current_album.SetLabel(still , label)
If I run this in a resolve gui I am unable to succesfully set the label but running that code by itself will set the label(preventing me from getting user input).
This is code that will not work. I am also running this on Resolve 17.4.2 on Windows 10.
Does anyone have any ideas on why it wouldn't work when spawning a gui window?
import sys
import os
###env initialization
from sys import platform
if platform == "linux" or platform == "linux2":
env = "linux"
Resolve_Loc = r'/opt/resolve/Developer/Scripting/Modules'
print("Linux OS")
elif platform == "darwin":
env = "mac"
Resolve_Loc=r'/Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Scripting/Modules'
print("System is mac OS")
elif platform == "win32":
env = "win"
Resolve_Loc=r'C:\ProgramData\Blackmagic Design\DaVinci Resolve\Support\Developer\Scripting\Modules'
print("Windows OS")
else:
print("error getting system platform")
sys.path.insert(1,Resolve_Loc)
import DaVinciResolveScript as bmd
ScriptDir = os.path.dirname(os.path.realpath(sys.argv[0]))
fu = bmd.scriptapp('Fusion')
resolve = bmd.scriptapp('Resolve')
ui = fu.UIManager
disp = bmd.UIDispatcher(ui)
dlg = disp.AddWindow({"WindowTitle": "StillLabel", "ID": "MyWin", "Geometry": [100, 100, 1000, 250], },
[
ui.VGroup({"Spacing": 2, },
[
# Add your GUI elements here:
ui.Label({"ID": "Timeline", "Text": "Enter Still Label", "Weight": 0.5}),
ui.LineEdit({"ID":"label"}),
ui.Button({"ID":"AddButton", "Text":"Add"}),
ui.Button({"ID":"Close", "Text":"Close"}),
]),
])
itm = dlg.GetItems()
def _func(ev):
disp.ExitLoop()
dlg.On.MyWin.Close = _func
def _func(ev):
disp.ExitLoop()
dlg.On.Close.Clicked = _func
def _func(ev):
#label="My Custom Label"
label=str(itm["label"].Text)
projectManager=resolve.GetProjectManager()
project=projectManager.GetCurrentProject()
gallery=project.GetGallery()
current_album=gallery.GetCurrentStillAlbum()
still=timeline.GrabStill()
current_album.SetLabel(still , label)
dlg.On.AddButton.Clicked = _func
dlg.Show()
disp.RunLoop()
dlg.Hide()