;ò =‘½Cc@sädkZdkiZdkZdeifd„ƒYZdeifd„ƒYZdeifd„ƒYZ deifd„ƒYZ dk Z d d d d d gZ gZ x†edƒD]xZhZx'd d d gD]Ze i ƒee Reset the grid view. Call this to update the grid if rows and columns have been added or deleted N(sgrids BeginBatchsselfs_rowss GetNumberRowssGridsGRIDTABLE_NOTIFY_ROWS_DELETEDsGRIDTABLE_NOTIFY_ROWS_APPENDEDs_colss GetNumberColssGRIDTABLE_NOTIFY_COLS_DELETEDsGRIDTABLE_NOTIFY_COLS_APPENDEDscurrentsnewsdelmsgsaddmsgsGridTableMessagesmsgsProcessTableMessages UpdateValuessEndBatchs_updateColAttrssAdjustScrollbarss ForceRefresh(sselfsgridsdelmsgscurrentsmsgsnewsaddmsg((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pys ResetView3s" C      cCs&ti|tiƒ}|i|ƒdS(sUpdate all displayed valuesN(sGridsGridTableMessagesselfs!GRIDTABLE_REQUEST_VIEW_GET_VALUESsmsgsgridsProcessTableMessage(sselfsgridsmsg((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pys UpdateValuesSscCsÄd}x·|iD]¬}tiƒ}||ijop|i||ƒ}|i o|i ||i ƒn|i o|i |i ƒn|itƒ|i|ƒn|i||ƒ|d7}qWdS(së wx.Grid -> update the column attributes to add the appropriate renderer given the column name. (renderers are stored in the self.plugins dictionary) Otherwise default to the default renderer. iiN(scolsselfscolnamesscolnamesGrids GridCellAttrsattrspluginssrendererscolSizesgrids SetColSizesrowSizesSetDefaultRowSizes SetReadOnlysTrues SetRenderers SetColAttr(sselfsgridsattrscolnamesrendererscol((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pys_updateColAttrsYs     cCsbh}x|iD]}d||| delete the columns from the dataset cols hold the column indices iiN( s deleteCountscolsssortsisselfscolnamesspopslensdata(sselfscolssis deleteCount((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pys DeleteCols‚s cCsJd}|}|iƒx,|D]$}|ii||ƒ|d7}qWdS(s\ rows -> delete the rows from the dataset rows hold the row indices iiN(s deleteCountsrowsssortsisselfsdataspop(sselfsrowssis deleteCount((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pys DeleteRows—s cCs|i|}g}x<|iD]1}|\}}|i |i |t ƒ|fƒqW|i ƒg|_x$|D]\}}|ii |ƒqlWdS(sI col -> sort the data based on the column indexed by col N(sselfscolnamesscolsnames_datasdatasrowsrownamesentrysappendsgetsNonessorts sortvalue(sselfscolsrownamesnames sortvaluesentrys_datasrow((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pys SortColumn¦s   #   (s__name__s __module__s__doc__s__init__s GetNumberColss GetNumberRowssGetColLabelValuesGetRowLabelValuesGetValues GetRawValuesSetValues ResetViews UpdateValuess_updateColAttrss AppendRows DeleteColss DeleteRowss SortColumn(((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pys MegaTable s             sMegaImageRenderercBstZd„Zd„ZRS(NcCsJtii|ƒ||_tititig|_ t |_ t |_ dS(s± Image Renderer Test. This just places an image in a cell based on the row index. There are N choices and the choice is made by choice[row%N] N( sGridsPyGridCellRenderers__init__sselfstablesimagessgetSmilesBitmapsgetMondrianBitmapsgetWXPdemoBitmaps_choicessNonescolSizesrowSize(sselfstable((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pys__init__¿s   c Cs—|ii||ƒ} |i| t|iƒƒ} t i ƒ} | i | ƒ|it iƒ|oE|it it it iƒƒ|it it idt iƒƒnB|it it it iƒƒ|it it idt iƒƒ|i|ƒ| iƒ| iƒf\}} ||idjo|id}n| |idjo|id} n|i|id|id|| | ddt i t!ƒ dS(Niii("sselfstables GetRawValuesrowscolschoices_choicesslensbmpswxsMemoryDCsimages SelectObjectsdcsSetBackgroundModesSOLIDs isSelectedsSetBrushsBrushsBLUEsSetPensPensWHITEsDrawRectangleRectsrectsGetWidths GetHeightswidthsheightsBlitsxsysCOPYsTrue( sselfsgridsattrsdcsrectsrowscols isSelectedswidthschoicesheightsbmpsimage((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pysDrawÏs&  &"  (s__name__s __module__s__init__sDraw(((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pysMegaImageRenderer¾s sMegaFontRenderercBs#tZdddd„Zd„ZRS(NsbluesARIALicCs•tii|ƒ||_||_ti|ti ti ti d|ƒ|_ ti dti ƒ|_ti titi ƒ|_t|_d|_dS(s8Render data in the specified color and font and fontsizeisbluei2N(sGridsPyGridCellRenderers__init__sselfstablescolorswxsFontsfontsizesDEFAULTsNORMALsfontsBrushsSOLIDs selectedBrushsWHITEs normalBrushsNonescolSizesrowSize(sselfstablescolorsfontsfontsize((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pys__init__ðs  * c Cs |i|ƒ|itiƒ|oE|ititi tiƒƒ|i ti ti dtiƒƒnB|ititi tiƒƒ|i ti ti dtiƒƒ|i |ƒ|ii||ƒ} |itiƒ|o!|i|iƒ|idƒn|i|iƒ|idƒ|i|iƒ|i|iƒ|i| |id|idƒ|i| ƒ\}} ||idjop|idƒ\}} |id|id|} |i!| |id|d| ƒ|id| |idƒn|i"ƒdS(Nisblueswhiteis...(#sdcsSetClippingRectsrectsSetBackgroundModeswxsSOLIDs isSelectedsSetBrushsBrushsBLUEsSetPensPensWHITEsDrawRectangleRectsselfstablesGetValuesrowscolstexts selectedBrushsSetTextBackgrounds normalBrushsSetTextForegroundscolorsSetFontsfontsDrawTextsxsys GetTextExtentswidthsheights DrawRectanglesDestroyClippingRegion( sselfsgridsattrsdcsrectsrowscols isSelectedswidthstextsheightsx((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pysDrawûs2 &"  !!(s__name__s __module__s__init__sDraw(((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pysMegaFontRendererïs sMegaGridcBs8tZed„Zd„Zd„Zd„Zd„ZRS(NcCs^tii||dƒt|||ƒ|_|i |iƒ||_ |i ti |i ƒdS(sóparent, data, colnames, plugins=None Initialize a grid using the data defined in data and colnames (see MegaTable for a description of the data format) plugins is a dictionary of columnName -> column renderers. iÿÿÿÿN(sGrids__init__sselfsparents MegaTablesdatascolnamesspluginss_tablesSetTables_pluginssBindsEVT_GRID_LABEL_RIGHT_CLICKsOnLabelRightClicked(sselfsparentsdatascolnamessplugins((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pys__init__2s  cCs|ii|ƒdS(sbreset the view based on the data in the table. Call this when rows are added or destroyedN(sselfs_tables ResetView(sself((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pysResetAscCsd|iƒ|iƒf\}}|djo|i||ƒn"|djo|i||ƒndS(Niÿÿÿÿ(sevtsGetRowsGetColsrowscolsselfscolPopupsrowPopup(sselfsevtscolsrow((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pysOnLabelRightClickedFs   c Cs÷tiƒ}tiƒ} |i|ƒd}|iƒ o|i |ƒnti ƒ}|i ƒ\}}|i|dƒ|i| dƒ||d„} ||d„}|iti| d|ƒ|iti|d| ƒ|i|ƒ|iƒdSdS(sD(row, evt) -> display a popup menu when a row label is right clickedis Append Rows Delete Row(s)cCs|ii|ƒ|iƒdS(N(sselfs_tables AppendRowsrowsReset(seventsselfsrow((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pysappendZscCs*|iƒ}|ii|ƒ|iƒdS(N(sselfsGetSelectedRowssrowss_tables DeleteRowssReset(seventsselfsrowsrows((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pysdelete^s sidN(swxsNewIdsappendIDsdeleteIDsselfs GetRowSizesrowsxsGetSelectedRowss SelectRowsMenusmenusevts GetPositionsxosyosAppendsappendsdeletesBindsEVT_MENUs PopupMenusDestroy( sselfsrowsevtsdeletesxosyosmenusappendIDsxsdeleteIDsappend((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pysrowPopupLs"     c Cs|i|ƒd} tiƒ}tiƒ}tiƒ}|i ƒ\}}|i|ƒ|iƒ} |iƒ|i|dƒ|i|dƒ||d„} ||d„}|iti| d|ƒt| ƒdjo|iti|d|ƒn|i|ƒ|iƒdSdS( sO(col, evt) -> display a popup menu when a column label is right clickedis Delete Col(s)s Sort ColumncCs*|iƒ}|ii|ƒ|iƒdS(N(sselfsGetSelectedColsscolss_tables DeleteColssReset(seventsselfscolscols((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pysdeleteys cCs|ii|ƒ|iƒdS(N(sselfs_tables SortColumnscolsReset(seventsselfscol((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pyssort~ssidiN(sselfs GetColSizescolsxswxsMenusmenusNewIdsid1ssortIDsevts GetPositionsxosyos SelectColsGetSelectedColsscolssRefreshsAppendsdeletessortsBindsEVT_MENUslens PopupMenusDestroy( sselfscolsevtssortsxosyosmenussortIDsid1scolssxsdelete((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pyscolPopupjs&        (s__name__s __module__sNones__init__sResetsOnLabelRightClickedsrowPopupscolPopup(((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pysMegaGrid1s     sRowsThissIssAsTestièisMegaFontRendererFactorycBstZd„Zd„ZRS(NcCs||_||_||_dS(sà (color, font, fontsize) -> set of a factory to generate renderers when called. func = MegaFontRenderFactory(color, font, fontsize) renderer = func(table) N(scolorsselfsfontsfontsize(sselfscolorsfontsfontsize((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pys__init__£s  cCs t||i|i|iƒSdS(N(sMegaFontRendererstablesselfscolorsfontsfontsize(sselfstable((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pys__call__®s(s__name__s __module__s__init__s__call__(((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pysMegaFontRendererFactory¢s s TestFramecBsGtZhdedddƒ<de<deddd ƒ
  • Uses a virtual grid
  • Columns and rows have popup menus (right click on labels)
  • Columns and rows can be deleted (i.e. table can be resized)
  • Dynamic renderers. Renderers are plugins based on column header name. Shows a simple Font Renderer and an Image Renderer. Look for 'XXX' in the code to indicate some workarounds for non-obvious behavior and various hacks. s__main__sii(%swxswx.gridsgridsGridsimagessPyGridTableBases MegaTablesPyGridCellRenderersMegaImageRenderersMegaFontRenderersMegaGridsrandomscolnamessdatasrangesrowsdsnameslenschoicesappendsstrsMegaFontRendererFactorysFrames TestFramesPanels TestPanelsrunTestsoverviews__name__ssyssossrunsmainspathsbasenamesargv(soverviewsrandoms TestFramesimagessrows MegaTablesMegaFontRendererFactorysGridswxs TestPanelsMegaGridsrunsMegaFontRendererssysscolnamessdatasnamesdsMegaImageRenderersrunTestsos((sp/mnt/gmirror/ports/x11-toolkits/py-wxPython26-common/work/wxPython-src-2.6.3.3/wxPython/demo/Grid_MegaExample.pys?s6   µ1Ba