SetGridCursor not working?

Hello!
I have a table with some rows and cells (code at the end), and created
a function which searches for text inside the cells and returns the
row number where the text is (to simplify the example, only English
Name is working). Then, it should set the grid cursor focus to that
row (I want to use the wx.grid.Grid.SelectRows style when created the
wx.Grid, but to reduce the number of variables I don't use it in the
example). To set the cursor focus, I am using

def OnSearch(self, event):
    CommonName = self.CommonNameTXT.GetValue()
    if CommonName != '':
        ind = self.parent.EnglishNameList.index(CommonName)
        self.parent.SpeciesGrid.SetGridCursor(ind, 0)
        self.parent.SpeciesGrid.MakeCellVisible(ind,0)

Theoretically, it should work using only the SetGridCursor method,
however somewhere I have read that it will not work unless you also
use the MaceCellVisible method as well. Anyway, it does not work at
all. Can anyone help?

Dani

1 Like

Hello!
Can anyone help, please? This is a very important feature for my application ... :wink:
Thank you so much!

Dani

···

On 09/22/2010 08:45 PM, acrocephalus wrote:

Hello!
I have a table with some rows and cells (code at the end), and created
a function which searches for text inside the cells and returns the
row number where the text is (to simplify the example, only English
Name is working). Then, it should set the grid cursor focus to that
row (I want to use the wx.grid.Grid.SelectRows style when created the
wx.Grid, but to reduce the number of variables I don't use it in the
example). To set the cursor focus, I am using

def OnSearch(self, event):
     CommonName = self.CommonNameTXT.GetValue()
     if CommonName != '':
         ind = self.parent.EnglishNameList.index(CommonName)
         self.parent.SpeciesGrid.SetGridCursor(ind, 0)
         self.parent.SpeciesGrid.MakeCellVisible(ind,0)

Theoretically, it should work using only the SetGridCursor method,
however somewhere I have read that it will not work unless you also
use the MaceCellVisible method as well. Anyway, it does not work at
all. Can anyone help?

  Dani

--
Daniel Valverde Saub�
c/Joan Maragall 37 4 2
17002 Girona
Spain
Tel�fon m�bil: +34651987662
e-mail: dani.valverde@gmail.com
http://www.acrocephalus.net
http://natupics.blogspot.com

Si no �s del tot necessari, no imprimeixis aquest missatge. Si ho fas utilitza paper 100% reciclat i blanquejat sense clor. D'aquesta manera ajudar�s a estalviar aigua, energia i recursos forestals. GR�CIES!

Do not print this message unless it is absolutely necessary. If you must print it, please use 100% recycled paper whitened without chlorine. By doing so, you will save water, energy and forest resources. THANK YOU!

It's working for me. What platform and version are you using? Please make a small runnable sample that demonstrates the problem. MakingSampleApps - wxPyWiki

···

On 9/23/10 3:15 PM, Dani Valverde wrote:

Hello!
Can anyone help, please? This is a very important feature for my
application ... :wink:
Thank you so much!

Dani

On 09/22/2010 08:45 PM, acrocephalus wrote:

Hello!
I have a table with some rows and cells (code at the end), and created
a function which searches for text inside the cells and returns the
row number where the text is (to simplify the example, only English
Name is working). Then, it should set the grid cursor focus to that
row (I want to use the wx.grid.Grid.SelectRows style when created the
wx.Grid, but to reduce the number of variables I don't use it in the
example). To set the cursor focus, I am using

def OnSearch(self, event):
CommonName = self.CommonNameTXT.GetValue()
if CommonName != '':
ind = self.parent.EnglishNameList.index(CommonName)
self.parent.SpeciesGrid.SetGridCursor(ind, 0)
self.parent.SpeciesGrid.MakeCellVisible(ind,0)

Theoretically, it should work using only the SetGridCursor method,
however somewhere I have read that it will not work unless you also
use the MaceCellVisible method as well. Anyway, it does not work at
all. Can anyone help?

--
Robin Dunn
Software Craftsman

Oops! I forgot to attach the runnable example. Sorry, find it attached. Please, note that only the English Name control is working. It returns the correct row number to the terminal, but it doesn't set the cursor focus to any row. I am using Linux Ubuntu Lucid Lynx, Python 2.6.5 and wx.python 2.8.11. I hope it helps.
Cheers!

