Forum Archive

Modifying Docverter Workflow

fred

Hi,

I'm trying to modify the Docverter workflow so that it includes an HTML preview.

In the UI, I've added "button4" with the title "Preview HTML," and placed this below "Open New File in …." My new button is hooked up to the action out_to_preview.

That action corresponds to the following code:

# button4
def out_to_preview(sender):
        global files, fields
        input_to_files()
        args_to_fields(scrollview['textfield1'])
        request = post_multipart(formats.items() + fields, files)
        o = open('docverter/' + filename + '.' + 'html', 'w').write(request)
        output_path = os.path.abspath('docverter/' + filename + '.' + 'html')
        preview_file(output_path)

And in the MAIN EXECUTE BLOCK I have:

@ui.in_background
def preview_file(p):
        console.quicklook(p)
        view.close()

When I select "To --> html" and then press the "Preview HTML" button in the workflow, the console appears and shows the converted HTML. However, the UI seems to freeze. When I press the "Done" button at the top of the screen, nothing happens and I need to force quit the program to get things working again. How can I fix this?

Here's a link to the non-functioning workflow http://www.editorial-workflows.com/workflow/5777303720165376/PJqAkD6AriQ.

Thanks for your help!

fred

Just a quick update:

I got around this problem by calling webbrowser.open instead of the preview_file method:

webbrowser.open('file://' + urllib.quote(output_path))