Browse files

Grid switching bug fixed

  • Loading branch information...
1 parent dde5dcf commit ca7551db6c28d979b71d513a7225b74c9c402a88 @manns committed Mar 18, 2012
View
4 pyspread/src/actions/_grid_actions.py
@@ -880,8 +880,8 @@ def switch_to_table(self, event):
newtable = event.newtable
- no_tabs = self.grid.code_array.shape[2]
-
+ no_tabs = self.grid.code_array.shape[2] - 1
+
if 0 <= newtable <= no_tabs:
self.grid.current_table = newtable
self.main_window.table_choice.SetMax(newtable+1)
View
2 pyspread/src/gui/_dialogs.py
@@ -74,7 +74,7 @@ def TransferFromWindow(self):
return True
def Clone(self):
- return Validator()
+ return wx.Validator()
def Validate(self, win):
"""Returns True if Value in digits, False otherwise"""
View
1 pyspread/src/gui/_events.py
@@ -204,6 +204,7 @@ def post_command_event(target, msg_cls, **kwargs):
GridActionOpenMsg, EVT_COMMAND_GRID_ACTION_OPEN = new_command_event()
GridActionSaveMsg, EVT_COMMAND_GRID_ACTION_SAVE = new_command_event()
+# For calling the grid
GridActionTableSwitchMsg, EVT_COMMAND_GRID_ACTION_TABLE_SWITCH = \
new_command_event()
View
16 pyspread/src/gui/_widgets.py
@@ -759,22 +759,30 @@ def change_max(self, no_tabs):
\tNumber of tables for choice
"""
-
+
+ self.no_tabs = no_tabs
+
if self.GetValue() >= no_tabs:
self.SetValue(no_tabs - 1)
-
+
self.SetMax(no_tabs - 1)
# Event handlers
def OnResizeGrid(self, event):
"""Event handler for grid resizing"""
-
+
self.change_max(event.shape[2])
def OnInt(self, event):
"""IntCtrl event method that updates the current table"""
+ self.SetMax(self.no_tabs - 1)
+ if event.GetValue() > self.GetMax():
+ print event.GetValue(), self.GetMax()
+ self.SetValue(self.GetMax())
+ return
+
if not self.switching:
self.switching = True
post_command_event(self, GridActionTableSwitchMsg,
@@ -785,6 +793,8 @@ def OnInt(self, event):
def OnMouseWheel(self, event):
"""Mouse wheel event handler"""
+ self.SetMax(self.no_tabs - 1)
+
if event.GetWheelRotation() > 0:
new_table = self.GetValue() + 1
else:

0 comments on commit ca7551d

Please sign in to comment.