def show(self, e=None): # The first time we're shown, decode the text. # That way we don't need to do it on startup. if self.text is not None: parsed_text = tkMarkdown.convert(self.text, package=None) self.textbox.set_text(parsed_text) self.text = None self.deiconify() self.update_idletasks() utils.center_win(self, TK_ROOT)
def set_corridors(config: Dict[Tuple[str, int], CorrDesc]): """Set the corridor data based on the passed in config.""" CORRIDOR_DATA.clear() CORRIDOR_DATA.update(config) default_icon = img.icon('clean/portal_door') corridor_conf = COMPILE_CFG['CorridorNames'] for group, length in CORRIDOR_COUNTS.items(): selector = CORRIDOR[group] for item in selector.item_list: if item.name == '<NONE>': continue # No customisation for this. ind = int(item.name) data = config[group, ind] corridor_conf['{}_{}_name'.format(group, ind)] = data.name corridor_conf['{}_{}_desc'.format(group, ind)] = data.desc corridor_conf['{}_{}_icon'.format(group, ind)] = data.icon # Note: default corridor description desc = data.name or _('Corridor') item.longName = item.shortName = item.context_lbl = item.name + ': ' + desc if data.icon: item.large_icon = img.png( 'corr/' + data.icon, resize_to=selector_win.ICON_SIZE_LRG, error=default_icon, ) item.icon = img.png( 'corr/' + data.icon, resize_to=selector_win.ICON_SIZE, error=default_icon, ) else: item.icon = item.large_icon = default_icon if data.desc: item.desc = tkMarkdown.convert(data.desc) else: item.desc = CORRIDOR_DESC selector.set_disp() COMPILE_CFG.save_check()
def set_corridors(config: dict[tuple[str, int], CorrDesc]) -> None: """Set the corridor data based on the passed in config.""" CORRIDOR_DATA.clear() CORRIDOR_DATA.update(config) corridor_conf = COMPILE_CFG['CorridorNames'] for group, length in CORRIDOR_COUNTS.items(): selector = CORRIDOR[group] for item in selector.item_list: if item.name == '<NONE>': continue # No customisation for this. ind = int(item.name) data = config[group, ind] corridor_conf['{}_{}_name'.format(group, ind)] = data.name corridor_conf['{}_{}_desc'.format(group, ind)] = data.desc corridor_conf['{}_{}_icon'.format(group, ind)] = str(data.icon) # Note: default corridor description desc = data.name or gettext('Corridor') item.longName = item.shortName = item.context_lbl = item.name + ': ' + desc if data.icon: item.large_icon = img.Handle.parse_uri( data.icon, *selector_win.ICON_SIZE_LRG, ) item.icon = None else: item.icon = default_sml_icon item.large_icon = default_lrg_icon if data.desc: item.desc = tkMarkdown.convert(data.desc, None) else: item.desc = CORRIDOR_DESC selector.refresh() selector.set_disp() COMPILE_CFG.save_check()
def desc_parse( info: Property, desc_id: str = '', *, prop_name: str = 'description', ) -> tkMarkdown.MarkdownData: """Parse the description blocks, to create data which matches richTextBox. """ has_warning = False lines = [] for prop in info.find_all(prop_name): if prop.has_children(): for line in prop: if line.name and not has_warning: LOGGER.warning('Old desc format: {}', desc_id) has_warning = True lines.append(line.value) else: lines.append(prop.value) return tkMarkdown.convert('\n'.join(lines))
from srctools import Property, AtomicWriter from srctools.logger import get_logger from app.tk_tools import FileField from typing import Dict, Tuple, Optional LOGGER = get_logger(__name__) # The size of PeTI screenshots PETI_WIDTH = 555 PETI_HEIGHT = 312 CORRIDOR: Dict[str, selector_win.selWin] = {} CORRIDOR_DATA: Dict[Tuple[str, int], CorrDesc] = {} CORRIDOR_DESC = tkMarkdown.convert('') COMPILE_DEFAULTS = { 'Screenshot': { 'Type': 'AUTO', 'Loc': '', }, 'General': { 'spawn_elev': 'True', 'player_model': 'PETI', 'force_final_light': '0', 'use_voice_priority': '1', 'packfile_dump_dir': '', 'packfile_dump_enable': '0', }, 'Corridor': {