def __init__(self, players, **kwargs): self.log = GraphicalCoup.Log() Coup.__init__(self, players=players, deck_size=2, hand_size=2) RelativeLayout.__init__(self, **kwargs) self.add_widget(self.log) self.add_widget(GraphicalCoup.StatusLabel(self)) self.run_game()
def __init__(self, **args): RelativeLayout.__init__(self, **args) self.lastTouch = None self.tiles = {} self.viewPos = (50.7, -1.3) self.viewZoom = 14 self.unscaledTileSize = 512 self.tileSize = metrics.dp(self.unscaledTileSize) self.map = map.Map() #source = osmfile.OsmFile("Simple.osm.gz") source = osmfilecached.OsmFileCached("IsleOfWight-Fosm-Oct2013.osm.gz") highways = maphighways.MapHighways() highways.SetSource(source) self.map.AddPlugin(highways) water = mapwater.MapWater() water.SetSource(source) self.map.AddPlugin(water) places = mapplaces.MapPlaces() places.SetSource(source) self.map.AddPlugin(places) landscape = maplandscape.MapLandscape() landscape.SetSource(source) self.map.AddPlugin(landscape) Clock.schedule_interval(self.LateRendering, 0.1) self.bind(pos=self.update_graphics_pos, size=self.update_graphics_size)
def __init__(self, **kwargs): self.ix = None self.iy = None RelativeLayout.__init__(self, **kwargs) self.type = kwargs['type'] self.ix = kwargs['ix'] self.iy = kwargs['iy'] self.rectangle = None self.bomb = None self.effect = None
def __init__(self, **kwargs): self.image_size = kwargs['size'] RelativeLayout.__init__(self, size_hint=(None,None), **kwargs) self.grid = kwargs['grid'] self.start_position = self.pos self.frozen = False self.alive = True self.animation = None self.safe_pos = self.pos self.path = [] self.moving = False self.last_to_tuple = None self.move_duration = 0.25 self.setup() self.init()
def __init__(self, car_idx, initial_destination, args): self.pos = (100, 100) self._idx = car_idx self._sand_speed = _PADDING / 5.0 self._full_speed = _PADDING / 4.0 self._velocity = self._full_speed self._last_action = 0 # index of _ROTATIONS self._direction = Vector(-1, 0) self._scores = [] self._orientation = 0.0 self._distance = 0.0 self._current_destination = initial_destination self._write_status_file = args.write_status_file if self._write_status_file: self._status_file = open("car{}_status".format(car_idx), "w") RelativeLayout.__init__(self) with self.canvas.before: PushMatrix() self._rotation = Rotate() with self.canvas.after: PopMatrix() self._center = Center() self._body = Body(Vector(-5, -5), _IDX_TO_COLOR[self._idx][0]) self._mid_sensor = Sensor(Vector(-30, -5), RGBAColor.RED, self._rotation) self._right_sensor = Sensor(Vector(-20, 10), RGBAColor.GREEN, self._rotation) self._left_sensor = Sensor(Vector(-20, -20), RGBAColor.BLUE, self._rotation) if args.use_pytorch: from torch_ai import Brain else: from simple_ai import Brain self._brain = Brain(len(self._state), len(self._ROTATIONS), args)
def __init__(self): def GoBack(self): print('activated') print(sm.current) sm.transition = NoTransition() if sm.current == "devicesnotes": sm.current = "notifications" elif sm.current == "phoneenotes": sm.current = 'notifications' elif sm.current == "notifications": sm.current = 'settings' elif sm.current == 'security': sm.current = 'settings' elif sm.current == 'dispensing': sm.current = 'settings' elif sm.current == 'accessibility': sm.current = 'settings' sm.transition = SlideTransition() Button.__init__(self) RelativeLayout.__init__(self) self.background_normal = '' self.background_color = White self.bind(on_press=GoBack)
def __init__(self, app): RelativeLayout.__init__(self) self.app = app self.init_child_widgets()
def __init__(self, **kwargs): RelativeLayout.__init__(self, **kwargs) self.app = App.get_running_app() update_event = Clock.schedule_interval(self.update, 1)
def __init__(self, **kwargs): RelativeLayout.__init__(self, **kwargs) self.item = SPACE self.category = 'map'
def __init__(self, **kwargs): RelativeLayout.__init__(self, **kwargs)
def __init__(self, **kw): RelativeLayout.__init__(self, **kw) self.__navegation_episode = None self._end_game_events = [] self.last_hl = None
def __init__(self, app, **kwargs): RelativeLayout.__init__(self, **kwargs) self.app = app self.hidden = False self.layout_color = BoxLayout(orientation='horizontal', size_hint=(1, 1), pos=(0, 0)) with self.layout_color.canvas: Color(0.2, 0.2, 0.2, 1) layout_rect = Rectangle(pos=self.pos, size=(Window.width * PALETTE_LAYOUT_SIZE_HINT[0], Window.height * PALETTE_LAYOUT_SIZE_HINT[1])) layout1 = BoxLayout(orientation='vertical', size_hint=PALETTE_LAYOUT_CLMN_SIZE_HINT, spacing=1, padding=[1, 1, 0, 1]) self.butList1 = [x for x in xrange(0, PALETTE_BTN_COUNT)] self.butList2 = [x for x in xrange(0, PALETTE_BTN_COUNT)] self.colorpicker_dialog = dialog.ColorPickerDialog(self.app, (Window.width, Window.height)) for t in xrange(0, len(self.butList1)): self.butList1[t] = PaletteToggleButton() self.butList1[t].bind(on_press=partial(self.but_select, self.butList1[t])) self.butList1[t].on_hold = partial(self.open_colorpicker, self.butList1[t]) self.butList1[t].background_normal = "" layout1.add_widget(self.butList1[t]) self.butList1[t].background_color = (1, 0.05 * t, 0.05 * t, 1) layout2 = BoxLayout(orientation='vertical', size_hint=PALETTE_LAYOUT_CLMN_SIZE_HINT, spacing=1, padding=[1, 1, 0, 1]) for t in xrange(0, len(self.butList2)): self.butList2[t] = PaletteToggleButton() self.butList2[t].bind(on_press=partial(self.but_select, self.butList2[t])) self.butList2[t].on_hold = partial(self.open_colorpicker, self.butList2[t]) self.butList2[t].background_normal = "" layout2.add_widget(self.butList2[t]) self.butList2[t].background_color = (1, 0.05 * t, 0.05 * t, 1) self.butList1[0].background_color = (1, 1, 1, 1) self.butList1[1].background_color = (195 / 255., 195 / 255., 195 / 255., 1) self.butList1[2].background_color = (185 / 255., 122 / 255., 87 / 255., 1) self.butList1[3].background_color = (255 / 255., 174 / 255., 201 / 255., 1) self.butList1[4].background_color = (255 / 255., 201 / 255., 14 / 255., 1) self.butList1[5].background_color = (239 / 255., 228 / 255., 176 / 255., 1) self.butList1[6].background_color = (181 / 255., 230 / 255., 29 / 255., 1) self.butList1[7].background_color = (153 / 255., 217 / 255., 234 / 255., 1) self.butList1[8].background_color = (112 / 255., 146 / 255., 190 / 255., 1) self.butList1[9].background_color = (200 / 255., 191 / 255., 231 / 255., 1) self.butList2[0].background_color = (0, 0, 0, 1) self.butList2[1].background_color = (127 / 255., 127 / 255., 127 / 255., 1) self.butList2[2].background_color = (136 / 255., 0 / 255., 21 / 255., 1) self.butList2[3].background_color = (237 / 255., 28 / 255., 36 / 255., 1) self.butList2[4].background_color = (255 / 255., 127 / 255., 39 / 255., 1) self.butList2[5].background_color = (255 / 255., 242 / 255., 0 / 255., 1) self.butList2[6].background_color = (34 / 255., 177 / 255., 76 / 255., 1) self.butList2[7].background_color = (0 / 255., 162 / 255., 232 / 255., 1) self.butList2[8].background_color = (63 / 255., 72 / 255., 204 / 255., 1) self.butList2[9].background_color = (163 / 255., 73 / 255., 164 / 255., 1) self.pos_in = (PALETTE_LAYOUT_POS_HINT[0] * Window.width, PALETTE_LAYOUT_POS_HINT[1] * Window.height) self.pos_out = (Window.width + 1, PALETTE_LAYOUT_POS_HINT[1] * Window.height) self.animation_show = Animation(pos=self.pos_in, transition='in_quad', duration=0.3) self.animation_hide = Animation(pos=self.pos_out, transition='in_quad', duration=0.3) self.size_hint = PALETTE_LAYOUT_SIZE_HINT self.pos = self.pos_in self.layout_color.add_widget(layout1) self.layout_color.add_widget(layout2) self.add_widget(self.layout_color) self.btn_show_palette = ToggleButton(pos=(Window.width - PALETTE_BTN_SHOW_SIZE_HINT[0] * Window.width, 0), background_normal=data_path('palette.png'), background_down=data_path('palette_down.png'), border=[0, 0, 0, 0], size_hint=PALETTE_BTN_SHOW_SIZE_HINT, on_press=self.animate_switch) self.btn_show_palette.state = 'down'
def __init__(self, app, **kwargs): self.cover_layout = None RelativeLayout.__init__(self, **kwargs) self.app = app self.active_tool = None self.prev_tool = None self.pos_in = (0, TOOLBAR_LAYOUT_POS_HINT[1] * Window.height + 1) self.pos_out = (-Window.width * TOOLBAR_LAYOUT_SIZE_HINT[0] - 1, TOOLBAR_LAYOUT_POS_HINT[1] * Window.height + 1) self.hidden = False self.animation_show = Animation(pos=self.pos_in, transition='in_quad', duration=0.3) self.animation_hide = Animation(pos=self.pos_out, transition='in_quad', duration=0.3) self.size_hint = TOOLBAR_LAYOUT_SIZE_HINT self.pos = (TOOLBAR_LAYOUT_POS_HINT[0] * Window.width, TOOLBAR_LAYOUT_POS_HINT[1] * Window.height + 1) self.add_popup_menus() # self.btn_figs.callback = self.tool_menu.show self.tool_menu.tool = TOOL_LINE self.tool_menu_pen.tool = TOOL_PENCIL1 self.tool_menu_eraser.tool = TOOL_ERASE1 self.remove_widget(self.tool_menu) self.remove_widget(self.tool_menu_pen) self.remove_widget(self.tool_menu_eraser) self.btn_show_toolbar = ToggleButton(pos=(0, 0), background_normal=data_path('pencil_tool.png'), background_down=data_path('pencil_down.png'), border=[0, 0, 0, 0], size_hint=PALETTE_BTN_SHOW_SIZE_HINT, on_press=self.animate_switch) self.btn_data_background_normal = { str(TOOL_PENCIL1): data_path('pencil_tool.png'), str(TOOL_PENCIL2): data_path('pencil_tool.png'), str(TOOL_PENCIL3): data_path('pencil_tool.png'), str(TOOL_ERASE1): data_path('eraser_tool.png'), str(TOOL_ERASE2): data_path('eraser_tool.png'), str(TOOL_ERASE3): data_path('eraser_tool.png'), str(TOOL_RECT): data_path('rect_tool.png'), str(TOOL_ELLIPSE): data_path('ellipse_tool.png'), str(TOOL_LINE): data_path('line_tool.png'), str(TOOL_FILL): data_path('buck_tool.png'), str(TOOL_PICKER): data_path('picker_tool.png'), str(TOOL_MOVE): data_path('move_tool.png'), str(TOOL_SELECT): data_path('select_tool.png'), } self.btn_data_background_down = { str(TOOL_PENCIL1): data_path('pencil_1_down.png'), str(TOOL_PENCIL2): data_path('pencil_2_down.png'), str(TOOL_PENCIL3): data_path('pencil_3_down.png'), str(TOOL_ERASE1): data_path('eraser_1_down.png'), str(TOOL_ERASE2): data_path('eraser_2_down.png'), str(TOOL_ERASE3): data_path('eraser_3_down.png'), str(TOOL_RECT): data_path('rect_down.png'), str(TOOL_ELLIPSE): data_path('ellipse_down.png'), str(TOOL_LINE): data_path('line_down.png'), str(TOOL_FILL): data_path('buck_down.png'), str(TOOL_PICKER): data_path('picker_down.png'), str(TOOL_MOVE): data_path('move_down.png'), str(TOOL_SELECT): data_path('select_down.png'), } self.btn_show_toolbar.state = 'down' with self.canvas.before: Color(0.2, 0.2, 0.2, 1) layout_rect = Rectangle(pos=(0, 0), size=(TOOLBAR_LAYOUT_SIZE_HINT[0]*WIN_WIDTH, TOOLBAR_LAYOUT_SIZE_HINT[1]*WIN_HEIGHT))