How to use an if statement inside the draw function to change the UI at runtime? 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: &lt;unknown location&gt;:-1


Thanks, Matthew
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")