1
$\begingroup$

I have a basic panel and an enum property and I want to change some of the things shown on the panel depending on what is selected in the enum. I tried what was logical and this is what I did:

if self.icons == 'Brightness':
    row.prop(scene.ignit_panel, "brightness_icon")
elif self.icons == 'Backlit Keys':
    row.prop(scene.ignit_panel, "backlit_keys_icon")
elif self.icons == 'Volume':
    row.prop(scene.ignit_panel, "volume_icon")

However it isn't working, it's no longer displaying those things, and everything below it is no longer displaying either. Can this actually be done or am I just showing my noobiness again?

*Update*

I tried playing with the buttons and started getting errors:

Traceback (most recent call last):
File "/Users/MacBook/Documents/Blender/Blends/MacBook/MacBook.blend/macbook_controller.py", line 302, in draw
AttributeError: 'IGLayoutDemoPanel' object has no attribute 'icons'

location: <unknown location>:-1

Thanks, Matthew

$\endgroup$
  • 1
    $\begingroup$ If everything below these lines doesn't show, it often means you have an error in your code, which crashes the draw function and stops the drawing at the line with the error. Take a look at the console (Window > Toggle System Console) to check the output and see if there are any error messages. You might have a typo (scene.ignit_panel ==> scene.ignite_panel?) or some other bug. $\endgroup$ – TLousky Dec 30 '15 at 21:38
  • $\begingroup$ I use the run script in pyconsole addon and that showed no errors in the console, I checked the spelling against everything before that and thats all fine... $\endgroup$ – mr-matt Dec 30 '15 at 21:40
  • $\begingroup$ Look at the console when you're hovering over the panel with your mouse (or any time a bit after running the script). Blender redraws and panel when the mouse moves and if there are any errors during drawing they will pop then. Might also help if you edit your question and paste more or all of your code there. $\endgroup$ – TLousky Dec 30 '15 at 21:55
  • $\begingroup$ Ok, I'll try that, also, how much code should I put in? I have a heck of a lot... $\endgroup$ – mr-matt Dec 30 '15 at 22:00
  • $\begingroup$ Ok, now we're getting somewhere, I tried playing with the buttons and now I have some errors, could have sworn I'd already tried that! I'll put the error into the description. $\endgroup$ – mr-matt Dec 30 '15 at 22:01
1
$\begingroup$

Found the problem, 'icons' wasn't recognized because it was from a different class, I just had to reference it.

icons = scene.ignit_panel.icons

if icons == 'Brightness':
    row.prop(scene.ignit_panel, "brightness_icon")
elif icons == 'Backlit Keys':
    row.prop(scene.ignit_panel, "backlit_keys_icon")
elif icons == 'Volume':
    row.prop(scene.ignit_panel, "volume_icon")
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.