wx.grid automatic cell focus

Hi,

···

On 3 April 2012 01:34, VC wrote:

I downloaded wxpython 2.9.3

I wrote this quick test:

import wx

class MyFrame(wx.Frame):

def __init__(self, parent, id, title ,pos, size):

    wx.Frame.__init__(self, parent, id, title, pos, size)

    self.Panel = wx.Panel(self, -1)

    self.Panel.SetBackgroundColour('grey')

    choicesList = ['one','two','three']

    self.RadioBox = wx.RadioBox(self.Panel, -1, 'chose a number',

                                choices = choicesList,

majorDimension = 3,

                                style = wx.RA_SPECIFY_ROWS)

class MyApp(wx.App):

def OnInit(self):

    self.Frame = MyFrame(None, -1, 'RadioBox test',

wx.DefaultPosition,

                         wx.DefaultSize)

    self.Frame.Show()

    return True

app = MyApp()

app.MainLoop()

It worked. The options showed correctly.

In my other program that i am writing that it is 500 lines long, i

have a similar implementation of the radiobox code and it does not

work.

That same code however displays a correct radiobox in wxpython 2.8.

Then it’s a bug in your code :slight_smile: . I would suggest one thing though: do not use capitalized attribute names (i.e., self.Panel, self.RadioBox etc…) as you may hit some funny stuff when your attributes conflict with wxPython windows properties (as they have capitalized names). See, for example, the list of properties wx.Window has starting from this:

http://xoomer.virgilio.it/infinity77/Phoenix/Window.html#Window.AcceleratorTable

So, just for the sake of it, use lower case starting names, i.e., self.panel (or self._panel or self.interestingPanel).

Andrea.

“Imagination Is The Only Weapon In The War Against Reality.”

http://xoomer.alice.it/infinity77/

I suggest that you use the WIT to see if something is maybe overlapping your rb.

When I changed your little test app to show how to "wit'ify" it I noticed two things.

- ctrl-alt-i is not bringing the WIT up if the radioBox has the focus, is the RB intercepting these keystrokes? Robin, is this a bug of RB or expected behaviour?

- the radioBox is not inheriting the background colour set on the parents panel in 2.9.3, it does in 2.8

Werner

radiobox.py (1.03 KB)

···

On 03/04/2012 01:34, VC wrote:

I downloaded wxpython 2.9.3

Thanks andrea for the advice, i will do that and use lower case. In my
code i thought maybe the problem was from that, i changed it to lower
case but it still had the same issue.

I know it seems like it is a problem in my code, but i have used the
same code as the one posted but just in a bigger program and it shows
the frame of the radiobox, the title of the radiobox and everything
just not the options.
That exact same code in my application works just fine in wxpython
2.8, not in wxpython 2.9.
I do not know why.

And werner is right, the radiobox in wxpython 2.9 does not take the
color of the background panel like in 2.8. So if the panel is grey the
radiobox stays white, whereas in 2.8 it is grey.

VC

···

On Apr 3, 1:29 am, Andrea Gavana <andrea.gav...@gmail.com> wrote:

Hi,

On 3 April 2012 01:34, VC wrote:

> I downloaded wxpython 2.9.3

> I wrote this quick test:

> import wx

> class MyFrame(wx.Frame):
> def __init__(self, parent, id, title ,pos, size):
> wx.Frame.__init__(self, parent, id, title, pos, size)
> self.Panel = wx.Panel(self, -1)
> self.Panel.SetBackgroundColour('grey')
> choicesList = ['one','two','three']
> self.RadioBox = wx.RadioBox(self.Panel, -1, 'chose a number',
> choices = choicesList,
> majorDimension = 3,
> style = wx.RA_SPECIFY_ROWS)

> class MyApp(wx.App):
> def OnInit(self):
> self.Frame = MyFrame(None, -1, 'RadioBox test',
> wx.DefaultPosition,
> wx.DefaultSize)
> self.Frame.Show()
> return True

> app = MyApp()
> app.MainLoop()

> It worked. The options showed correctly.

> In my other program that i am writing that it is 500 lines long, i
> have a similar implementation of the radiobox code and it does not
> work.
> That same code however displays a correct radiobox in wxpython 2.8.

