class MyApp (App): def build (self): parent = BoxLayout () def print_move (self, touch): print touch.x, ', ', touch.y parent.bind (on_touch_move=print_move) self.btnIndex = 1 self.c = CircularLayout () editlayout = BoxLayout (orientation='vertical', size_hint = (0.2, 1)) addwidgetbutton = Button (text='Add buttons') addwidgetbutton.bind (on_press=self.add_widget_action) rotateleftbutton = Button (text='Rotate Left') rotateleftbutton.bind (on_press=self.rotate_left_action) rotaterightbutton = Button (text='Rotate right') rotaterightbutton.bind (on_press=self.rotate_right_action) editlayout.add_widget (addwidgetbutton) editlayout.add_widget (rotateleftbutton) editlayout.add_widget (rotaterightbutton) parent.add_widget (self.c) parent.add_widget (editlayout) return parent def add_widget_action (self, instance): btnText = 'Button text ' + str(self.btnIndex) btnTemp = Button (text=btnText) self.c.add_widget(btnTemp) self.btnIndex += 1 print self.c.get_child().text def rotate_right_action (self, instance): self.c.do_rotation() def rotate_left_action (self, instance): self.c.do_rotation(-1)
def build (self): parent = BoxLayout () def print_move (self, touch): print touch.x, ', ', touch.y parent.bind (on_touch_move=print_move) self.btnIndex = 1 self.c = CircularLayout () editlayout = BoxLayout (orientation='vertical', size_hint = (0.2, 1)) addwidgetbutton = Button (text='Add buttons') addwidgetbutton.bind (on_press=self.add_widget_action) rotateleftbutton = Button (text='Rotate Left') rotateleftbutton.bind (on_press=self.rotate_left_action) rotaterightbutton = Button (text='Rotate right') rotaterightbutton.bind (on_press=self.rotate_right_action) editlayout.add_widget (addwidgetbutton) editlayout.add_widget (rotateleftbutton) editlayout.add_widget (rotaterightbutton) parent.add_widget (self.c) parent.add_widget (editlayout) return parent
def layout_setup(self): self.p = Parser('info.uwaft') wheelRim = CircularLayout(pos=(Window.center[0],Window.center[1]-40),size_hint=(None,None),radius=self.wheel1.parent.height*1,rotate=True) for i in range(1,5): wheelRim.add_widget(Button (background_normal = 'img/n'+str(i)+'.png', background_down='img/n'+str(i)+'.png',size_hint=(None,None),size=(self.wheel1.parent.size[0]*1.1,self.wheel1.parent.size[1]*1.1))) self.wheel1.add_widget(wheelRim) wheelMenu = CircularLayout(fin=self.p,pos=(Window.center[0],Window.center[1]-55),size_hint=(None,None),radius=self.wheel1.parent.height*1.7,pushAnimate=True) self.menu = wheelMenu for view in self.p.v_icons: wheelMenu.add_widget(Button (background_normal = view, background_down=view,size_hint=(None,None),size=(self.wheel1.parent.size[0]*1.1,self.wheel1.parent.size[1]*1.1))) self.wheel1.add_widget(wheelMenu) scatterImg = [] size = (200,200) dir = -1 for i in range(0,8): src = 'img/' + str(i)+'w.png' temp = self.scatter_image(src,size) scatterImg.append(temp) self.wheel1.add_widget(scatterImg[i]) dir = -dir self.rotate(scatterImg[i], direction = dir)