Merhaba, öncelikle Kivyde çok yeniyim. Deneme amaçlı bir apk yazmak istedim .Ancak Apk ya çevirip telefona atınca program açılıp hemen kapanıyor. Kod pc de çok iyi çalışıyor ancak bunu Bluestacks’e atınca da aynı oluyor.
işte kod
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.core.window import Window
from kivy.uix.popup import Popup
import mysql.connector
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.label import Label
from kivy.uix.button import Button
sm = ScreenManager()
Builder.load_string("""
:
StackLayout:
orientation : "lr-tb"
Button:
size_hint:1.0,0.1
text: 'SİPARİŞ EKLE'
on_press: root.manager.current = 'siparisEkle'
Button:
size_hint:1.0,0.1
text: 'SİPARİŞ DÜZENLE'
on_press: root.manager.current = 'siparisDuzenle'
Button:
size_hint:1.0,0.1
text: 'SİPARİŞ TAMAMLA'
on_press: root.manager.current = 'siparisTamamla'
<Siparis_Ekle>:
StackLayout:
orientation : "tb-rl"
Button:
size_hint:0.07,0.05
text: 'X'
on_press: root.manager.current = 'menu'
Label:
size_hint: (1.0, 0.05)
text:"TELEFON"
background_color: 1, 1, 1, 1
TextInput:
id:telephone
size_hint: (1.0, 0.05)
Button:
size_hint:1.0,0.1
text: 'SORGULA'
on_press:app.db_sorgula()
Label:
size_hint: (1.0, 0.05)
text:""
background_color: 1, 1, 1, 1
Label:
size_hint: (1.0, 0.05)
text:"İSİM"
background_color: 1, 1, 1, 1
TextInput:
id:name
size_hint: (1.0, 0.05)
Label:
size_hint: (1.0, 0.05)
text:"SOYİSİM"
background_color: 1, 1, 1, 1
TextInput:
id:surname
size_hint: (1.0, 0.05)
Label:
size_hint: (1.0, 0.05)
text:"ADRES"
background_color: 1, 1, 1, 1
TextInput:
id:country
size_hint: (1.0, 0.05)
Label:
size_hint: (1.0, 0.05)
text:"ADRES 2"
background_color: 1, 1, 1, 1
TextInput:
id:country2
size_hint: (1.0, 0.05)
StackLayout:
orientation : "rl-bt"
Button:
size_hint:1.0,0.1
text: 'TAMAMLA'
on_press: app.db_ekle()
<Siparis_Duzenle>:
StackLayout:
orientation : "bt-rl"
Button:
size_hint:1.0,0.1
text: 'GERİ'
on_press: root.manager.current = 'menu'
<Siparis_Tamamla>:
StackLayout:
orientation : "bt-rl"
Button:
size_hint:1.0,0.1
text: 'GERİ'
on_press: root.manager.current = 'menu'
“”")
Declare both screens
class MenuScreen(Screen):
pass
class Siparis_Ekle(Screen):
pass
class Siparis_Duzenle(Screen):
pass
class Siparis_Tamamla(Screen):
pass
class TestApp(App):
con = mysql.connector.connect(
host="",
user="",
password="",
database=“zrn”,
autocommit=True
)
cursor = con.cursor()
def build(self,value=0):
sm = ScreenManager()
sm.add_widget(MenuScreen(name='menu'))
sm.add_widget(Siparis_Ekle(name='siparisEkle'))
sm.add_widget(Siparis_Duzenle(name='siparisDuzenle'))
sm.add_widget(Siparis_Tamamla(name='siparisTamamla'))
return sm
####----------------------------------------------------SİPARİŞ EKLE-------------------------------------------------------------------------------------
def son_sayi(self):#SON SAYI NUMARASINI VERİR
say=0
self.cursor.execute("select * from hali")
tara=self.cursor.fetchall()
for i in tara:
say=i[0]
return str(say+1)
def PopUP(self,pop_message):#POP UP MESAJI
content = Button(text=pop_message,size_hint=(1,1))
popup = Popup(content=content, auto_dismiss=False)
content.bind(on_press=popup.dismiss)
popup.open()
def Temizle(self):#EKRANI TEMİZLE
self.root.get_screen('siparisEkle').ids.name.text=""
self.root.get_screen('siparisEkle').ids.surname.text=""
self.root.get_screen('siparisEkle').ids.country.text=""
self.root.get_screen('siparisEkle').ids.country2.text=""
def db_ekle(self):#DB YE EKLER
telefon=self.root.get_screen('siparisEkle').ids.telephone.text
isim=self.root.get_screen('siparisEkle').ids.name.text
soyisim=self.root.get_screen('siparisEkle').ids.surname.text
adres=self.root.get_screen('siparisEkle').ids.country.text
adres2=self.root.get_screen('siparisEkle').ids.country2.text
if len(telefon)>5:
if len(telefon)>5 and len(isim)>1 and len(adres)>1:
if self.db_sorgula() == True:
add_musteri="""INSERT INTO zrn.musteri (telefon,isim,soyisim,adres,adres2) VALUES(%s,%s,%s,%s,%s)"""
data_musteri=(telefon,isim.upper(),soyisim.upper(),
adres.upper(), adres2.upper())
self.cursor.execute(add_musteri,data_musteri)
self.con.commit()
durum=0
add_hali="""INSERT INTO zrn.hali (musteri_telefon,musteri_durum) VALUES(%s,%s)"""
data_hali=(telefon, durum)
self.cursor.execute(add_hali,data_hali)
self.con.commit()
Pop_Txt="İŞLEM BAŞARILI "+"SPNO :"+self.son_sayi()
self.PopUP(Pop_Txt)
self.Temizle()
else:
durum = 0
add_hali = """INSERT INTO zrn.hali (musteri_telefon,musteri_durum) VALUES(%s,%s)"""
data_hali = (telefon, durum)
self.cursor.execute(add_hali, data_hali)
self.con.commit()
Pop_Txt="İŞLEM BAŞARILI "+"SPNO :"+self.son_sayi()
self.PopUP(Pop_Txt)
self.Temizle()
else:
self.PopUP("TELEFON,İSİM,ADRES BOŞ BIRAKILAMAZ")
else:
self.PopUP("TELEFON NUMARASI HATALI")
def db_sorgula(self):
try:
self.Temizle()
telefon=self.root.get_screen('siparisEkle').ids.telephone.text
self.cursor.execute("select * from musteri")
tara=self.cursor.fetchall()
say=0
for i in tara:
if i[0]==int(telefon):
say+=1
if say==0:
return True
else:
self.cursor.execute("select * from musteri")
tara = self.cursor.fetchall()
for i in tara:
if i[0] == int(telefon):
self.root.get_screen('siparisEkle').ids.name.text = i[1]
self.root.get_screen('siparisEkle').ids.surname.text = i[2]
self.root.get_screen('siparisEkle').ids.country.text = i[3]
self.root.get_screen('siparisEkle').ids.country2.text = i[4]
return False
except ValueError:
self.PopUP("TELEFON NUMARASI HATALI")
if name == ‘main’:
TestApp().run()