473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

[wxPython] How to change deafult tab traversing (radiobuttons & panel)

Hello!

I want change default tab traversing in my app. But i don't know how to do it :(

Belowe i include simple example - i want change default tab order:

radiobutton "mode11" -> radiobutton "mode31" -> button OK

I can't find any option, flag, or another way.

I try use wx.EVT_KEY_DOWN macro, or Bind - but without success.
When i use Borland Builder C++ i must only set tabStop=False ....

sorry for my english !

w.p.

################################################## #####################################
import wx

class MyFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title)

mainPanel = wx.Panel(self)
mainSizer = wx.BoxSizer(wx.VERTICAL)

panel1=wx.Panel(mainPanel,style=wx.TAB_TRAVERSAL|w x.SUNKEN_BORDER,size=(200,100))
mainSizer.Add(panel1,flag=wx.ALL,border=5)

panel2=wx.Panel(mainPanel,style=wx.TAB_TRAVERSAL|w x.SUNKEN_BORDER,size=(200,100))
mainSizer.Add(panel2,flag=wx.ALL,border=5)

# group 1
gridSiz1 = wx.FlexGridSizer(2,2)
panel1.SetSizer(gridSiz1)

self.rb11 = wx.RadioButton(panel1, -1, style=wx.RB_GROUP, label="mode 11")
self.rb12 = wx.RadioButton(panel1, -1, label="mode 12")
self.rb21 = wx.RadioButton(panel1, -1, style=wx.RB_GROUP, label="mode 21")
self.rb22 = wx.RadioButton(panel1, -1, label="mode 22")

gridSiz1.Add(self.rb11,flag=wx.ALL,border=3)
gridSiz1.Add(self.rb12,flag=wx.ALL,border=3)
gridSiz1.Add(self.rb21,flag=wx.ALL,border=3)
gridSiz1.Add(self.rb22,flag=wx.ALL,border=3)

# group 2
gridSiz2 = wx.FlexGridSizer(2,2)
panel2.SetSizer(gridSiz2)

self.rb31 = wx.RadioButton(panel2, -1, style=wx.RB_GROUP, label="mode 31")
self.rb32 = wx.RadioButton(panel2, -1, label="mode 32")
self.rb41 = wx.RadioButton(panel2, -1, style=wx.RB_GROUP, label="mode 41")
self.rb42 = wx.RadioButton(panel2, -1, label="mode 42")

gridSiz2.Add(self.rb31,flag=wx.ALL,border=3)
gridSiz2.Add(self.rb32,flag=wx.ALL,border=3)
gridSiz2.Add(self.rb41,flag=wx.ALL,border=3)
gridSiz2.Add(self.rb42,flag=wx.ALL,border=3)

okBut = wx.Button(mainPanel,label="-- OK --")
mainSizer.Add(okBut,flag=wx.ALL|wx.ALIGN_CENTER,bo rder=10)

mainPanel.SetSizer(mainSizer)
self.Layout()

# wx.EVT_KEY_DOWN(self.rb11,self.OnRBKD)
self.rb11.Bind(wx.EVT_KEY_DOWN, self.OnRBKD)
def OnRBKD(self,event):
print "OnKey!"
event.Skip()
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, "Simple wxPython App")
self.SetTopWindow(frame)
frame.Show(True)
return True

app = MyApp(0)
app.MainLoop()

Jul 19 '05 #1
1 4166
I just figured this out myself, but probably not the way you're asking.
There are supposed to be ways to change the tab order using
tk_focusNext() and tk_focusPrevious(), but I've never used it.

What I've done is simply point one widget to the next one, basically
creating a linked list of tabs. I only had a couple that I wanted to
change the order of, so this was pretty easy to change.

I bound the widgets I wanted changed to <tab> and had a function that
knew where to go. Here's a simple example:

def tab(self, event):
self.port.component('entry').focus_set()

return 'break'

The return 'break' is very important, because if you don't include it
then the default tab functionality of window will be used which will
override whatever changes you make.

I had problems using the tk_focusNext() and tk_focusPrevious() commands
because the two widgets that were supposed to be next to each other in
order were in different windows. I kept getting errors when I tried it.
And since I only had two widgets I created two different functions to
handle the tabs. But if I had more than two I would have created a
forwarding table based on widget names or ids using the event that is
returned in the callback from the binding. Based on the event id
returned I would know where to set focuse next.

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: mdk.R | last post by:
Hello all: i'am installed wxPython 2.5 and Python2.3.4..i try execute script with wxPython but it show error: Traceback (most recent call last): File "E:\py\test.py", line 7, in ? import wx...
4
by: KvS | last post by:
Hi all, I'm pretty new to (wx)Python so plz. don't shoot me if I've missed something obvious ;). I have a panel inside a frame, on which a Button and a StaticText is placed: self.panel =...
2
by: nelson | last post by:
Hi all, i'm doing a COM server that have to expose some graphics (panels and configuration controls), that would be embedded in an application through OLE. I was wondering if I can do this using...
3
by: John Salerno | last post by:
I'm using the sample code of the file 'simple.py' and trying to make a single window with a panel in it, but I keep getting an error. Here's my code: (I know I might need something else, like a...
9
by: zxo102 | last post by:
Hi everyone, I am using a python socket server to collect data from a socket client and then control a image location ( wxpython) with the data, i.e. moving the image around in the wxpython frame....
0
by: gopython | last post by:
Hi, I just started coding with wxPython. The idea is to be able to change the gui dynamically. I am trying to change the static text inside the panel after the panel is created without user...
9
by: Tyler | last post by:
Hello All: I am currently working on a project to create an FEM model for school. I was thinking about using wxPython to gather the 12 input variables from the user, then, after pressing the...
3
by: Soren | last post by:
Hi, Id like to make my own special listbox.. I want to able (at the push of a button) to add another item to my special listbox... each item is a panel with a label, some buttons and maybe a...
3
by: Gandalf | last post by:
I try to reach a specific wx StaticText element's text and to change it by clicking on a button now let's say the this is my element: wx.StaticText(panel, 15, "Hello" ,(30, 70) ,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.