Hi all!
I'm having some difficulty trying to do something so I would really appreciate any help
I'm trying to create a GridLayout which will be displaying the contents of an excel spreadsheet.
The problem is that there's not a fixed number of columns (or rows for that matter) in the excel file. For example, when you load one file it can have, say, 12 columns and the next time you load a different excel file with 15 columns.
In my python code, I have a method which returns the number of columns and rows. However, in my .kv file, I cannot find a way to make it recognise the numbers.
So, when I do for example:
ScrollView:
id: scroll_view
size_hint_y: 0.8
size_hint_x: 1
GridLayout:
id: scroll_box
orientation: 'vertical'
cols: m.MainMenu.get_cols()
raws: m.MainMenu.get_rows()
size_hint: None, None
I get this error (I post the whole Trace back):
Traceback (most recent call last):
File "main.py", line 84, in <module>
IWTApp().run()
File "/usr/lib/python2.7/dist-packages/kivy/app.py", line 798, in run
root = self.build()
File "main.py", line 57, in build
sm.add_widget(TestCondition(name='test'))
File "/home/eleftherios/Desktop/App/choice.py", line 27, in __init__
super(TestCondition, self).__init__(**kwargs)
File "/usr/lib/python2.7/dist-packages/kivy/uix/relativelayout.py", line 255, in __init__
super(RelativeLayout, self).__init__(**kw)
File "/usr/lib/python2.7/dist-packages/kivy/uix/floatlayout.py", line 66, in __init__
super(FloatLayout, self).__init__(**kwargs)
File "/usr/lib/python2.7/dist-packages/kivy/uix/layout.py", line 66, in __init__
super(Layout, self).__init__(**kwargs)
File "/usr/lib/python2.7/dist-packages/kivy/uix/widget.py", line 271, in __init__
Builder.apply(self)
File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1872, in apply
self._apply_rule(widget, rule, rule)
File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 2018, in _apply_rule
e), cause=tb)
kivy.lang.BuilderException: Parser: File "./iwtapp.kv", line 213:
...
211: #:set nrows 15
212: cols: m.MainMenu.get_cols()
>> 213: raws: m.MainMenu.get_rows()
214: size_hint: None, None
215: # TextInput:
...
ValueError: None is not allowed for GridLayout.raws
File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 2012, in _apply_rule
setattr(widget_set, key, value)
File "weakproxy.pyx", line 22, in kivy.weakproxy.WeakProxy.__setattr__ (kivy/weakproxy.c:1218)
File "properties.pyx", line 397, in kivy.properties.Property.__set__ (kivy/properties.c:4543)
File "properties.pyx", line 426, in kivy.properties.Property.set (kivy/properties.c:4982)
In my python code I have defined
cols = None
rows = None
so I suppose that's why I get the above ValueError. However, if I comment out this line (rows = None) I get an AttributeError:
AttributeError: type object 'MainMenu' has no attribute 'rows'
I have to admit that my experience with python and kivy is limited so I would really appreciate it if someone could help me out with this!
Thanks,
Lefteris