def designTimeDefaults(self, vals, method=None): if method is None: method = self.insertionMethod if method in ('AddWindow', 'AddSizer', 'Insert'): if method in ('AddWindow', 'AddSizer'): ctrlIdx = 0 elif method == 'Insert': ctrlIdx = 1 if vals[ctrlIdx] != 'None': srcRef = vals[ctrlIdx] try: # XXX improve int(srcRef) except: params = copy.copy(vals) del params[ctrlIdx] dtd = CollectionDTC.designTimeDefaults( self, params, method) dtd[ctrlIdx] = self.designer.controllerView.getAllObjects( )[srcRef] if method == 'AddSizer': dtd[ctrlIdx]._sub_sizer = self.control elif method == 'AddWindow': dtd[ctrlIdx]._in_sizer = self.control return dtd return CollectionDTC.designTimeDefaults(self, vals, method)
def __init__(self, name, designer, parentCompanion, ctrl): CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl) self.editors = { 'Position': IntConstrPropEdit, 'Item': StrConstrPropEdit, 'Bitmap': BitmapConstrPropEdit }
def deleteItem(self, index): CollectionDTC.deleteItem(self, index) for idx in range(index, len(self.widths)): self.control.SetStatusText(self.control.GetStatusText(idx+1), idx) del self.widths[index] self.control.SetStatusWidths(self.widths) self.control.SetFieldsCount(len(self.widths))
def designTimeDefaults(self, vals, method=None): if method is None: method = self.insertionMethod if method in ('AddWindow', 'AddSizer', 'Insert'): if method in ('AddWindow', 'AddSizer'): ctrlIdx = 0 elif method == 'Insert': ctrlIdx = 1 if vals[ctrlIdx] != 'None': srcRef = vals[ctrlIdx] try: # XXX improve int(srcRef) except: params = copy.copy(vals) del params[ctrlIdx] dtd = CollectionDTC.designTimeDefaults(self, params, method) dtd[ctrlIdx] = self.designer.controllerView.getAllObjects()[srcRef] if method == 'AddSizer': dtd[ctrlIdx]._sub_sizer = self.control elif method == 'AddWindow': dtd[ctrlIdx]._in_sizer = self.control return dtd return CollectionDTC.designTimeDefaults(self, vals, method)
def appendItem(self, method=None): if not (self.control.GetWindowStyleFlag() & wx.LC_REPORT): wx.MessageBox( _('wx.ListCtrl must be created with the wx.LC_REPORT flag.'), 'Error', wx.ICON_ERROR | wx.OK, self.designer) return CollectionDTC.appendItem(self, method)
def __init__(self, name, designer, parentCompanion, ctrl): CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl) self.editors = {'Width': IntConstrPropEdit, 'Heading': StrConstrPropEdit, 'Format': EnumConstrPropEdit}#StyleConstrPropEdit} # self.options = {'Format': formatStyle} self.names = {'Format': formatStyle}
def persistProp(self, name, setterName, value): CollectionDTC.persistProp(self, name, setterName, value) if name in ('Size', ): self.recreateSizers() elif name in ('Flag', 'Border', 'Proportion'): si = self.control.GetChildren()[self.index] getattr(si, 'Set' + name)(self.eval(value)) self.updateGUI()
def __init__(self, name, designer, parentCompanion, ctrl): CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl) self.editors = {'Bitmap': BitmapConstrPropEdit, 'Mask': BitmapConstrPropEdit, # 'Icon': BitmapConstrPropEdit, 'MaskColour': ColourConstrPropEdit} from Views.CollectionEdit import ImageListCollectionEditor self.CollEditorFrame = ImageListCollectionEditor
def __init__(self, name, designer, parentCompanion, ctrl): CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl) self.editors = {'Page': ClassLinkConstrPropEdit, 'Text': StrConstrPropEdit, 'Selected' : BoolConstrPropEdit, 'ImageId': IntConstrPropEdit} self.tempPlaceHolders = []
def __init__(self, name, designer, parentCompanion, ctrl): CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl) self.editors = { 'Number': IntConstrPropEdit, 'Text': StrConstrPropEdit, 'Width': SBFWidthConstrPropEdit } self.widths = []
def persistProp(self, name, setterName, value): CollectionDTC.persistProp(self, name, setterName, value) if name in ('Size',): self.recreateSizers() elif name in ('Flag', 'Border', 'Proportion'): si = self.control.GetChildren()[self.index] getattr(si, 'Set'+name)(self.eval(value)) self.updateGUI()
def __init__(self, name, designer, parentCompanion, ctrl): CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl) self.editors = { 'Width': IntConstrPropEdit, 'Heading': StrConstrPropEdit, 'Format': EnumConstrPropEdit } #StyleConstrPropEdit} # self.options = {'Format': formatStyle} self.names = {'Format': formatStyle}
def writeCollectionItems(self, output, stripFrmId=''): CollectionDTC.writeCollectionItems(self, output, stripFrmId) warn = 0 for constr in self.textConstrLst: if constr.params['page'] == 'None': wx.LogWarning('No control for %s, page %s'%( self.parentCompanion.name, constr.params['text'])) warn = 1 if warn: wx.LogWarning(_('The red-dashed area of a %s page must contain\n'\ 'a control or the generated source will be invalid outside the '\ 'Designer')% self.parentCompanion.bookCtrlName)
def writeCollectionItems(self, output, stripFrmId=''): CollectionDTC.writeCollectionItems(self, output, stripFrmId) warn = 0 for constr in self.textConstrLst: if constr.params[0] == 'None': wx.LogWarning(_('No control/sizer for sizer item of %s')%( self.parentCompanion.name)) warn = 1 if warn: wx.LogWarning(_('None values are only valid in the Designer.\n' 'The generated source will be invalid outside the ' 'Designer and should be fixed before executing.'))
def writeCollectionItems(self, output, stripFrmId=''): CollectionDTC.writeCollectionItems(self, output, stripFrmId) warn = 0 for constr in self.textConstrLst: if constr.params[0] == 'None': wx.LogWarning( _('No control/sizer for sizer item of %s') % (self.parentCompanion.name)) warn = 1 if warn: wx.LogWarning( _('None values are only valid in the Designer.\n' 'The generated source will be invalid outside the ' 'Designer and should be fixed before executing.'))
def __init__(self, name, designer, parentCompanion, ctrl): CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl) self.editors = {'Window': SizerWinEnumConstrPropEdit, 'Sizer': SizerEnumConstrPropEdit, 'Proportion': IntConstrPropEdit, 'Flag': SizerFlagsConstrPropEdit, 'Border': IntConstrPropEdit, 'Size': SizeConstrPropEdit, } self.windowStyles = ['wx.LEFT', 'wx.RIGHT', 'wx.TOP', 'wx.BOTTOM', 'wx.ALL', 'wx.SHRINK', 'wx.GROW', 'wx.EXPAND', 'wx.SHAPED', 'wx.ALIGN_LEFT', 'wx.ALIGN_CENTER_HORIZONTAL', 'wx.ALIGN_RIGHT', 'wx.ALIGN_BOTTOM', 'wx.ALIGN_CENTER_VERTICAL', 'wx.ALIGN_TOP', 'wx.ALIGN_CENTER', 'wx.ADJUST_MINSIZE']
def properties(self): props = CollectionDTC.properties(self) props.update({'Page': ('NoneRoute', None, None), 'Text': ('IndexRoute', wx.Notebook.GetPageText.im_func, wx.Notebook.SetPageText.im_func), 'Selected' : ('CompnRoute', self.GetPageSelected, self.SetPageSelected), 'ImageId': ('IndexRoute', wx.Notebook.GetPageImage.im_func, wx.Notebook.SetPageImage.im_func)}) return props
def applyDesignTimeDefaults(self, params, method=None): if method is None: method = self.insertionMethod if (method in ('AddWindow', 'AddSizer') and params[0] == 'None') or \ (method == 'Insert' and params[1] == 'None'): defaults = self.designTimeDefaults(params, method) if method == 'Insert': proportion = defaults[2] import warnings; warnings.warn('Insert called with BlankSizer') else: proportion = defaults[1] self.control.AddSizer(BlankSizer(), proportion, defaults['flag'], defaults['border']) else: CollectionDTC.applyDesignTimeDefaults(self, params, method)
def moveItem(self, idx, dir): newIdx = CollectionDTC.moveItem(self, idx, dir) if newIdx != idx: self.control.RemoveAll() for crt in self.textConstrLst: self.applyDesignTimeDefaults(crt.params, crt.method) return newIdx
def moveItem(self, idx, dir): newIdx = CollectionDTC.moveItem(self, idx, dir) if newIdx != idx: title = self.control.GetLabelTop(idx) menu = self.control.Remove(idx) self.control.Insert(newIdx, menu, title) return newIdx
def properties(self): props = CollectionDTC.properties(self) props.update({'Bitmap': ('CompnRoute', None, self.setBitmap), 'Mask': ('NoneRoute', None, None), # 'Icon': ('CompnRoute', None, self.setBitmap), }) return props
def applyDesignTimeDefaults(self, params, method=None): if method is None: method = self.insertionMethod if (method in ('AddWindow', 'AddSizer') and params[0] == 'None') or \ (method == 'Insert' and params[1] == 'None'): defaults = self.designTimeDefaults(params, method) if method == 'Insert': proportion = defaults[2] import warnings warnings.warn('Insert called with BlankSizer') else: proportion = defaults[1] self.control.AddSizer(BlankSizer(), proportion, defaults['flag'], defaults['border']) else: CollectionDTC.applyDesignTimeDefaults(self, params, method)
def __init__(self, name, designer, parentCompanion, ctrl): CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl) self.editors = { 'Window': SizerWinEnumConstrPropEdit, 'Sizer': SizerEnumConstrPropEdit, 'Proportion': IntConstrPropEdit, 'Flag': SizerFlagsConstrPropEdit, 'Border': IntConstrPropEdit, 'Size': SizeConstrPropEdit, } self.windowStyles = [ 'wx.LEFT', 'wx.RIGHT', 'wx.TOP', 'wx.BOTTOM', 'wx.ALL', 'wx.SHRINK', 'wx.GROW', 'wx.EXPAND', 'wx.SHAPED', 'wx.ALIGN_LEFT', 'wx.ALIGN_CENTER_HORIZONTAL', 'wx.ALIGN_RIGHT', 'wx.ALIGN_BOTTOM', 'wx.ALIGN_CENTER_VERTICAL', 'wx.ALIGN_TOP', 'wx.ALIGN_CENTER', 'wx.ADJUST_MINSIZE' ]
def properties(self): props = CollectionDTC.properties(self) props.update({ 'Position': ('NoneRoute', None, None), 'Item': ('NoneRoute', None, None), 'Bitmap': ('CompnRoute', self.GetItemBitmap, self.SetItemBitmap) }) return props
def properties(self): props = CollectionDTC.properties(self) props.update({'Column': ('NoneRoute', None, None), 'Heading': ('NoneRoute', None, None), # 'Format': ('IndexRoute', None, None), 'Width': ('IndexRoute', wx.ListCtrl.GetColumnWidth, wx.ListCtrl.SetColumnWidth)}) return props
def properties(self): props = CollectionDTC.properties(self) props.update({ 'Number': ('NoneRoute', None, None), 'Text': ('CompnRoute', self.GetText, self.SetText), 'Width': ('NoneRoute', None, None) }) return props
def moveItem(self, idx, dir): newIdx = CollectionDTC.moveItem(self, idx, dir) if newIdx != idx: li = self.control.GetColumn(idx) text = li.GetText() self.control.DeleteColumn(idx) self.control.InsertColumnInfo(newIdx, li) self.control.SetColumn(newIdx, li) # doesn't update without this return newIdx
def moveItem(self, idx, dir): newIdx = CollectionDTC.moveItem(self, idx, dir) if newIdx != idx: focus = self.control.GetSelection() == idx text = self.control.GetPageText(idx) img = self.control.GetPageImage(idx) page = self.control.GetPage(idx) if self.control.RemovePage(idx): self.control.InsertPage(newIdx, page, text, focus, img) return newIdx
def properties(self): props = CollectionDTC.properties(self) props.update({ 'Column': ('NoneRoute', None, None), 'Heading': ('NoneRoute', None, None), # 'Format': ('IndexRoute', None, None), 'Width': ('IndexRoute', wx.ListCtrl.GetColumnWidth, wx.ListCtrl.SetColumnWidth) }) return props
def moveItem(self, idx, dir): newIdx = CollectionDTC.moveItem(self, idx, dir) if newIdx != idx: w = self.widths[idx] del self.widths[idx] self.widths.insert(newIdx, w) self.control.SetStatusWidths(self.widths) oldText = self.control.GetStatusText(idx) newText = self.control.GetStatusText(newIdx) self.control.SetStatusText(newText, idx) self.control.SetStatusText(oldText, newIdx) return newIdx
def deleteItem(self, idx): activePageDeleted = self.control.GetSelection() == idx CollectionDTC.deleteItem(self, idx) # Delete BlankWindow self.tempPlaceHolders[idx].Destroy() del self.tempPlaceHolders[idx] # Set new active page if necesary if activePageDeleted: newIdx = idx if idx == len(self.textConstrLst): newIdx = newIdx - 1 elif len(self.textConstrLst) == 0: newIdx = None if newIdx is not None: if newIdx < self.control.GetPageCount(): self.updateSelection(newIdx) self.control.SetSelection(newIdx) self.control.Refresh() del self.textConstrLst[idx]
def designTimeDefaults(self, vals, method=None): dtd = CollectionDTC.designTimeDefaults(self, vals) # resize wx.NullBitmap if different size than the imagelist ix, iy = self.parentCompanion.control.GetSize(0) for param in vals.keys(): if vals[param] == 'wx.NullBitmap' and (\ dtd[param].GetWidth() != ix or\ dtd[param].GetHeight() != iy): newbmp = wx.EmptyBitmap(ix, iy) mdc = wx.MemoryDC() mdc.SelectObject(newbmp) mdc.DrawBitmap(dtd[param], 0, 0, False) mdc.SelectObject(wx.NullBitmap) dtd[param] = newbmp return dtd
def deleteItem(self, idx): CollectionDTC.deleteItem(self, idx) del self.textConstrLst[idx] self.recreateSizers()
def appendItem(self, method=None, srcParams={}): CollectionDTC.appendItem(self, method, srcParams) self.recreateSizers()
def properties(self): props = CollectionDTC.properties(self) props.update({'Number': ('NoneRoute', None, None), 'Text': ('CompnRoute', self.GetText, self.SetText), 'Width': ('NoneRoute', None, None)}) return props
def __init__(self, name, designer, parentCompanion, ctrl): CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl) self.editors['Index'] = IntConstrPropEdit
def initialiser(self): return [sourceconst.bodyIndent+'parent.SetFieldsCount(%d)'%( self.getCount())]+CollectionDTC.initialiser(self)
def vetoedMethods(self): return CollectionDTC.vetoedMethods(self)+['GetPosition', 'SetPosition', 'GetSize', 'SetSize']
def moveItem(self, idx, dir): newIdx = CollectionDTC.moveItem(self, idx, dir) if newIdx != idx: self.recreateSizers() return newIdx
def appendItem(self, method=None): self.widths.append(-1) self.control.SetFieldsCount(len(self.widths)) CollectionDTC.appendItem(self, method)
def setConstrs(self, constrLst, inits, fins): CollectionDTC.setConstrs(self, constrLst, inits, fins) if len(fins): self.widths = self.eval(fins[0]\ [fins[0].find('(')+1 : fins[0].rfind(')')]) self.control.SetFieldsCount(len(self.widths))
def __init__(self, name, designer, parentCompanion, ctrl): CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl) self.editors.update({'Menu': MenuEnumConstrPropEdit, 'Title': StrConstrPropEdit})
def applyDesignTimeDefaults(self, params, method=None): dtparams = {}; dtparams.update(params) if 'mask' in dtparams and dtparams['mask'] == 'wx.NullBitmap': del dtparams['mask'] CollectionDTC.applyDesignTimeDefaults(self, dtparams, method)
def __init__(self, name, designer, parentCompanion, ctrl): CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl) self.editors = {'Number' : IntConstrPropEdit, 'Text': StrConstrPropEdit, 'Width': SBFWidthConstrPropEdit} self.widths = []
def __init__(self, name, designer, parentCompanion, ctrl): CollectionDTC.__init__(self, name, designer, parentCompanion, ctrl) self.editors['Entry'] = AcceleratorEntryPropEdit