Example #1
0
    def get_button_hider(self):
        """
        Creates a GridLayout that looks similar to the button layout but is invisible. This is used in order to
        'disable' the buttons after pressing (disallowing double press)
        """
        layout = GridLayout(cols=1,
                            col_default_width=self.button_width,
                            col_force_default=True)
        im1 = Image(source=path.join(Utils.image_folder, Utils.btn_1_img),
                    allow_stretch=True,
                    keep_ratio=False,
                    color=[0.8, 0.8, 0.8, 1])
        im2 = Image(source=path.join(Utils.image_folder, Utils.btn_2_img),
                    allow_stretch=True,
                    keep_ratio=False,
                    color=[0.8, 0.8, 0.8, 1])
        im3 = Image(source=path.join(Utils.image_folder, Utils.btn_3_img),
                    allow_stretch=True,
                    keep_ratio=False,
                    color=[0.8, 0.8, 0.8, 1])
        im4 = Image(source=path.join(Utils.image_folder, Utils.btn_4_img),
                    allow_stretch=True,
                    keep_ratio=False,
                    color=[0.8, 0.8, 0.8, 1])

        layout.add_widget(im1)
        layout.add_widget(im2)
        layout.add_widget(im3)
        layout.add_widget(im4)
        layout.pos = (0, 0)

        return layout
Example #2
0
 def call_function(self):
     """
     Function checks if any button put a new argument in 'next_func' variable, if so said argument is called and
      variable is reset, otherwise all buttons are enabled
     """
     if self.next_func is not None:
         func = self.next_func
         self.next_func = None
         func()
         self.tablet_game.send_info_from_screen()
         self.move_counter += 1
         if self.move_counter == self.tablet_game.max_turns:
             # once all the moves are played, removes the buttons from the screen and creates a new button in order
             # to finish the game
             self.remove_widget(self.button_layout)
             self.remove_widget(self.button_hider)
             end_layout = GridLayout(cols=1,
                                     col_default_width=self.button_width,
                                     col_force_default=True)
             end_button = EndButton(self.end_game)
             end_layout.add_widget(end_button)
             self.add_widget(end_layout)
             end_layout.pos = (0, 0)
     else:
         self.enable_buttons()
Example #3
0
 def get_buttons(self):
     """
     Creates a GridLayout that holds GraphButton needed for the game. Each button should be
     initialized using a string representing an image to be displayed on the button, a list of functions that will be
     responsible for the button's functionality, the button's number and the current gameLayout (self).
     """
     layout = GridLayout(cols=1, col_default_width=self.button_width, col_force_default=True)
     button1 = MultiButton(img=path.join(Utils.image_folder, Utils.btn_1_img), funcs=self.button1_func,
                           button_num=1, game_layout=self)
     button1.name = 'button1'
     button2 = MultiButton(img=path.join(Utils.image_folder, Utils.btn_2_img), funcs=self.button2_func,
                           button_num=2, game_layout=self)
     button2.name = 'button2'
     button3 = MultiButton(img=path.join(Utils.image_folder, Utils.btn_3_img), funcs=self.button3_func,
                           button_num=3, game_layout=self)
     button3.name = 'button3'
     button4 = MultiButton(img=path.join(Utils.image_folder, Utils.btn_4_img), funcs=self.button4_func,
                           button_num=4, game_layout=self)
     button4.name = 'button4'
     layout.add_widget(button1)
     layout.add_widget(button2)
     layout.add_widget(button3)
     layout.add_widget(button4)
     self.buttons.append(button1)
     self.buttons.append(button2)
     self.buttons.append(button3)
     self.buttons.append(button4)
     layout.pos = (0, 0)
     return layout