[Fxpy-commits] FXPy/examples table.py,1.4,1.5
Status: Inactive
Brought to you by:
lyle
From: Lyle J. <ly...@us...> - 2003-04-18 01:41:29
|
Update of /cvsroot/fxpy/FXPy/examples In directory sc8-pr-cvs1:/tmp/cvs-serv26313 Modified Files: table.py Log Message: Incorporated James Lockley's patches for the table.py example program. Index: table.py =================================================================== RCS file: /cvsroot/fxpy/FXPy/examples/table.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- table.py 7 Feb 2002 12:35:14 -0000 1.4 +++ table.py 18 Apr 2003 01:41:25 -0000 1.5 @@ -38,7 +38,7 @@ contents = FXVerticalFrame(self, LAYOUT_SIDE_TOP|FRAME_NONE|\ LAYOUT_FILL_X|LAYOUT_FILL_Y) - # Add a vertical fram layout manager + # Add a vertical frame layout manager frame = FXVerticalFrame(contents, FRAME_SUNKEN|FRAME_THICK|\ LAYOUT_FILL_X|LAYOUT_FILL_Y, 0,0,0,0, 0,0,0,0) @@ -51,13 +51,13 @@ self.table.setLeadingRows(1) self.table.setLeadingCols(1) - months = ['January', 'Feburary', 'March', 'April', 'May', 'June', + self.months = ['January', 'Feburary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] # Set the first and last fixed rows in the table row = 1 - for month in months: + for month in self.months: self.table.setItemText(0, row, month) self.table.setItemText(49, row, month) row = row + 1 @@ -69,7 +69,7 @@ # Set the scrollable part of the table for row in range(48): - for column in range(len(months)): + for column in range(len(self.months)): self.table.setItemText(row+1, column+1, "row %i; column %i" %(row+1, column+1)) @@ -121,7 +121,7 @@ return 1 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - def onCmdResizeTable(self, sel): + def onCmdResizeTable(self, sel, ptr, sender): # Create a dialog box dlg = FXDialogBox(self, "Resize Table") @@ -133,25 +133,25 @@ FXLabel(frame, "Rows :", None, LAYOUT_SIDE_LEFT|LAYOUT_CENTER_Y) # Add a text filed - rows = FXTextFiled(frame, 5, None, 0, JUSTIFY_RIGHT|FRAME_SUNKEN|\ + rows = FXTextField(frame, 5, None, 0, JUSTIFY_RIGHT|FRAME_SUNKEN|\ FRAME_THICK|LAYOUT_SIDE_LEFT|LAYOUT_CENTER_Y) # Add the "Columns" label FXLabel(frame, "Columns:", None, (LAYOUT_SIDE_LEFT|LAYOUT_CENTER_Y)) # Add atext field - cols = FXTextFiled(frame, 5, None, 0, JUSTIFY_RIGHT|FRAME_SUNKEN|\ + cols = FXTextField(frame, 5, None, 0, JUSTIFY_RIGHT|FRAME_SUNKEN|\ FRAME_THICK|LAYOUT_SIDE_LEFT|LAYOUT_CENTER_Y) - # Add a Cancle button - FXButton(frame, "Cancle", None, dlg, FXDialogBox.ID_CANCLE, + # Add a Cancel button + FXButton(frame, "Cancel", None, dlg, FXDialogBox.ID_CANCEL, (FRAME_RAISED|FRAME_THICK|LAYOUT_SIDE_LEFT|LAYOUT_CENTER_Y)) # Add an OK button FXButton(frame, " OK ", None, dlg, FXDialogBox.ID_ACCEPT, (FRAME_RAISED|FRAME_THICK|LAYOUT_SIDE_LEFT|LAYOUT_CENTER_Y)) - # Get the curretn number of rows and columns in the table + # Get the current number of rows and columns in the table curNoRows = self.table.getNumRows() curNoCols = self.table.getNumCols() @@ -164,20 +164,28 @@ if dlg.execute(): # Get the new number of rows and columns - newNoRows = rows.getText() - newNoCols = cols.getText() + newNoRows = int(rows.getText()) + newNoCols = int(cols.getText()) if newNoRows < 0: newNoRows = 0 if newNoCols < 0: newNoCols = 0 - self.table.setTableSize(newNoRows, newNoCols) - for row in range(newNoRows): - for col in range(newNoCols): - if row > curNoRows or col > curNoCols: - self.table.setItemText(row, col, - "row %i; column %i" %(row+1, column+1)) + self.table.setTableSize(newNoRows, newNoCols) + for row in range(0, newNoRows): + for col in range(0, newNoCols): + # minus 1 to tkae account of zero index + if (row > curNoRows-1) or col > (curNoCols-1): + if row == 0: + self.table.setItemText(row, col, + "%s" %self.months[col%12-1]) + elif col == 0: + self.table.setItemText(row, col, + "%i" %col) + else: + self.table.setItemText(row, col, + "row %i; column %i" %(row, col)) return 1 |