Connecting Tech Pros Worldwide Forums | Help | Site Map

tabbing between textctrl's

Member
 
Join Date: Jun 2007
Posts: 66
#1: Sep 20 '09
in all my research everyone is saying that pressing tab by default gets u to the next textctrl, but when i try to do that, i get the error sound "ting", and it doesn't, what is a way to have the tab navigate through textctrls?

another thing is that the cursor is not on the first textctrl by default, is there a way to set it in the Frame?

thank you all

T

Newbie
 
Join Date: Aug 2009
Location: Louisville
Posts: 13
#2: Sep 20 '09

re: tabbing between textctrl's


I feel that it might be easier to help you if you can show us some example code.
Member
 
Join Date: Jun 2007
Posts: 66
#3: Sep 20 '09

re: tabbing between textctrl's


Expand|Select|Wrap|Line Numbers
  1. def addLocationEvent(event):
  2.  
  3.     global addLocationDlg
  4.     addLocationDlg = wx.Frame(loginFrame, -1, "Add Location", size=(450, 550), style=wx.DEFAULT_DIALOG_STYLE)        
  5.  
  6.     addLocationDlg.SetBackgroundColour("")
  7.     #TextBox 
  8.     targetTX = wx.StaticText(addLocationDlg ,-1,"Enter Location Information:", pos = (20,20))
  9.  
  10.  
  11.     global ownerTF
  12.     ownerTF = wx.TextCtrl(addLocationDlg,-1,"", (150,270),size =(180,20),style = wx.TE_LEFT | wx.TE_PROCESS_TAB)
  13.  
  14.     addPhotoBT = wx.Button(addLocationDlg,-1,'Browse',pos = (220,365), size = (60,30))
  15.     addPhotoBT.Bind(wx.EVT_BUTTON,pickPhotoEvent,addPhotoBT)
  16.  
  17.     global photoAddressTF
  18.     photoAddressTF = wx.TextCtrl(addLocationDlg,-1,"", (20,370),size =(180,20),style = wx.TE_LEFT)
  19.  
  20.  
  21.  
  22.     addLocationBT = wx.Button(addLocationDlg,-1,'-Add-',pos = (20,410), size = (50,50))
  23.     addLocationBT.Bind(wx.EVT_BUTTON,addLocEvent,addLocationBT)
  24.  
  25.     addLocationDlg.Show(True)
  26.  
  27.  


it's just a traditional old dialog, nothing too special about it, and the problem also exists in frames not only dialogues

please help?

thanks
Newbie
 
Join Date: Aug 2009
Location: Louisville
Posts: 13
#4: Sep 20 '09

re: tabbing between textctrl's


I'm not entirely positive but I think this has much to do with your other question about classes. And it makes it a little difficult to answer your question. Take a look at this code and I think you will understand the differences.

Note this isn't perfect code (what is really?) but it should suffice as an example.

I hope it helps!

Expand|Select|Wrap|Line Numbers
  1. import wx
  2.  
  3. class AddLocationDlg(wx.Dialog):
  4.     def __init__(self, parent, ID, title, pos=wx.DefaultPosition,
  5.                  size=wx.DefaultSize, style=wx.DEFAULT_DIALOG_STYLE):
  6.         # Init the dialog class
  7.         wx.Dialog.__init__(self, parent, ID, title, pos, size, style)
  8.  
  9.         # Init our controls, note global is replaced by naming objects
  10.         # with 'self.', also the parent argument is 'self' as opposed to
  11.         # 'AddLocationDlg'
  12.         self.SetBackgroundColour("")
  13.         targetTX = wx.StaticText(self ,-1,"Enter Location Information:",
  14.                                  pos=(20,20))
  15.         self.ownerTF = wx.TextCtrl(self, -1, "", (150,270), size=(180, 20),
  16.                                    style=wx.TE_LEFT | wx.TE_PROCESS_TAB)
  17.         self.photoAddressTF = wx.TextCtrl(self, -1, "", (20, 370),
  18.                                           size=(180,20), style=wx.TE_LEFT)
  19.         self.addPhotoBT = wx.Button(self, -1, 'Browse', pos =(220, 365),
  20.                                     size=(60,30)) 
  21.         self.addLocationBT = wx.Button(self, -1, '-Add-', pos=(20,410),
  22.                                        size=(50,50))
  23.         self.Bind(wx.EVT_BUTTON, self.OnButton)
  24.  
  25.     def OnButton(self, event):
  26.         # Handle Button events for the dialog here.
  27.         pass
  28.  
  29. class MainFrame(wx.Frame):
  30.     def __init__(self, parent, ID, title, pos=wx.DefaultPosition, \
  31.                  size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE):
  32.         # Init the frame class
  33.         wx.Frame.__init__(self, parent, ID, title, pos, size, style)
  34.  
  35.         # Create a button and bind the event.
  36.         self.btn = wx.Button(self, -1, "Show Dialog!")
  37.         self.Bind(wx.EVT_BUTTON, self.OnButton)
  38.  
  39.     def OnButton(self, event):
  40.         # If the ID of the button causing the event is the ID of
  41.         # self.btn, then show the dialog.
  42.         if event.GetId() == self.btn.GetId():
  43.             self.addLocationEvent()
  44.  
  45.     def addLocationEvent(self):
  46.         dlg = AddLocationDlg(self, -1, "Add Location", size=(450, 550))
  47.         dlg.Show()
  48.  
  49. if __name__ == "__main__":
  50.     app = wx.App()
  51.     mainframe = MainFrame(None, -1, "Test", size=(225, 200))
  52.     mainframe.Show()
  53.     app.MainLoop()
  54.  
Reply

Tags
tab, textctrl, wxpython