Hello,
is there a way to change the behaviour of clicking a cell of a grid in the way that the content/text of the cell is not automatically selected?
Thanks for any help and hints,
Frank
Hello,
is there a way to change the behaviour of clicking a cell of a grid in the way that the content/text of the cell is not automatically selected?
Thanks for any help and hints,
Frank
Frank,
Hello,
is there a way to change the behaviour of clicking a cell of a grid in the way that the content/text of the cell is not automatically selected?
Thanks for any help and hints,
Frank
You can use the grid's SetReadOnly method, although I think it's for setting entire rows or columns to read-only. Of course, you can also bind to the left click and do something in the handler that keeps the using from editing the cell:
<code>
myGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnCellLeftClick)
def OnCellLeftClick(self, event):
# do something here
</code>
Something like this should work.
-------------------
Mike Driscoll
Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org
Hello,
Mike Driscoll wrote:
Frank,
Hello,
is there a way to change the behaviour of clicking a cell of a grid in the way that the content/text of the cell is not automatically selected?
Thanks for any help and hints,
FrankYou can use the grid's SetReadOnly method, although I think it's for setting entire rows or columns to read-only. Of course, you can also bind to the left click and do something in the handler that keeps the using from editing the cell:
<code>
myGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnCellLeftClick)
def OnCellLeftClick(self, event):
# do something here</code>
Something like this should work.
-------------------
Mike Driscoll
As you don't get many answers and if you still want to edit your the text in the cell and avoid selecting all the text when editing it, I suggest you to make your own GridCellEditor.
I think you can get an example from the wiki.
Mathias
Mathias Lorente schrieb:
As you don't get many answers and if you still want to edit your the text in the cell and avoid selecting all the text when editing it, I suggest you to make your own GridCellEditor.
I think you can get an example from the wiki.
I found an example in the wx-demo showing how to implement a custom celleditor (GridCustEditor.py). In the BeginEdit() method of the custom editor the value of the textctrl is explicitly selected with a call to SelSelection(). But uncommenting this statement does not change the behaviour. Additional uncommenting of SetFocus() for the textctrl gives me nearly what I want. After the third mouse click (the first selects the cell, the second activates the cell editor, and the third sets the cursor in the textctrl) the content is not selected. But Unfortunatly it was selected during the third mouse click, while the mouse button was pressed. I'm now experimenting with custom textctrls trying to prevent this. My goal is to be able to copy/paste content to a grid's cell which is selected somewhere else by pressing the middle mouse button.
cu, frank
Hi Frank,
Below are ideas to serve as basis…
You’d need a bind like so:
self.Bind(event=wx.grid.EVT_GRID_SELECT_CELL, handler=self.OnSelectCell, source=None)
and the function would be like so:
def OnSelectCell(self, evt):
row,col = evt.GetRow(),evt.GetCol()
self.cur_row = row
print '(row: %s, col: %s) selected' % (row,col)
evt.Skip()
Bye,
Ron.
-----Original Message-----
From: Frank Hempel [mailto:red_socks@gmx.de]
Sent: Friday, October 24, 2008 12:27
To: wxpython-users@lists.wxwidgets.org
Subject: [wxpython-users] Clicking in a grid selects cells’s content
Hello,
is there a way to change the behaviour of clicking a cell of a grid in the way that the content/text of the cell is not automatically selected?
Thanks for any help and hints,
Frank
The selection occurs when the cell editor is enacted.
So I suggest to subclass this editor (usually wx.grid.GridCellTextEditor or wx.grid.GridCellAutoWrapStringEditor).
Then bind the event wx.EVT_SET_FOCUS of the editor’s property Control, with:
editor.Control.Bind(wx.EVT_SET_FOCUS, self.OnEVT_SET_FOCUS)
Finally,
def OnEVT_SET_FOCUS(self, event):
it is possible to select whatever you like.
It is also possible to build a custom cell editor (see WxPython in Action by Rappin and Dunn).
I always use my own editors, and have no problem with selection because the editor never received the instruction to select the whole cell’s text.
2008/10/26 Barak, Ron Ron.Barak@lsi.com
Hi Frank,
Below are ideas to serve as basis…
You’d need a bind like so:
self.Bind(event=wx.grid.EVT_GRID_SELECT_CELL, handler=self.OnSelectCell, source=None)
and the function would be like so:
def OnSelectCell(self, evt): row,col = evt.GetRow(),evt.GetCol() self.cur_row = row print '(row: %s, col: %s) selected' % (row,col) evt.Skip()
Bye,
Ron.-----Original Message-----
From: Frank Hempel [mailto:red_socks@gmx.de]
Sent: Friday, October 24, 2008 12:27
To: wxpython-users@lists.wxwidgets.org
Subject: [wxpython-users] Clicking in a grid selects cells’s contentHello,
is there a way to change the behaviour of clicking a cell of a grid in the way that the content/text of the cell is not automatically selected?
Thanks for any help and hints,
Frank
wxpython-users mailing list