Dani

test.txt (5.08 KB)

···

On 09/24/2010 12:47 AM, Robin Dunn wrote:

On 9/23/10 3:15 PM, Dani Valverde wrote:

Hello!
Can anyone help, please? This is a very important feature for my
application ... :wink:
Thank you so much!

Dani

On 09/22/2010 08:45 PM, acrocephalus wrote:

Hello!
I have a table with some rows and cells (code at the end), and created
a function which searches for text inside the cells and returns the
row number where the text is (to simplify the example, only English
Name is working). Then, it should set the grid cursor focus to that
row (I want to use the wx.grid.Grid.SelectRows style when created the
wx.Grid, but to reduce the number of variables I don't use it in the
example). To set the cursor focus, I am using

def OnSearch(self, event):
CommonName = self.CommonNameTXT.GetValue()
if CommonName != '':
ind = self.parent.EnglishNameList.index(CommonName)
self.parent.SpeciesGrid.SetGridCursor(ind, 0)
self.parent.SpeciesGrid.MakeCellVisible(ind,0)

Theoretically, it should work using only the SetGridCursor method,
however somewhere I have read that it will not work unless you also
use the MaceCellVisible method as well. Anyway, it does not work at
all. Can anyone help?

It's working for me. What platform and version are you using? Please make a small runnable sample that demonstrates the problem. MakingSampleApps - wxPyWiki

--
Daniel Valverde Saub�
c/Joan Maragall 37 4 2
17002 Girona
Spain
Tel�fon m�bil: +34651987662
e-mail: dani.valverde@gmail.com
http://www.acrocephalus.net
http://natupics.blogspot.com

Si no �s del tot necessari, no imprimeixis aquest missatge. Si ho fas utilitza paper 100% reciclat i blanquejat sense clor. D'aquesta manera ajudar�s a estalviar aigua, energia i recursos forestals. GR�CIES!

Do not print this message unless it is absolutely necessary. If you must print it, please use 100% recycled paper whitened without chlorine. By doing so, you will save water, energy and forest resources. THANK YOU!

Hello Robin,
Did you recieved the runnable example (I send it again just in case)? Did it worked for you?
Cheers!

Dani

test.txt (5.26 KB)

···

On 09/24/2010 02:21 AM, Dani Valverde wrote:

On 09/24/2010 12:47 AM, Robin Dunn wrote:

On 9/23/10 3:15 PM, Dani Valverde wrote:

Hello!
Can anyone help, please? This is a very important feature for my
application ... :wink:
Thank you so much!

Dani

On 09/22/2010 08:45 PM, acrocephalus wrote:

Hello!
I have a table with some rows and cells (code at the end), and created
a function which searches for text inside the cells and returns the
row number where the text is (to simplify the example, only English
Name is working). Then, it should set the grid cursor focus to that
row (I want to use the wx.grid.Grid.SelectRows style when created the
wx.Grid, but to reduce the number of variables I don't use it in the
example). To set the cursor focus, I am using

def OnSearch(self, event):
CommonName = self.CommonNameTXT.GetValue()
if CommonName != '':
ind = self.parent.EnglishNameList.index(CommonName)
self.parent.SpeciesGrid.SetGridCursor(ind, 0)
self.parent.SpeciesGrid.MakeCellVisible(ind,0)

Theoretically, it should work using only the SetGridCursor method,
however somewhere I have read that it will not work unless you also
use the MaceCellVisible method as well. Anyway, it does not work at
all. Can anyone help?

It's working for me. What platform and version are you using? Please make a small runnable sample that demonstrates the problem. MakingSampleApps - wxPyWiki

Oops! I forgot to attach the runnable example. Sorry, find it attached. Please, note that only the English Name control is working. It returns the correct row number to the terminal, but it doesn't set the cursor focus to any row. I am using Linux Ubuntu Lucid Lynx, Python 2.6.5 and wx.python 2.8.11. I hope it helps.
Cheers!

Dani

--
Daniel Valverde Saub�
c/Joan Maragall 37 4 2
17002 Girona
Spain
Tel�fon m�bil: +34651987662
e-mail: dani.valverde@gmail.com
http://www.acrocephalus.net
http://natupics.blogspot.com

