I am creating buttons (eventually in a loop) in a PY file in the TileStack claas below.
from kivy.uix.button import Button
from kivy.uix.widget import Widget
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.floatlayout import FloatLayout
from kivy.config import Config
Config.set('graphics', 'resizable', True)
class Main(GridLayout):
pass
class TileStack(Widget): ##################################################
def __init_subclass__(self, **kwargs):
super().__init__(**kwargs)
bt = Button(text="z")
self.add_widget(bt)
class MainApp(App):
def build(self):
return Main()
if __name__ == "__main__":
app = MainApp()
app.run()
I then then want to insert these using the TileStack class name into the KY design file below.
Main:
<TestLabel@Label>:
font_size: 32
text: "0"
background_color: 1, 1, 1, 1
background_normal: ""
size_hint: [0.093,0.15]
canvas.before:
Color:
rgba: 1, 1, 1, 1
RoundedRectangle:
size: self.size
pos: self.pos
<TestButton@Button>:
font_size: 32
background_color: 0, 0, 0, 0
color: 0,0,0,1
background_normal: ""
canvas.before:
Color:
rgba: 1, 237/255, 89/255, 1
Rectangle:
size: self.size
pos: self.pos
<Main>:
rows: 2
cols: 1
canvas.before:
Rectangle:
source: "graphics/gameboard.png"
size: self.size
pos: self.pos
TileStack: ################################################
FloatLayout:
TestLabel:
color: 0,0,0,1
pos_hint: {'x':0.056, 'y':0.011}
TestLabel:
color: 0,0,0,1
pos_hint: {'x':0.456, 'y':0.011}
TestButton:
text: "Submit"
size_hint: 0.090,0.047
pos_hint: {'x':0.562, 'y':0.026}
TestLabel:
color: 0,0,0,1
pos_hint: {'x':0.854, 'y':0.011}
I have two problems.
1. The FloatLayout is inserted into the GridLayout as if there are two buttons: one blank one followed the one as built in the KV file.
2. The TileStack button does not appear at all.
I have reviewed many videos and visited many google searches but have had no success. Any suggestions as how to eliminate these problems is appreciated.