wx.grid: Copying Entered Data Across A Selected Range

All

I’m looking for a solution to a wx.grid problem and I am hoping someone can assist. The behavior I want from the grid is like this:

  1. User selects a range of at least 2 cells horizontally (say Column C, Rows 3-9)

  2. User keys in data into the first cell in the selection (C3)

  3. User completes edit, and exits cell by pressing Enter, or any of the arrow keys.

  4. Program takes the value entered into the first cell in the selection (C3), and copies that value to the remaining cells in the selection (C4-C9).

I have tried a couple of different methods of solving this problem, but my noobness is showing:

-Binding directly to the select/change events (EVT_GRID_RANGE_SELECT, EVT_GRID_CELL_CHANGE, EVT_GRID_SELECT_CELL, EVT_GRID_EDITOR_CREATED), which had problems holding the selection after the Enter or arrow keys were pressed

-Using the wx.grid.PyCellEditor (which can’t tell the selected range in the grid)

Any thoughts? I can post code, if needed.

Using Python 2.7.2, wxPython 2.8.12.1 on OS X 10.8.1.

Thanks

-Ed

Ed,
I would have thought that you would have needed something along the
lines of:

···

On 28/08/2012 10:12 PM, edoxtator
wrote:

All

    I'm looking for a solution to a wx.grid problem and I am

hoping someone can assist. The behavior I want from the grid is
like this:

    1.  User selects a range of at least 2 cells horizontally

(say Column C, Rows 3-9)

    2.  User keys in data into the first cell in the selection

(C3)

    3.  User completes edit, and exits cell by pressing Enter, or

any of the arrow keys.

    4.  Program takes the value entered into the first cell in

the selection (C3), and copies that value to the remaining cells
in the selection (C4-C9).

    I have tried a couple of different methods of solving this

problem, but my noobness is showing:

    -Binding directly to the select/change events

(EVT_GRID_RANGE_SELECT, EVT_GRID_CELL_CHANGE,
EVT_GRID_SELECT_CELL, EVT_GRID_EDITOR_CREATED), which had
problems holding the selection after the Enter or arrow keys
were pressed

    -Using the wx.grid.PyCellEditor (which can't tell the

selected range in the grid)

Any thoughts? I can post code, if needed.

Using Python 2.7.2, wxPython 2.8.12.1 on OS X 10.8.1.

Thanks

-Ed

  To unsubscribe, send email to

or visit

  •     In a range select handler store the details of what is
    
    selected to self.LastSelectedRange,
  • In all the other select handlers clear self.LastSelectedRange,
  •     In whichever event tells you an edit has ended check if
    
    self.LastSelectedRange is set and if it is copy your new value
    to all the cells in the range.
    Gadget/Steve

wxPython-users+unsubscribe@googlegroups.com
http://groups.google.com/group/wxPython-users?hl=en