Ir ao conteúdo
  • Cadastre-se

Rodrigo Diamond

Membro Júnior
  • Posts

    7
  • Cadastrado em

  • Última visita

Reputação

3
  1. Venho fazendo uma programação e quero abrir uma terceira tela após a pessoa efetuar o login na minha programação. Nisso já fiz: from kivy.app import App from kivy.uix.boxlayout import BoxLayout from kivy.uix.screenmanager import ScreenManager, Screen from kivy.uix.scrollview import ScrollView from kivy.uix.label import Label import sqlite3 tabela= sqlite3.connect("database.db") tabela.execute(''' CREATE TABLE IF NOT EXISTS user( UserID INTEGER PRIMARY KEY, usuario VARCHAR(20) NOT NULL, senha VARCHAR(20) NOT NULL); ''') class Tela(ScreenManager): pass class Exibicao(App): def build(self): return Tela() def login(self,usuario,senha,lblKiva,ScMain): while True: cursor=tabela.cursor() find_user= ("SELECT * FROM user WHERE usuario = ? AND senha = ?") cursor.execute(find_user,[(usuario.text),(senha.text)]) results= cursor.fetchall() if results: ScMain.current= 'golas' else: lblKiva.color= [1,0,0,1] lblKiva.text= 'Usuário ou senha inválidos, tente novamente.' def registro(self,usuario,senha,lblKivy): username= usuario.text password= senha.text cursor= tabela.cursor() cursor.execute("SELECT * FROM user WHERE usuario = ?",(username,)) results = cursor.fetchall() if results: lblKivy.color= [1,0,0,1] lblKivy.text= 'Usuário ja existente, entre com um novo usuário.' else: tabela.execute('INSERT INTO user VALUES(NULL,?,?)',(username,password)) tabela.commit() lblKivy.color=[0,1,0,1] lblKivy.text='Registrado com sucesso!' Exibicao().run() ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- A parte a cima é a parte da programação, e sobre a tela do kivy: <Tela>: id: ScMain Screen: name: 'inicio' BoxLayout: padding: 25 spacing: 10 canvas.before: Color: rgba: [.09, .09, .09, 1] Rectangle: pos: self.pos size: self.size orientation: 'vertical' Image: id: logo source: 'Imagens/logotipo.png' allow_stretch: True size_hint: None, None size: 325, 325 pos_hint: {'center_x': 0.5} Button: id: btnLogin size_hint: None,None text: 'Login' font_size: 30 size: 300, 75 pos_hint: {'center_x': 0.5} on_release: ScMain.current = 'Login' ScMain.transition.direction = 'left' Button: id: btnRegistrar size_hint: None,None text: 'Registrar-se' font_size: 30 size: 300, 75 pos_hint: {'center_x': 0.5} on_release: ScMain.current = 'Registrar' ScMain.transition.direction = 'left' Button: id: btnFechar background_normal: 'Imagens/butFecharN.png' background_down: 'Imagens/butFecharD.png' size_hint: None,None size: 300, 75 pos_hint: {'center_x': 0.5} on_press: app.stop() Screen: name: 'Login' BoxLayout: padding: 30 canvas.before: Color: rgba: [0, .65, .65, 1] Rectangle: pos: self.pos size: self.size orientation: 'vertical' Label: text: 'Insira seus Dados:' font_size: 60 color: 0, 0, 1, 1 BoxLayout: orientation: 'horizontal' Label: text: 'Usuário: ' font_size: 30 TextInput: id: txtUsuario font_size: 30 size_hint: None, None size: 630, 45 pos_hint: {'center_y': 0.5} BoxLayout: orientation: 'horizontal' Label: text: 'Senha: ' font_size: 30 size_hint: None, None pos_hint: {'center_y': 0.5} TextInput: id: txtSenha font_size: 30 size_hint: None, None size: 630, 45 pos_hint: {'center_y': 0.5} Label: id: lblKiva text: '' font_size: 30 size_hint: None, None pos_hint: {'center_x': 0.5} BoxLayout: spacing: 10 orientation: 'horizontal' size_hint_y: None height: 80 Button: id: btnVoltar text: 'VOLTAR' font_size: 60 background_color: 0, 0, .35, 1 on_release: ScMain.current = 'inicio' ScMain.transition.direction = 'right' Button: id: btnEntrar text: 'Entrar' font_size: 60 background_color: 0, .20, 0, 1 on_press: app.login(txtUsuario,txtSenha,lblKiva,ScMain) Screen: name: 'Registrar' BoxLayout: padding: 10 canvas.before: Color: rgba: [.65, .65, .65, 1] Rectangle: pos: self.pos size: self.size orientation: 'vertical' Label: text: 'Insira seus Dados:' font_size: 60 color: 0, 0, 1, 1 BoxLayout: orientation: 'horizontal' Label: text: 'Usuário:' font_size: 30 TextInput: id: entradaUsuario font_size: 30 size_hint: None, None size: 630, 45 pos_hint: {'center_y': 0.5} BoxLayout: orientation: 'horizontal' Label: text: 'Senha:' font_size: 30 TextInput: id: entradaSenha font_size: 30 size_hint: None, None size: 630, 45 pos_hint: {'center_y': 0.5} Button: id: btnRegistro text: 'Registrar' font_size: 20 background_color: 0, .20, 0, 1 size_hint: None, None size: 225, 45 pos_hint: {'center_x': 0.5} on_press: app.registro(entradaUsuario,entradaSenha,lblKivy) Label: id:lblKivy text: '' font_size: 30 pos_hint: {'center_x': 0.5} Button: text: 'VOLTAR' font_size: 15 background_color: 0, 0, .35, 1 size_hint: None, None size: 100, 30 pos_hint: {'center_y': 0.5} on_release: ScMain.current = 'inicio' ScMain.transition.direction = 'right' Screen: name:'golas' BoxLayout: padding: 25 spacing: 10 canvas.before: Color: rgba: [.09, .09, .09, 1] Rectangle: pos: self.pos size: self.size orientation: 'vertical' Image: id: logo source: 'Imagens/logotipo.png' allow_stretch: True size_hint: None, None size: 325, 325 pos_hint: {'center_x': 0.5} ---------------------------------------------------------------------------------------------------------------------------- Porém quando a pessoa efetua o registro e tenta logar, dá erro e fecha a tela. Não consigo achar o erro, se puderem me ajudar agradeço. Deixarei o arquivo caso prefiram P2_Rodrigo186127.rar
  2. @herbertbahia acho que sim mano, muito obrigado mesmo, me salvou muito. sim mano, me salvou muito. obrigado adicionado 0 minutos depois @devair1010 obrigado !! nao tinha pensado nisso
  3. @AdrianoSiqueira Muito obrigado, consegui entender tudo nessa programação
  4. @Cordas desculpa, não prestei atenção nisso ! Muito obrigado, vou dar uma olhada.
  5. Olá, eu estou tentando descobrir quantas vogais contém nesta palavra que eu digito, e está dando 0, se alguém puder me ajudar ficaria grato! OBS: não sei o que estou fazendo de errado, gostaria de algum auxílio, por favor !!

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

 

GRÁTIS: ebook Redes Wi-Fi – 2ª Edição

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!