tabbing between textctrl's

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • askalottaqs
    New Member
    • Jun 2007
    • 75

    tabbing between textctrl's

    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
  • Hackworth
    New Member
    • Aug 2009
    • 13

    #2
    I feel that it might be easier to help you if you can show us some example code.

    Comment

    • askalottaqs
      New Member
      • Jun 2007
      • 75

      #3
      Code:
      def addLocationEvent(event):
      	
      	global addLocationDlg
      	addLocationDlg = wx.Frame(loginFrame, -1, "Add Location", size=(450, 550), style=wx.DEFAULT_DIALOG_STYLE)        
      	
      	addLocationDlg.SetBackgroundColour("")
      	#TextBox 
      	targetTX = wx.StaticText(addLocationDlg ,-1,"Enter Location Information:", pos = (20,20))
      	
      	
      	global ownerTF
      	ownerTF = wx.TextCtrl(addLocationDlg,-1,"", (150,270),size =(180,20),style = wx.TE_LEFT | wx.TE_PROCESS_TAB)
      	
      	addPhotoBT = wx.Button(addLocationDlg,-1,'Browse',pos = (220,365), size = (60,30))
      	addPhotoBT.Bind(wx.EVT_BUTTON,pickPhotoEvent,addPhotoBT)
      	
      	global photoAddressTF
      	photoAddressTF = wx.TextCtrl(addLocationDlg,-1,"", (20,370),size =(180,20),style = wx.TE_LEFT)
      	
      	
      	
      	addLocationBT = wx.Button(addLocationDlg,-1,'-Add-',pos = (20,410), size = (50,50))
      	addLocationBT.Bind(wx.EVT_BUTTON,addLocEvent,addLocationBT)
      	
      	addLocationDlg.Show(True)


      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

      Comment

      • Hackworth
        New Member
        • Aug 2009
        • 13

        #4
        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!

        Code:
        import wx
        
        class AddLocationDlg(wx.Dialog):
            def __init__(self, parent, ID, title, pos=wx.DefaultPosition,
                         size=wx.DefaultSize, style=wx.DEFAULT_DIALOG_STYLE):
                # Init the dialog class
                wx.Dialog.__init__(self, parent, ID, title, pos, size, style)
        
                # Init our controls, note global is replaced by naming objects
                # with 'self.', also the parent argument is 'self' as opposed to
                # 'AddLocationDlg'
                self.SetBackgroundColour("")
                targetTX = wx.StaticText(self ,-1,"Enter Location Information:",
                                         pos=(20,20))
                self.ownerTF = wx.TextCtrl(self, -1, "", (150,270), size=(180, 20),
                                           style=wx.TE_LEFT | wx.TE_PROCESS_TAB)
                self.photoAddressTF = wx.TextCtrl(self, -1, "", (20, 370),
                                                  size=(180,20), style=wx.TE_LEFT)
                self.addPhotoBT = wx.Button(self, -1, 'Browse', pos =(220, 365),
                                            size=(60,30)) 
                self.addLocationBT = wx.Button(self, -1, '-Add-', pos=(20,410),
                                               size=(50,50))
                self.Bind(wx.EVT_BUTTON, self.OnButton)
        
            def OnButton(self, event):
                # Handle Button events for the dialog here.
                pass
        
        class MainFrame(wx.Frame):
            def __init__(self, parent, ID, title, pos=wx.DefaultPosition, \
                         size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE):
                # Init the frame class
                wx.Frame.__init__(self, parent, ID, title, pos, size, style)
        
                # Create a button and bind the event.
                self.btn = wx.Button(self, -1, "Show Dialog!")
                self.Bind(wx.EVT_BUTTON, self.OnButton)
        
            def OnButton(self, event):
                # If the ID of the button causing the event is the ID of
                # self.btn, then show the dialog.
                if event.GetId() == self.btn.GetId():
                    self.addLocationEvent()
                    
            def addLocationEvent(self):
                dlg = AddLocationDlg(self, -1, "Add Location", size=(450, 550))
                dlg.Show()
                
        if __name__ == "__main__":
            app = wx.App()
            mainframe = MainFrame(None, -1, "Test", size=(225, 200))
            mainframe.Show()
            app.MainLoop()
        Last edited by Hackworth; Sep 20 '09, 03:34 PM. Reason: Couple afterthoughts.

        Comment

        Working...