Then it's a bug in your code :slight_smile: . I would suggest one thing though: do not
use capitalized attribute names (i.e., self.Panel, self.RadioBox etc...) as
you may hit some funny stuff when your attributes conflict with wxPython
windows properties (as they have capitalized names). See, for example, the
list of properties wx.Window has starting from this:

http://xoomer.virgilio.it/infinity77/Phoenix/Window.html#Window.Accel

So, just for the sake of it, use lower case starting names, i.e.,
self.panel (or self._panel or self.interestingPanel).

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."http://xoomer.alice.it/infinity77/- Hide quoted text -

- Show quoted text -

I am sorry, but what is WIT?

VC

···

On Apr 3, 4:10 am, Werner <werner.bru...@sfr.fr> wrote:

On 03/04/2012 01:34, VC wrote:

> I downloaded wxpython 2.9.3

I suggest that you use the WIT to see if something is maybe overlapping
your rb.

When I changed your little test app to show how to "wit'ify" it I
noticed two things.

- ctrl-alt-i is not bringing the WIT up if the radioBox has the focus,
is the RB intercepting these keystrokes? Robin, is this a bug of RB or
expected behaviour?

- the radioBox is not inheriting the background colour set on the
parents panel in 2.9.3, it does in 2.8

Werner

radiobox.py
1KViewDownload

http://wiki.wxpython.org/Widget%20Inspection%20Tool

In the changed sample I attached to the last message it is added, run the sample, click on the textctrl and press ctrl-alt-i.

BTW, any chance you could bottom post:).

Werner

···

On 03/04/2012 16:35, VC wrote:

I am sorry, but what is WIT?

that is what i got, i did not know what i was looking for:
Widget:
    name = 'radioBox'
    class = <class 'wx._controls.RadioBox'>
    bases = (<class 'wx._core.Control'>,)
    module = <module 'wx._controls' from 'C:\Python27\lib\site-packages
\wx-2.9.3-msw\wx\_controls.py'>
    this = '<Swig Object of type 'wxRadioBox *' at 0x2bdeca0>'
    id = -31992
    style = 8
    pos = (0, 0)
    size = (105, 95)
    minsize = (-1, -1)
    bestsize = (105, 95)
    client size = (105, 95)
    virtual size = (105, 95)
    IsEnabled = True
    IsShown = True
    IsFrozen = False
    fg color = (0, 0, 0, 255)
    bg color = (128, 128, 128, 255)
    label = 'chose a number'
    child count = 0 (direct) 0 (recursive) 0 (include TLWs)

VC

···

On Apr 3, 9:54 am, Werner <werner.bru...@sfr.fr> wrote:

On 03/04/2012 16:35, VC wrote:> I am sorry, but what is WIT?

http://wiki.wxpython.org/Widget%20Inspection%20Tool

In the changed sample I attached to the last message it is added, run
the sample, click on the textctrl and press ctrl-alt-i.

BTW, any chance you could bottom post:).

Werner

Good morning,

On 03/04/2012 16:35, VC wrote:> I am sorry, but what is WIT?

http://wiki.wxpython.org/Widget%20Inspection%20Tool

In the changed sample I attached to the last message it is added, run
the sample, click on the textctrl and press ctrl-alt-i.

BTW, any chance you could bottom post:).

Werner

that is what i got, i did not know what i was looking for:
Widget:
     name = 'radioBox'
     class =<class 'wx._controls.RadioBox'>

...

On the toolbar use the "Highlight" tool to see if anything is overlapping your RB. You can also use the PyCrust at the bottom to inspect the widget. In the widget tree you can inspect that the hierarchy of the widgets (parenting) is actually the way it should be, you can check the sizers and the options etc etc.

I use the WIT very often to figure out problems with my code.

If you still don't get anywhere with your actual problem then it is time to make a MakingSampleApps - wxPyWiki .

You have two ways for this:
1. add things you do in your real application to your small sample until you see the problem
2. comment code in your real script until the problem goes away or until you made it small enough to attach it here (remove all the commented code and try to have as few dependencies as possible) so others can have a look at it.

I would probably go with option 2.

Werner

···

On 04/04/2012 04:27, VC wrote:

On Apr 3, 9:54 am, Werner<werner.bru...@sfr.fr> wrote: