"Tab" trough widgets?

How do I make [Tab] switch between my widgets and how do I tell it which
one comes after which one?

Thanks for answering,

name

···

--
Best regards
Florian Mayer

GPG public key: http://florianmayer.fl.funpic.de/name/name.gpg
Jabber: name@jabber.org
ICQ: 446504088
Aim: segfaulthunter
Yahoo: segfaulthunter
IRC: name @ irc.freenode.net
Secondary email: segfaulthunter@gmail.com

Florian Mayer <florian-mayer <at> gmx.at> writes:

How do I make [Tab] switch between my widgets and how do I tell it which
one comes after which one?

Thanks for answering,

Put them on a Panel =)

Hi Florian,

Florian Mayer wrote:

How do I make [Tab] switch between my widgets and how do I tell it which
one comes after which one?
  

Default Tab order is defined by the creation order of the widgets.

I use Boa and it has a handy option in the designer to change the tab order, but one can also do it by hand.

There are also some methods MoveAfterInTabOrder and MoveBeforeInTabOrder to change it after creation.

Werner

···

Thanks for answering,

name

Werner F. Bruhin wrote:

Hi Florian,

Florian Mayer wrote:

How do I make [Tab] switch between my widgets and how do I tell it which
one comes after which one?
  

Default Tab order is defined by the creation order of the widgets.

I use Boa and it has a handy option in the designer to change the tab
order, but one can also do it by hand.

There are also some methods MoveAfterInTabOrder and MoveBeforeInTabOrder
to change it after creation.

Werner

Thanks for answering,

name
  

Tab does nothing for me, that's the strange thing..
I created them like this:
self.given = wx.TextCtrl(self, -1, '', (400, 270), (150,
-1),style=wx.TE_PROCESS_ENTER)
    self.asked = wx.TextCtrl(self, -1, '', (250, 270), (150, -1),style=
wx.TE_READONLY)
    self.add1 = wx.TextCtrl(self, -1, '', (250, 400), (150, -1))
    self.add = wx.TextCtrl(self, -1, '', (400, 400), (150,
-1),style=wx.TE_PROCESS_ENTER)

···

--
Best regards
Florian Mayer

GPG public key: http://florianmayer.fl.funpic.de/name/name.gpg
Jabber: name@jabber.org
ICQ: 446504088
Aim: segfaulthunter
Yahoo: segfaulthunter
IRC: name @ irc.freenode.net
Secondary email: segfaulthunter@gmail.com

Hi Florian,

Florian Mayer wrote:

Werner F. Bruhin wrote:
  ...
Tab does nothing for me, that's the strange thing..
I created them like this:
self.given = wx.TextCtrl(self, -1, '', (400, 270), (150,
-1),style=wx.TE_PROCESS_ENTER)
    self.asked = wx.TextCtrl(self, -1, '', (250, 270), (150, -1),style=
wx.TE_READONLY)
    self.add1 = wx.TextCtrl(self, -1, '', (250, 400), (150, -1))
    self.add = wx.TextCtrl(self, -1, '', (400, 400), (150,
-1),style=wx.TE_PROCESS_ENTER)

What is "self"? If it is a panel do you have "style=wx.TAB_TRAVERSAL"

Werner

Werner F. Bruhin wrote:

Hi Florian,

Florian Mayer wrote:

Werner F. Bruhin wrote:
  ...
Tab does nothing for me, that's the strange thing..
I created them like this:
self.given = wx.TextCtrl(self, -1, '', (400, 270), (150,
-1),style=wx.TE_PROCESS_ENTER)
        self.asked = wx.TextCtrl(self, -1, '', (250, 270), (150,
-1),style=
wx.TE_READONLY)
        self.add1 = wx.TextCtrl(self, -1, '', (250, 400), (150, -1))
        self.add = wx.TextCtrl(self, -1, '', (400, 400), (150,
-1),style=wx.TE_PROCESS_ENTER)

What is "self"? If it is a panel do you have "style=wx.TAB_TRAVERSAL"

Werner

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

self is a wx.Frame...

···

--
Best regards
Florian Mayer

GPG public key: http://florianmayer.fl.funpic.de/name/name.gpg
Jabber: name@jabber.org
ICQ: 446504088
Aim: segfaulthunter
Yahoo: segfaulthunter
IRC: name @ irc.freenode.net
Secondary email: segfaulthunter@gmail.com

Hi Florian,

Florian Mayer wrote:

Werner F. Bruhin wrote:
  

...
What is "self"? If it is a panel do you have "style=wx.TAB_TRAVERSAL"

Werner

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

self is a wx.Frame...
  

