📄 xxx.py
字号:
except KeyError: elem = g.tree.dom.createElement(param) p = xxxParam(elem) p.update(value) self.params[param] = p self.node.appendChild(elem) # Special processing for growablecols-like parameters # represented by several nodes def special(self, tag, node): if not self.params.has_key(tag): # Create new multi-group self.params[tag] = xxxParamMulti(node) self.params[tag].append(xxxParamInt(node)) def setSpecial(self, param, value): # Straightforward implementation: remove, add again self.params[param].remove() del self.params[param] for i in value: node = g.tree.dom.createElement(param) text = g.tree.dom.createTextNode(str(i)) node.appendChild(text) self.node.appendChild(node) self.special(param, node)# Imitation of FindResource/DoFindResource from xmlres.cppdef DoFindResource(parent, name, classname, recursive): for n in parent.childNodes: if n.nodeType == minidom.Node.ELEMENT_NODE and \ n.tagName in ['object', 'object_ref'] and \ n.getAttribute('name') == name: cls = n.getAttribute('class') if not classname or cls == classname: return n if not cls or n.tagName == 'object_ref': refName = n.getAttribute('ref') if not refName: continue refNode = FindResource(refName) if refName and refNode.getAttribute('class') == classname: return n if recursive: for n in parent.childNodes: if n.nodeType == minidom.Node.ELEMENT_NODE and \ n.tagName in ['object', 'object_ref']: found = DoFindResource(n, name, classname, True) if found: return founddef FindResource(name, classname='', recursive=True): found = DoFindResource(g.tree.mainNode, name, classname, recursive) if found: return found wx.LogError('XRC resource "%s" not found!' % name) ################################################################################# This is a little special: it is both xxxObject and xxxNodeclass xxxParamFont(xxxObject, xxxNode): allParams = ['size', 'family', 'style', 'weight', 'underlined', 'face', 'encoding'] def __init__(self, parent, element): xxxObject.__init__(self, parent, element) xxxNode.__init__(self, element) self.parentNode = parent # required to behave similar to DOM node v = [] for p in self.allParams: try: v.append(str(self.params[p].value())) except KeyError: v.append('') self.data = v def update(self, value): # `value' is a list of strings corresponding to all parameters elem = self.node # Remove old elements first childNodes = elem.childNodes[:] for node in childNodes: elem.removeChild(node) i = 0 self.params.clear() v = [] for param in self.allParams: if value[i]: fontElem = g.tree.dom.createElement(param) textNode = g.tree.dom.createTextNode(value[i]) self.params[param] = textNode fontElem.appendChild(textNode) elem.appendChild(fontElem) v.append(value[i]) i += 1 self.data = v def value(self): return self.data################################################################################class xxxContainer(xxxObject): hasChildren = True exStyles = []# Simulate normal parameter for encodingclass xxxEncoding: def value(self): return g.currentEncoding def update(self, val): g.currentEncoding = val# Special class for root nodeclass xxxMainNode(xxxContainer): allParams = ['encoding'] hasStyle = hasName = False def __init__(self, dom): xxxContainer.__init__(self, None, dom.documentElement) self.className = 'XML tree' # Reset required parameters after processing XML, because encoding is # a little special self.required = ['encoding'] self.params['encoding'] = xxxEncoding()################################################################################# Top-level windwowsclass xxxPanel(xxxContainer): allParams = ['pos', 'size', 'style'] winStyles = ['wxNO_3D', 'wxTAB_TRAVERSAL'] styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle', 'tooltip']class xxxDialog(xxxContainer): allParams = ['title', 'centered', 'pos', 'size', 'style'] paramDict = {'centered': ParamBool} required = ['title'] default = {'title': ''} winStyles = ['wxDEFAULT_DIALOG_STYLE', 'wxCAPTION', 'wxSTAY_ON_TOP', 'wxSYSTEM_MENU', 'wxTHICK_FRAME', 'wxRESIZE_BORDER', 'wxRESIZE_BOX', 'wxCLOSE_BOX', 'wxMAXIMIZE_BOX', 'wxMINIMIZE_BOX', 'wxDIALOG_MODAL', 'wxDIALOG_MODELESS', 'wxDIALOG_NO_PARENT', 'wxNO_3D', 'wxTAB_TRAVERSAL'] exStyles = ['wxWS_EX_VALIDATE_RECURSIVELY', 'wxDIALOG_EX_METAL'] styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle', 'tooltip']class xxxFrame(xxxContainer): allParams = ['title', 'centered', 'pos', 'size', 'style'] paramDict = {'centered': ParamBool} required = ['title'] default = {'title': ''} winStyles = ['wxDEFAULT_FRAME_STYLE', 'wxDEFAULT_DIALOG_STYLE', 'wxCAPTION', 'wxSTAY_ON_TOP', 'wxSYSTEM_MENU', 'wxTHICK_FRAME', 'wxRESIZE_BORDER', 'wxRESIZE_BOX', 'wxCLOSE_BOX', 'wxMAXIMIZE_BOX', 'wxMINIMIZE_BOX', 'wxFRAME_NO_TASKBAR', 'wxFRAME_SHAPED', 'wxFRAME_TOOL_WINDOW', 'wxFRAME_FLOAT_ON_PARENT', 'wxNO_3D', 'wxTAB_TRAVERSAL'] exStyles = ['wxWS_EX_VALIDATE_RECURSIVELY', 'wxFRAME_EX_METAL'] styles = ['fg', 'bg', 'font', 'enabled', 'focused', 'hidden', 'exstyle', 'tooltip']class xxxTool(xxxObject): allParams = ['bitmap', 'bitmap2', 'radio', 'toggle', 'tooltip', 'longhelp', 'label'] required = ['bitmap'] paramDict = {'bitmap2': ParamBitmap, 'radio': ParamBool, 'toggle': ParamBool} hasStyle = Falseclass xxxToolBar(xxxContainer): allParams = ['bitmapsize', 'margins', 'packing', 'separation', 'dontattachtoframe', 'pos', 'size', 'style'] hasStyle = False paramDict = {'bitmapsize': ParamPosSize, 'margins': ParamPosSize, 'packing': ParamUnit, 'separation': ParamUnit, 'dontattachtoframe': ParamBool, 'style': ParamNonGenericStyle} winStyles = ['wxTB_FLAT', 'wxTB_DOCKABLE', 'wxTB_VERTICAL', 'wxTB_HORIZONTAL', 'wxTB_3DBUTTONS','wxTB_TEXT', 'wxTB_NOICONS', 'wxTB_NODIVIDER', 'wxTB_NOALIGN', 'wxTB_HORZ_LAYOUT', 'wxTB_HORZ_TEXT']class xxxStatusBar(xxxObject): hasStyle = False allParams = ['fields', 'widths', 'styles', 'style'] paramDict = {'fields': ParamIntNN, 'widths': ParamText, 'styles': ParamText, 'style': ParamNonGenericStyle} winStyles = ['wxST_SIZEGRIP']class xxxWizard(xxxContainer): allParams = ['title', 'bitmap', 'pos'] required = ['title'] default = {'title': ''} winStyles = [] exStyles = ['wxWIZARD_EX_HELPBUTTON'] styles = ['fg', 'bg', 'font', 'exstyle']class xxxWizardPage(xxxContainer): allParams = ['bitmap'] winStyles = [] exStyles = []class xxxWizardPageSimple(xxxContainer): allParams = ['bitmap'] winStyles = [] exStyles = []################################################################################# Bitmap, Iconclass xxxBitmap(xxxObject): allParams = ['bitmap'] required = ['bitmap']# Just like bitmapclass xxxIcon(xxxObject): allParams = []################################################################################# Controlsclass xxxStaticText(xxxObject): allParams = ['label', 'pos', 'size', 'style'] required = ['label'] default = {'label': ''} winStyles = ['wxALIGN_LEFT', 'wxALIGN_RIGHT', 'wxALIGN_CENTRE', 'wxST_NO_AUTORESIZE']class xxxStaticLine(xxxObject): allParams = ['pos', 'size', 'style'] winStyles = ['wxLI_HORIZONTAL', 'wxLI_VERTICAL']class xxxStaticBitmap(xxxObject): allParams = ['bitmap', 'pos', 'size', 'style'] required = ['bitmap']class xxxTextCtrl(xxxObject): allParams = ['value', 'pos', 'size', 'style'] winStyles = ['wxTE_NO_VSCROLL', 'wxTE_AUTO_SCROLL', 'wxTE_PROCESS_ENTER', 'wxTE_PROCESS_TAB', 'wxTE_MULTILINE', 'wxTE_PASSWORD', 'wxTE_READONLY', 'wxHSCROLL', 'wxTE_RICH', 'wxTE_RICH2', 'wxTE_AUTO_URL', 'wxTE_NOHIDESEL', 'wxTE_LEFT', 'wxTE_CENTRE', 'wxTE_RIGHT', 'wxTE_DONTWRAP', 'wxTE_LINEWRAP', 'wxTE_WORDWRAP'] paramDict = {'value': ParamMultilineText}class xxxChoice(xxxObject): allParams = ['content', 'selection', 'pos', 'size', 'style'] required = ['content'] default = {'content': '[]'} winStyles = ['wxCB_SORT']class xxxSlider(xxxObject): allParams = ['value', 'min', 'max', 'pos', 'size', 'style', 'tickfreq', 'pagesize', 'linesize', 'thumb', 'tick', 'selmin', 'selmax'] paramDict = {'value': ParamInt, 'tickfreq': ParamIntNN, 'pagesize': ParamIntNN, 'linesize': ParamIntNN, 'thumb': ParamUnit, 'tick': ParamInt, 'selmin': ParamInt, 'selmax': ParamInt} required = ['value', 'min', 'max'] winStyles = ['wxSL_HORIZONTAL', 'wxSL_VERTICAL', 'wxSL_AUTOTICKS', 'wxSL_LABELS', 'wxSL_LEFT', 'wxSL_RIGHT', 'wxSL_TOP', 'wxSL_BOTTOM', 'wxSL_BOTH', 'wxSL_SELRANGE', 'wxSL_INVERSE']class xxxGauge(xxxObject): allParams = ['range', 'pos', 'size', 'style', 'value', 'shadow', 'bezel'] paramDict = {'range': ParamIntNN, 'value': ParamIntNN, 'shadow': ParamIntNN, 'bezel': ParamIntNN} winStyles = ['wxGA_HORIZONTAL', 'wxGA_VERTICAL', 'wxGA_PROGRESSBAR', 'wxGA_SMOOTH']class xxxScrollBar(xxxObject): allParams = ['pos', 'size', 'style', 'value', 'thumbsize', 'range', 'pagesize'] paramDict = {'value': ParamIntNN, 'range': ParamIntNN, 'thumbsize': ParamIntNN, 'pagesize': ParamIntNN} winStyles = ['wxSB_HORIZONTAL', 'wxSB_VERTICAL']class xxxListCtrl(xxxObject): allParams = ['pos', 'size', 'style'] winStyles = ['wxLC_LIST', 'wxLC_REPORT', 'wxLC_ICON', 'wxLC_SMALL_ICON', 'wxLC_ALIGN_TOP', 'wxLC_ALIGN_LEFT', 'wxLC_AUTOARRANGE', 'wxLC_USER_TEXT', 'wxLC_EDIT_LABELS', 'wxLC_NO_HEADER', 'wxLC_SINGLE_SEL', 'wxLC_SORT_ASCENDING', 'wxLC_SORT_DESCENDING', 'wxLC_VIRTUAL', 'wxLC_HRULES', 'wxLC_VRULES', 'wxLC_NO_SORT_HEADER']class xxxTreeCtrl(xxxObject): allParams = ['pos', 'size', 'style'] winStyles = ['wxTR_EDIT_LABELS', 'wxTR_NO_BUTTONS', 'wxTR_HAS_BUTTONS', 'wxTR_TWIST_BUTTONS', 'wxTR_NO_LINES', 'wxTR_FULL_ROW_HIGHLIGHT', 'wxTR_LINES_AT_ROOT', 'wxTR_HIDE_ROOT', 'wxTR_ROW_LINES', 'wxTR_HAS_VARIABLE_ROW_HEIGHT', 'wxTR_SINGLE', 'wxTR_MULTIPLE', 'wxTR_EXTENDED', 'wxTR_DEFAULT_STYLE']class xxxHtmlWindow(xxxObject): allParams = ['pos', 'size', 'style', 'borders', 'url', 'htmlcode'] paramDict = {'htmlcode':ParamMultilineText} winStyles = ['wxHW_SCROLLBAR_NEVER', 'wxHW_SCROLLBAR_AUTO', 'wxHW_NO_SELECTION']class xxxCalendarCtrl(xxxObject): allParams = ['pos', 'size', 'style'] winStyles = ['wxCAL_SUNDAY_FIRST', 'wxCAL_MONDAY_FIRST', 'wxCAL_SHOW_HOLIDAYS', 'wxCAL_NO_YEAR_CHANGE', 'wxCAL_NO_MONTH_CHANGE', 'wxCAL_SEQUENTIAL_MONTH_SELECTION', 'wxCAL_SHOW_SURROUNDING_WEEKS']class xxxNotebook(xxxContainer): allParams = ['pos', 'size', 'style'] winStyles = ['wxNB_TOP', 'wxNB_LEFT', 'wxNB_RIGHT', 'wxNB_BOTTOM', 'wxNB_FIXEDWIDTH', 'wxNB_MULTILINE', 'wxNB_NOPAGETHEME', 'wxNB_FLAT']class xxxChoicebook(xxxContainer): allParams = ['pos', 'size', 'style'] winStyles = ['wxCHB_DEFAULT', 'wxCHB_LEFT', 'wxCHB_RIGHT', 'wxCHB_TOP', 'wxCHB_BOTTOM']
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -