2 problems I am facing. Grid and autocomplete in textCtrl

Hi folks

I am facing 2 problems.

1)
I tried googlig for the last 4 hours and I am getting crazy
I can not find the method how to highlight a specific row in a grid
when I click on a cell in the row. It should look like when I click od
the label of a row.
I thought myself of just changing the background color but this does
not sattisfy me.

def OnGridPregledGridCellLeftClick(self, event):
    self.grid.XXX(event.GetRow())

is there any way to to this.

2)

The second thing I am needing help with is a problem I am facing with
Events of a TextCtrl.

I wanted to create an autocomplete TextCtrl that is connected with a
database from witch it gets the suggested words.

self.txtUlica = wx.TextCtrl(-1, name='txtUlica',
              parent=self, pos=wx.Point(352, 48), size=wx.Size(120,
21),
              style=0, value='')
self.txtUlica.Bind(wx.EVT_TEXT, self.OnTxtUlicaText,
              self.txtUlica)

···

---------------------------------------------

    def OnTxtUlicaText(self, event):
        currentUlica = self.txtUlica.GetValue()
        suggestedUlica = self.DbAdapter.selByLike(currentUlica)
        if suggestedUlica != "None":
            self.txtUlica.SetValue(suggestedUlica)
            self.txtUlica.SetSelection(len(currentUlica), len
(suggestedUlica))

------------------------------------------

Here I need some advise. Till now It is working fine. If I want to
write for example "Carry" and I type "Car", it writes Carry and
selects the part "ry". But if I want to write "Car", then "ry" stays
anyway even if I try to delete it.
So I thought myself to bind also another Eventhandler wich would react
with the TAB or ENTER key. I thought myself that this could be
wx.EVT_TEXT_ENTER event but I failed.

Any advise how to do it? Or is it maybe the KeyEvents

Thnx

You just need to call

self.grid.SelectRow(event.GetRow())

To browse all the methods, do this:

dir(wx.grid.Grid)

That's how I found it. But it's also listed in the docs:

http://www.wxpython.org/docs/api/wx.grid.Grid-class.html

HTH

- Mike

···

On Aug 18, 12:13 pm, azrael <jura.gro...@gmail.com> wrote:

Hi folks

I am facing 2 problems.

1)
I tried googlig for the last 4 hours and I am getting crazy
I can not find the method how to highlight a specific row in a grid
when I click on a cell in the row. It should look like when I click od
the label of a row.
I thought myself of just changing the background color but this does
not sattisfy me.

def OnGridPregledGridCellLeftClick(self, event):
self.grid.XXX(event.GetRow())

is there any way to to this.

I Allready tried that. It only sets the value of a row in a list that
is retrived through the GetSelectedRows method. It does not highlight
the entire row. The highlighting is the thing that is bugging me.

···

On 18 kol, 19:53, Mike Driscoll <kyoso...@gmail.com> wrote:

On Aug 18, 12:13 pm, azrael <jura.gro...@gmail.com> wrote:

> Hi folks

> I am facing 2 problems.

> 1)
> I tried googlig for the last 4 hours and I am getting crazy
> I can not find the method how to highlight a specific row in a grid
> when I click on a cell in the row. It should look like when I click od
> the label of a row.
> I thought myself of just changing the background color but this does
> not sattisfy me.

> def OnGridPregledGridCellLeftClick(self, event):
> self.grid.XXX(event.GetRow())

> is there any way to to this.

You just need to call

self.grid.SelectRow(event.GetRow())

To browse all the methods, do this:

dir(wx.grid.Grid)

That's how I found it. But it's also listed in the docs:

wxPython API Documentation — wxPython Phoenix 4.2.2 documentation

HTH

- Mike

I Allready tried that. It only sets the value of a row in a list that
is retrived through the GetSelectedRows method. It does not highlight
the entire row. The highlighting is the thing that is bugging me.

It highlights the entire row for me on Windows XP, Python 2.5,
wxPython 2.8.10.1. Otherwise, I wouldn't have posted that.

- Mike

···

On Aug 18, 2:36 pm, azrael <jura.gro...@gmail.com> wrote:

On 18 kol, 19:53, Mike Driscoll <kyoso...@gmail.com> wrote:

> On Aug 18, 12:13 pm, azrael <jura.gro...@gmail.com> wrote:

> > Hi folks

> > I am facing 2 problems.

> > 1)
> > I tried googlig for the last 4 hours and I am getting crazy
> > I can not find the method how to highlight a specific row in a grid
> > when I click on a cell in the row. It should look like when I click od
> > the label of a row.
> > I thought myself of just changing the background color but this does
> > not sattisfy me.

> > def OnGridPregledGridCellLeftClick(self, event):
> > self.grid.XXX(event.GetRow())

> > is there any way to to this.

> You just need to call

> self.grid.SelectRow(event.GetRow())

> To browse all the methods, do this:

> dir(wx.grid.Grid)

> That's how I found it. But it's also listed in the docs:

>wxPython API Documentation — wxPython Phoenix 4.2.2 documentation

> HTH

> - Mike

WELL I guess I found a BUG in my release.:smiley: Nothing happens in my
applications. thanks

···

On 18 kol, 22:24, Mike Driscoll <kyoso...@gmail.com> wrote:

On Aug 18, 2:36 pm, azrael <jura.gro...@gmail.com> wrote:

> I Allready tried that. It only sets the value of a row in a list that
> is retrived through the GetSelectedRows method. It does not highlight
> the entire row. The highlighting is the thing that is bugging me.

It highlights the entire row for me on Windows XP, Python 2.5,
wxPython 2.8.10.1. Otherwise, I wouldn't have posted that.

- Mike

> On 18 kol, 19:53, Mike Driscoll <kyoso...@gmail.com> wrote:

> > On Aug 18, 12:13 pm, azrael <jura.gro...@gmail.com> wrote:

> > > Hi folks

> > > I am facing 2 problems.

> > > 1)
> > > I tried googlig for the last 4 hours and I am getting crazy
> > > I can not find the method how to highlight a specific row in a grid
> > > when I click on a cell in the row. It should look like when I click od
> > > the label of a row.
> > > I thought myself of just changing the background color but this does
> > > not sattisfy me.

> > > def OnGridPregledGridCellLeftClick(self, event):
> > > self.grid.XXX(event.GetRow())

> > > is there any way to to this.

> > You just need to call

> > self.grid.SelectRow(event.GetRow())

> > To browse all the methods, do this:

> > dir(wx.grid.Grid)

> > That's how I found it. But it's also listed in the docs:

> >wxPython API Documentation — wxPython Phoenix 4.2.2 documentation

> > HTH

> > - Mike

Hi,

WELL I guess I found a BUG in my release.:smiley: Nothing happens in my
applications. thanks

It would be good if you gave what OS, Python and wxPython versions you
are using so others could try to replicate the problem.

- Mike

···

On Aug 18, 9:55 pm, azrael <jura.gro...@gmail.com> wrote:

On 18 kol, 22:24, Mike Driscoll <kyoso...@gmail.com> wrote:

> On Aug 18, 2:36 pm, azrael <jura.gro...@gmail.com> wrote:

> > I Allready tried that. It only sets the value of a row in a list that
> > is retrived through the GetSelectedRows method. It does not highlight
> > the entire row. The highlighting is the thing that is bugging me.

> It highlights the entire row for me on Windows XP, Python 2.5,
> wxPython 2.8.10.1. Otherwise, I wouldn't have posted that.

> - Mike

> > On 18 kol, 19:53, Mike Driscoll <kyoso...@gmail.com> wrote:

> > > On Aug 18, 12:13 pm, azrael <jura.gro...@gmail.com> wrote:

> > > > Hi folks

> > > > I am facing 2 problems.

> > > > 1)
> > > > I tried googlig for the last 4 hours and I am getting crazy
> > > > I can not find the method how to highlight a specific row in a grid
> > > > when I click on a cell in the row. It should look like when I click od
> > > > the label of a row.
> > > > I thought myself of just changing the background color but this does
> > > > not sattisfy me.

> > > > def OnGridPregledGridCellLeftClick(self, event):
> > > > self.grid.XXX(event.GetRow())

> > > > is there any way to to this.

> > > You just need to call

> > > self.grid.SelectRow(event.GetRow())

> > > To browse all the methods, do this:

> > > dir(wx.grid.Grid)

> > > That's how I found it. But it's also listed in the docs:

> > >wxPython API Documentation — wxPython Phoenix 4.2.2 documentation

> > > HTH

> > > - Mike

Windows xp,
Python 2.5,
wxpython v.2.8.8.1

Any ideas about the other problem?

···

On 19 kol, 16:07, Mike Driscoll <kyoso...@gmail.com> wrote:

Hi,

On Aug 18, 9:55 pm, azrael <jura.gro...@gmail.com> wrote:

> WELL I guess I found a BUG in my release.:smiley: Nothing happens in my
> applications. thanks

It would be good if you gave what OS, Python and wxPython versions you
are using so others could try to replicate the problem.

- Mike

> On 18 kol, 22:24, Mike Driscoll <kyoso...@gmail.com> wrote:

> > On Aug 18, 2:36 pm, azrael <jura.gro...@gmail.com> wrote:

> > > I Allready tried that. It only sets the value of a row in a list that
> > > is retrived through the GetSelectedRows method. It does not highlight
> > > the entire row. The highlighting is the thing that is bugging me.

> > It highlights the entire row for me on Windows XP, Python 2.5,
> > wxPython 2.8.10.1. Otherwise, I wouldn't have posted that.

> > - Mike

> > > On 18 kol, 19:53, Mike Driscoll <kyoso...@gmail.com> wrote:

> > > > On Aug 18, 12:13 pm, azrael <jura.gro...@gmail.com> wrote:

> > > > > Hi folks

> > > > > I am facing 2 problems.

> > > > > 1)
> > > > > I tried googlig for the last 4 hours and I am getting crazy
> > > > > I can not find the method how to highlight a specific row in a grid
> > > > > when I click on a cell in the row. It should look like when I click od
> > > > > the label of a row.
> > > > > I thought myself of just changing the background color but this does
> > > > > not sattisfy me.

> > > > > def OnGridPregledGridCellLeftClick(self, event):
> > > > > self.grid.XXX(event.GetRow())

> > > > > is there any way to to this.

> > > > You just need to call

> > > > self.grid.SelectRow(event.GetRow())

> > > > To browse all the methods, do this:

> > > > dir(wx.grid.Grid)

> > > > That's how I found it. But it's also listed in the docs:

> > > >wxPython API Documentation — wxPython Phoenix 4.2.2 documentation

> > > > HTH

> > > > - Mike

Windows xp,
Python 2.5,
wxpython v.2.8.8.1

Any ideas about the other problem?

I don't know. You might want to upgrade your wxPython though. There's
a wiki entry on autocompletion that might help too:

http://wiki.wxpython.org/TextCtrlAutoComplete

Otherwise, hopefully someone else will drop in here.

- Mike

···

On Aug 19, 9:53 am, azrael <jura.gro...@gmail.com> wrote:

On 19 kol, 16:07, Mike Driscoll <kyoso...@gmail.com> wrote:

> Hi,

> On Aug 18, 9:55 pm, azrael <jura.gro...@gmail.com> wrote:

> > WELL I guess I found a BUG in my release.:smiley: Nothing happens in my
> > applications. thanks

> It would be good if you gave what OS, Python and wxPython versions you
> are using so others could try to replicate the problem.

> - Mike

> > On 18 kol, 22:24, Mike Driscoll <kyoso...@gmail.com> wrote:

> > > On Aug 18, 2:36 pm, azrael <jura.gro...@gmail.com> wrote:

> > > > I Allready tried that. It only sets the value of a row in a list that
> > > > is retrived through the GetSelectedRows method. It does not highlight
> > > > the entire row. The highlighting is the thing that is bugging me.

> > > It highlights the entire row for me on Windows XP, Python 2.5,
> > > wxPython 2.8.10.1. Otherwise, I wouldn't have posted that.

> > > - Mike

> > > > On 18 kol, 19:53, Mike Driscoll <kyoso...@gmail.com> wrote:

> > > > > On Aug 18, 12:13 pm, azrael <jura.gro...@gmail.com> wrote:

> > > > > > Hi folks

> > > > > > I am facing 2 problems.

> > > > > > 1)
> > > > > > I tried googlig for the last 4 hours and I am getting crazy
> > > > > > I can not find the method how to highlight a specific row in a grid
> > > > > > when I click on a cell in the row. It should look like when I click od
> > > > > > the label of a row.
> > > > > > I thought myself of just changing the background color but this does
> > > > > > not sattisfy me.

> > > > > > def OnGridPregledGridCellLeftClick(self, event):
> > > > > > self.grid.XXX(event.GetRow())

> > > > > > is there any way to to this.

> > > > > You just need to call

> > > > > self.grid.SelectRow(event.GetRow())

> > > > > To browse all the methods, do this:

> > > > > dir(wx.grid.Grid)

> > > > > That's how I found it. But it's also listed in the docs:

> > > > >wxPython API Documentation — wxPython Phoenix 4.2.2 documentation

> > > > > HTH

> > > > > - Mike

azrael wrote:

Here I need some advise. Till now It is working fine. If I want to
write for example "Carry" and I type "Car", it writes Carry and
selects the part "ry". But if I want to write "Car", then "ry" stays
anyway even if I try to delete it.
So I thought myself to bind also another Eventhandler wich would react
with the TAB or ENTER key. I thought myself that this could be
wx.EVT_TEXT_ENTER event but I failed.

Any advise how to do it? Or is it maybe the KeyEvents

If the widget is in a container that is taking care of the wx.TAB_TRAVERSAL then the Tab and Enter keys are going to be used for navigation and will likely be stolen before your event handlers get them. For the wx.TextCtrl there are the wx.TE_PROCESS_TAB and wx.TE_PROCESS_ENTER style flags that you can use that should let those keys result in EVT_CHAR and EVT_TEXT_ENTER events.

···

--
Robin Dunn
Software Craftsman

I Think that I can get it around through the event object and it's
getter method event.GetKeyCode()

I solved the other problem using elf.grid.SetSelectionMode
(wx.grid.Grid.wxGridSelectRows) plus I found something that can
improve it a bit. now it functions like a listctrl.
http://www.devpicayune.com/entry/200609272116

···

On 19 kol, 20:52, Robin Dunn <ro...@alldunn.com> wrote:

azrael wrote:
> Here I need some advise. Till now It is working fine. If I want to
> write for example "Carry" and I type "Car", it writes Carry and
> selects the part "ry". But if I want to write "Car", then "ry" stays
> anyway even if I try to delete it.
> So I thought myself to bind also another Eventhandler wich would react
> with the TAB or ENTER key. I thought myself that this could be
> wx.EVT_TEXT_ENTER event but I failed.

> Any advise how to do it? Or is it maybe the KeyEvents

If the widget is in a container that is taking care of the
wx.TAB_TRAVERSAL then the Tab and Enter keys are going to be used for
navigation and will likely be stolen before your event handlers get
them. For the wx.TextCtrl there are the wx.TE_PROCESS_TAB and
wx.TE_PROCESS_ENTER style flags that you can use that should let those
keys result in EVT_CHAR and EVT_TEXT_ENTER events.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org