Fairly new to building apps in Python and I cannot figure out how to pass argument from other class function to other class. Based on what i read, i guess I should use def init in CustomPopup class but haven't been able to get it working.
Here is a stripped version of what i am trying to do, this works but i am trying to get txt_input from popuper to CustomPopup but cannot get it working:
Python:
from kivy.app import App
from kivy.lang import Builder
from os import listdir
from kivy.uix.screenmanager import Screen, ScreenManager
from kivy.uix.popup import Popup
import teradata
import Global
class CustomPopup(Popup):
txt_input = 'Text'
udaExec = teradata.UdaExec()
kv_path = './kv/'
for kv in listdir(kv_path):
Builder.load_file(kv_path+kv)
class LoginScreen(Screen):
def buttonClicked(self):
Global.u_name = self.ids.u_name.text
Global.p_word = self.ids.p_word.text
status = None
try:
with udaExec.connect("${dataSourceName}",username=self.ids.u_name.text,password=self.ids.p_word.text) as session:
try:
session
except teradata.DatabaseError as e:
status = e.code
except teradata.DatabaseError as e:
status = e.code
if status == 8017:
self.popuper('Hello')
elif status == None:
self.popuper('All Good')
elif status == 0:
self.popuper('Fill in username')
else:
self.popuper('Something else')
def popuper(self, txt_input):
popuper = CustomPopup()
popuper.open()
class MainScreen(Screen):
pass
class ScreenManagement(ScreenManager):
pass
application = Builder.load_file("main.kv")
class MainApp(App):
def build(self):
self.title = 'Push Notfication Tool'
return application
if __name__ == "__main__":
MainApp().run()
Kivy:
<CustomPopup@Popup>:
size_hint: (.5,.5)
auto_dismiss: False
title: "af"
BoxLayout:
orientation: 'vertical'
Label:
text: root.txt_input
Button:
text: "Close now"
on_press: root.dismiss()
Thank you!
*EDIT added kivy file as well.