Ejemplo n.º 1
0
def load_uh_widget(filename, style=None, center_widget=False):
	"""Loads a pychan widget from an xml file and applies uh-specific modifications
	"""
	# load widget
	try:
		widget = loadXML(BytesIO(get_widget_xml(filename)))
	except (IOError, ValueError) as error:
		log = logging.getLogger('gui')
		log.error('PLEASE REPORT: invalid path %s in translation!\n> %s', filename, error)
		raise

	# translate
	widget = translate_widget(widget, filename)

	if style:
		widget.stylize(style)
	# format headline
	for w in widget.findChildren():
		if w.name.startswith("headline") or w.name == "name":
			w.stylize('headline')
		elif w.name.startswith("uni_") or w.comment.startswith("uni_"):
			w.font = 'unifont'
		elif w.name.startswith("transparent_"):
			w.stylize('transparent')
	if center_widget:
		widget.position_technique = "center:center"

	return widget
Ejemplo n.º 2
0
def load_uh_widget(filename, style=None, center_widget=False):
    """Loads a pychan widget from an xml file and applies uh-specific modifications
	"""
    # load widget
    try:
        widget = loadXML(StringIO(get_widget_xml(filename)))
    except (IOError, ValueError) as error:
        log = logging.getLogger("gui")
        log.error(u"PLEASE REPORT: invalid path %s in translation!\n> %s", filename, error)
        raise

        # translate
    widget = translate_widget(widget, filename)

    if style:
        widget.stylize(style)
        # format headline
    for w in widget.findChildren():
        if w.name.startswith("headline") or w.name == "name":
            w.stylize("headline")
        elif w.name.startswith("uni_") or w.comment.startswith("uni_"):
            w.font = "unifont"
        elif w.name.startswith("transparent_"):
            w.stylize("transparent")
    if center_widget:
        widget.position_technique = "center:center"

    return widget
Ejemplo n.º 3
0
def load_uh_widget(filename, style=None, center_widget=False):
    """Loads a pychan widget from an xml file and applies uh-specific modifications
	"""
    # load widget
    try:
        widget = loadXML(get_gui_files_map()[filename])
    except (IOError, ValueError) as error:
        print u"PLEASE REPORT: invalid path {path} in translation! {error}".format(path=filename, error=error)
        raise

        # translate
    widget = translate_widget(widget, filename)

    if style:
        widget.stylize(style)
        # format headline
    for w in widget.findChildren():
        if w.name.startswith("headline") or w.name == "name":
            w.stylize("headline")
        elif w.name.startswith("uni_") or w.comment.startswith("uni_"):
            w.font = "unifont"
    if center_widget:
        widget.position_technique = "center:center"

    return widget