Code hier eingeben...#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.button import Button
class MeinLayout(GridLayout):
def __init__(self, **kwargs):
super(MeinLayout, self).__init__(**kwargs)
self.cols = 1
self.top1 = GridLayout()
self.top1.cols = 2
self.top2 = GridLayout()
self.top2.cols = 5
self.add_widget(self.top1)
titel = "Dashboard"
self.top1.add_widget(Label(text=titel, font_size=60))
self.add_widget(self.top2)
self.top2.add_widget(Label(text="Step1", font_size=30))
self.top2.add_widget(Label(text="Step2", font_size=30))
self.top2.add_widget(Label(text="Step3", font_size=30))
self.top2.add_widget(Label(text="Step4", font_size=30))
self.top2.add_widget(Label(text="Step5", font_size=30))
self.top2.add_widget(Label(text="12", font_size=30))
self.top2.add_widget(Label(text="3", font_size=30))
self.top2.add_widget(Label(text="34", font_size=30))
self.top2.add_widget(Label(text="32", font_size=30))
self.top2.add_widget(Label(text="3", font_size=30))
self.add_widget(Label(text=" ", font_size=60))
self.add_widget(Label(text=" ", font_size=60))
self.add_widget(Label(text=" ", font_size=60))
self.add_widget(Label(text=" ", font_size=60))
self.add_widget(Label(text=" ", font_size=60))
self.add_widget(Label(text=" ", font_size=60))
self.add_widget(Label(text=" ", font_size=60))
self.button1 = Button(text="update",font_size=30)
self.add_widget(self.button1)
def crawl():
pass
### crawling local folders###
#returning integer values for every step
#step1 = 3
#step2 = 2
class epicbrain(App):
def build(self):
return MeinLayout()
if __name__ == "__main__":
epicbrain().run()
Here are 2 key things you need to do:
Don’t fear kv, it makes the layout of widgets very effective. If you need more explicit help, let me know.
From: mg
Sent: Monday, November 25, 2019 8:03 PM
To: Kivy users support
Subject: [kivy-users] Constantly updating label-text (GridLayout)
Hey! I'm pretty new to Kivy so please be kind and patient.
With the help of GODS and Kivy i want to create this amazing live-dashboard showing the actual amount of projects in our local project-folders
production
-----P33203-Projectname
-----P33204-Projectname
-----P33205-Projectname
post-production
-----P33208-Projectname
-----P33212-Projectname
GOAL:
production: 3 (projects)
post-production: 2 (projects)
finished: 231 (projects)
I just want python to crawl through the folders (maybe every 5 seconds) counting the projects and. Kivy only had one task... update the lables-texts.
Why can't i just say time.sleep(x). Python was so easy before Kivi showed up and destroyed ALL my dreams. :D
--
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/218f4666-ac6a-4ed9-b772-5429504e4e53%40googlegroups.com.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.button import Button
from kivy.clock import Clock
from kivy.event import EventDispatcher
class MeinLayout(GridLayout):
def __init__(self, **kwargs):
super(MeinLayout, self).__init__(**kwargs)
#gogogo = EventDispatcher()
#gogogo.register_event_type('my_callback')
self.cols = 1
self.top1 = GridLayout()
self.top1.cols = 2
self.top2 = GridLayout()
self.top2.cols = 5
self.add_widget(self.top1)
titel = "Dashboard"
self.top1.add_widget(Label(text=titel, font_size=60))
self.add_widget(self.top2)
self.top2.add_widget(Label(text="Step1", font_size=30))
self.top2.add_widget(Label(text="Step2", font_size=30))
self.top2.add_widget(Label(text="Step3", font_size=30))
self.top2.add_widget(Label(text="Step4", font_size=30))
self.top2.add_widget(Label(text="Step5", font_size=30))
self.value1 = Label(text="value",font_size=30)
self.top2.add_widget(self.value1)
self.value2 = Label(text="value",font_size=30)
self.top2.add_widget(self.value2)
self.value3 = Label(text="value",font_size=30)
self.top2.add_widget(self.value3)
self.value4 = Label(text="value",font_size=30)
self.top2.add_widget(self.value4)
self.value5 = Label(text="value",font_size=30)
self.top2.add_widget(self.value5)
self.add_widget(Label(text=" ", font_size=60))
self.add_widget(Label(text=" ", font_size=60))
self.add_widget(Label(text=" ", font_size=60))
self.add_widget(Label(text=" ", font_size=60))
self.add_widget(Label(text=" ", font_size=60))
self.add_widget(Label(text=" ", font_size=60))
self.add_widget(Label(text=" ", font_size=60))
def my_callback1(dt):
global a
import random
a = str(random.randrange(0,100))
self.value1.text=a
def my_callback2(dt):
global b
import random
b = str(random.randrange(0,100))
self.value2.text=b
def my_callback3(dt):
global c
import random
c = str(random.randrange(0,100))
self.value3.text=c
def my_callback4(dt):
global d
import random
d = str(random.randrange(0,100))
self.value4.text=d
def my_callback5(dt):
global e
import random
e = str(random.randrange(0,100))
self.value5.text=e
# call my_callback every 0.5 seconds
Clock.schedule_interval(my_callback1, 0.5)
Clock.schedule_interval(my_callback2, 0.5)
Clock.schedule_interval(my_callback3, 0.5)
Clock.schedule_interval(my_callback4, 0.5)
Clock.schedule_interval(my_callback5, 0.5)
class epicbrain(App):
def build(self):
return MeinLayout()
if __name__ == "__main__":
epicbrain().run()
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.
I put my implementation below. Happy to answer any questions.
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.clock import Clock
from kivy.properties import StringProperty # Use the String Property
from kivy.lang.builder import Builder
import random
kv = """
<BigLabel30@Label>:
font_size: 30
<BigLabel60@Label>: # This defined a class BigLable60, derived from Label to avoid typing the same font_size 5 times.
font_size: 60
MeinLayout:
orientation: 'vertical'
Label:
size_hint_y: 10
text: 'Dashboard'
font_size: 60
GridLayout:
size_hint_y: 4
cols: 5
BigLabel30:
text: 'Step 1'
BigLabel30:
text: 'Step 2'
BigLabel30:
text: 'Step 3'
BigLabel30:
text: 'Step 4'
BigLabel30:
text: 'Step 5'
GridLayout:
cols: 5
size_hint_y: 10
BigLabel60:
text: root.a # root.x refers the properties defined in the class. They update automatically.
BigLabel60:
text: root.b
BigLabel60:
text: root.c
BigLabel60:
text: root.d
BigLabel60:
text: root.e
BoxLayout:
size_hint_y: 20 # This is for spacing
"""
class MeinLayout(BoxLayout):
a = StringProperty('value') # you would give these variables meaningful names...
b = StringProperty('value') # This sets the initial value to 'value'
c = StringProperty('value')
d = StringProperty('value')
e = StringProperty('value')
def __init__(self, **kwargs):
super().__init__(**kwargs)
Clock.schedule_interval(self.my_callback1, 0.5)
def my_callback1(self, dt): # call my_callback every 0.5 seconds
self.a = str(random.randrange(0, 100))
self.b = str(random.randrange(0, 100))
self.c = str(random.randrange(0, 100))
self.d = str(random.randrange(0, 100))
self.e = str(random.randrange(0, 100))
class EpicBrain(App):
def build(self):
return Builder.load_string(kv)
if __name__ == "__main__":
EpicBrain().run()
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/d6253bd6-c098-40ff-bba5-6869d73e406d%40googlegroups.com.