Jump to: Board index » General » Fusion

Get slider value from python dict?

Learn about 3D compositing, animation, broadcast design and VFX workflows.
  • Author
  • Message
Offline

Alberto Gutz

  • Posts: 26
  • Joined: Wed Sep 21, 2016 2:28 pm

Get slider value from python dict?

PostThu Apr 19, 2018 12:38 pm

I'm trying get values from a couple of sliders in a basic python script.

Code: Select all
comp.Lock()

dialog = {
  1: {1: 'compw', 'Name': 'Width', 2: 'Slider', 'Default': 7000, 'Integer': 1, 'Min': 1, 'Max':8000},
  2: {1: 'comph', 'Name': 'Heigh', 2: 'Slider', 'Default': 4000, 'Integer': 1, 'Min': 1, 'Max':8000}
}

ret = composition.AskUser('Frame Format', dialog)

print(ret)

comp.Unlock()



How I can to get values from each one subkeys?
I want to store them in a vars outside of dict.

Thanks!
Offline

Alberto Gutz

  • Posts: 26
  • Joined: Wed Sep 21, 2016 2:28 pm

Re: Get slider value from python dict?

PostFri Apr 20, 2018 7:05 am

Well, I found a solution that it works, but it seems a bit ugly method. I've got output from ret and put in new dict, then from this new dict get values from keys (not subkeys now) and assign each one into vars.

Code: Select all
comp.Lock()

dialog = {
   1: {1: 'compw', 'Name': 'Width', 2: 'Slider', 'Default': 7600, 'Integer': 1, 'Min': 1, 'Max': 9000},
   2: {1: 'comph', 'Name': 'Height', 2: 'Slider', 'Default': 4500, 'Integer': 1, 'Min': 1, 'Max': 9000}
}

ret = composition.AskUser('Frame format', dialog)

if ret:
   keys = ['compw', 'comph']
   dict2 = {x:ret[x] for x in keys}

   compw = dict2.get('compw')
   comph = dict2.get('comph')
   
   comp.SetPrefs('Comp.FrameFormat.Width', compw)
   comp.SetPrefs('Comp.FrameFormat.Height', comph)
else:
   print("Cancelled by user")

comp.Unlock()

Return to Fusion

Who is online

Users browsing this forum: No registered users and 33 guests