Forum Archive

pyui render - view .pyui files on PC

JadedTuna

Hey guys. I was annoyed of not having a tool which allows you to view .pyui files on PC so I thought about creating one :).

It is a python script, which will parse .pyui file (which is basically json file) and then generate HTML file which can be viewed in the browser such as Firefox, Safari, etc.

It is still dirty and surely not complete yet. Program supports View, Label and TextField elements (hopefully). Gonna try to add more elements tomorrow after school. Please post your reviews and ideas here or open issues on the github page :].

Repository: https://github.com/Vik2015/pyui-renderer/

briarfox

@ShadowSlayer Very cool, can't wait to check it out.

JonB

Pprint actually works pretty well. I tend to think of pyuis as just a repr of a dict. You can read pyuis and eval them, and pprint shows the structure well. This can be useful,for, for instance moving a bunch of components into some container, or flattening a view that had subviews.


from pprint import pprint

def showpyui(filename):
    with open(filename) as f:
        s=f.read()
        # safe eval.  Pyuis have literals true and false instead of True and False, so we have to fix those by defining appropriate locals
        pyuidict=eval(s,{'__builtins__':None},{'true':True,'false':False})
        pprint(pyuidict)