Skip to content

Commit

Permalink
add spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
MonykPenafor committed May 30, 2023
1 parent 7aa46da commit 2a8e2b9
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 21 deletions.
1 change: 1 addition & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 49 additions & 19 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from kivy.event import EventDispatcher
from kivy.lang import Builder
from kivy.properties import StringProperty
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.popup import Popup
from kivy.uix.screenmanager import ScreenManager, NoTransition
from kivy.uix.textinput import TextInput
from kivy.uix.spinner import Spinner
from kivymd.uix.label import MDLabel
from kivymd.uix.screen import MDScreen
from kivy.core.window import Window
Expand Down Expand Up @@ -286,6 +284,10 @@ def confirm(self):
self.dismiss()


class CustomSpinner(Spinner):
pass


# --------------------- CLASES MDSCREEN --------------------


Expand Down Expand Up @@ -380,7 +382,6 @@ def principal(self):
def salvar_dados(self):

try:

idaluno = self.ids.idaluno.text
nome = self.ids.idnome.text
cpf = self.ids.idcpf.text
Expand Down Expand Up @@ -458,7 +459,6 @@ def principal(self):

def salvar_dados(self):
try:

idprof = self.ids.idprof.text
nome = self.ids.nome.text
cpf = self.ids.cpf.text
Expand Down Expand Up @@ -533,17 +533,14 @@ def salvar_dados(self):

conn = conectar()
cur = conn.cursor()

cur.execute("""INSERT into Funcionario (nome, login, senha)Values (%s, %s, %s)
""", (nome, login, senha))

cur.execute("""INSERT into Funcionario (nome, login, senha)Values (%s, %s, %s)""", (nome, login, senha))
conn.commit()

toast("Salvo com sucesso!", duration=2)
self.principal()

else:
toast('senhas não coincidem', duration=4)
toast('Senhas não coincidem', duration=4)

except Exception as e:
toast(f"Erro ao salvar dados: {e}", duration=5)
Expand Down Expand Up @@ -577,7 +574,7 @@ def pesquisar(self, texto):
print(e)

def novo(self):
self.manager.current = 'cad_aluno'
self.manager.current = 'cad_funcionario'


class CadastrarSala(MDScreen):
Expand Down Expand Up @@ -642,6 +639,47 @@ def novo(self):
self.manager.current = 'cad_sala'


class CadastrarCurso(MDScreen):

def principal(self):
principal(self)

def salvar_dados(self):
try:

idsala = '1'

idcurso = self.ids.idcurso.text
ch = self.ids.ch.text
descricao = self.ids.desc.text
numod = self.ids.numod.text
valor = self.ids.valor.text
dupli = self.ids.dupli.text

conn = conectar()
cur = conn.cursor()

if idcurso == '-':
cur.execute("""INSERT into Curso (id_sala, descricao, CH, num_modulos, VLR_total, num_duplicatas)
Values (%s, %s, %s, %s, %s, %s)""", (idsala, descricao, ch, numod, valor, dupli))
else:
cur.execute("""UPDATE Curso
SET id_sala = %s, descricao = %s, CH = %s, num_modulos = %s, VLR_total = %s, num_duplicatas = %s
WHERE id_curso = %s""", (idsala, descricao, ch, numod, valor, dupli, idcurso))

conn.commit() # Confirma a transação

toast("Salvo com sucesso!", duration=2)
self.principal()

except Exception as e:
toast(f"Erro ao salvar dados: {e}", duration=2)


class ConsultarCurso(MDScreen):
pass


class CadastrarTurma(MDScreen):
pass

Expand All @@ -666,14 +704,6 @@ class ConsultarPagamento(MDScreen):
pass


class CadastrarCurso(MDScreen):
pass


class ConsultarCurso(MDScreen):
pass


# --------------------------- APP ---------------------------------

class DibTopApp(MDApp):
Expand Down
2 changes: 1 addition & 1 deletion screens.kv
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
#:include screens/consultar_curso.kv
#:include screens/consultar_alunoturma.kv
#:include screens/consultar_turma.kv
#:include screens/consultar_pagamento.kv
#:include screens/consultar_pagamento.kv
138 changes: 137 additions & 1 deletion screens/cadastrar_curso.kv
Original file line number Diff line number Diff line change
@@ -1 +1,137 @@
<CadastrarCurso>
#: import Factory kivy.factory.Factory

