def __init__(self, **kwargs): super(MyPaintWidget, self).__init__(**kwargs) self._keyboard = Window.request_keyboard(self._keyboard_closed, self, 'text') self._keyboard.bind(on_key_down=self._on_keyboard_down) Window.size = (1366, 768) self.size = Window.size # if smoke true - user can draw rectangle self.smoke = False # if fire true - user can draw rectangle self.fire = False # list with points of fire rectangle self.rectanglePoints = [] # number of current frame self.numberOfFrame = 0 # if video open isVideoOpen = True self.isVideoOpen = False # video self.video = None # filename of result txt file self.txtFilename = "" # path to temp directory self.dirPath = "" # dictionary with points self.dictionary = {} self.Forest = "" self.In = "" self.Out = "" self.start = 0 self.finish = 0 self.type = "None" self.move = False self.time = time.time()
def build(self): self._keyboard = Window.request_keyboard(self._keyboard_closed, self) self._keyboard.bind(on_key_down=self._on_keyboard_down) self.buildOrganells() root = FloatLayout(width=(Window.width),height=(Window.height),) with root.canvas: Line(circle=(Window.width/2,Window.height/2,Window.height/2)) for obj in self.organelles: root.add_widget(obj[1]) for obj in self.mitochondria: root.add_widget(obj[1]) self.buildATP() root.add_widget(self.ATP) Clock.schedule_interval(self.makeSureOrganellesAreAlive, 1) Clock.schedule_interval(self.updateGlucose,10) return root
def __init__(self, app, *args, **kwargs): super(ScreenNine, self).__init__(*args, **kwargs) self.app = app self.win_popup = WinPopup(app, "You have played all the stages", "Taking you to menu screen", "menu") self.lose_popup = LosePopup(app, "Sorry you lost the game", "Try again", "nine") self.box_size = [Window.size[0] / 16., Window.size[1] / 10.] self.init_physics() self.keyboard = Window.request_keyboard(self.keyboard_closed, self, 'text') self.keyboard.bind(on_key_down=self.on_keyboard_down) self.keyboard.bind(on_key_up=self.on_keyboard_up) Clock.schedule_interval(self.step, 1/FRAMES) #Adding the lines for i in xrange(16): with self.canvas: Color(0, 0, 0, 0.3) Line(points=[self.box_size[0]*i, 0, self.box_size[0]*i, Window.size[1]], width=0.3) for i in xrange(10): with self.canvas: Line(points=[0, self.box_size[1]*i, Window.size[0], self.box_size[1]*i], width=0.3) #Adding back and forward buttons back_button = Button(text="<", pos=[Window.size[0]*0.025, Window.size[1]*0.925], size_hint = [0.05, 0.05]) back_button.bind(on_press=self.back_btn_pressed) #forward_button = Button(text=">", pos=[Window.size[0]*0.925, Window.size[1]*0.925], size_hint = [0.05, 0.05]) #forward_button.bind(on_press=self.forward_btn_pressed) self.add_widget(back_button)
def start(self, difficulty): if not android: self._keyboard = Window.request_keyboard( self.keyboard_closed, self) self._keyboard.bind(on_key_down=self._on_keyboard_down) self.points = 0 self.life = LIFE self.life_list = [] self.index = 0 for life in range(LIFE): image = Image( source=('img/life_%s.png' % random.randint(1, 2)), x = 1.1 * life * (self.height // 17), y = self.height - self.height // 17, size = (self.height // 17, self.height // 17), allow_stretch = True) self.life_list.append(image) Clock.schedule_interval(self.display_lifes, 0.2) for child in self.children: if isinstance(child, UFO): self.remove_widget(child) self.difficulty = difficulty self.add_widget(UFO(self.cows, self.difficulty, self.engine_sound, self.shot_sound)) self.control_object = Controls() self.add_widget(self.control_object)
def __init__(self, app, *args, **kwargs): super(ScreenThree, self).__init__(*args, **kwargs) self.app = app self.win_popup = WinPopup(app, "You won the game", "Green = Good\nRed = Bad", "four") self.win_popup.bind(on_dismiss=self.on_pre_leave) self.box_size = [Window.size[0] / 16., Window.size[1] / 10.] self.init_physics() if not self.app.is_touch: self.keyboard = Window.request_keyboard(self.keyboard_closed, self, 'text') self.keyboard.bind(on_key_down=self.on_keyboard_down) self.keyboard.bind(on_key_up=self.on_keyboard_up) Clock.schedule_interval(self.step, 1/FRAMES) #Adding the lines for i in xrange(16): with self.canvas: Color(0, 0, 0, 0.3) Line(points=[self.box_size[0]*i, 0, self.box_size[0]*i, Window.size[1]], width=0.3) for i in xrange(10): with self.canvas: Line(points=[0, self.box_size[1]*i, Window.size[0], self.box_size[1]*i], width=0.3) #Adding back and forward buttons back_button = Button(text="<", pos=[Window.size[0]*0.025, Window.size[1]*0.925], size_hint = [0.05, 0.05]) back_button.bind(on_press=self.back_btn_pressed) forward_button = Button(text=">", pos=[Window.size[0]*0.925, Window.size[1]*0.925], size_hint = [0.05, 0.05]) forward_button.bind(on_press=self.forward_btn_pressed) self.add_widget(back_button) self.add_widget(forward_button)
def __init__(self, **kwargs): super(Pairs, self).__init__(**kwargs) self._keyboard = Window.request_keyboard( self._keyboard_closed, self, 'text') self._keyboard.bind(on_key_down=self._on_keyboard_down) self.datafile = open('pairs.csv', 'a') self.newkind = 'nothing'
def __init__(self, **kwargs): # Call the super constructor and then set the number of columns super(GameBoard, self).__init__(**kwargs) self.cols = 4 self.rows = 4 # Create the 2D array to store the board self.game_board = [[0 for x in range(4)] for x in range(4)] # Create the previous game board self.previous_game_board = [[0 for x in range(4)] for x in range(4)] # Add the grid blocks self.display_board = [[0 for x in range(4)] for x in range(4)] for row_ind in range(0,4): for col_ind in range(0,4): self.display_board[row_ind][col_ind] = Label(text='0',text_size=(None, None)) self.add_widget(self.display_board[row_ind][col_ind]) # Add the keyboard listener self._keyboard = Window.request_keyboard(self._keyboard_closed, self, 'text') if self._keyboard.widget: pass self._keyboard.bind(on_key_down=self._on_keyboard_down) # Initialize the board self._initialize_board() # Update the board self._update_board()
def __init__(self, **kwargs): super(DarkforcesGame, self).__init__(**kwargs) self._keyboard = Window.request_keyboard(self._keyboard_closed, self) self._keyboard.bind(on_key_down=self._on_keyboard_down) #self.ground[0].pos = Vector(self.ground.pos) + Vector(self.player.pos) self.generateFloor()
def __init__(self, **kwargs): super(PongGame, self).__init__(**kwargs) self._keyboard = Window.request_keyboard(self._keyboard_closed, self) self._keyboard.bind(on_key_down=self._on_keyboard_down) # initialize concentration self.concentration = 0.0
def __init__(self, binds=None, **kwargs): self.binds = binds super().__init__(**kwargs) keyboard = Window.request_keyboard(lambda:None, self) keyboard.bind(on_key_down=self._on_key_down) self._keyboard = keyboard self.factory = factory
def __init__(self): App.__init__(self) self.STACK= ExdStack() self._keyboard = Window.request_keyboard(self._keyboard_closed, self) self._keyboard.bind(on_key_down=self._on_keyboard_down) self.keyEvents = {}
def _request_keyboard(self): print("Requesting keyboard.") self._keyboard = Window.request_keyboard( self._keyboard_closed, self ) self._keyboard.bind(on_key_down=self._on_keyboard_down)
def save_level(self): # Pull the level number from the text input box next to the save button. level_number = self.ids.level_number.text # Save a picture of the level to be used as a level_button thumbnail in the level selector. self.physics_interface.export_to_png("libs/level_selector/Resources/{}.png".format(level_number)) # Retrieve the total list of game objects currently populating the physics interface. level = self.physics_interface.get_game_objects() # Remove all objects from the physics interface. (Without this step, the objects won't pickle) for obj in level: obj.remove() # Pickle (Serialize) the objects into a file called 'levels/levelX' where X is specified by the user. level_name = "levels/level{}".format(level_number) with open(level_name, "w") as f: pickle.dump(level, f) # Load the objects back into the physics interface. for obj in level: obj.load_into_physics_interface(self.physics_interface) # When working on desktop, it's useful to enable scaling and translation. self._keyboard = Window.request_keyboard(self._keyboard_closed, self, "text") self._keyboard.bind(on_key_down=self._on_keyboard_down)
def __init__ (self, **kwargs): super (LoginScreen, self).__init__ (**kwargs) self._keyboard = Window.request_keyboard (self._keyboard_closed, self, "text") if self._keyboard.widget: self._keyboard.widget.layout = "newLayout.json" self._keyboard.widget.margin_hint = [.05, .03, .05, .03] self._keyboard.bind (on_key_down = self._on_keyboard_down)
def __init__(self, **kwargs): super(PostScreenManager, self).__init__(**kwargs) self.transition = RiseInTransition() # get the post wall and post carousel references wall = self.ids['pw'] carousel = self.ids['pc'] # pass the refernece to the screen manager wall.screen_manager = self carousel.screen_manager = self # generate new data data = post_generator.generate_new_data() self.number_of_posts = len(data) # pass the data tot he post wall wall.data = data # feed the carousel with the data for item in data: if 'ImagePost' in item['viewclass']: carousel.add_widget(Image(source=item['image_path'])) elif 'TextPost' in item['viewclass']: carousel.add_widget(Label(text=item['label_text'])) self._keyboard = Window.request_keyboard(self._keyboard_closed, self) if not self._keyboard: return self._keyboard.bind(on_key_down=self.on_keyboard_down) self.movement_flag = False #self.current_active_post_index = None Clock.schedule_once(wall.center_first_post, 1)
def _keyboard_open(self): # Used to add keyboard functionality. This must be called whenever one loses focus to other text-inputs in the editor. Very important! # Keyboard listener: self._keyboard = Window.request_keyboard(self._keyboard_closed, self) # Bind keyboard. self._keyboard.bind(on_key_down = self._on_keyboard_down) self._keyboard.bind(on_key_up = self._on_keyboard_up)
def __init__(self, game_state, device): super(PongMonitorWidget, self).__init__() self.game_state = game_state self.device = device self.game_elements = {} self._keyboard = Window.request_keyboard(self._keyboard_closed, self) self._keyboard.bind(on_key_down=self._on_keyboard_down)
def __init__(self, *args, **kwargs): super(Snake, self).__init__(*args, **kwargs) self._keyboard = Window.request_keyboard(self._keyboard_closed, self, "text") self._keyboard.bind(on_key_down=self._on_keyboard_down) self._initialize_game()
def __init__(self, root_widget, **kw): super(GameWidget, self).__init__(**kw) self.root_widget = root_widget self._keyboard = Window.request_keyboard(self._keyboard_closed, self) self._keyboard.bind(on_key_down=self._on_keyboard_down) self._keyboard.bind(on_key_up=self._on_keyboard_up) self.ship = Ship() with self.canvas.before: self.rect_bg1 = Image(source='img/background-blue.png', allow_stretch=True, keep_ratio=False) self.rect_bg2 = Image(source='img/background-blue.png', allow_stretch=True, keep_ratio=False) # , allow_stretch=True, keep_ratio=False self.bind(size=self._update_rect) self.bind(pos=self._update_rect) self.counter = 0 self.level = 0 self.drones = [] self.saucers = [] Clock.schedule_interval(self.update_game, 1./60) self.sfx_laser = SoundPygame(source='sfx/laser.wav') self.sfx_explo = SoundPygame(source='sfx/explosion.wav') # self.sfx_laser = SoundLoader.load('sfx/laser.wav') # self.sfx_explo = SoundLoader.load('sfx/explosion.wav') self.img_explo = [] with self.canvas.after: Color(.8, .2, .2, 1) self.lifebar = Rectangle() self.score = 0 self.accel = 0 self._initialized = False
def build(self): # Create the screen manager #sm = ScreenManager() self.sm.add_widget(SpeakerScreen(name='SpeakerScreen')) self.sm.add_widget(FavoriteScreen(name='FavoriteScreen')) self.sm.add_widget(SearchScreen(name='SearchScreen')) if raspPi == 0: #if not on a pi use keyboard self._keyboard = Window.request_keyboard(self._keyboard_closed, self) self._keyboard.bind(on_key_down=self._on_keyboard_down) #if a pi setup GPIO if raspPi == 1: GPIO.setmode(GPIO.BCM) #input pins for pagescroll GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.add_event_detect(23, GPIO.FALLING, callback=self.ButtonPress, bouncetime=300) GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.add_event_detect(22, GPIO.FALLING, callback=self.ButtonPress, bouncetime=300) GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.add_event_detect(27, GPIO.FALLING, callback=self.ButtonPress, bouncetime=300) GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.add_event_detect(17, GPIO.FALLING, callback=self.ButtonPress, bouncetime=300) #output for backlight GPIO.setup(18, GPIO.OUT) GPIO.output(18, True) return self.sm
def __init__(self, **kwargs): self.dataDir = "" super(TestGame, self).__init__(**kwargs) Clock.schedule_once(self.init_game) self.entIDs = [] self.mainTools = self.ids['gamescreenmanager'].ids['main_screen'].ids['mainTools'] self.mainTools.setRef(self) self.mainTools.setTool("poly") self.startID = -1 self.finishID = -1 self.selectedShapeID = None self.space = None self.serials = None self.scripty = None self.todelete = [] self.jointEnts = {} self.selectedListIndex = 0 self.lastlist = None self.touches = {}#0: {"active": False, "pos": (0, 0), "screenpos": (0, 0)}} self.atlas = Atlas('assets/myatlas.atlas') try: self._keyboard = Window.request_keyboard(self._keyboard_closed, self) self._keyboard.bind(on_key_down=self._on_keyboard_down) except: print 'Python python no keyboard' size = Window.size with self.canvas.before: #Color(0.5, 0.65, 0.95) self.bgrect = Rectangle(source='sprites/bgm.jpg', size=size) Window.bind(on_resize=self.redogb)
def __init__(self, **kwargs): super(OverView, self).__init__(**kwargs) self.add_widget(TreeView()) self._keyboard = Window.request_keyboard(self._keyboard_closed, self) self._keyboard.bind(on_key_down=self._on_keyboard_down)
def __init__(self, **kwargs): self.writing = False Window.bind(mouse_pos=self.update_pos) self._keyboard = Window.request_keyboard(self._keyboard_closed,self) self._keyboard.bind(on_key_down=self._on_keyboard_down) super(MyPaintWidget, self).__init__(**kwargs) self.connect()
def __init__(self, **kwargs): super(CounterWidget, self).__init__(**kwargs) self._keyboard = Window.request_keyboard(self._keyboard_closed, self) self._keyboard.bind(on_key_down=self._keydown_handler) self.red_counter = Counter() self.blue_counter = Counter() self.__sync()
def __init__(self, **kwargs): super(StartWidget, self).__init__(**kwargs) # import window after config.set takes effect from kivy.core.window import Window self._keyboard = Window.request_keyboard(self._keyboard_closed, self) self._keyboard.bind(on_key_down=self._on_keyboard_down)
def __init__(self, app, *args, **kwargs): super(ScreenEight, self).__init__(*args, **kwargs) self.app = app quiz = "X O X X X X X X X X X X X X\n" for i in xrange(7): quiz += "X X X X X X X X X X X X X X\n" self.win_popup = WinPopup(app, "You won the game", quiz, "nine") self.lose_popup = LosePopup(app, "Sorry you lost the game", "Try again", "eight") self.box_size = [Window.size[0] / 16.0, Window.size[1] / 10.0] self.init_physics() self.keyboard = Window.request_keyboard(self.keyboard_closed, self, "text") self.keyboard.bind(on_key_down=self.on_keyboard_down) self.keyboard.bind(on_key_up=self.on_keyboard_up) Clock.schedule_interval(self.step, 1 / FRAMES) # Adding the lines for i in xrange(16): with self.canvas: Color(0, 0, 0, 0.3) Line(points=[self.box_size[0] * i, 0, self.box_size[0] * i, Window.size[1]], width=0.3) for i in xrange(10): with self.canvas: Line(points=[0, self.box_size[1] * i, Window.size[0], self.box_size[1] * i], width=0.3) # Adding back and forward buttons back_button = Button(text="<", pos=[Window.size[0] * 0.025, Window.size[1] * 0.925], size_hint=[0.05, 0.05]) back_button.bind(on_press=self.back_btn_pressed) forward_button = Button(text=">", pos=[Window.size[0] * 0.925, Window.size[1] * 0.925], size_hint=[0.05, 0.05]) forward_button.bind(on_press=self.forward_btn_pressed) self.add_widget(back_button) self.add_widget(forward_button)
def build(self): self.root = FloatLayout() self.cam = MirrorCamera(index=0, resolution=(1280,960), play=True, stopped=False, allow_stretch=True) self.cam.pos_hint['center'] = [0.5,0.5] self.cam.size_hint = [1,1] self.cam.bind(on_capture_start=self.stop_countdown) self.cam.bind(on_capture_end=self.capture_end) # self.cam.bind(on_capture_timer=lambda _:setattr(self.info, 'text', "Wait, there's more")) self.root.add_widget(self.cam) self.cam.bind(on_touch_down=self.start_countdown) self.info = Label(color=[1,0,0,1], font_size=96, pos_hint={'center': [0.5,0.9]}) self.root.add_widget(self.info) self.file_info = Label(color=[0,1,0,1], font_size=64, pos_hint={'center': [0.5,0.05]}) self.root.add_widget(self.file_info) self.countdown_number = Label(text='', color=[0,1,0,0.5], font_size=256, pos_hint={'center': [0.5,0.5]},size_hint=[0.25,0.25]) self.root.add_widget(self.countdown_number) with self.countdown_number.canvas: self.countdown_number.cb = Callback(self.redraw_timer) self.countdown_number.bind(size=lambda a, b: self.countdown_number.cb.ask_update(), pos=lambda a, b: self.countdown_number.cb.ask_update()) ### Get keyboard keypress kbd = Window.request_keyboard(None, self.cam) #, 'text') kbd.bind( on_key_down=self.start_countdown, # on_key_up= , ) self.capture_end() # This sets some of the display correctly return self.root
def __init__(self, **kwargs): super(Paddle, self).__init__(**kwargs) self._keyboard = Window.request_keyboard(lambda: None, self) self._keyboard.bind(on_key_down=self.on_key_down, on_key_up=self.on_key_up)
def on_pre_enter(self): print("art style", root.art_style_filename) self.art_style = style = prep_image(cv2.imread(root.art_style_filename), 640, 480) self.start_wait() self._keyboard = Window.request_keyboard(self._keyboard_closed, self) self._keyboard.bind(on_key_down=self._on_keyboard_down) Clock.schedule_interval(self._tick, 1./20)
def __init__(self, **kwargs): super(EducorderCanvas, self).__init__() # This list holds all the shapes that are drawn on the canvas self.shapes = [] self.selected_shapes = [] self.canvastextinput = TextInput(text='foo', size=(self.width, 50), pos=(0, 0)) self.touch_down = None self.touch_up = None # Default colour values # Until a point where colours work properly # Should not be none or 0 as that would lead to # first shapes being drawn without fill or line self.line_colour = 1 self.fill_colour = 1 # All the possible modes will be here self.modes = {0: 'Standard', 1: 'Rectangle', 2: 'Ellipse', 3: 'Line', 4: 'Text'} self.selected_mode = 0 self.reshaping = False self.menu = None # Drawing the canvas to start off self.draw_canvas() # Keyboard controls self._keyboard = Window.request_keyboard(self._keyboard_closed, self, 'text') self._keyboard.bind(on_key_down=self._on_keyboard_down)
def __init__(self, player, **kwargs): super(Controller, self).__init__(**kwargs) self._keyboard = Window.request_keyboard(self._keyboard_closed, self, 'text') if self._keyboard.widget: # If it exists, this widget is a VKeyboard object which you can use # to change the keyboard layout. pass self._keyboard.bind(on_key_down=self._on_keyboard_down, on_key_up=self._on_keyboard_up) self.player = player
def _set_keyboard(self, layout): #Dock the keyboard kb = Window.request_keyboard(self._keyboard_close, self) if kb.widget: self._keyboard = kb.widget self._keyboard.layout = layout self._style_keyboard() else: self._keyboard = kb self._keyboard.bind(on_key_down=self.key_down) Logger.info('Keyboard: Init {}'.format(layout))
def __init__(self): Widget.__init__(self) Worker.__init__(self) self._keyboard = Window.request_keyboard(self._keyboard_closed, self) self._keyboard.bind(on_key_down=self.__on_key_down) # OutputExecutor Clock.schedule_interval(self.__update_frame, 1.0/60.0) self._mission_out = []
def get_keyboard(self): """ Get keyboard focus. :return: None """ # get the keyboard instance self._keyboard = Window.request_keyboard(self._keyboard_closed, self) # bind to run _on_keyboard_down when a key is pressed self._keyboard.bind(on_key_down=self._on_keyboard_down)
def build(self): from kivy.base import EventLoop EventLoop.ensure_window() self.window = EventLoop.window self.menu = MenuDialog(app=self) self.configure() self.root = GameWidget(app=self) self.root.keyboard = Window.request_keyboard(self.keyboard_closed, self.root) self.root.keyboard.bind(on_key_down=self.on_keyboard_down)
def _enable_keyboard(self): """ Enables keyboard events for this input handler """ if self._view is None: return from kivy.core.window import Window self._keyboard = Window.request_keyboard(self._disable_keyboard, self._view, 'text') self._keyboard.bind(on_key_down=self._capture_key) self._keyboard.bind(on_key_up=self._release_key)
def __init__(self,app,player_count,game_length,**kwargs): super().__init__(**kwargs) self.app=app self._keyboard=Window.request_keyboard(self._keyboard_closed, self) self._keyboard.bind(on_key_up=self._on_keyboard_up,on_key_down=self._on_keyboard_down) self.player_count=player_count self.game_length=game_length*5 self.game=Game(self) self.video=self.game.video self.vid_sm=ScreenManager() self.vid_sm.transition=FadeTransition() self.vid_screen=Screen() self.vid_screen.add_widget(self.video) self.vid_sm.add_widget(self.vid_screen) self.top_label= Label(text=f"Round {self.game.round} of {self.game_length}.{' '*400} {self.player_count} players playing the game", pos_hint={"y":.48}, outline_width=1 ) self.title=Label(text="[size=80][b]THE [color=FF581A]GREAT[/color] DRINKING GAME[/b][/size]", y=1080//2-250, text_size=(1800, 400), valign="top", halign="center", markup=True, outline_width=1 ) self.desc = Label(text="", markup=True, text_size= (1800,600), y=-50, outline_width=1, halign="center", valign="bottom" ) self.rules= FloatLayout() mg = self.minigame = RelativeLayout(size=(1600, 600)) self.add_widget(self.vid_sm) self.add_widget(mg) self.add_widget(self.top_label) self.add_widget(self.rules) self.add_widget(self.title) self.add_widget(self.desc) self.bind(size=self.center_things)
def __init__(self, **kwargs): super(QuizGame, self).__init__(**kwargs) Logger.debug("QuizGame __init__") self.update_messages() """ Initialize the components. """ self._keyboard = Window.request_keyboard(self._keyboard_closed, self, 'text') if self._keyboard.widget: # If it exists, this widget is a VKeyboard object which you can use # to change the keyboard layout. pass self._keyboard.bind(on_key_down=self._on_keyboard_down)
def __init__(self, **kwargs): print("OrthographicRenderer: __init__: start") # Load the shaders kwargs['shader_file'] = 'shaders.glsl' self.canvas = RenderContext(compute_normal_mat=True) shader_file = kwargs.pop('shader_file') self.canvas.shader.source = resource_find(shader_file) self._touches = [] # Setup the vertex format, to be used with the shader self.vertex_format = [(b'v_pos', 3, 'float'), (b'v_color', 4, 'float'), (b'v_tc0', 2, 'float')] # Setup keyboard event handler Window.request_keyboard(None, self).bind(on_key_down=self.on_keyboard_down) # Call super super(OrthographicRenderer, self).__init__(**kwargs)
def __init__(self, root, down_binds: key_bindings = {}, up_binds: key_bindings = {}, full_binds: key_bindings = {}): super().__init__() self.bind_keys(True, **down_binds, **full_binds) self.bind_keys(False, **up_binds, **full_binds) self._keyboard = Window.request_keyboard(self._close_keyboard, root) self._keyboard.bind(on_key_down=self._key_down, on_key_up=self._key_up)
def __init__(self, **kwargs): super(PongGame, self).__init__(**kwargs) self._keyboard = Window.request_keyboard(self._keyboard_closed, self) self._keyboard.bind(on_key_down=self._on_keyboard_down, on_key_up = self._on_keyboard_up) self.paddle_speed = 10 self.controlls = { "w": False, "s": False, "up": False, "down": False, }
def __init__(self, **args): super(Application, self).__init__(**args) self.points = set() self.structure = algorithms.Delanuay([(-4320., -4320.), (4320., 0.), (0., 4320.)]) self.polygons = [] self.tempPoly = None self.polygonFlag = False self._keyboard = Window.request_keyboard(self._keyboard_closed, self, 'text') self._keyboard.bind(on_key_down=self._on_keyboard_down)
def build(self): dataHandler = DataHandler() screenManager.add_widget(MenuScreen(name='menu')) screenManager.add_widget(GameScreen(name='game')) self._keyboard = Window.request_keyboard(self._keyboard_closed, self.root) self._keyboard.bind(on_key_down=self._on_keyboard_down) Window.set_title(TITLE) return screenManager
def __init__(self, **kwargs): super(WorldMap, self).__init__(**kwargs) self.map=Map2D(source='images/back.png', pos=(0,0), dx=tile_width, dy=tile_width) self.add_widget(self.map) self.mage_avatar=Sprite(source='images/run_1.png', pos=(Window.width/2,Window.height/2)) self.mage_avatar.size=(tile_width,tile_width) self.mage_avatar.x-=self.mage_avatar.size[0]/2 self.mage_avatar.y-=self.mage_avatar.size[1]/2 self.add_widget(self.mage_avatar) self._keyboard = Window.request_keyboard(self._keyboard_closed, self, 'text') self._keyboard.bind(on_key_down=self._on_keyboard_down) self._keyboard.bind(on_key_up=self._on_keyboard_up)
def __init__(self, **kwargs): # self.canvas = RenderContext() super(LetterWidget, self).__init__(**kwargs) self._keyboard = Window.request_keyboard(self._keyboard_closed, self) self._keyboard.bind(on_key_down=self._on_keyboard_down) self._tts = pyttsx3.init() self._tts.startLoop(False) # call the constructor of parent # if they are any graphics object, they will be added on our new canvas # We'll update our glsl variables in a clock Clock.schedule_interval(self._tick, 1 / 60.)
def __init__(self, **kwargs): super(MainScreen, self).__init__(**kwargs) self._keyboard = Window.request_keyboard(self._keyboard_closed, self, 'text') # キーボード設定 if self._keyboard.widget: # If it exists, this widget is a VKeyboard object which you can use # to change the keyboard layout. pass self._keyboard.bind(on_key_down=self._on_keyboard_down) # ボタンテキスト設定 self.button_text_change()
def __init__(self, **kwargs): super(MainWidget, self).__init__(**kwargs) # print("INIT W:" + str(self.width) + " H:" + str(self.height)) self.init_vertical_lines() self.init_horizontal_lines() if self.is_desktop(): self._keyboard = Window.request_keyboard(self.keyboard_closed, self) self._keyboard.bind(on_key_down=self.on_keyboard_down) self._keyboard.bind(on_key_up=self.on_keyboard_up) Clock.schedule_interval(self.update, 1.0 / 60.0)
def __init__(self, platform): self.platform = platform super(InputController, self).__init__() if self.platform == 'win': self.keyboard = Window.request_keyboard(self._keyboard_closed, self) self.keyboard.bind(on_key_down=self.handle_key_down) self.keyboard.bind(on_key_up=self.handle_key_up) self.initialize_touchscreen_components() elif self.platform == 'android': pass
def __init__(self, **kwargs): super(MyKeyboardListener, self).__init__(**kwargs) self._game = UI.mainUI.CLIENT self._player = self._game.me self._keyboard = Window.request_keyboard(self._keyboard_closed, self, 'text') if self._keyboard.widget: # If it exists, this widget is a VKeyboard object which you can use # to change the keyboard layout. pass self._keyboard.bind(on_key_down=self._on_keyboard_down)
def __init__(self, **kwargs): super().__init__(**kwargs) self.angles = [[-90, 90] for _ in range(16)] self.draw_circles() self.anim_event = Clock.schedule_interval( lambda _: self.change_angles(), 0.05) self._keyboard = Window.request_keyboard(self.keyboard_closed, self, 'text') self.bind(on_touch_down=self.toggle_animation) self._keyboard.bind(on_key_down=self.on_key_down)
def on_source(self, instance, value): self._keyboard = Window.request_keyboard(None, self) if self._keyboard: self._keyboard.bind(on_key_down=self.on_keyboard_down) self.pdf = Pdf(value) self.pages_count = self.pdf.get_n_pages() # force triggering page and check for min/max page = self.page self.page = -1 self.page = page
def __init__(self, decal, onEvent): self._keyboard = Window.request_keyboard(self._keyboard_closed, self, 'text') self.decal = decal self.onEvent = onEvent self.decaly = 20 self.decalx = 20 if self._keyboard.widget: pass self._keyboard.bind(on_key_down=self._on_keyboard_down)
def __init__(self, **kwargs): super(TypeGridLayout, self).__init__(**kwargs) self._keyboard = Window.request_keyboard(self._keyboard_closed, self) self._keyboard.bind(on_key_down=self._on_keyboard_down) self.rotor1 = Rotor(1, self) self.rotor2 = Rotor(2, self) self.rotor3 = Rotor(3, self) self.reflector = [[0, 24], [1, 17], [2, 20], [3, 7], [4, 16], [5, 18], [6, 11], [7, 3], [8, 15], [9, 23], [10, 13], [11, 6], [12, 14], [13, 10], [14, 12], [15, 8], [16, 4], [17, 1], [18, 5], [19, 25], [20, 2], [21, 22], [22, 21], [23, 9], [24, 0], [25, 19]]
def __init__(self, **kwargs): super(KeyboardListener, self).__init__(**kwargs) self._keyboard = Window.request_keyboard(self._keyboard_closed, self, 'text') self.keycode_inputs: Dict[str, bool] = { keycode_str: False for keycode_str in keyboard_inputs.values() } # self.keycode_inputs: Dict[int, bool] = {keycode_int: False for keycode_int in keyboard_inputs.keys()} self._keyboard.bind(on_key_down=self._on_keyboard_down, on_key_up=self._on_keyboard_up)
def set_layout(self, layout, button): """ Change the keyboard layout to the one specified by *layout*. """ kb = Window.request_keyboard(self._keyboard_close, self) if kb.widget: # If the current configuration supports Virtual Keyboards, this # widget will be a kivy.uix.vkeyboard.VKeyboard instance. self._keyboard = kb.widget self._keyboard.layout = layout else: self._keyboard = kb self._keyboard.bind(on_key_down=self.key_down, on_key_up=self.key_up)
def __init__(self, **kwargs): super().__init__(**kwargs) # Keyboard: self._keyboard = Window.request_keyboard( self._keyboard_closed, self, 'text') self._keyboard.bind(on_key_down=self._on_keyboard_down) self.open_file() print("1 verbs", self.verbs) self.translate_pt = create_translator("pt") self.new_verb() print("all_points", self.all_points)
def __init__(self, env_data, **kwargs): super(SelfDriveEnv, self).__init__(**kwargs) # Add callback to get keyboard close event self._keyboard = Window.request_keyboard(self._keyboard_closed, self) # Add callback to bind the keybaord events with environment object self._keyboard.bind(on_key_down=self._on_keyboard_down) self.AUTO_MODE = True self.env_data: SelfDriveEnvData = env_data self.car.set_env_data(self.env_data) self.brain = DeepQLearningNetwork(5,3,0.9)
def __init__(self, **kwargs): super().__init__(**kwargs) self.touchpos = None self.focused = False self.keys_active = set() self.keyboard = Window.request_keyboard(self.on_kb_close, self, 'text') self.keyboard.bind(on_key_down=self.key_down) self.keyboard.bind(on_key_up=self.key_up) global GAMECANVAS_OBJ GAMECANVAS_OBJ = self Clock.schedule_interval(self.tick, GAME_FPS)
def __init__(self, **kwargs): super(ShmupGame, self).__init__(**kwargs) with self.canvas.before: texture = CoreImage('./assets/bg.png').texture texture.wrap = 'repeat' self.rect_1 = Rectangle(texture=texture, size=(800 * 2, 600 * 2), pos=self.pos) self._keyboard = Window.request_keyboard(self._keyboard_closed, self) self._keyboard.bind(on_key_down=self._on_keyboard_down)
def __init__(self, **kwargs): """Constructor. Args: NONE Returns: NONE """ super(ZoomWidget, self).__init__() self.keyboard = Window.request_keyboard(self.keyboard_closed, self) self.keyboard.bind(on_key_down=self.on_keyboard_down)