Ir para conteúdo
Fórum Script Brasil
  • 0

Trocar Tab Pelo Enter Em Programa Pyhon


Guest - André -

Pergunta

5 respostass a esta questão

Posts Recomendados

  • 0

Bom, QT eu não conheço, por isso só fiz exemplos em Tkinter e wxPython.

Tkinter:

from Tkinter import *

class Janela(Frame):
    def __init__(self, pai):
        Frame.__init__(self, pai)
        self.pack()

        self.Text1 = Entry(self)
        self.Text1.pack(side=TOP)
        self.Text2 = Entry(self)
        self.Text2.pack(side=TOP)
        self.Text3 = Entry(self)
        self.Text3.pack(side=TOP)

        self.Text1.bind("<KeyPress>", self.Tecla)
        self.Text2.bind("<KeyPress>", self.Tecla)
        self.Text2.bind("<KeyPress>", self.Tecla)
        
    def Tecla(self, evento):
        if evento.keycode==13:
            name = evento.widget.tk.call('tk_focusNext', evento.widget._w) 
            evento.widget._nametowidget(str(name)).focus_set()            
        

pai = Tk()
janela = Janela(pai)
janela.mainloop()
wxPython:
import wx

class Janela(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, 'teste')
        Text1 = wx.TextCtrl(self, -1, '', wx.Point(10, 10), style=wx.TAB_TRAVERSAL)
        Text2 = wx.TextCtrl(self, -1, '', wx.Point(10, 40))
        Text3 = wx.TextCtrl(self, -1, '', wx.Point(10, 70))

        Text1.Bind(wx.EVT_CHAR, self.OnChar)
        Text2.Bind(wx.EVT_CHAR, self.OnChar)
        Text3.Bind(wx.EVT_CHAR, self.OnChar)
        
    def OnChar(self, evento):
        if evento.GetKeyCode()==13:
            c = self.FindWindowById(self.NextControlId(evento.GetId()))
            if c!=None:
                c.SetFocus()
            
        evento.Skip()
            

app = wx.App()
janela = Janela()
app.SetTopWindow(janela)
janela.Show()
app.MainLoop()

Ok? wink.gif

Graymalkin

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...