<CadastrarCurso>
BoxLayout:
orientation:'horizontal'

BoxLayout:
size_hint_x: 0.2

CustomBoxLayout:

orientation: 'vertical'
padding: '40dp'
spacing: 2

MDLabel:
text: "CADASTRO DE CURSO"
halign: "center"
pos_hint: {'center_x': 0.5, 'center_y': 0.75}
font_size: 35

BoxLayout:
orientation: 'horizontal'
spacing: 5

MDLabel:
id: idcurso
hint_text:"ID"
text: '-'
pos_hint: {'center_x':0.5,'center_y':0.8}
size_hint_x: 0.07


MDTextField:
id: desc
hint_text:"Descriçao"
pos_hint: {'center_x':0.5,'center_y':0.8}
size_hint_x: 0.7
write_tab: False
multiline: False
max_text_length: 100
#line_color_normal: [0,1,1,1]
#line_color_focus: [0,1,0,1]

MDTextField:
id: ch
hint_text:"CH"
pos_hint: {'center_x':0.5,'center_y':0.8}
size_hint_x: 0.23
max_text_length: 11
#line_color_normal: [0,1,1,1]
#line_color_focus: [0,1,0,1]
write_tab: False

CustomSpinner:
id: sala
text: 'Sala'
size_hint: 0.1, None # Reduz o tamanho verticalmente (altura)
height: dp(30) # Define uma altura específica (30 pixels neste exemplo)
size_hint_x: None # Permite definir uma largura fixa
width: dp(150) # Define uma largura específica (80 pixels neste exemplo)
pos_hint: {'center_x':0.5,'center_y':0.8} # Centraliza horizontalmente
values: 'a', 'a', 'a', 'v' # Os valores do spinner
font_size: '17sp' # Define o tamanho da fonte
color: 'black' # Define a cor do texto como branco (RGBA)
background_normal: '' # Remove o fundo padrão do Spinner
background_color: 0.18,0.53,1,1 # Define a cor de fundo do Spinner

option_cls: Factory.get('SpinnerOption') # Define a classe das opções do spinner

BoxLayout:
orientation: 'horizontal'
spacing: 5
MDTextField:
id: numod
hint_text:"Nº de modulos"
pos_hint: {'center_x':0.5,'center_y':0.8}
#line_color_normal: [0,1,1,1]
#line_color_focus: [0,1,0,1]
write_tab: False


MDTextField:
id: valor
hint_text:"valor"
pos_hint: {'center_x':0.5,'center_y':0.8}
max_text_length: 120
#line_color_normal: [0,1,1,1]
#line_color_focus: [0,1,0,1]
write_tab: False

MDTextField:
id: dupli
hint_text:"nº duplicatas"
pos_hint: {'center_x':0.5,'center_y':0.8}
max_text_length: 50
#line_color_normal: [0,1,1,1]
#line_color_focus: [0,1,0,1]
write_tab: False

BoxLayout:
orientation: 'horizontal'
BoxLayout:
BoxLayout:
spacing: 15
MDFillRoundFlatButton:
id:btnsalvar
text: "SALVAR"
md_bg_color: 0.18,0.53,1,1
pos_hint: {'center_x':0.5}
size_hint_x: 0.75
font_size: 20
on_release: root.salvar_dados()

MDFillRoundFlatButton:
id: btncancelar
text: 'CANCELAR'
md_bg_color: 'red'
pos_hint: {'center_x':0.5}
size_hint_x: 0.75
font_size: 20
on_release: root.principal()

BoxLayout:
size_hint_x: 0.2



<SpinnerOption>:
background_normal: '' # Remove o fundo padrão do Spinner
background_color: 0.18,0.53,1,1 # Define a cor de fundo do Spinner
color: 'black' # Define a cor do texto das opções
size_hint: 0.1, None # Reduz o tamanho verticalmente (altura)
height: dp(30) # Define uma altura específica (30 pixels neste exemplo)
size_hint_x: None # Permite definir uma largura fixa
width: dp(150) # Define uma largura específica (80 pixels neste exemplo)
font_size: '15sp' # Define o tamanho da fonte

0 comments on commit 2a8e2b9

Please sign in to comment.