rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
self.Refresh(false)
def underlineWord(self, start, length):
stl = ord(self.GetStyleAt(pos)) & 31
if old_stc: stl = ord(self.GetStyleAt(pos)) & 31 else: stl = self.GetStyleAt(pos) & 31
def OnBrowseMotion(self, event): try: #check if words should be underlined if event.ControlDown(): mp = event.GetPosition() pos = self.PositionFromPoint(wxPoint(mp.x, mp.y)) stl = ord(self.GetStyleAt(pos)) & 31 if self.StyleVeto(stl): if self.styleLength > 0: self.styleStart, self.styleLength = \ self.clearUnderline(self.styleStart, self.styleLength) return lnNo = self.GetLineFromPos(pos) lnStPs = self.GetLineStartPos(lnNo) line = self.GetLine(lnNo) piv = pos - lnStPs start, length = idWord(line, piv, lnStPs) #mark new if length > 0 and self.styleStart != start: if self.styleLength > 0: self.clearUnderline(self.styleStart, self.styleLength) self.styleStart,self.styleLength = \ self.underlineWord(start, length) #keep current elif self.styleStart == start: pass #delete previous elif self.styleLength > 0: self.styleStart, self.styleLength = \ self.clearUnderline(self.styleStart, self.styleLength) #clear any underlined words elif self.styleLength > 0: self.styleStart, self.styleLength = \ self.clearUnderline(self.styleStart, self.styleLength) finally: event.Skip()
def OnBrowseClick(self, event): if self.styleLength > 0: lnNo = self.GetLineFromPos(self.styleStart)
def getStyledWordElems(self, styleStart, styleLength): if styleLength > 0: lnNo = self.GetLineFromPos(styleStart)
def OnBrowseMotion(self, event): try: #check if words should be underlined if event.ControlDown(): mp = event.GetPosition() pos = self.PositionFromPoint(wxPoint(mp.x, mp.y)) stl = ord(self.GetStyleAt(pos)) & 31 if self.StyleVeto(stl): if self.styleLength > 0: self.styleStart, self.styleLength = \ self.clearUnderline(self.styleStart, self.styleLength) return lnNo = self.GetLineFromPos(pos) lnStPs = self.GetLineStartPos(lnNo) line = self.GetLine(lnNo) piv = pos - lnStPs start, length = idWord(line, piv, lnStPs) #mark new if length > 0 and self.styleStart != start: if self.styleLength > 0: self.clearUnderline(self.styleStart, self.styleLength) self.styleStart,self.styleLength = \ self.underlineWord(start, length) #keep current elif self.styleStart == start: pass #delete previous elif self.styleLength > 0: self.styleStart, self.styleLength = \ self.clearUnderline(self.styleStart, self.styleLength) #clear any underlined words elif self.styleLength > 0: self.styleStart, self.styleLength = \ self.clearUnderline(self.styleStart, self.styleLength) finally: event.Skip()
start = self.styleStart-lnStPs word = line[start:start+self.styleLength] style = ord(self.GetStyleAt(self.styleStart)) & 31 if self.BrowseClick(word, line, lnNo, start, style): return
start = styleStart - lnStPs word = line[start:start+styleLength] return word, line, lnNo, start else: return '', 0, 0, 0 def OnBrowseClick(self, event): word, line, lnNo, start = self.getStyledWordElems(self.styleStart, self.styleLength) if word: if old_stc: style = ord(self.GetStyleAt(self.styleStart)) & 31 else: style = self.GetStyleAt(self.styleStart) & 31 if self.BrowseClick(word, line, lnNo, start, style): return
def OnBrowseClick(self, event): if self.styleLength > 0: lnNo = self.GetLineFromPos(self.styleStart) lnStPs = self.GetLineStartPos(lnNo) line = self.GetLine(lnNo) start = self.styleStart-lnStPs word = line[start:start+self.styleLength] style = ord(self.GetStyleAt(self.styleStart)) & 31 if self.BrowseClick(word, line, lnNo, start, style): return event.Skip()
self.SetKeywords(0, hypertext_elements + hypertext_attributes + \ ' public !doctype '+zope_elements)
if old_stc: self.SetKeywords(0, hypertext_elements + hypertext_attributes + \ ' public !doctype '+zope_elements) else: self.SetKeyWords(0, hypertext_elements + hypertext_attributes + \ ' public !doctype '+zope_elements)
def __init__(self, wId): self.SetEOLMode(wxSTC_EOL_LF) self.eol = wxSTC_EOL_LF #endOfLines[self.GetEOLMode()]
charBefore = self.GetCharAt(caretPos - 1) styleBefore = self.GetStyleAt(caretPos - 1)
if old_stc: charBefore = self.GetCharAt(caretPos - 1) styleBefore = ord(self.GetStyleAt(caretPos - 1)) else: charBefore = chr(self.GetCharAt(caretPos - 1)) styleBefore = self.GetStyleAt(caretPos - 1)
def OnUpdateUI(self, evt): # check for matching braces braceAtCaret = -1 braceOpposite = -1 charBefore = None caretPos = self.GetCurrentPos() if caretPos > 0: charBefore = self.GetCharAt(caretPos - 1) styleBefore = self.GetStyleAt(caretPos - 1)
if charBefore and charBefore in "<>[]{}()" and ord(styleBefore) == 10:
if charBefore and charBefore in "<>[]{}()" and styleBefore == 10:
def OnUpdateUI(self, evt): # check for matching braces braceAtCaret = -1 braceOpposite = -1 charBefore = None caretPos = self.GetCurrentPos() if caretPos > 0: charBefore = self.GetCharAt(caretPos - 1) styleBefore = self.GetStyleAt(caretPos - 1)
charAfter = self.GetCharAt(caretPos) styleAfter = self.GetStyleAt(caretPos) if charAfter and charAfter in "<>[]{}()" and ord(styleAfter) == 10:
if old_stc: charAfter = self.GetCharAt(caretPos) styleAfter = ord(self.GetStyleAt(caretPos)) else: charAfter = chr(self.GetCharAt(caretPos)) styleAfter = self.GetStyleAt(caretPos) if charAfter and charAfter in "<>[]{}()" and styleAfter == 10:
def OnUpdateUI(self, evt): # check for matching braces braceAtCaret = -1 braceOpposite = -1 charBefore = None caretPos = self.GetCurrentPos() if caretPos > 0: charBefore = self.GetCharAt(caretPos - 1) styleBefore = self.GetStyleAt(caretPos - 1)
f = open(filename, 'w') pickle.dump(persProps, f) f.close()
from Explorers.Explorer import openEx t = openEx(filename) t.save(t.resourcepath, pickle.dumps(persProps))
def saveSizes(self, filename): '''Build a picklable dictionary of sizes/positions and save.''' persProps = {}
f = open(filename, 'r') persProps = pickle.load(f) f.close()
from Explorers.Explorer import openEx t = openEx(filename) persProps = pickle.loads(t.load())
def loadSizes(self, filename): # construct list of non matching
if path.exists(layoutFile):
from Explorers.Explorer import TransportLoadError try:
def refreshCtrl(self): layoutFile = path.splitext(self.model.filename)[0]+self.ext if path.exists(layoutFile): self.canvas.loadSizes(layoutFile)
if string.strip(line) == 'Traceback (innermost last):':
if string.strip(line) == tb_id:
def errorList(stderr): errs = [] currerr = [] lines = stderr.readlines() print lines lines.reverse() for line in lines: if string.strip(line) == 'Traceback (innermost last):': errs.append(currerr) currerr = [] else: currerr.append(line) errs.reverse() res = [] for err in errs: err.reverse() res.append(ErrorParser(err)) return res
tb = ['Traceback (innermost last):\n',
tb = [tb_id+'\n',
def readlines(self): return self.data
'Traceback (innermost last):\n',
tb_id+'\n',
def readlines(self): return self.data
elif self.routeType == 'IndexRoute' and self.compn and len(params):
elif self.routeType == 'IndexRoute' and self.ctrl and len(params):
def getValue(self, *params):
print 'PropWrap setValue', self.name, value, self.routeType
def setValue(self, value, *params): print 'PropWrap setValue', self.name, value, self.routeType if self.routeType == 'CtrlRoute' and self.ctrl: self.setter(self.ctrl, value) elif self.routeType == 'CompnRoute' and self.compn: self.setter(value) elif self.routeType == 'EventRoute' and self.compn and len(params): self.setter(params[0], value) elif self.routeType == 'IndexRoute' and self.compn and len(params):
elif self.routeType == 'IndexRoute' and self.compn and len(params):
elif self.routeType == 'IndexRoute' and self.ctrl and len(params):
def setValue(self, value, *params): print 'PropWrap setValue', self.name, value, self.routeType if self.routeType == 'CtrlRoute' and self.ctrl: self.setter(self.ctrl, value) elif self.routeType == 'CompnRoute' and self.compn: self.setter(value) elif self.routeType == 'EventRoute' and self.compn and len(params): self.setter(params[0], value) elif self.routeType == 'IndexRoute' and self.compn and len(params):
elif type(self.setter) == MethodType:
if type(self.setter) == MethodType:
def getSetterName(self): from types import FunctionType, MethodType if self.setter: if type(self.setter) == FunctionType: return self.setter.func_name elif type(self.setter) == MethodType: return self.setter.im_func.func_name else: return '' else: return ''
if (type(dict[method]) == FunctionType): prefix = method[:3] property = method[3:]
if _methodTypeCache.has_key( (method, obj) ): return _methodTypeCache[(method, obj)] else: if (type(dict[method]) == FunctionType): prefix = method[:3] property = method[3:] if (method[:2] == '__'): result = ('Built-ins', method, dict[method], dict[method]) elif (prefix == 'Get') and dict.has_key('Set'+property) and property: try: v = dict[method](obj) result = ('Properties', property, dict[method], dict['Set'+property]) except: result = ('Methods', method, dict[method], dict[method]) elif (prefix == 'Set') and dict.has_key('Get'+property) and property: try: v = dict['Get'+property](obj) result = ('Properties', property, dict['Get'+property], dict[method]) except: result = ('Methods', method, dict[method], dict[method]) else: result = ('Methods', method, dict[method], dict[method]) else: result = ('Methods', method, dict[method], dict[method])
def getMethodType(method, obj, dict): """ classify methods according to prefix return category, property name, getter, setter """ if (type(dict[method]) == FunctionType): prefix = method[:3] property = method[3:] if (method[:2] == '__'): return 'Built-ins', method, dict[method], dict[method]
if (method[:2] == '__'): return 'Built-ins', method, dict[method], dict[method] if (prefix == 'Get') and dict.has_key('Set'+property) and property: try: v = dict[method](obj) return 'Properties', property, dict[method], dict['Set'+property] except: return 'Methods', method, dict[method], dict[method] if (prefix == 'Set') and dict.has_key('Get'+property) and property: try: v = dict['Get'+property](obj) return 'Properties', property, dict['Get'+property], dict[method] except: return 'Methods', method, dict[method], dict[method] return 'Methods', method, dict[method], dict[method]
return result
def getMethodType(method, obj, dict): """ classify methods according to prefix return category, property name, getter, setter """ if (type(dict[method]) == FunctionType): prefix = method[:3] property = method[3:] if (method[:2] == '__'): return 'Built-ins', method, dict[method], dict[method]
def save(self, filename, data):
def save(self, filename, data, mode='wb'):
def save(self, filename, data): """ Saves contents of data to Zope """ try: self.getResource().PUT({'BODY':data}) except xmlrpclib.ProtocolError, error: # Getting a zero content warning is not an error if error.errcode != 204: raise ExplorerNodes.TransportSaveError(error, filename) except Exception, error: raise ExplorerNodes.TransportSaveError(error, filename)
def save(self, filename, data):
def save(self, filename, data, mode='wb'):
def save(self, filename, data): self.getResource().manage_edit(self.name, self.getParams(data), self.getBody(data))
parent.AddPage(bSelect = true, imageId = -1, pPage = self.htmlWindow, strText = 'Response') parent.AddPage(bSelect = false, imageId = -1, pPage = self.textCtrl, strText = 'Source')
parent.AddPage(select = true, imageId = -1, page = self.htmlWindow, text = 'Response') parent.AddPage(select = false, imageId = -1, page = self.textCtrl, text = 'Source')
def _init_coll_notebook1_Pages(self, parent): # generated method, don't edit
print _('Not running in server mode')
print 'Not running in server mode'
def __init__(self, parent, id, inspector, newMenu, componentPalette, app, palette): self._created = False self._init_ctrls(parent)
if node.protocol == 'recent.files':
if node and node.protocol == 'recent.files':
def OnOpen(self, event, curdir='.'): fn = self.openFileDlg(curdir=curdir) if fn: self.openOrGotoModule(fn) self.explorerStore.recentFiles.add(fn)
self.wID = NewId()
self.wID = wxNewId()
def __init__(self, propEditor, value): self.propEditor = propEditor self.editorCtrl = None self.wID = NewId() self.value = value
print 'DESTROY InspectableObjectCollectionView', self.__class__.__name__
def destroy(self): print 'DESTROY InspectableObjectCollectionView', self.__class__.__name__ del self.controllerView del self.inspector for objval in self.objects.values(): objval[0].destroy() for coll in self.collEditors.values(): coll.destroy() del self.collEditors del self.objects del self.senderMapper EditorViews.EditorView.destroy(self)
for ctrl in creators: self.initObjCreator(ctrl) self.initObjProps(objColl.propertiesByName, ctrl.comp_name, ctrl, dependents, depLinks) self.initObjColls(objColl.collectionsByName, ctrl.comp_name, ctrl, collDeps) self.initObjEvts(objColl.eventsByName, ctrl.comp_name, ctrl) self.applyDepsForCtrl(ctrl.comp_name, depLinks)
for constr in creators: self.initObjCreator(constr) self.initObjProps(objColl.propertiesByName, constr.comp_name, constr, dependents, depLinks) self.initObjColls(objColl.collectionsByName, constr.comp_name, constr, collDeps) self.initObjEvts(objColl.eventsByName, constr.comp_name, constr) self.applyDepsForCtrl(constr.comp_name, depLinks)
def initObjectsAndCompanions(self, creators, objColl, dependents, depLinks): collDeps = {} for ctrl in creators: self.initObjCreator(ctrl) self.initObjProps(objColl.propertiesByName, ctrl.comp_name, ctrl, dependents, depLinks) self.initObjColls(objColl.collectionsByName, ctrl.comp_name, ctrl, collDeps) self.initObjEvts(objColl.eventsByName, ctrl.comp_name, ctrl) self.applyDepsForCtrl(ctrl.comp_name, depLinks)
target = Utils.ctrlNameFromSrcRef(prop.params[0]) if target not in definedCtrls:
refs = self.getRefsFromProp(prop) allCtrlsDefined = len(refs) > 0 for ref in refs: if ref not in definedCtrls: allCtrlsDefined = false if not allCtrlsDefined:
def checkAndAddDepLink(self, ctrlName, prop, dependentProps, deps, depLinks, definedCtrls): if prop.prop_name in dependentProps: # Don't postpone if target ctrl already defined target = Utils.ctrlNameFromSrcRef(prop.params[0]) if target not in definedCtrls: self.addDepLink(prop, ctrlName, deps, depLinks) return true return false
for prop in depLinks[ctrlName]: ctrl = self.objects[prop.comp_name][1] if ctrlName == '': value = self
for prop, otherRefs in depLinks[ctrlName]: for oRf in otherRefs: if not oRf in self.objectOrder: break
def applyDepsForCtrl(self, ctrlName, depLinks): if depLinks.has_key(ctrlName): for prop in depLinks[ctrlName]: ctrl = self.objects[prop.comp_name][1] if ctrlName == '': value = self else: ord, objs = self.model.allObjects() if objs.has_key(ctrlName): value = objs[ctrlName][1] else: continue RTTI.getFunction(ctrl, prop.prop_setter)(ctrl, value) del depLinks[ctrlName]
ord, objs = self.model.allObjects() if objs.has_key(ctrlName): value = objs[ctrlName][1]
ctrl = self.objects[prop.comp_name][1] if len(prop.params) == 1: if ctrlName == '': value = self else: ord, objs = self.model.allObjects() if objs.has_key(ctrlName): value = objs[ctrlName][1] else: continue RTTI.getFunction(ctrl, prop.prop_setter)(ctrl, value)
def applyDepsForCtrl(self, ctrlName, depLinks): if depLinks.has_key(ctrlName): for prop in depLinks[ctrlName]: ctrl = self.objects[prop.comp_name][1] if ctrlName == '': value = self else: ord, objs = self.model.allObjects() if objs.has_key(ctrlName): value = objs[ctrlName][1] else: continue RTTI.getFunction(ctrl, prop.prop_setter)(ctrl, value) del depLinks[ctrlName]
continue RTTI.getFunction(ctrl, prop.prop_setter)(ctrl, value)
refs = [] for param in prop.params: if len(param) >= 4 and param[:4] == 'self': refs.append(self.objects[Utils.ctrlNameFromSrcRef(param)][1]) else: refs.append(eval(param)) apply(RTTI.getFunction(ctrl, prop.prop_setter), [ctrl,]+refs)
def applyDepsForCtrl(self, ctrlName, depLinks): if depLinks.has_key(ctrlName): for prop in depLinks[ctrlName]: ctrl = self.objects[prop.comp_name][1] if ctrlName == '': value = self else: ord, objs = self.model.allObjects() if objs.has_key(ctrlName): value = objs[ctrlName][1] else: continue RTTI.getFunction(ctrl, prop.prop_setter)(ctrl, value) del depLinks[ctrlName]
if not dependents.has_key(name): dependents[name] = [] dependents[name].append(prop) link = Utils.ctrlNameFromSrcRef(prop.params[0]) if not depLinks.has_key(link): depLinks[link] = [] depLinks[link].append(prop)
refs = self.getRefsFromProp(prop) for link in refs: if not depLinks.has_key(link): depLinks[link] = [] otherRefs = refs[:] otherRefs.remove(link) depLinks[link].append( (prop, otherRefs) )
def addDepLink(self, prop, name, dependents, depLinks): if not dependents.has_key(name): dependents[name] = [] dependents[name].append(prop)
companion.renameCtrlRefs(oldName, newName)
def renameCtrl(self, oldName, newName): """ Rename a control and update all its properties and events."""
compn.writeDependencies(newBody, ctrlName, depLinks)
compn.writeDependencies(newBody, ctrlName, depLinks, definedCtrls) imp = compn.writeImports() if imp and imp not in imports: imports.append(imp)
def saveCtrls(self, definedCtrls): """ Replace current source of method in collectionMethod with values from constructors, properties and events. """
compn.writeDependencies(output, ctrlName, depLinks)
compn.writeDependencies(output, ctrlName, depLinks, definedCtrls)
output.insert(0, ' def %s(%s):'% (self.collectionMethod, self.collectionParams))
except:
except NameError:
if line[:8] == ' def ': meth = line[8:string.find(line, '(', 9)] currMeth = [meth] methList.append(currMeth)
print methList
if line[:8] == ' def ': meth = line[8:string.find(line, '(', 9)] currMeth = [meth] methList.append(currMeth)
print 'Empty clipboard'
if line[:8] == ' def ': meth = line[8:string.find(line, '(', 9)] currMeth = [meth] methList.append(currMeth)
pns = objCol.getCtrlNames()
pasteNameClasses = objCol.getCtrlNames()
if line[:8] == ' def ': meth = line[8:string.find(line, '(', 9)] currMeth = [meth] methList.append(currMeth)
for name, clss in pns:
oldNames = [] for name, clss in pasteNameClasses:
if line[:8] == ' def ': meth = line[8:string.find(line, '(', 9)] currMeth = [meth] methList.append(currMeth)
objCol.renameCtrl(name, newName)
oldNames.append(name) else: newNames.append(name) oldNames.append(name) for oldName, newName in map(None, oldNames, newNames): if newName != oldName: objCol.renameCtrl(oldName, newName)
if line[:8] == ' def ': meth = line[8:string.find(line, '(', 9)] currMeth = [meth] methList.append(currMeth)
if collCtrlName == name: print 'renaming Coll Obj Coll'
collObjColl.renameCtrl(oldName, newName) if collCtrlName == oldName:
if line[:8] == ' def ': meth = line[8:string.find(line, '(', 9)] currMeth = [meth] methList.append(currMeth)
collObjColl.renameCtrl(name, newName)
if line[:8] == ' def ': meth = line[8:string.find(line, '(', 9)] currMeth = [meth] methList.append(currMeth)
pastedCtrls.append(name) print 'Update models object collections'
pastedCtrls.append(oldName)
if line[:8] == ' def ': meth = line[8:string.find(line, '(', 9)] currMeth = [meth] methList.append(currMeth)
print meth, collCtrlName
if line[:8] == ' def ': meth = line[8:string.find(line, '(', 9)] currMeth = [meth] methList.append(currMeth)
copySource = objCol.creators[0].params['parent'] objCol.reparent(copySource, Utils.srcRefFromCtrlName(destCtrlName))
if objCol.creators[0].params.has_key('parent'): copySource = objCol.creators[0].params['parent'] objCol.reparent(copySource, Utils.srcRefFromCtrlName(destCtrlName))
if line[:8] == ' def ': meth = line[8:string.find(line, '(', 9)] currMeth = [meth] methList.append(currMeth)
def refreshContainment(self, selectName = None):
def refreshContainment(self, selectName = None): """ Rebuild parent tree and optionally select given control """
def refreshContainment(self, selectName = None): parRelations, parReference = self.buildParentRelationship() self.inspector.containment.refreshCtrl(self.model.main, parRelations, self) if selectName is not None: self.inspector.containment.selectName(selectName) return parRelations, parReference
results['self.'+objName] = self.objects[objName][1]
if objName: results['self.'+objName] = self.objects[objName][1] else: results['self'] = self.objects[objName][1] return results def getObjectsOfClassWithParent(self, theClass, theParentName): results = {} for objName in self.objects.keys(): if self.objects[objName][2] == theParentName and \ issubclass(self.objects[objName][1].__class__, theClass): if objName: results['self.'+objName] = self.objects[objName][1] else: results['self'] = self.objects[objName][1]
def getObjectsOfClass(self, theClass): results = {} for objName in self.objects.keys(): if issubclass(self.objects[objName][1].__class__, theClass): results['self.'+objName] = self.objects[objName][1] return results
self.SetIcon(wxIcon(path.join(Preferences.toPyPath(\ 'Images/Icons/Designer.ico')), wxBITMAP_TYPE_ICO))
self.SetIcon(IS.load('Images/Icons/Designer.ico'))
def __init__(self, parent, inspector, model, compPal, companionClass, dataView): args = self.setupArgs(model.main, model.mainConstr.params, ['parent', 'id'], parent, companionClass) wxFrame.__init__(self, parent, -1, args['title'], args['pos'], args['size'])#, args['style'], args['name']) InspectableObjectCollectionView.__init__(self, inspector, model, compPal)
if Preferences.drawDesignerGrid: EVT_PAINT(self, self.OnPaint) self.drawGridMethods = {'lines' : self.drawGrid_intersectingLines, 'dots' : self.drawGrid_dots, 'bitmap': self.drawGrid_bitmap, 'grid' : self.drawGrid_grid}
def __init__(self, parent, inspector, model, compPal, companionClass, dataView): args = self.setupArgs(model.main, model.mainConstr.params, ['parent', 'id'], parent, companionClass) wxFrame.__init__(self, parent, -1, args['title'], args['pos'], args['size'])#, args['style'], args['name']) InspectableObjectCollectionView.__init__(self, inspector, model, compPal)
('Paste', wxID_EDITPASTE)): tpe, key = PrefsKeys.keyDefs[name]
('Paste', wxID_EDITPASTE), ('MoveLeft', wxID_EDITMOVELEFT), ('MoveRight', wxID_EDITMOVERIGHT), ('MoveUp', wxID_EDITMOVEUP), ('MoveDown', wxID_EDITMOVEDOWN), ('WidthInc', wxID_EDITWIDTHINC), ('WidthDec', wxID_EDITWIDTHDEC), ('HeightInc', wxID_EDITHEIGHTINC), ('HeightDec', wxID_EDITHEIGHTDEC), ): tpe, key, code = PrefsKeys.keyDefs[name]
def __init__(self, parent, inspector, model, compPal, companionClass, dataView): args = self.setupArgs(model.main, model.mainConstr.params, ['parent', 'id'], parent, companionClass) wxFrame.__init__(self, parent, -1, args['title'], args['pos'], args['size'])#, args['style'], args['name']) InspectableObjectCollectionView.__init__(self, inspector, model, compPal)
self.selection = SingleSelectionGroup(self, self.senderMapper, self.inspector, self)
self.selection = \ SelectionTags.SingleSelectionGroup(self, self.senderMapper, self.inspector, self)
def refreshCtrl(self): if self.destroying: return
self.selection = SingleSelectionGroup(self, self.senderMapper, self.inspector, self)
self.selection = SelectionTags.SingleSelectionGroup(self, self.senderMapper, self.inspector, self)
def initSelection(self): self.selection = SingleSelectionGroup(self, self.senderMapper, self.inspector, self)
def CtrlAnchored(self, ctrl): result = (ctrl == self)
def CtrlAnchored(self, ctrl): result = (ctrl == self)
def getAllObjects(self):
def getAllObjects(self): """ Overridden to also add objects from the DataView """
def getAllObjects(self):#, theClass): results = InspectableObjectCollectionView.getAllObjects(self) for objName in self.dataView.objects.keys(): if objName: results['self.'+objName] = self.dataView.objects[objName][1] else: results['self'] = self.dataView.objects[objName][1] return results
self.notifyAction(ctrlInfo[0], 'delete')
def deleteCtrl(self, name, parentRef = None): ctrlInfo = self.objects[name] if ctrlInfo[1] == self: wxMessageBox("Can't delete frame") return parRel = None # build relationship, this will only happen for the first call if not parentRef: # select parent so long, pretty soon won't be able to ask who # the parent is parentName = ctrlInfo[1].GetParent().GetName() if parentName == self.GetName(): parentName = ''
if wxIntersectRect((clickPos.x, clickPos.y + tbOffset, 1, 1),
if childCtrl.IsShown() and wxIntersectRect((clickPos.x, clickPos.y + tbOffset, 1, 1),
def checkChildCtrlClick(self, ctrlName, ctrl, companion, clickPos): selCtrl, selCompn, selPos = ctrl, companion, clickPos if companion.container: parent = ctrl else: parent = ctrl.GetParent() # Workaround toolbar offset bug tbOffset = 0 if parent == self: tb = self.GetToolBar() if tb: tbOffset = tb.GetSize().y * -1
break;
break
def checkChildCtrlClick(self, ctrlName, ctrl, companion, clickPos): selCtrl, selCompn, selPos = ctrl, companion, clickPos if companion.container: parent = ctrl else: parent = ctrl.GetParent() # Workaround toolbar offset bug tbOffset = 0 if parent == self: tb = self.GetToolBar() if tb: tbOffset = tb.GetSize().y * -1
self.selection = SingleSelectionGroup(self, self.senderMapper, self.inspector, self)
self.selection = SelectionTags.SingleSelectionGroup(self, self.senderMapper, self.inspector, self)
def assureSingleSelection(self): if not self.selection: self.selection = SingleSelectionGroup(self, self.senderMapper, self.inspector, self)
def OnMouseOver(self, event): if event.Dragging(): pos = event.GetPosition() ctrl = self.senderMapper.getObject(event) if self.selection: self.selection.moving(ctrl, pos) elif self.multiSelection: for sel in self.multiSelection: sel.moving(ctrl, pos, self.mainMultiDrag) event.Skip() def OnControlSelect(self, event): """ Control is clicked. Either select it or add control from palette """ ctrl = self.senderMapper.getObject(event)
def collapseNamesToContainers(self, ctrlNames): """ Collapse set of names to exclude the names of all their children """ def hasParentInList(item, list): return intem in list exp = ctrlNames[:] colLst = filter(\ lambda name, names=ctrlNames, objs=self.objects: \ objs[name][2] not in names, ctrlNames) return colLst def selectControlByPos(self, ctrl, pos, multiSelect): """ Handle selection of a control from a users click of creation of a new one if a component was selected on the palette. Some ctrls do not register clicks, the click is then picked up from the parent which checks if a click intersects any child regions. For efficiency this is only applied for 2 levels. Also handles single and multiple selection logic. Returns true if the ctrl also wants the click event """
def OnMouseOver(self, event): if event.Dragging(): pos = event.GetPosition() ctrl = self.senderMapper.getObject(event)
pos = event.GetPosition() if companion.container: parent = ctrl
if selCompn.container: parent = selCtrl pos = selPos
def OnControlSelect(self, event): """ Control is clicked. Either select it or add control from palette """ ctrl = self.senderMapper.getObject(event)
parent = ctrl.GetParent() screenPos = ctrl.ClientToScreen(pos)
parent = selCtrl.GetParent() screenPos = selCtrl.ClientToScreen(selPos)
def OnControlSelect(self, event): """ Control is clicked. Either select it or add control from palette """ ctrl = self.senderMapper.getObject(event)
pos = wxPoint(granularise(pos.x), granularise(pos.y))
def OnControlSelect(self, event): """ Control is clicked. Either select it or add control from palette """ ctrl = self.senderMapper.getObject(event)
evtPos = event.GetPosition() ctrlName = companion.name selCtrl, selCompn, selPos = \ self.checkChildCtrlClick(ctrlName, ctrl, companion, evtPos)
def OnControlSelect(self, event): """ Control is clicked. Either select it or add control from palette """ ctrl = self.senderMapper.getObject(event)
if event.ShiftDown():
if multiSelect:
def OnControlSelect(self, event): """ Control is clicked. Either select it or add control from palette """ ctrl = self.senderMapper.getObject(event)
if ctrl.GetParent().this != self.selection.selection.GetParent().this:
if selCtrl.GetParent().this != self.selection.selection.GetParent().this:
def OnControlSelect(self, event): """ Control is clicked. Either select it or add control from palette """ ctrl = self.senderMapper.getObject(event)
if ctrl.GetParent().this != self.multiSelection[0].selection.GetParent().this:
if selCtrl.GetParent().this != self.multiSelection[0].selection.GetParent().this:
def OnControlSelect(self, event): """ Control is clicked. Either select it or add control from palette """ ctrl = self.senderMapper.getObject(event)
if ctrl == self.selection.selection:
if selCtrl == self.selection.selection:
def OnControlSelect(self, event): """ Control is clicked. Either select it or add control from palette """ ctrl = self.senderMapper.getObject(event)
newSelection = MultiSelectionGroup(self, self.senderMapper, self.inspector, self)
newSelection = SelectionTags.MultiSelectionGroup(self, self.senderMapper, self.inspector, self)
def OnControlSelect(self, event): """ Control is clicked. Either select it or add control from palette """ ctrl = self.senderMapper.getObject(event)
self.selection = SingleSelectionGroup(self,
self.selection = SelectionTags.SingleSelectionGroup(self,
def OnControlSelect(self, event): """ Control is clicked. Either select it or add control from palette """ ctrl = self.senderMapper.getObject(event)
def OnControlRelease(self, event): if self.selection: self.selection.moveRelease() elif self.multiSelection: for sel in self.multiSelection: sel.moveRelease() self.mainMultiDrag = None
return 0 def OnFramePos(self, event): """ Called when frame is repositioned """ if self.selection and self.selection.selection == self: self.inspector.constructorUpdate('Position')
def OnControlSelect(self, event): """ Control is clicked. Either select it or add control from palette """ ctrl = self.senderMapper.getObject(event)
def OnControlResize(self, event):
def _drawLines(self, dc, col, loglFunc, sze, sg): pen1 = wxPen(col) dc.SetPen(pen1) dc.SetLogicalFunction(loglFunc) for y in range(sze.y / sg): dc.DrawLine(0, y * sg, sze.x, y * sg) for x in range(sze.x / sg): dc.DrawLine(x * sg, 0, x * sg, sze.y) def drawGrid_intersectingLines(self, dc, sze, sg): bgCol = dc.GetBackground().GetColour() xorBgCol = wxColour(255^bgCol.Red(), 255^bgCol.Green(), 255^bgCol.Blue()) self._drawLines(dc, xorBgCol, wxCOPY, sze, sg) self._drawLines(dc, wxNamedColour('WHITE'), wxXOR, sze, sg) darken = 20 def drawGrid_grid(self, dc, sze, sg): bgCol = dc.GetBackground().GetColour() darkerBgCol = wxColour(max(bgCol.Red() -self.darken, 0), max(bgCol.Green() -self.darken, 0), max(bgCol.Blue() -self.darken, 0)) self._drawLines(dc, darkerBgCol, wxCOPY, sze, sg) def drawGrid_dots(self, dc, sze, sg): pen1 = wxPen(wxNamedColour('BLACK')) dc.SetPen(pen1) for y in range(sze.y / sg): for x in range(sze.x / sg): dc.DrawPoint(x * sg, y * sg) def drawGrid_bitmap(self, dc, sze, sg): pass def OnPaint(self, event): dc = wxPaintDC(self) sze = self.GetSize() sg = SelectionTags.screenGran drawGrid = self.drawGridMethods[Preferences.drawGridMethod] dc.BeginDrawing()
def OnControlRelease(self, event): if self.selection: self.selection.moveRelease() elif self.multiSelection: for sel in self.multiSelection: sel.moveRelease() self.mainMultiDrag = None event.Skip()
if event.GetId() == self.GetId(): self.selection.selectCtrl(self, self.companion) sze = self.GetSize() granSze = granularise(sze.x), granularise(sze.y)+3 self.SetSize(granSze) if not self.GetAutoLayout(): c = 0 ctrl = None for ctrlLst in self.objects.values(): if len(ctrlLst) > 2 and ctrlLst[2] == '' and \ (ctrlLst[1].__class__ not in self.ignoreWindows): c = c + 1 ctrl = ctrlLst[1] if c == 1: s = self.GetClientSize() ctrl.SetDimensions(0, 0, s.x, s.y) if self.selection: self.selection.sizeFromCtrl() self.selection.setSelection()
drawGrid(dc, sze, sg)
def OnControlResize(self, event): try: if event.GetId() == self.GetId(): self.selection.selectCtrl(self, self.companion)
event.Skip() self.Layout() def OnControlDClick(self, event): pass def OnFramePos(self, event): self.assureSingleSelection() self.selection.selectCtrl(self, self.companion) self.inspector.constructorUpdate('Position') event.Skip()
dc.EndDrawing()
def OnControlResize(self, event): try: if event.GetId() == self.GetId(): self.selection.selectCtrl(self, self.companion)
def OnEditor(self, event): self.model.editor.Show(true) self.model.editor.Raise()
def OnControlDelete(self, event): ctrls = [] if self.selection: ctrls = [self.selection.name] elif self.multiSelection: ctrls = map(lambda sel: sel.name, self.multiSelection) #map(self.deleteCtrl, ctrls) for ctrlName in ctrls: self.deleteCtrl(ctrlName)
clip = wxTheClipboard clip.Open() try: clip.SetData(wxTextDataObject(string.join(output, os.linesep))) finally: clip.Close()
Utils.writeTextToClipboard(string.join(output, os.linesep))
def OnCutSelected(self, event): if self.selection: ctrls = [self.selection.name] elif self.multiSelection: ctrls = map(lambda sel: sel.name, self.multiSelection)
clip = wxTheClipboard clip.Open() try: clip.SetData(wxTextDataObject(string.join(output, os.linesep))) finally: clip.Close()
Utils.writeTextToClipboard(string.join(output, os.linesep))
def OnCopySelected(self, event): if self.selection: ctrls = [self.selection.name] elif self.multiSelection: ctrls = map(lambda sel: sel.name, self.multiSelection)
clip = wxTheClipboard clip.Open() try: data = wxTextDataObject() clip.GetData(data) finally: clip.Close()
if not self.selection.selCompn.container: self.selectParent(self.selection.selection)
def OnPasteSelected(self, event): if self.selection: clip = wxTheClipboard clip.Open() try: data = wxTextDataObject() clip.GetData(data) finally: clip.Close()
string.split(data.GetText(), os.linesep))
string.split(Utils.readTextFromClipboard(), os.linesep))
def OnPasteSelected(self, event): if self.selection: clip = wxTheClipboard clip.Open() try: data = wxTextDataObject() clip.GetData(data) finally: clip.Close()
self.selection.selectCtrl(self.objects[pasted[0]][1], self.objects[pasted[0]][0])
pasted = self.collapseNamesToContainers(pasted) if len(pasted) == 1: self.selection.selectCtrl(self.objects[pasted[0]][1], self.objects[pasted[0]][0]) else: self.selection.destroy() self.selection = None self.multiSelection = [] for ctrlName in pasted: selCompn, selCtrl, prnt = self.objects[ctrlName] newSelection = SelectionTags.MultiSelectionGroup(self, self.senderMapper, self.inspector, self) newSelection.selectCtrl(selCtrl, selCompn) self.multiSelection.append(newSelection)
def OnPasteSelected(self, event): if self.selection: clip = wxTheClipboard clip.Open() try: data = wxTextDataObject() clip.GetData(data) finally: clip.Close()
elif hasattr(wxNamespace, wx.word): obj = getattr(wxNamespace, wx.word)
elif hasattr(wxNamespace, word): obj = getattr(wxNamespace, word)
def handleBrwsRuntimeGlobals(self, word, currLineNo): # The current runtime values of the shell is inspected # as well as the wxPython namespaces if self.model.editor.shell: shellLocals = self.model.editor.shell.getShellLocals() else: shellLocals = {}
EVT_STC_MARGINCLICK(self, wxID_PYTHONSOURCEDIFFVIEW, self.OnMarginClick)
wx.stc.EVT_STC_MARGINCLICK(self, wxID_PYTHONSOURCEDIFFVIEW, self.OnMarginClick)
def __init__(self, parent, model): wxID_PYTHONSOURCEDIFFVIEW = wx.NewId()
if line[:9]=='<a href="': idx = string.find(line, '">')
if line[:8]=='<a href=': idx = string.find(line, '>')
def ripPythonDocs(splLst, dir, name_term): dict = {} for line in splLst: if line[:9]=='<a href="': idx = string.find(line, '">') if idx != -1: href = line[9:idx] name = line[idx+2:] idx = string.find(name, name_term) if idx != -1: name = string.strip(name[:idx]) dict[name] = dir+href return dict
href = line[9:idx] name = line[idx+2:]
href = line[9:idx-1] name = line[idx+1:]
def ripPythonDocs(splLst, dir, name_term): dict = {} for line in splLst: if line[:9]=='<a href="': idx = string.find(line, '">') if idx != -1: href = line[9:idx] name = line[idx+2:] idx = string.find(name, name_term) if idx != -1: name = string.strip(name[:idx]) dict[name] = dir+href return dict
output.write(header % strftime('%Y/%d/%m', gmtime(time()), '$', '$'))
output.write(header % (strftime('%Y/%d/%m', gmtime(time())), '$', '$'))
def ripPythonDocs(splLst, dir, name_term): dict = {} for line in splLst: if line[:9]=='<a href="': idx = string.find(line, '">') if idx != -1: href = line[9:idx] name = line[idx+2:] idx = string.find(name, name_term) if idx != -1: name = string.strip(name[:idx]) dict[name] = dir+href return dict
lns = text.split(self.eol)
lns = text.split('\n')
def insertCodeBlock(self, text): cp = self.GetCurrentPos() ln = self.LineFromPosition(cp) indent = cp - self.PositionFromLine(ln) lns = text.split(self.eol) # XXX adapt for tab mode text = (self.eol+indent*' ').join(lns)
def isDir(self, path): return path[-1] == '/'
def isDir(self, path = ''): if path: return path[-1] == '/' else: return false
def isDir(self, path): return path[-1] == '/'
InspectableObjectView.saveCtrls(self, definedCtrls, module)
InspectableObjectView.saveCtrls(self, definedCtrls, module, collDeps)
def saveCtrls(self, definedCtrls, module=None): """ Generate source code for Designer """
for collEditor in self.collEditors.values() + self.dataView.collEditors.values():
collEditors = self.collEditors.values() + \ self.dataView.collEditors.values() if self.sizersView: collEditors.extend(self.sizersView.collEditors.values()) for collEditor in collEditors:
def renameFrame(self, oldName, newName): """ Hook that also updates the Model and window ids of the Frame when it's name changes """ self.SetName(newName)
self.saveCtrls(self.dataView.objectOrder[:], module)
otherRefs = self.dataView.objectOrder[:] if self.sizersView: otherRefs.extend(self.sizersView.objectOrder[:]) self.saveCtrls(otherRefs, module)
def refreshModel(self): """ Update model with streamed out controls """ # Make source r/w self.model.views['Source'].disableSource(false)
dataResults = {}
otherResults = {}
def getObjectsOfClass(self, theClass): """ Overridden to also add objects from the DataView """ results = InspectableObjectView.getObjectsOfClass(self, theClass) dataResults = {} for objName in self.dataView.objects.keys(): if isinstance(self.dataView.objects[objName][1], theClass): dataResults['self.'+objName] = self.dataView.objects[objName][1] results.update(dataResults) return results
dataResults['self.'+objName] = self.dataView.objects[objName][1] results.update(dataResults)
otherResults['self.'+objName] = self.dataView.objects[objName][1] if self.sizersView: for objName in self.sizersView.objects.keys(): if isinstance(self.sizersView.objects[objName][1], theClass): otherResults['self.'+objName] = self.sizersView.objects[objName][1] results.update(otherResults)
def getObjectsOfClass(self, theClass): """ Overridden to also add objects from the DataView """ results = InspectableObjectView.getObjectsOfClass(self, theClass) dataResults = {} for objName in self.dataView.objects.keys(): if isinstance(self.dataView.objects[objName][1], theClass): dataResults['self.'+objName] = self.dataView.objects[objName][1] results.update(dataResults) return results
offset[0] = offset[0] + realParent.GetPosition().x offset[1] = offset[1] + realParent.GetPosition().y
offset[0] += realParent.GetPosition().x offset[1] += realParent.GetPosition().y
def checkChildCtrlClick(self, ctrlName, ctrl, companion, clickPos): """ Check whether the click on the control actually falls within a region occupied by one of it's children. The click is then transfered to the child. """ selCtrl, selCompn, selPos = ctrl, companion, clickPos
evt = wxSizeEvent(ctrl.GetSize()) evt.SetId(ctrl.GetId()) wxPostEvent(ctrl, evt)
sizer = ctrl.GetSizer() if sizer: sizer.Layout() wxPostEvent(ctrl, wxSizeEvent(ctrl.GetSize(), ctrl.GetId())) wxCallAfter(ctrl.Refresh)
def relayoutCtrl(self, ctrl): self.forceResize = true # cleared by the event evt = wxSizeEvent(ctrl.GetSize()) evt.SetId(ctrl.GetId()) wxPostEvent(ctrl, evt)
imports = line[7+impIndent:].split(', ')
imports = line[7+impIndent:].strip().split(', ')
def updateAutoCreateImports(self, oldName, newName): """ Rename module in import list.
elif prop.params[0][:11] == 'self._init_':
elif len(prop.params) and prop.params[0][:11] == 'self._init_':
def initObjProps(self, props, name, creator, dependents, depLinks): """ Initialise property list by evaluating 1st parameter and calling prop's setter with it. Also associate companion name with prop parse objs """
self.specialAttrs = []
self.specialAttrs = {}
def __init__(self, data, name, main, editor, saved, app = None): ClassModel.__init__(self, data, name, main, editor, saved, app) self.designerTool = None self.specialAttrs = []
paramLst.append('%s = %s'%(param, params[param]))
paramLst.append(Preferences.cgKeywordArgFormat %{'keyword': param, 'value': params[param]})
def new(self, params): """ Create a new frame module """ paramLst = [] for param in params.keys(): paramLst.append('%s = %s'%(param, params[param])) paramStr = 'self, ' + string.join(paramLst, ', ')
self.data = (defSig + defImport + defCreateClass + defWindowIds + \ defClass) % (self.modelIdentifier, self.main, self.main, Utils.windowIdentifier(self.main, ''), init_ctrls, 1, self.main, self.defaultName, self.defaultName, paramStr)
self.data = (sourceconst.defSig + sourceconst.defImport + \ sourceconst.defCreateClass + sourceconst.defWindowIds + \ sourceconst.defClass) % ( self.modelIdentifier, self.main, self.main, Utils.windowIdentifier(self.main, ''), sourceconst.init_ctrls, 1, self.main, self.defaultName, self.defaultName, paramStr)
def new(self, params): """ Create a new frame module """ paramLst = [] for param in params.keys(): paramLst.append('%s = %s'%(param, params[param])) paramStr = 'self, ' + string.join(paramLst, ', ')