You should put a wx.Panel on to your wx.Frame and then it should work. BTW, if you want to have the correct look of your application on all platforms then you need to do this anyhow.

Werner

Werner F. Bruhin wrote:

Hi Florian,

Florian Mayer wrote:

Werner F. Bruhin wrote:

...
What is "self"? If it is a panel do you have "style=wx.TAB_TRAVERSAL"

Werner

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail:
wxPython-users-help@lists.wxwidgets.org

self is a wx.Frame...
  

You should put a wx.Panel on to your wx.Frame and then it should
work. BTW, if you want to have the correct look of your application
on all platforms then you need to do this anyhow.

Werner

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Thanks for you answers!
But what is wrong about this code, the output is crap, i just don't see
the widgets:
panel = wx.Panel(self, -1)
        self.outputt = wx.StaticText(panel, -1, 'None', (410, 300))
        self.dont_ask_me_again = wx.CheckBox(panel,-1,"Don't ask me
again",(250,300),(150,20))
        self.SelectLanguage()
        #self.outputn = wx.TextCtrl(self, -1, '', (150, 170))
        self.given = wx.TextCtrl(panel, -1, '', (400, 270), (150,
-1),style=wx.TE_PROCESS_ENTER | wx.TAB_TRAVERSAL)
        self.asked = wx.TextCtrl(panel, -1, '', (250, 270), (150,
-1),style= wx.TE_READONLY | wx.TAB_TRAVERSAL)
        self.submit = wx.Button(panel, 7, 'Submit', (550,
270),style=wx.TAB_TRAVERSAL)
        self.add1 = wx.TextCtrl(panel, -1, '', (250, 400), (150,
-1),style=wx.TAB_TRAVERSAL)
        self.add = wx.TextCtrl(panel, -1, '', (400, 400), (150,
-1),style=wx.TE_PROCESS_ENTER | wx.TAB_TRAVERSAL)
        self.addVocButton = wx.Button(panel, 6, 'Add Vocabulary', (550,
400),style=wx.TAB_TRAVERSAL)
        self.given.SetFocus()
        self.times_till_lock =
wx.SpinCtrl(panel,-1,"",(250,320),(50,-1),style=wx.TAB_TRAVERSAL)
        self.times_till_lock.SetValue(9)

Thank you for your answers!

···

--
Best regards
Florian Mayer

GPG public key: http://florianmayer.fl.funpic.de/name/name.gpg
Jabber: name@jabber.org
ICQ: 446504088
Aim: segfaulthunter
Yahoo: segfaulthunter
IRC: name @ irc.freenode.net
Secondary email: segfaulthunter@gmail.com

Hi Florian,

Florian Mayer wrote:

...
Thanks for you answers!
But what is wrong about this code, the output is crap, i just don't see
the widgets:
  

For something like this it be much more convenient for people trying to help to get self running script as an attachment.

If you are starting using wx I would strongly suggest to start with using sizers to layout your widgets. You hard coded positions and size, and I think some are overlapping.

Attached is a small sample generated with Boa and using a flexgridsizer. You don't need to use Boa but just give (-1, -1) for your position to each widget and then put them in a sizer to get the layout.

Werner

P.S. Boa also generates fixed positions (long story) but they basically get ignored if you use sizers.

Frame1.py (2.12 KB)

Werner F. Bruhin wrote:

flexgridsizer. You don't need to use Boa but just give (-1, -1) for your position to each widget

even better, don't define a position at all:

W = wx.Button(parent, label="The label")

that's all you need!

If you really, really want to put something in that place, use:

wx.DefaultPosition

see:

http://wiki.wxpython.org/index.cgi/wxPython_Style_Guide

for more hints.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Florian Mayer wrote:

But what is wrong about this code, the output is crap, i just don't see
the widgets:

I"m guessing your widgets were off the visible part of the Panel your smallest Y dimension is 270 pixels.

If you want help here, you really should put your code in a small runnable app. Also, in a case like this, you should probably make a custom Panel for your widgets, then put that Panel on a Frame. I've enclosed your code set up this way (Panel.py), and it works, if you make the panel big enough.

However, it looks like this code is auto-generated, but the style could use a lot of help, and you really do want to use sizers. That's one reason I don't like auto-generated code. Panel2.py is closer to how I would write it. I think it's a LOT of readable, and more adaptable to future changes. Note that the tap order follows the order of widget creation, which is a bit odd in this case -- you probably want to re-order them.

oh, and the style: wx.TAB_TRAVERSAL applies to a Panel, not each individual widget.

-Chris

Panel.py (1.5 KB)

Panel2.py (1.72 KB)

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov