from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.properties import NumericProperty, ReferenceListProperty, ObjectProperty
class MoneyControl(Widget):
mainScrollView = ObjectProperty(None)#This references an INSTACE YET CREATED from kv file
childGridLayout = ObjectProperty(None)
# Just a for to create 100 instances of button.
buttonsList = [None]
for i in range(100):
buttonsList.append(Tbutton())#What should I put here in place of "Tbutton()" to get a new tButton instance? OR how can I "import" the class from .kv file, and not a single instance?
buttonList[-1].parent(childGridLayout)
print buttonsList
class MoneyControlApp(App):
def build(self):
prog = MoneyControl()
return prog
if __name__ == '__main__':
MoneyControlApp().run()
#:kivy 1.0.9
<Tbutton@Button>:# nameYouWant @ class
text: "Test Text"
size_hint_y: None
height: 40
background_normal: ""
background_color: 0.7, 0.9, 0.7, 1.0
<ScView@ScrollView>:
size_hint: None, None
#size: root.width, root.height
#top: 0
#center_x: root.width
pos: 100,200
<Glo@GridLayout>:
cols:1
spacing:0
size_hint: None, None
#size_hint_x: None
#size_hint_y: None
height: self.minimum_height
<MoneyControl@Widget>:
mainScrollView:rollerresults
childGridLayout:resultsBlock
ScView:
id:rollerresults
size: 800, 600
Glo:
id:resultsBlock
# Tbutton:#This list of buttons, from main.py
# Tbutton:#To be able to add/remove as user needs.
# Tbutton: ....
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.properties import NumericProperty, ReferenceListProperty, ObjectProperty
from kivy.factory import Factory
class MoneyControl(Widget):
mainScrollView = ObjectProperty(None)#This references an INSTACE YET CREATED from kv file
childGridLayout = ObjectProperty(None)
Factory.register('buttonFromKvFile', cls=Tbutton)#Here Factory register the class "Tbutton" from KvFile with the name of "buttonFromKvFile"
Tbutton1 = Factory.buttonFromKvFile()#Here we create an INSTANCE called Tbutton1 from Tbutton class?
# Just a for to create 100 instances of button.
buttonsList = [None]
for i in range(100):
buttonsList.append(Tbutton())#What should I put here in place of "Tbutton()" to get a new tButton instance? OR how can I "import" the class from .kv file, and not a single instance?
buttonList[-1].parent(childGridLayout)
print buttonsList
class MoneyControlApp(App):
def build(self):
prog = MoneyControl()
return prog
if __name__ == '__main__':
MoneyControlApp().run()
from kivy.lang import Builder
Builder.load_file(myfile.kv)
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.properties import NumericProperty, ReferenceListProperty, ObjectProperty
from kivy.factory import Factory
from kivy.lang import Builder #Used for import rules from several .kv files
class MoneyControl(Widget):
Builder.load_file("moneycontrol.kv")#"moneycontrol.kv" is a path/file relative to main.py, string type.
mainScrollView = ObjectProperty(None)#This references an INSTACE YET CREATED from kv file
childGridLayout = ObjectProperty(None)
Factory.register('buttonFromKvFile', cls=Tbutton)#Here Factory register the class "Tbutton" from KvFile with the name of "buttonFromKvFile"
Tbutton1 = Factory.buttonFromKvFile()#Here we create an INSTANCE called Tbutton1 from Tbutton class?
# Just a for to create 100 instances of button.
buttonsList = [None]
for i in range(100):
buttonsList.append(Tbutton())#What should I put here in place of "Tbutton()" to get a new tButton instance? OR how can I "import" the class from .kv file, and not a single instance?
buttonList[-1].parent(childGridLayout)
print buttonsList
class MoneyControlApp(App):
def build(self):
prog = MoneyControl()
return prog
if __name__ == '__main__':
MoneyControlApp().run()
I think kv file was applying correctly, since haves the same name (in lowercase) than app name...
So, ideas?.
Zen, do you really have some time to take it a look?
I'm grateful at least, to find somebody can help and put me in the right way, but I have the sensation you have not much time for this, as if other worries and problems would be distracting or giving you very little time to help here, in spite of you really want to help, no doubt about this for my side.
Hope all to be going well there.
Man, take your time for your needs, you have no obligation with me or anybody else, and when you can, if you want, come back and give us a hand.
Thanks for your time, really.
# Just a for to create 100 instances of button.
def __init__(self, **kwargs):
super(MoneyControl, self).__init__(**kwargs)
buttonsList = [None]
for i in range(100):
button = Factory.Tbutton()
buttonsList.append(button)
self.childGridLayout.add_widget(button)