def get_root_path_and_pattern(): root_path = properties.get('root_path') filter_starts = properties.get('filter_start') filter_ends = properties.get('filter_end') start = '(' + '|'.join(filter_starts) + ')' end = '(' + '|'.join(filter_ends) + ')' pattern = start + '(.*)' + end return root_path, pattern
def CreatePropGridPage(self,Element): from MSE import ENUMS from properties import forms,editors,properties page= self.propgrid.AddPage( Element.name) labels=("Game","Style") element=ElementsClass[Element.Type]() for Label in labels: page.Append(wxpg.PropertyCategory('MSE %s Properties'%Label)) for pName in element.params: p=element.params[pName] if p.component!=Label.lower(): continue _p=forms[p.typ] prop=page.Append(_p(pName)) #SPecial case _data=editors.get(p.typ,None) if _data: page.SetPropertyEditor(pName,_data) #Special hack for enums if _p in (wxpg.MultiChoiceProperty,wxpg.EnumProperty): prop.SetPyChoices(ENUMS[pName]) _data=properties.get(p.typ,()) if _data: for pgprop in _data: page.SetPropertyAttribute(pName, *pgprop) prop.SetValue(p.value) page.Type=Element.Type return page
def Build(self, template): EXISTING = False #Get Current Template info if template.name in self._pages: self.SelectPage(template.name) page = self.GetCurrentPage() EXISTING = True else: self._pages[template.name] = template page = self.AddPage(template.name) page.Append( wxpg.PropertyCategory("%s - %s" % (template.name, template.help))) for colname in template.column: OLDVALUE = False #If replacing an exiting grid, first remove the property if it exists if EXISTING: p = page.GetPropertyByName(colname) if p: oldpropertyvalue = p.GetValue() OLDVALUE = True page.DeleteProperty(p) #print colname, template.column[colname] _typ, val = template.column[colname] if _typ == "color": if type('') == type(val): val = strcolor(val) else: if val is None: val = "" #print _typ, colname,val #print forms[_typ](colname,value=val) ##In case of choice, create a list of choices for the choices if _typ in ("choice", 'new_choice'): init, vals = val, template.choices[colname] try: value = vals.index(init) except ValueError: value = 0 _prop = page.Append(forms[_typ](colname, value=vals[value])) _prop.SetPyChoices(vals) else: _prop = page.Append(forms[_typ](colname, value=val)) _data = properties.get(_typ, ()) if _data: for pgprop in _data: page.SetPropertyAttribute(colname, *pgprop) #Special hack for int type spin _data = editors.get(_typ, ()) if _data: page.SetPropertyEditor(colname, _data) #now, when replacing eisting properyt, reset oldvalues if it existed if OLDVALUE: _prop.SetValue(oldpropertyvalue) self.SelectPage(template.name)
def Build(self, template): EXISTING = False # Get Current Template info if template.name in self._pages: self.SelectPage(template.name) page = self.GetCurrentPage() EXISTING = True else: self._pages[template.name] = template page = self.AddPage(template.name) page.Append(wxpg.PropertyCategory("%s - %s" % (template.name, template.help))) for colname in template.column: OLDVALUE = False # If replacing an exiting grid, first remove the property if it exists if EXISTING: p = page.GetPropertyByName(colname) if p: oldpropertyvalue = p.GetValue() OLDVALUE = True page.DeleteProperty(p) # print colname, template.column[colname] _typ, val = template.column[colname] if _typ == "color": if type("") == type(val): val = strcolor(val) else: if val is None: val = "" # print _typ, colname,val # print forms[_typ](colname,value=val) ##In case of choice, create a list of choices for the choices if _typ in ("choice", "new_choice"): init, vals = val, template.choices[colname] try: value = vals.index(init) except ValueError: value = 0 _prop = page.Append(forms[_typ](colname, value=vals[value])) _prop.SetPyChoices(vals) else: _prop = page.Append(forms[_typ](colname, value=val)) _data = properties.get(_typ, ()) if _data: for pgprop in _data: page.SetPropertyAttribute(colname, *pgprop) # Special hack for int type spin _data = editors.get(_typ, ()) if _data: page.SetPropertyEditor(colname, _data) # now, when replacing eisting properyt, reset oldvalues if it existed if OLDVALUE: _prop.SetValue(oldpropertyvalue) self.SelectPage(template.name)