Question about Custom Components in Beta Designer

Ah, that would do it! There’s a limited set of modules available inside the designer, but we’ll add anvil.tz to it :smiley:

However, here’s an as-yet-undocumented but useful feature: You can write:

from anvil.designer import in_designer

and now you have a boolean variable called in_designer, which you can use! So for example, you could replace your import anvil.tz with:

from anvil.designer import in_designer
if not in_designer:
    import anvil.tz

Then you won’t get the ImportError in the designer. (Of course, you’ll then get an AttributeError anywhere you try to use anvil.tz – but if those usages are important you can stub them out in the designer).

Again, for this particular example there’s no point, because we’ll have anvil.tz supported in a few minutes’ time, but as a general strategy for dealing with APIs that aren’t available in the designer it’s a handy thing to know!

4 Likes