Forum Archive

ui.load_view() fails with 'UI could not be loaded' (Custom Action Advanced)

zrzka

Hi all,

just started on my Jekyll's post settings editor and I'm kinda lost now, because it fails to load my view and don't know what else to try. Here's the link to the unlisted (for now) workflow.

What's hapenning ...

1st scenario

  • start Editorial from scratch
  • try to run this workflow
  • fails with UI could not be loaded

2nd scenario

  • start Editorial from scratch
  • just for fun, run Calculator workflow (included within Editorial)
  • try to run my workflow
  • Calculator UI appears with ton of messages about not working bindings, ...

Anyone have an idea what's going on?

iPad Air 2 & Editorial 1.1.1

zrzka

If I move my stuff under Run Python Script (without input parameters), it does work. It just doesn't work if it's within Custom Action (Advanced).

zrzka

Here's rewritten version which does work perfectly (not Custom Action, just Run Python Script). Anyway I'm still curious what's wrong with the first version (OLD ...).

ccc

I can not resolve your issue but I like your code... In parse_file_settings() you write:

string.find(content,SEPARATOR)
# which can be rewritten
content.find(SEPARATOR)

This is because content is already a str so it has a .find() method. This way is shorter, easier to read, and means that you no longer need to import string.

However, I sense that parse_file_settings() could be made even simpler thru the use of:

before, _, after = content.partition(SEPARATOR)

str.partition() really simplifies finding text between separators.

In update_post_settings() you write:

output = '---\n'
for name, value in settings.iteritems():            
    output += '%s: %s\n' % (name, value)
output += '---\n'

# which could be rewritten

out_list = ['%s: %s' % (name, value) for name, value in settings.iteritems()]
output = '---\n%s\n---\n' % '\n'.join(out_list)

The first line is a list comprehension which is really fast and it avoids doing string concatenation which is slow in Python. The second line joins the strings instead of concatenating them which is much faster. These improvements will help as settings get longer but will be of negligible value on short files.

zrzka

Thanks @ccc for your comments. I updated the workflow. Skilled asm, C, C++, Swift, Obj-C, ... guy, but total newbie in Python :-)

zrzka

But back to my original issue. I just tried to:

Still same problem - Calculator UI appears in my sheet, because UI can't be loaded. Here's the video of how it behaves.