Jump to content

button widgets makes another version of my PIO


Recommended Posts

started working with widgets this week... kinda frustrating NGL. lol

 

i've overcome most of the issues I'm having but the main one is i have some button widgets that open a color picker to change the color of some items in my PIO. that works great but whenever I'm done picking a color it spawns another version of my PIO at (0,0) but its not a PIO, its just all the objects the PIO normally creates but not all individual pieces. I'm sure its something stupid in my code... the thing thats causing it is when i run the "mainloop()" after it processes the button but i don't know why its causing the issue... 

 

 

 

SOLUTION:

when using event based plugins you should only be running your main code during ResetEvents. Don't trigger your main loop after your button login is done, instead run vs.ResetObject() and that will act as if something was changed in the OIP. thanks @JBenghiat

 

def start():
  ##### Correct use ######
  if theEvent == kObjOnObjectUIButtonHit:
          if theButton == buttonID_1:
              ### Code for when your button is pressed....
              vs.ResetObject(PIO_handle) ### <----- Good ###

  ##### incorrect use ######
  if theEvent == kObjOnObjectUIButtonHit:
          if theButton == buttonID_1:
              ### Code for when your button is pressed....
              main() ### <----- bad ###
            
def main():
  ###main loop for building your stuff
  return None

 

 

Edited by Jayme McColgan
found a solution
Link to comment

Take a look in the archives for examples of event enabled plug-ing. You need to take care that each event type only runs what you need. 
 

Assuming mainloop() draws your geometry, you should only call it during the reset event. Adding widgets and setting object properties should only happen during the init event. 
 

If you want the PIO to redraw based on the button press, call ResetObject(). 
 

Also note, you should catch pressing the button for all selected objects by using ForEachObject to run SetRField and ResetObject. 

  • Like 1
Link to comment

yes! vs.ResetObject() was exactly what i was looking for! that fixed my issue. 

 

events and widgets are very cool and I'm already finding some cool ways to use them. if anything just being able to have a full width separator for the different sections really helps my OCD. lol 

 

because you can't really use vs.EnableParameter() while using widgets, my next thing to figure out is how to insert and change drop down options based on other fields in the OIP

Link to comment
20 minutes ago, Jayme McColgan said:

because you can't really use vs.EnableParameter() while using widgets, my next thing to figure out is how to insert and change drop down options based on other fields in the OIP

You can do this during the widget prep event. Look at the vsoWidget calls.

Link to comment

ok so ive moved onto making popups with widgets and i have some questions...

 

I'm using vs.vsoInsertWidget() and vs.vsoWidgetPopupAdd() to make some popups that hidden by default. they then appear and disappear based on the value of a standard Parameter popup...  

 

the questions i have are:

1. how do i get the current value of the WidgetPopups?

2. how do i set a default value for the WidgetPopups? using vs.SetRField() doesn't seem to work (im assuming because its a widget)

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...