<SmoothLabel@Label> background_color: (0,0,0,0) background_normal: '' back_color: (255,255,255,1) border_radius: [18] canvas.before: Color: rgba: (255,255,255,0.3) RoundedRectangle: size: self.size pos: self.pos radius: self.border_radius
<Money_Manager>
FloatLayout: size_hint_y: None height:150 Image: pos: 0,350 source:'image4.png' size: self.texture_size allow_stretch: True keep_ratio: False
SmoothLabel: id: Total_Wealth text: "Total Wealth :" + app.t_w pos: 600,450 size_hint: (.3, .2)
SmoothLabel: id: Cash text: "Cash :" + app.cash size_hint: (.3,0.2) pos: 600,410
SmoothLabel: id: Savings text: "Savings :" + app.savings size_hint: (.3,0.2) pos: 600,370
SmoothLabel: id: Date_lbl text: app.fulldate size_hint: (.3, .2) pos: 30, 450
SmoothLabel: id: Expences_lbl text: ("Expences :" + app.total_expences) size_hint: (.3, .2) pos: 30,410
SmoothLabel: id: Income_lbl text: ("Income :" + app.total_income) size_hint: (.3, .2) pos: 30, 370 ScrollView: size_hint: (.4,.6) do_scroll_x: False do_scroll_y: True pos: 30,30 Label: size_hint_y: None height: self.texture_size[1] text: app.index+") "+app.date+" "+app.details+" "+app.amount +'\n' haligh: 'left'
from kivy.app import Appfrom kivy.uix.floatlayout import FloatLayoutfrom kivy.uix.image import Imagefrom kivy.lang import Builderimport datetimefrom kivy.config import Configfrom kivy.properties import StringProperty, NumericPropertyimport psycopg2from kivy.uix.label import Label
Config.set('graphics', 'width', '900')Config.set('graphics', 'height', '500')Config.write()
month = datetime.datetime.now().strftime("%B")date = datetime.datetime.now().strftime("%w")
connection = psycopg2.connect(user="postgres",password="postgres",host="localhost",port="5432",database="money_db")cursor = connection.cursor()
query_cash = "select cash from main where index = 1;"query_savings = "select savings from main where index = 1;"query_income = "select sum(amount) from income where month="+"'"+month+"'"+";"query_expences = "select sum(amount) from expences where month="+"'"+month+"'"+";"
cursor.execute(query_income)total_income_amount, = cursor.fetchone()
cursor.execute(query_expences)total_expences_amount, = cursor.fetchone()
cursor.execute(query_cash)cash_amount, = cursor.fetchone()
cursor.execute(query_savings)savings_amount, = cursor.fetchone()
cursor.execute("commit;")
q_e_n = "select count(*) from expences where month="+"'"+month+"'"+";"q_e = "select index, date, details, amount from expences where month="+"'"+month+"'"+";"
cursor.execute(q_e_n)e_n, = cursor.fetchone()
cursor.execute(q_e)expences = cursor.fetchall()
cursor.execute("commit;")
Builder.load_file('total_wealth.kv')
class Money_Manager(App, FloatLayout): fulldate = StringProperty() total_income = StringProperty() total_expences = StringProperty() cash = StringProperty() savings = StringProperty() t_w = StringProperty() index = StringProperty() date = StringProperty() details = StringProperty() amount = StringProperty() index2= NumericProperty() def build(self): i = 1 for row in expences: index_amount = str(i) date_amount = str(row[1]) details_amount = str(row[2]) amount_amount = str(row[3]) i = i+1
self.index = index_amount self.date = date_amount self.details = details_amount self.amount = amount_amount self.fulldate = (month+", "+date) self.total_income = str(total_income_amount) self.total_expences = str(total_expences_amount) self.cash = str(cash_amount) self.savings = str(savings_amount) self.t_w = str(cash_amount+savings_amount) return self Money_Manager().run()
There are a number of issues here:
Dynamically create a label for each data element. This is the fundamental problem.
Other Items:
for i, row in enumerate(expences):
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/ac48a029-96b2-4964-9c3e-21d206c8e9a0%40googlegroups.com.