Si no �s del tot necessari, no imprimeixis aquest missatge. Si ho fas utilitza paper 100% reciclat i blanquejat sense clor. D'aquesta manera ajudar�s a estalviar aigua, energia i recursos forestals. GR�CIES!

Do not print this message unless it is absolutely necessary. If you must print it, please use 100% recycled paper whitened without chlorine. By doing so, you will save water, energy and forest resources. THANK YOU!

Ah, you didn't mention that you are using row selection mode...

SetGridCursor is moving the cursor (the thicker lines around the current cell) just as the code is telling it to, it just isn't moving the row selection. And since the grid does not have the focus (the Search button does) you can't see the cursor moving because it is only drawn when the grid has the focus. Adding this to your OnSelectCell method will make it work more like what you are expecting:

  self.SpeciesGrid.SelectRow(self.row)

···

On 9/23/10 5:21 PM, Dani Valverde wrote:

On 09/24/2010 12:47 AM, Robin Dunn wrote:

On 9/23/10 3:15 PM, Dani Valverde wrote:

Hello!
Can anyone help, please? This is a very important feature for my
application ... :wink:
Thank you so much!

Dani

On 09/22/2010 08:45 PM, acrocephalus wrote:

Hello!
I have a table with some rows and cells (code at the end), and created
a function which searches for text inside the cells and returns the
row number where the text is (to simplify the example, only English
Name is working). Then, it should set the grid cursor focus to that
row (I want to use the wx.grid.Grid.SelectRows style when created the
wx.Grid, but to reduce the number of variables I don't use it in the
example). To set the cursor focus, I am using

def OnSearch(self, event):
CommonName = self.CommonNameTXT.GetValue()
if CommonName != '':
ind = self.parent.EnglishNameList.index(CommonName)
self.parent.SpeciesGrid.SetGridCursor(ind, 0)
self.parent.SpeciesGrid.MakeCellVisible(ind,0)

Theoretically, it should work using only the SetGridCursor method,
however somewhere I have read that it will not work unless you also
use the MaceCellVisible method as well. Anyway, it does not work at
all. Can anyone help?

It's working for me. What platform and version are you using? Please
make a small runnable sample that demonstrates the problem.
MakingSampleApps - wxPyWiki

Oops! I forgot to attach the runnable example. Sorry, find it attached.
Please, note that only the English Name control is working. It returns
the correct row number to the terminal, but it doesn't set the cursor
focus to any row. I am using Linux Ubuntu Lucid Lynx, Python 2.6.5 and
wx.python 2.8.11. I hope it helps.

--
Robin Dunn
Software Craftsman

1 Like

Thank you so much. Not it sets the cursor focus properly. However, if the searched string is outside the visible region, it does not scroll the grid to this row. For example, in the new example I provide, if you search for the "Killdeer", which is outside the visible area, it focuses the focus on the row of interest but it does not scroll the grid to make it visible, you have to do it manually. It it possible to make the grid behave like this?
Cheers!

Dani

test.txt (5.79 KB)

···

On 09/25/2010 01:08 AM, Robin Dunn wrote:

On 9/23/10 5:21 PM, Dani Valverde wrote:

On 09/24/2010 12:47 AM, Robin Dunn wrote:

On 9/23/10 3:15 PM, Dani Valverde wrote:

Hello!
Can anyone help, please? This is a very important feature for my
application ... :wink:
Thank you so much!

Dani

On 09/22/2010 08:45 PM, acrocephalus wrote:

Hello!
I have a table with some rows and cells (code at the end), and created
a function which searches for text inside the cells and returns the
row number where the text is (to simplify the example, only English
Name is working). Then, it should set the grid cursor focus to that
row (I want to use the wx.grid.Grid.SelectRows style when created the
wx.Grid, but to reduce the number of variables I don't use it in the
example). To set the cursor focus, I am using

def OnSearch(self, event):
CommonName = self.CommonNameTXT.GetValue()
if CommonName != '':
ind = self.parent.EnglishNameList.index(CommonName)
self.parent.SpeciesGrid.SetGridCursor(ind, 0)
self.parent.SpeciesGrid.MakeCellVisible(ind,0)

Theoretically, it should work using only the SetGridCursor method,
however somewhere I have read that it will not work unless you also
use the MaceCellVisible method as well. Anyway, it does not work at
all. Can anyone help?

