this is my python file content i made a mysql data base and connected it to the program and i have a problem with the home screen because i am trying to make a search bar
from kivy.app import App
import mysql.connector
from arabic_reshaper import reshape
from bidi.algorithm import get_display
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.widget import Widget
from kivy.graphics import Rectangle, Color
from kivy.core.window import Window
from kivy.uix.button import Button
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.properties import StringProperty
sm=ScreenManager()
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="A.C.A_2024",
database="users_data"
)
my_cursor = mydb.cursor()
my_cursor.execute("SELECT * FROM data")
data=my_cursor.fetchall()
def arab(text):
return get_display(reshape(text))
class LoginPageLayout(Screen):
error_text=StringProperty("")
def SignIn(self,username,password):
print("hello")
for i in data:
if i[0] == username and i[1] == password:
print("hi")
print(username)
print(password)
sm.current="HomePage"
print("try again")
class SignUpLayout(Screen):
error_text = StringProperty("")
def SignUp(self,username,password):
if len(username)<8:
self.error_text="user name must be 8 charcters atleast"
elif len(password)<8:
self.error_text="password must be 8 characters atleast"
else:
print("hello")
my_cursor.execute("INSERT INTO data (username , password) VALUES (%s , %s)", (username, password))
mydb.commit()
print("done excecuting")
sm.current = "HomePage"
class HomePage(Screen):
pass
class ACAapp(App):
def build(self):
sm.add_widget(LoginPageLayout(name="LoginPageLayout"))
sm.add_widget(SignUpLayout(name="SignUpLayout"))
sm.add_widget(HomePage(name="HomePage"))
return sm
ACAapp().run()
and this is my kivy file
<LoginPageLayout>:
BoxLayout:
padding: [50,10,50,30]
spacing: 20
orientation: "vertical"
Label:
text: "login page"
font_name: "andlso.ttf"
TextInput:
id: user
multiline: False
TextInput:
id: password
multiline: False
password: True
Button:
font_name: "andlso.ttf"
text: "login"
on_press: root.SignIn(user.text , password.text)
Button:
font_name: "andlso.ttf"
text: "don`t have an account? sign up"
on_press: root.manager.current="SignUpLayout"
<SignUpLayout>
BoxLayout:
font_size: 40
padding: [50,10,50,30]
spacing: 20
orientation: "vertical"
Label:
text: "sign up page"
font_name: "andlso.ttf"
TextInput:
id: user2
multiline: False
TextInput:
id: pass2
multiline: False
password: True
Label:
text: root.error_text
font_name: "andlso.ttf"
Button:
text: "sign up"
on_press: root.SignUp(user2.text,pass2.text)
<HomePage>:
canvas.before:
RoundedRectangle:
pos: 50 , self.height-75
size: self.width-50 , 50
radius: [(40,40),(40,40),(40,40),(40,40)]
TextInput:
size_hint: (None , None)
width: root.width-100
height: 50
pos: 75 , root.height-75
signup and signin screens are already done and i am working on the home page
i tried to make a search bar in the home screen but the color of the text input when active is diffrent from the color of the rectangle
New contributor
Ziad Elhusiny is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.