| | 66 | # Toolbar. |
|---|
| | 67 | button_size = (32, 32) |
|---|
| | 68 | tb = self.tb = wx.ToolBar(self, style=wx.TB_FLAT | wx.TB_NODIVIDER) |
|---|
| | 69 | tb.SetToolBitmapSize(button_size) |
|---|
| | 70 | # |
|---|
| | 71 | bmp = wx.ArtProvider_GetBitmap(wx.ART_ERROR, size=button_size) |
|---|
| | 72 | tb.AddLabelTool(10, 'Test', bmp, shortHelp='Autosize column data') |
|---|
| | 73 | self.Bind(wx.EVT_TOOL, self.on_autosize_grid_data__clicked, id=10) |
|---|
| | 74 | ## tb.AddSeparator() |
|---|
| | 75 | # |
|---|
| | 76 | bmp = wx.ArtProvider_GetBitmap(wx.ART_QUESTION, size=button_size) |
|---|
| | 77 | tb.AddLabelTool(20, 'Test', bmp, shortHelp='Autosize column headers') |
|---|
| | 78 | self.Bind(wx.EVT_TOOL, self.on_autosize_grid_headers__clicked, id=20) |
|---|
| | 79 | # |
|---|
| | 80 | bmp = wx.ArtProvider_GetBitmap(wx.ART_INFORMATION, size=button_size) |
|---|
| | 81 | tb.AddLabelTool(30, 'Test', bmp, shortHelp='Autosize column maximum') |
|---|
| | 82 | self.Bind(wx.EVT_TOOL, self.on_autosize_grid_max__clicked, id=30) |
|---|
| | 83 | # |
|---|
| | 84 | bmp = wx.ArtProvider_GetBitmap(wx.ART_WARNING, size=button_size) |
|---|
| | 85 | tb.AddLabelTool(40, 'Test', bmp) |
|---|
| | 86 | # |
|---|
| | 87 | bmp = wx.ArtProvider_GetBitmap(wx.ART_MISSING_IMAGE, size=button_size) |
|---|
| | 88 | tb.AddLabelTool(50, 'Test', bmp) |
|---|
| | 89 | tb.Realize() |
|---|
| | 90 | p = wx.aui.AuiPaneInfo() |
|---|
| | 91 | p.ToolbarPane() |
|---|
| | 92 | p.CloseButton(False) |
|---|
| | 93 | p.Floatable(False) |
|---|
| | 94 | p.LeftDockable(False) |
|---|
| | 95 | p.MaximizeButton(False) |
|---|
| | 96 | p.Movable(False) |
|---|
| | 97 | p.Name('%s_toolbar' % label(extent).lower()) |
|---|
| | 98 | p.RightDockable(False) |
|---|
| | 99 | p.Show() |
|---|
| | 100 | p.Top() |
|---|
| | 101 | mgr.AddPane(tb, p) |
|---|
| | 102 | # Grid. |
|---|
| | 103 | grid = self.grid = EntityGrid(self) |
|---|
| | 104 | grid.set_extent(extent) |
|---|
| | 105 | p = wx.aui.AuiPaneInfo() |
|---|
| | 106 | p.Caption('%s' % plural(extent)) |
|---|
| | 107 | p.CloseButton(False) |
|---|
| | 108 | p.Center() |
|---|
| | 109 | p.MaximizeButton(True) |
|---|
| | 110 | p.Name('%s_grid' % label(extent).lower()) |
|---|
| | 111 | p.Show() |
|---|
| | 112 | mgr.AddPane(grid, p) |
|---|
| | 113 | # Update. |
|---|
| | 114 | mgr.Update() |
|---|
| | 115 | |
|---|
| | 116 | def autosize_grid_data(self): |
|---|
| | 117 | grid = self.grid |
|---|
| | 118 | grid.Freeze() |
|---|
| | 119 | for n in range(grid.GetColumnCount()): |
|---|
| | 120 | grid.SetColumnWidth(n, wx.LIST_AUTOSIZE) |
|---|
| | 121 | ## width = grid.GetColumnWidth(n) + 10 |
|---|
| | 122 | ## grid.SetColumnWidth(n, width) |
|---|
| | 123 | grid.Thaw() |
|---|
| | 124 | |
|---|
| | 125 | def on_autosize_grid_data__clicked(self, event): |
|---|
| | 126 | self.autosize_grid_data() |
|---|
| | 127 | |
|---|
| | 128 | def autosize_grid_headers(self): |
|---|
| | 129 | grid = self.grid |
|---|
| | 130 | grid.Freeze() |
|---|
| | 131 | for n in range(grid.GetColumnCount()): |
|---|
| | 132 | grid.SetColumnWidth(n, wx.LIST_AUTOSIZE_USEHEADER) |
|---|
| | 133 | ## width = grid.GetColumnWidth(n) + 10 |
|---|
| | 134 | ## grid.SetColumnWidth(n, width) |
|---|
| | 135 | grid.Thaw() |
|---|
| | 136 | |
|---|
| | 137 | def on_autosize_grid_headers__clicked(self, event): |
|---|
| | 138 | self.autosize_grid_headers() |
|---|
| | 139 | |
|---|
| | 140 | def autosize_grid_max(self): |
|---|
| | 141 | grid = self.grid |
|---|
| | 142 | grid.Freeze() |
|---|
| | 143 | for n in range(grid.GetColumnCount()): |
|---|
| | 144 | grid.SetColumnWidth(n, wx.LIST_AUTOSIZE) |
|---|
| | 145 | width_1 = grid.GetColumnWidth(n) |
|---|
| | 146 | grid.SetColumnWidth(n, wx.LIST_AUTOSIZE_USEHEADER) |
|---|
| | 147 | width_2 = grid.GetColumnWidth(n) |
|---|
| | 148 | width = max(width_1, width_2) + 10 |
|---|
| | 149 | grid.SetColumnWidth(n, width) |
|---|
| | 150 | grid.Thaw() |
|---|
| | 151 | |
|---|
| | 152 | def on_autosize_grid_max__clicked(self, event): |
|---|
| | 153 | self.autosize_grid_max() |
|---|