Howto talk:Processing legacy PUI dialogs using Canvas

From FlightGear wiki
Jump to navigation Jump to search

Prioritizing tag/widget support

Note  The following script is WIP and expects $FG_ROOT to be set up correctly
#!/bin/python
import os
import fnmatch

import string
import getopt, sys
from xml.dom.minidom import parseString

def usage():
    print "Usage info ..."

def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="])
    except getopt.GetoptError as err:
        # print help information and exit:
        print(err)  # will print something like "option -a not recognized"
        usage()
        sys.exit(2)
    output = None
    verbose = False
    for o, a in opts:
        if o == "-v":
            verbose = True
        elif o in ("-h", "--help"):
            usage()
            sys.exit()
        elif o in ("-o", "--output"):
            output = a
        else:
            assert False, "unhandled option"
    # ...

fgroot =  os.environ['FG_ROOT']
dialogs = os.path.join(fgroot, "gui/dialogs")
os.chdir(dialogs)
xml_dialogs = []
for file in os.listdir('.'):
    if fnmatch.fnmatch(file, '*.xml'):
        xml_dialogs.append(file)

print "xml dialogs found:", len(xml_dialogs)

file = open('autopilot.xml','r')
data = file.read()
file.close()
dom = parseString(data)

layouting_directives = ['group','frame']
# https://sourceforge.net/p/flightgear/flightgear/ci/next/tree/src/GUI/FGPUIDialog.cxx#l853
pui_tags = ['hrule','vrule','list','airport-list','property-list','input','text','checkbox','radio','button','map','canvas','combo','slider','dial','textbox','select','waypointlist','loglist','label']

for tag in pui_tags:
	print tag + " occurrences: ", len(dom.getElementsByTagName(tag))



if __name__ == "__main__":
    main()