def build(self, source, i, j, cols, rows, onpress): self.do_translation = False self.do_rotation = False self.do_Scale = False self.myNum = 1 + i + j * cols self.cellPos = [i, j] self.btn = Button(text="[color=000000]" + str(self.myNum) + "[/color]", size=self.size, font_size=70, markup=True) self.btn.background_color = (10.0, 10.0, 10.0, 0.2) self.btn.bind(on_press=onpress) texture = Image(source=source).texture texture.uvpos = (float(i) / cols, float(j + 1) / rows) texture.uvsize = (1.0 / cols, -1.0 / rows) with self.canvas: Rectangle(texture=texture, size=self.size) Color(0, 0, 0, 0.5) self.outline = Line(points=[ 0, 0, self.size[0], 0, self.size[0], self.size[1], 0, self.size[1] ], joint='round', width=self.size[0] / 50.0, close=True) self.add_widget(self.btn)
def build(self, source, i, j, cols, rows, onpress): self.do_translation = False self.do_rotation = False self.do_Scale = False self.myNum = 1+i+j*cols self.cellPos = [i, j] self.btn=Button(text = "[color=000000]" + str(self.myNum) + "[/color]", size = self.size, font_size = 70, markup = True) self.btn.background_color = (10.0, 10.0, 10.0, 0.2) self.btn.bind(on_press=onpress) texture = Image(source = source).texture texture.uvpos=(float(i)/cols, float(j+1)/rows) texture.uvsize=(1.0/cols, -1.0/rows) with self.canvas: Rectangle(texture=texture, size=self.size) Color(0,0,0,0.5) self.outline = Line(points=[0, 0, self.size[0], 0, self.size[0], self.size[1], 0, self.size[1]], joint = 'round', width = self.size[0]/50.0, close = True) self.add_widget(self.btn)
def __init__(self, size, *args): super(Menu, self).__init__(size=size, *args) font_size = size[1] / 10 background = Image(source='images/background.png').texture background.wrap = 'repeat' aspectRatio = size[1] / float(background.size[1]) x = (Window.width / background.size[0] // aspectRatio) + 2 print(x) background.uvsize = x, -1 with self.canvas: rect = Rectangle(texture=background, size=[(background.size[0] * aspectRatio * x), size[1]]) boxlayout = BoxLayout(orientation='vertical', size=size) boxlayout.add_widget(Label(text='tap to start', font_size=font_size)) boxlayout.add_widget(Label(text='debug mode', font_size=font_size)) self.add_widget(boxlayout)