It's working for me. What platform and version are you using? Please
make a small runnable sample that demonstrates the problem.
MakingSampleApps - wxPyWiki

Oops! I forgot to attach the runnable example. Sorry, find it attached.
Please, note that only the English Name control is working. It returns
the correct row number to the terminal, but it doesn't set the cursor
focus to any row. I am using Linux Ubuntu Lucid Lynx, Python 2.6.5 and
wx.python 2.8.11. I hope it helps.

Ah, you didn't mention that you are using row selection mode...

SetGridCursor is moving the cursor (the thicker lines around the current cell) just as the code is telling it to, it just isn't moving the row selection. And since the grid does not have the focus (the Search button does) you can't see the cursor moving because it is only drawn when the grid has the focus. Adding this to your OnSelectCell method will make it work more like what you are expecting:

    self.SpeciesGrid.SelectRow(self.row)

--
Daniel Valverde Saub�
c/Joan Maragall 37 4 2
17002 Girona
Spain
Tel�fon m�bil: +34651987662
e-mail: dani.valverde@gmail.com
http://www.acrocephalus.net
http://natupics.blogspot.com

Si no �s del tot necessari, no imprimeixis aquest missatge. Si ho fas utilitza paper 100% reciclat i blanquejat sense clor. D'aquesta manera ajudar�s a estalviar aigua, energia i recursos forestals. GR�CIES!

Do not print this message unless it is absolutely necessary. If you must print it, please use 100% recycled paper whitened without chlorine. By doing so, you will save water, energy and forest resources. THANK YOU!

MakeCellVisible(self, row, col)

should do it.

Werner

···

On 25/09/2010 10:24, Dani Valverde wrote:

On 09/25/2010 01:08 AM, Robin Dunn wrote:

On 9/23/10 5:21 PM, Dani Valverde wrote:

On 09/24/2010 12:47 AM, Robin Dunn wrote:

On 9/23/10 3:15 PM, Dani Valverde wrote:

Hello!
Can anyone help, please? This is a very important feature for my
application ... :wink:
Thank you so much!

Dani

On 09/22/2010 08:45 PM, acrocephalus wrote:

Hello!
I have a table with some rows and cells (code at the end), and created
a function which searches for text inside the cells and returns the
row number where the text is (to simplify the example, only English
Name is working). Then, it should set the grid cursor focus to that
row (I want to use the wx.grid.Grid.SelectRows style when created the
wx.Grid, but to reduce the number of variables I don't use it in the
example). To set the cursor focus, I am using

def OnSearch(self, event):
CommonName = self.CommonNameTXT.GetValue()
if CommonName != '':
ind = self.parent.EnglishNameList.index(CommonName)
self.parent.SpeciesGrid.SetGridCursor(ind, 0)
self.parent.SpeciesGrid.MakeCellVisible(ind,0)

Theoretically, it should work using only the SetGridCursor method,
however somewhere I have read that it will not work unless you also
use the MaceCellVisible method as well. Anyway, it does not work at
all. Can anyone help?

It's working for me. What platform and version are you using? Please
make a small runnable sample that demonstrates the problem.
MakingSampleApps - wxPyWiki

Oops! I forgot to attach the runnable example. Sorry, find it attached.
Please, note that only the English Name control is working. It returns
the correct row number to the terminal, but it doesn't set the cursor
focus to any row. I am using Linux Ubuntu Lucid Lynx, Python 2.6.5 and
wx.python 2.8.11. I hope it helps.

Ah, you didn't mention that you are using row selection mode...

SetGridCursor is moving the cursor (the thicker lines around the current cell) just as the code is telling it to, it just isn't moving the row selection. And since the grid does not have the focus (the Search button does) you can't see the cursor moving because it is only drawn when the grid has the focus. Adding this to your OnSelectCell method will make it work more like what you are expecting:

    self.SpeciesGrid.SelectRow(self.row)

Thank you so much. Not it sets the cursor focus properly. However, if the searched string is outside the visible region, it does not scroll the grid to this row. For example, in the new example I provide, if you search for the "Killdeer", which is outside the visible area, it focuses the focus on the row of interest but it does not scroll the grid to make it visible, you have to do it manually. It it possible to make the grid behave like this?
Cheers!