def __init__(self, driver):
        super().__init__(driver)

        WebDriverWait(self.driver, 10).until(
            EC.presence_of_element_located(
                CheckoutPageLocators.FIRST_NAME_SHIPPING))

        self.firstname = self.driver.find_element(
            *CheckoutPageLocators.FIRST_NAME_SHIPPING)
        self.lastname = self.driver.find_element(
            *CheckoutPageLocators.LAST_NAME_SHIPPING)
        self.company = self.driver.find_element(
            *CheckoutPageLocators.COMPANY_SHIPPING)
        self.address_1 = self.driver.find_element(
            *CheckoutPageLocators.ADDRESS_1_SHIPPING)
        self.address_2 = self.driver.find_element(
            *CheckoutPageLocators.ADDRESS_2_SHIPPING)
        self.city = self.driver.find_element(
            *CheckoutPageLocators.CITY_SHIPPING)
        self.post_code = self.driver.find_element(
            *CheckoutPageLocators.POST_CODE_SHIPPING)
        self.country = self.driver.find_element(
            *CheckoutPageLocators.COUNTRY_SHIPPING)
        self.region_or_state = self.driver.find_element(
            *CheckoutPageLocators.REGION_OR_STATE_SHIPPING)

        self.btn_new_address = Button(
            self.driver, CheckoutPageLocators.RADIO_ADDRESS_DELIVERY)

        self.btn = Button(self.driver, CheckoutPageLocators.BTN_CONTINUE_S_3)
Example #2
0
    def __init__(self, driver):
        super().__init__(driver)

        self.guest_account = Button(self.driver,
                                    CheckoutPageLocators.GUEST_ACCOUNT)
        self.register_account = Button(self.driver,
                                       CheckoutPageLocators.REGISTER_ACCOUNT)

        self.btn_account = Button(self.driver,
                                  CheckoutPageLocators.BTN_ACCOUNT)
Example #3
0
    def __init__(self, driver):
        super().__init__(driver)

        WebDriverWait(self.driver, 10).until(
            EC.visibility_of_element_located(
                CheckoutPageLocators.AGREE_TERMS_AND_CONDITIONS))

        self.btn_agree = Button(
            self.driver, CheckoutPageLocators.AGREE_TERMS_AND_CONDITIONS)
        self.btn_continue = Button(self.driver,
                                   CheckoutPageLocators.BTN_CONTINUE_S_5)
    def load_rules_screen(self) -> None:
        self.rules_title_text = Text(
            text=self.settings["rules_title_text_text"],
            width=self.settings["rules_title_text_width"],
            height=self.settings["rules_title_text_height"],
            position_x=self.settings["rules_title_text_pos_x"],
            position_y=self.settings["rules_title_text_pos_y"],
            text_font=self.settings["rules_title_text_text_font"],
            text_size=self.settings["rules_title_text_text_size"],
            screen=self.screen,
            text_color=tuple(self.settings["rules_title_text_text_color"]))

        self.back_button = Button(
            text=self.settings["back_button_text"],
            width=self.settings["back_button_width"],
            height=self.settings["back_button_height"],
            position_x=self.settings["back_button_pos_x"],
            position_y=self.settings["back_button_pos_y"],
            text_font=self.settings["back_button_text_font"],
            text_size=self.settings["back_button_text_size"],
            screen=self.screen,
            button_color=tuple(self.settings["back_button_color"]),
            text_color=tuple(self.settings["back_button_text_color"]))

        self.rules_text = Text(
            text=load_text(self.settings["rules_text_path"]),
            width=self.settings["rules_text_box_width"],
            height=self.settings["rules_text_box_height"],
            position_x=self.settings["rules_text_box_pos_x"],
            position_y=self.settings["rules_text_box_pos_y"],
            text_font=self.settings["rules_text_box_text_font"],
            text_size=self.settings["rules_text_box_text_size"],
            screen=self.screen,
            text_color=tuple(self.settings["rules_text_box_text_color"]))

        self.copyright_button = Button(
            text=self.settings["copyright_button_text"],
            width=self.settings["copyright_button_width"],
            height=self.settings["copyright_button_height"],
            position_x=self.settings["copyright_button_pos_x"],
            position_y=self.settings["copyright_button_pos_y"],
            text_font=self.settings["copyright_button_text_font"],
            text_size=self.settings["copyright_button_text_size"],
            screen=self.screen,
            button_color=tuple(self.settings["copyright_button_color"]),
            text_color=tuple(self.settings["copyright_button_text_color"]))

        self.rules_title_text.draw_text()
        self.back_button.draw_button()
        self.rules_text.draw_text()
        self.copyright_button.draw_button()
        pygame.display.flip()
Example #5
0
    def load_game_screen(self) -> None:
        self.game_board = Board(width=self.settings["board_width"],
                                height=self.settings["board_height"],
                                position_x=self.settings["board_pos_x"],
                                position_y=self.settings["board_pos_y"],
                                screen=self.screen,
                                board_color=tuple(
                                    self.settings["board_color"]))

        self.log_screen_title_text = Text(
            text=self.settings["log_screen_title_text_text"],
            width=self.settings["log_screen_title_text_width"],
            height=self.settings["log_screen_title_text_height"],
            position_x=self.settings["log_screen_title_text_pos_x"],
            position_y=self.settings["log_screen_title_text_pos_y"],
            text_font=self.settings["log_screen_title_text_text_font"],
            text_size=self.settings["log_screen_title_text_text_size"],
            screen=self.screen,
            text_color=tuple(
                self.settings["log_screen_title_text_text_color"]))

        self.log_screen = LogScreen(
            width=self.settings["log_screen_width"],
            height=self.settings["log_screen_height"],
            position_x=self.settings["log_screen_pos_x"],
            position_y=self.settings["log_screen_pos_y"],
            log_text=self.settings["log_screen_log_text"],
            text_font=self.settings["log_screen_text_font"],
            text_size=self.settings["log_screen_text_size"],
            screen=self.screen,
            log_screen_color=tuple(self.settings["log_screen_color"]),
            log_screen_text_color=tuple(
                self.settings["log_screen_text_color"]))

        self.confirm_button = Button(
            text=self.settings["confirm_button_text"],
            width=self.settings["confirm_button_width"],
            height=self.settings["confirm_button_height"],
            position_x=self.settings["confirm_button_pos_x"],
            position_y=self.settings["confirm_button_pos_y"],
            text_font=self.settings["confirm_button_text_font"],
            text_size=self.settings["confirm_button_text_size"],
            screen=self.screen,
            button_color=tuple(self.settings["confirm_button_color"]),
            text_color=tuple(self.settings["confirm_button_text_color"]))

        self.game_board.draw_board()
        self.log_screen.draw_log_screen()
        self.log_screen_title_text.draw_text()
        self.confirm_button.draw_button()
        pygame.display.flip()
Example #6
0
    def __init__(self, screen, char, **kwargs):
        super(NamesScreen, self).__init__(screen)

        self.char = char

        self.objects.append(
            Button(self.screen,
                   text="BACK",
                   pos=(30, 30),
                   click=self.back,
                   font=monospace,
                   size=30))

        self.timeout = Progress(
            self.screen,
            pos=(200, 50),
            speed=1 / 15.0,
            on_elapsed=self.time_elapsed,
        )
        self.objects.append(self.timeout)
        self.timeout.start()

        self.objects.append(
            Label(
                self.screen,
                text='Wer bist du?',
                pos=(20, 110),
            ))

        users = Users.get_all(self.char)

        btns_y = 7
        num_cols = int(math.ceil(len(users) / float(btns_y)))
        for i, user in enumerate(users):
            padding = 20
            xoff, yoff = 30, 190
            btn_ypos = 90
            i_y = i % btns_y
            i_x = i // btns_y
            x = i_x * (screen.get_width() / num_cols)
            y = i_y * btn_ypos
            self.objects.append(
                Button(self.screen,
                       text=user["name"],
                       pos=(xoff + x, y + yoff),
                       click=self.switch_to_screen,
                       click_param=user,
                       padding=padding))
            i += 1
    def __init__(self, screen, **kwargs):
        super(NewIDScreen, self).__init__(screen)

        self.objects.append(
            Button(self.screen,
                   text="BACK",
                   pos=(30, 30),
                   font=monospace,
                   click=self.back,
                   size=30))

        self.timeout = Progress(
            self.screen,
            pos=(200, 50),
            speed=1 / 30.0,
            on_elapsed=self.time_elapsed,
        )
        self.objects.append(self.timeout)
        self.timeout.start()

        self.objects.append(
            Label(self.screen,
                  text="Wirf EURO in die Kasse!",
                  pos=(30, 120),
                  size=50))
        self.objects.append(
            Label(self.screen,
                  text="Wie viel hast du eingeworfen?",
                  pos=(30, 220),
                  size=40))
        self.message = Label(self.screen, text="", pos=(50, 320), size=40)
        self.objects.append(self.message)

        for i, euro in enumerate([5, 10, 20, 50]):
            self.objects.append(
                Button(self.screen,
                       text="EUR " + str(euro),
                       pos=((i % 2) * 200 + 30, 600 + (i / 2 * 80)),
                       size=30,
                       click=partial(self.btn_euro, euro)))

        self.progress = Progress(self.screen,
                                 pos=(200, 420),
                                 size=100,
                                 speed=1 / 10.0,
                                 on_elapsed=self.time_elapsed)
        self.progress.stop()
        self.objects.append(self.progress)
Example #8
0
    def __init__(self, screen, **kwargs):
        super(MainScreen, self).__init__(screen)

        self.objects.append(Image(self.screen, pos=(30, 20)))

        self.objects.append(
            Label(self.screen,
                  text=u'member auswählen',
                  pos=(65, 250),
                  size=50))

        all_users = Users.get_all()
        i = 0
        for c in range(97, 97 + 26):
            text = str(chr(c))
            users = filter(lambda u: u["name"].lower().startswith(text),
                           all_users)
            if len(users) == 0:
                continue
            self.objects.append(
                Button(
                    self.screen,
                    text=text,
                    pos=self.__get_pos(i),
                    click=self.switch_to_screen,
                    click_param=text,
                    force_width=440 / 6,
                    force_height=440 / 6,
                ))

            i += 1

        self.objects.append(
            Button(
                self.screen,
                text='Abbrechen',
                pos=(150, 700),
                size=30,
                click=self.home,
            ))
        self.timeout = Progress(
            self.screen,
            pos=(380, 715),
            speed=1 / 15.0,
            on_elapsed=self.time_elapsed,
        )
        self.objects.append(self.timeout)
        self.timeout.start()
Example #9
0
    def __init__(self, driver):
        super().__init__(driver)

        WebDriverWait(self.driver, 10).until(
            EC.presence_of_element_located(CheckoutPageLocators.GUEST_ACCOUNT))

        self.guest_account = self.driver.find_element(*CheckoutPageLocators.GUEST_ACCOUNT)
        self.register_account = self.driver.find_element(*CheckoutPageLocators.REGISTER_ACCOUNT)

        self.btn_account = Button(self.driver, CheckoutPageLocators.BTN_ACCOUNT)
        self.btn_login = Button(self.driver, CheckoutPageLocators.BTN_LOGIN)

        self.email_field = self.driver.find_element(*CheckoutPageLocators.E_MAIL)
        self.pass_field = self.driver.find_element(*CheckoutPageLocators.PASSWORD)

        self.alert = self.driver.find_element(*CheckoutPageLocators.ALERT)
    def __init__(self, driver):
        super().__init__(driver)

        WebDriverWait(self.driver, 10).until(
            EC.presence_of_element_located(
                CheckoutPageLocators.FIRST_NAME_PAYMENT))

        self.firstname = self.driver.find_element(
            *CheckoutPageLocators.FIRST_NAME_PAYMENT)
        self.lastname = self.driver.find_element(
            *CheckoutPageLocators.LAST_NAME_PAYMENT)
        self.email = self.driver.find_element(
            *CheckoutPageLocators.EMAIL_PAYMENT)
        self.telephone = self.driver.find_element(
            *CheckoutPageLocators.TELEPHONE_PAYMENT)
        self.company = self.driver.find_element(
            *CheckoutPageLocators.COMPANY_PAYMENT)
        self.address_1 = self.driver.find_element(
            *CheckoutPageLocators.ADDRESS_1_PAYMENT)
        self.address_2 = self.driver.find_element(
            *CheckoutPageLocators.ADDRESS_2_PAYMENT)
        self.city = self.driver.find_element(
            *CheckoutPageLocators.CITY_PAYMENT)
        self.post_code = self.driver.find_element(
            *CheckoutPageLocators.POST_CODE_PAYMENT)
        self.country = self.driver.find_element(
            *CheckoutPageLocators.COUNTRY_PAYMENT)
        self.region_or_state = self.driver.find_element(
            *CheckoutPageLocators.REGION_OR_STATE_PAYMENT)
        self.checkbox_delivery = self.driver.find_element(
            *CheckoutPageLocators.CHECKBOX_DELIVERY)
        self.btn = Button(self.driver, CheckoutPageLocators.BTN_CONTINUE_S_2_G)
Example #11
0
 def confirm_order(self) -> "CheckoutPage":
     """
     Confirm order
     """
     logging.info('Purchase successful')
     Button(self.driver, CheckoutPageLocators.BTN_CONFIRM_ORDER).click()
     return self
Example #12
0
    def __init__(self, screen, **kwargs):
        super(MainScreen, self).__init__(screen)

        self.objects.append(
            Label(
                self.screen,
                text='flipdot Getraenkezaehler',
                pos=(20, 20),
                color=(255, 255, 0),
            ))

        self.objects.append(Image(self.screen, pos=(100, 70)))

        i = 0
        for c in range(97, 97 + 26):
            text = str(chr(c))
            self.objects.append(
                Button(self.screen,
                       text=text,
                       pos=self.__get_pos(i),
                       color=(255, 255, 0),
                       click=self.switch_to_screen,
                       click_param=text))

            i += 1
    def __init__(self, driver):
        super().__init__(driver)

        WebDriverWait(self.driver, 10).until(
            EC.visibility_of_element_located(
                CheckoutPageLocators.BTN_CONTINUE_S_4))
        self.btn_s_4 = Button(self.driver,
                              CheckoutPageLocators.BTN_CONTINUE_S_4)
Example #14
0
    def __init__(self, driver):
        super().__init__(driver)

        WebDriverWait(self.driver, 10).until(
            EC.presence_of_element_located(
                CheckoutPageLocators.FIRST_NAME_SHIPPING))

        self.btn = Button(self.driver, CheckoutPageLocators.BTN_CONTINUE_S_4)
Example #15
0
    def click_back(self) -> LoginPage:
        """
        Click on back button

        :return: object of LoginPage class
        """
        Button(self.driver, ReturnsPageLocators.BTN_BACK).click()
        logging.info('Click on BACK button')
        return LoginPage(self.driver)
Example #16
0
    def click_submit(self) -> "ReturnsPage":
        """
        Click on submit button

        :return: object of the class
        """
        Button(self.driver, ReturnsPageLocators.BTN_SUBMIT).click()
        logging.info('Click on SUBMIT button')
        return self
Example #17
0
    def __init__(self, driver):
        super().__init__(driver)

        WebDriverWait(self.driver, 30).until(
            EC.element_to_be_clickable(
                CheckoutPageLocators.AGREE_TERMS_AND_CONDITIONS))

        self.agree = self.driver.find_element(
            *CheckoutPageLocators.AGREE_TERMS_AND_CONDITIONS)
        self.btn = Button(self.driver, CheckoutPageLocators.BTN_CONTINUE_S_5)
Example #18
0
class ProductPage(BasePage):
    """
    Product page action methods come here
    """

    def __init__(self, driver):
        """
        Add cart button element to the page
        """
        super().__init__(driver)
        self.cart_btn = Button(driver, ProductPageLocators.BTN_CART)

    def add_to_cart(self):
        """
        Click on cart button
        """
        self.cart_btn.click()
        return self

    def go_to_cart(self):
        """
        Go to Cart Page
        """
        self.top_links.cart_click()
        return CartPage(self.driver)

    def add_to_cart_apple_cinema(self):
        """
        TODO
        """
        add_to_cart_button = self.driver.find_element(*ProductPageLocators.ADD_APPLE_CINEMA)
        add_to_cart_button.click()
        return self

    def add_mac_to_cart(self):
        """Make webdriver add Mac product to Cart."""
        get_to_imac = self.driver.find(*ProductPageLocators.GO_TO_IMAC)
        get_to_imac.click()
        add_mac_to_cart = self.driver.find_element(*ProductPageLocators.ADD_IMAC_TO_CART)
        add_mac_to_cart.click()
        return self
Example #19
0
    def __init__(self, height):  # height to Sidebar???
        super(MainSidebar, self).__init__()

        self.height = height

        self.viewport.top_x = MAIN_SIDEBAR_MAX_WIDTH
        self.viewport.top_y = self.height  # should get window height here in some nice way (CassopiWindow height change -> sidebar height etc.) (works as reference? validate. if not, use trigger)

        self.tab_manager = TabManager(max_width=MAIN_SIDEBAR_MAX_WIDTH)

        # ElementGroup ???
        main_tab = Tab('Main')
        main_tab.add(Button('New', None))  # attach events too! None -> func
        main_tab.add(Button('Open'))  # make this foldable instead? Folder()
        main_tab.add(Element())
        main_tab.add(Button('Save'))
        main_tab.add(Button('Save as...'))
        main_tab.add(Element())
        main_tab.add(Button('Quit'))

        settings_tab = Tab('Settings')
        settings_tab.add(Button('Some setting'))

        self.tab_manager.add(main_tab)
        self.tab_manager.add(settings_tab)
Example #20
0
    def __init__(self, screen, user, drink, text, session, **kwargs):
        super(SuccessScreen, self).__init__(screen)

        self.user = user

        self.objects.append(
            Label(self.screen, text='Danke,', pos=(30, 120), size=70))
        self.objects.append(
            Label(self.screen, text=user['name'] + "!", pos=(30, 170),
                  size=70))
        self.objects.append(
            Label(self.screen, text=text, size=45, pos=(30, 250)))

        self.objects.append(
            Label(self.screen, text='Verbleibendes Guthaben: ', pos=(30, 350)))
        self.objects.append(
            Label(
                self.screen,
                text=str(Users.get_balance(self.user['id'], session=session)) +
                ' EUR',
                pos=(50, 400)))

        self.objects.append(
            Button(self.screen,
                   text='OK',
                   pos=(50, 600),
                   size=50,
                   click=self.btn_home))

        self.progress = Progress(self.screen,
                                 pos=(400, 500),
                                 size=80,
                                 on_elapsed=self.home)
        self.objects.append(self.progress)
        self.progress.start()
        balance = Users.get_balance(user['id'])
        if balance >= 0:
            sound = "smb_coin.wav"
        elif balance < -10:
            sound = "alarm.wav"
        else:
            sound = "smb_bowserfalls.wav"
        os.system(
            "ssh -o StrictHostKeyChecking=no pi@pixelfun aplay sounds/%s >/dev/null 2>&1 &"
            % sound)

        if drink:
            send_drink(user, drink, True)
Example #21
0
 def render_digit_btn(self, label, x, y):
     width = 480 / 6
     cord_x = width * 1.8 + x * width
     cord_y = 250 + y * width
     self.objects.append(
         Button(
             self.screen,
             text=label,
             pos=(cord_x, cord_y),
             click=self.add_char,
             click_param=label,
             font=monospace,
             size=50,
             force_width=width,
             force_height=width,
         ))
    def __init__(self, screen, **kwargs):
        super(WaitScanScreen, self).__init__(screen)

        self.barcode_label = Label(
            self.screen,
            pos=(60, 400),
        )

        self.scanned_info = [
            self.barcode_label,
            Button(self.screen,
                   pos=(50, 600),
                   text="drink buchen",
                   size=52,
                   click=self.set_member),
            Button(self.screen,
                   pos=(50, 700),
                   text="Nur Statistik",
                   click=self.stat_drink),
            Button(self.screen,
                   pos=(350, 700),
                   text="nope",
                   click=self.btn_reset)
        ]
        self.empty_info = [
            Button(self.screen,
                   pos=(30, 700),
                   text="Benutzer",
                   click=self.set_member),
            Button(self.screen,
                   pos=(210, 700),
                   text="Geld einwerfen",
                   click=self.btn_new_id)
        ]

        self.objects.append(Image(self.screen, pos=(30, 20)))

        self.objects.append(
            Label(
                self.screen,
                text=u"Scanne dein Getränk",
                pos=(60, 240),
            ))
        self.objects.append(
            Label(
                self.screen,
                text=u"oder deine ID-Card :)",
                pos=(70, 280),
            ))

        self.processing = Label(self.screen,
                                text="Moment bitte...",
                                size=40,
                                pos=(80, 350))
        self.processing.is_visible = False
        self.objects.append(self.processing)

        self.timeout = Progress(
            self.screen,
            pos=(400, 500),
            size=100,
            speed=1 / 10.0,
            on_elapsed=self.time_elapsed,
        )
        self.objects.append(self.timeout)

        for o in self.scanned_info + self.empty_info:
            self.objects.append(o)

        self.reset()
    def __init__(self, screen, user, **kwargs):
        super(IDCardScreen, self).__init__(screen)

        self.user = user

        self.objects.append(
            Button(self.screen,
                   text="BACK",
                   pos=(30, 30),
                   font=monospace,
                   click=self.back,
                   size=30))

        self.timeout = Progress(
            self.screen,
            pos=(200, 50),
            speed=1 / 15.0,
            on_elapsed=self.time_elapsed,
        )
        self.objects.append(self.timeout)
        self.timeout.start()

        self.objects.append(
            Button(self.screen,
                   text='Reset',
                   pos=(350, 30),
                   size=30,
                   click=self.reset_id))

        self.objects.append(
            Label(self.screen, text=self.user["name"], pos=(30, 120), size=70))

        self.objects.append(
            Label(self.screen, text="Momentan zugeordnet:", pos=(30, 300)))

        self.id_label = Label(self.screen,
                              text=self.user['id_card'],
                              pos=(50, 400),
                              size=70,
                              font="Serif")
        self.objects.append(self.id_label)

        self.objects.append(
            Label(self.screen, text="Scanne deine ID,", pos=(30, 550),
                  size=60))
        self.objects.append(
            Label(self.screen,
                  text="um sie zuzuweisen.",
                  pos=(30, 600),
                  size=60))

        self.objects.append(
            Button(self.screen,
                   text='OK bye',
                   pos=(330, 700),
                   size=30,
                   click=self.btn_home))

        self.objects.append(
            Button(self.screen,
                   text='Drucken',
                   pos=(30, 700),
                   size=30,
                   click=self.print_id))
        self.progress = Progress(self.screen, pos=(200, 720), speed=1 / 15.0)
        self.progress.stop()
        self.objects.append(self.progress)
Example #24
0
    def __init__(self, screen, user, **kwargs):
        super(EnterPinScreen, self).__init__(screen)
        self.user = user

        self.objects.append(
            Button(self.screen,
                   text="BACK",
                   pos=(30, 30),
                   click=self.back,
                   font=monospace,
                   size=30))

        self.timeout = Progress(
            self.screen,
            pos=(200, 50),
            speed=1 / 15.0,
            on_elapsed=self.time_elapsed,
        )
        self.objects.append(self.timeout)
        self.timeout.start()

        self.objects.append(
            Button(self.screen,
                   text="UNLOCK!",
                   pos=(100, 680),
                   click=self.btn_ok,
                   font=monospace,
                   size=70))

        self.objects.append(
            Label(
                self.screen,
                text='/s Barcode oder /e PIN:',
                pos=(40, 110),
            ))

        self.input = Label(
            self.screen,
            text='_',
            pos=(100, 180),
        )
        self.objects.append(self.input)

        keys = [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9'],
                ['#', '0', '*']]

        x = 0
        y = 0
        for row in keys:
            for label in row:
                self.render_digit_btn(label, x, y)
                x += 1
            x = 0
            y += 1

        self.objects.append(
            Button(self.screen,
                   text='DEL',
                   pos=(200, 580),
                   font=monospace,
                   click=self.del_char,
                   size=50))
Example #25
0
    def __init__(self, screen, user, **kwargs):
        super(ProfileScreen, self).__init__(screen)

        self.user = user

        self.objects.append(Button(
            self.screen,
            text = "BACK",
            pos=(30,30),
            font = monospace,
            click=self.back
        ))

        self.objects.append(Button(
            self.screen,
            text = "ID card",
            pos=(340,30),
            font = monospace,
            click=self.id_card
        ))

        self.objects.append(Label(
            self.screen,
            text =self.user["name"],
            pos=(30, 120),
            size=70,
            max_width=335 - 30 - 10,  # balance.x - self.x - margin
        ))

        self.objects.append(Label(
            self.screen,
            text = 'Guthaben',
            pos=(330, 120),
            size=30
        ))

        self.label_verbrauch = Label(
            self.screen,
            text='Bisheriger Verbrauch:',
            pos=(30, 180),
            size=30
        )
        self.label_aufladungen = Label(
            self.screen,
            text='Aufladungen:',
            pos=(30, 180),
            size=30
        )

        self.processing = Label(
            self.screen,
            text="Moment bitte...",
            size=40,
            pos=(150, 750)
        )
        self.processing.is_visible = False
        self.objects.append(self.processing)

        self.timeout = Progress(
            self.screen,
            pos=(200, 50),
            speed=1/30.0,
            on_elapsed=self.time_elapsed,
            click=self.btn_home,
        )
        self.objects.append(self.timeout)
        self.timeout.start()

        drink = DrinksManager.get_instance().get_selected_drink()
        self.drink_info = Label(
            self.screen,
            text=drink['name'] if drink else "",
            size=60,
            pos=(30, 630)
        )

        self.zuordnen = Button(
            self.screen,
            text='Trinken',
            pos=(30, 690),
            size=50,
            click=self.save_drink
        )
        self.btn_aufladungen = Button(
            self.screen,
            text='Aufladungen',
            pos=(30, 700),
            click=self.show_aufladungen
        )
        self.btn_drinks = Button(
            self.screen,
            text='Buchungen',
            pos=(20, 700),
            click=self.show_drinks
        )
        self.btn_abbrechen = Button(
            self.screen,
            text='Abbrechen',
            pos=(290, 700),
            size=30,
            click=self.btn_home,
        )
        self.btn_aufladen = Button(
            self.screen,
            text='Jetzt Aufladen',
            pos=(210, 700),
            size=30,
            click=self.recharge,
        )

        self.elements_aufladungen = [self.btn_drinks, self.label_aufladungen,
            self.btn_aufladen]
        self.elements_drinks = [self.label_verbrauch, self.btn_abbrechen]
        if drink:
            self.elements_drinks.extend([self.zuordnen, self.drink_info])
        else:
            self.elements_drinks.append(self.btn_aufladungen)


        balance = Users.get_balance(self.user['id'])
        self.objects.append(Label(
            self.screen,
            text = str(balance),
            pos=(335, 145),
            size=40
        ))

        drinks = self.get_stats()
        for i, drinks in enumerate(drinks):
            x = 30
            if i == 11:
                self.elements_drinks.append(Label(
                    self.screen,
                    text = "...",
                    pos=(x, 210 + (i * 35))
                ))
                continue
            if i > 11:
                continue
            text = get_by_ean(drinks["name"])['name']
            count_width = 80
            margin_right = 10
            self.elements_drinks.append(Label(
                self.screen,
                text = text,
                pos=(x, 210 + (i * 35)),
                max_width=480-x-margin_right-count_width
            ))
            self.elements_drinks.append(Label(
                self.screen,
                text = str(drinks["count"]),
                align_right=True,
                pos=(480-margin_right, 210 + (i * 35)),
                max_width=count_width
            ))

        self.objects.extend(self.elements_drinks)

        self.render_aufladungen()
    def __init__(self, screen, user, **kwargs):
        super(RechargeScreen, self).__init__(screen)

        self.user = user

        self.objects.append(
            Button(self.screen,
                   text="BACK",
                   pos=(30, 30),
                   font=monospace,
                   click=self.back,
                   size=30))

        self.timeout = Progress(
            self.screen,
            pos=(200, 50),
            speed=1 / 30.0,
            on_elapsed=self.time_elapsed,
        )
        self.objects.append(self.timeout)
        self.timeout.start()

        qr_file = make_sepa_qr(20,
                               self.user['name'],
                               self.user['id'],
                               pixel_width=7,
                               border=4,
                               color="black",
                               bg="yellow")
        self.select_objects = [
            Button(self.screen,
                   text='EUR 5',
                   pos=(30, 300),
                   size=30,
                   click=partial(self.verify_payment, 5)),
            Button(self.screen,
                   text='EUR 10',
                   pos=(250, 300),
                   size=30,
                   click=partial(self.verify_payment, 10)),
            Button(self.screen,
                   text='EUR 20',
                   pos=(30, 400),
                   size=30,
                   click=partial(self.verify_payment, 20)),
            Button(self.screen,
                   text='EUR 50',
                   pos=(250, 400),
                   size=30,
                   click=partial(self.verify_payment, 50)),
            Label(self.screen,
                  text="Wirf Geld in die Kasse,",
                  pos=(30, 100),
                  size=50),
            Label(self.screen,
                  text=u"und drück den passenden",
                  pos=(30, 150),
                  size=50),
            Label(self.screen, text="Knopf.", pos=(30, 200), size=50),
            Image(self.screen, src=qr_file, pos=(70, 470), size=(300, 330))
        ]
        self.objects.extend(self.select_objects)

        self.verify_objects = [
            Label(self.screen, text="Hast du", pos=(30, 150), size=55),
            Label(self.screen,
                  text="in die Kasse geworfen?",
                  pos=(30, 250),
                  size=55),
            Button(self.screen,
                   text='Ja',
                   pos=(250, 400),
                   size=30,
                   click=self.save_payment)
        ]
        self.verify_amount = Label(self.screen,
                                   text="EUR X",
                                   pos=(30, 200),
                                   size=60)
        self.verify_objects.append(self.verify_amount)
Example #27
0
 def __init__(self, driver):
     """
     Add cart button element to the page
     """
     super().__init__(driver)
     self.cart_btn = Button(driver, ProductPageLocators.BTN_CART)
Example #28
0
 def clickLogIn(self):
     logInBtn = Button(driver=self.driver,
                       locator=LoginLocators.SIGN_UP_BTN)
     logInBtn.click()
class TitleScreen():
    screen: pygame.Surface = None
    settings: dict = {}

    def __init__(self,
                 screen: pygame.Surface = screen,
                 settings: dict = settings):
        self.screen = screen
        self.settings = settings
        self.initial_load = False

        self.play_button = None
        self.rules_button = None
        self.quit_button = None
        self.game_title = None
        self.copyright_button = None

    def load_title_screen(self) -> None:
        self.game_title = Text(text=self.settings["title_text_text"],
                               width=self.settings["title_text_width"],
                               height=self.settings["title_text_height"],
                               position_x=self.settings["title_text_pos_x"],
                               position_y=self.settings["title_text_pos_y"],
                               text_font=self.settings["title_text_text_font"],
                               text_size=self.settings["title_text_text_size"],
                               screen=self.screen,
                               text_color=tuple(
                                   self.settings["title_text_text_color"]))

        self.play_button = Button(
            text=self.settings["start_button_text"],
            width=self.settings["start_button_width"],
            height=self.settings["start_button_height"],
            position_x=self.settings["start_button_pos_x"],
            position_y=self.settings["start_button_pos_y"],
            text_font=self.settings["start_button_text_font"],
            text_size=self.settings["start_button_text_size"],
            screen=self.screen,
            button_color=tuple(self.settings["start_button_color"]),
            text_color=tuple(self.settings["start_button_text_color"]))

        self.rules_button = Button(
            text=self.settings["rules_button_text"],
            width=self.settings["rules_button_width"],
            height=self.settings["rules_button_height"],
            position_x=self.settings["rules_button_pos_x"],
            position_y=self.settings["rules_button_pos_y"],
            text_font=self.settings["rules_button_text_font"],
            text_size=self.settings["rules_button_text_size"],
            screen=self.screen,
            button_color=tuple(self.settings["rules_button_color"]),
            text_color=tuple(self.settings["rules_button_text_color"]))

        self.quit_button = Button(
            text=self.settings["quit_button_text"],
            width=self.settings["quit_button_width"],
            height=self.settings["quit_button_height"],
            position_x=self.settings["quit_button_pos_x"],
            position_y=self.settings["quit_button_pos_y"],
            text_font=self.settings["quit_button_text_font"],
            text_size=self.settings["quit_button_text_size"],
            screen=self.screen,
            button_color=tuple(self.settings["quit_button_color"]),
            text_color=tuple(self.settings["quit_button_text_color"]))

        self.copyright_button = Button(
            text=self.settings["copyright_button_text"],
            width=self.settings["copyright_button_width"],
            height=self.settings["copyright_button_height"],
            position_x=self.settings["copyright_button_pos_x"],
            position_y=self.settings["copyright_button_pos_y"],
            text_font=self.settings["copyright_button_text_font"],
            text_size=self.settings["copyright_button_text_size"],
            screen=self.screen,
            button_color=tuple(self.settings["copyright_button_color"]),
            text_color=tuple(self.settings["copyright_button_text_color"]))

        self.game_title.draw_text()
        self.play_button.draw_button()
        self.rules_button.draw_button()
        self.copyright_button.draw_button()
        self.quit_button.draw_button()
        pygame.display.flip()

    def run_title_screen(self, game_status: GameStatus) -> None:
        if not self.initial_load:
            self.load_title_screen()
            self.initial_load = True
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit(0)
            if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
                mouse_x, mouse_y = pygame.mouse.get_pos()
                if self.play_button.is_clicked(mouse_x, mouse_y):
                    game_status.game_screen = GameState.MIDDLE
                    clear_screen(screen=self.screen, settings=self.settings)
                    self.initial_load = False
                elif self.rules_button.is_clicked(mouse_x, mouse_y):
                    game_status.game_screen = GameState.RULES
                    clear_screen(screen=self.screen, settings=self.settings)
                    self.initial_load = False
                elif self.copyright_button.is_clicked(mouse_x, mouse_y):
                    game_status.game_screen = GameState.COPYRIGHT
                    clear_screen(screen=self.screen, settings=self.settings)
                    self.initial_load = False
                elif self.quit_button.is_clicked(mouse_x, mouse_y):
                    pygame.quit()
                    sys.exit(0)
    def load_title_screen(self) -> None:
        self.game_title = Text(text=self.settings["title_text_text"],
                               width=self.settings["title_text_width"],
                               height=self.settings["title_text_height"],
                               position_x=self.settings["title_text_pos_x"],
                               position_y=self.settings["title_text_pos_y"],
                               text_font=self.settings["title_text_text_font"],
                               text_size=self.settings["title_text_text_size"],
                               screen=self.screen,
                               text_color=tuple(
                                   self.settings["title_text_text_color"]))

        self.play_button = Button(
            text=self.settings["start_button_text"],
            width=self.settings["start_button_width"],
            height=self.settings["start_button_height"],
            position_x=self.settings["start_button_pos_x"],
            position_y=self.settings["start_button_pos_y"],
            text_font=self.settings["start_button_text_font"],
            text_size=self.settings["start_button_text_size"],
            screen=self.screen,
            button_color=tuple(self.settings["start_button_color"]),
            text_color=tuple(self.settings["start_button_text_color"]))

        self.rules_button = Button(
            text=self.settings["rules_button_text"],
            width=self.settings["rules_button_width"],
            height=self.settings["rules_button_height"],
            position_x=self.settings["rules_button_pos_x"],
            position_y=self.settings["rules_button_pos_y"],
            text_font=self.settings["rules_button_text_font"],
            text_size=self.settings["rules_button_text_size"],
            screen=self.screen,
            button_color=tuple(self.settings["rules_button_color"]),
            text_color=tuple(self.settings["rules_button_text_color"]))

        self.quit_button = Button(
            text=self.settings["quit_button_text"],
            width=self.settings["quit_button_width"],
            height=self.settings["quit_button_height"],
            position_x=self.settings["quit_button_pos_x"],
            position_y=self.settings["quit_button_pos_y"],
            text_font=self.settings["quit_button_text_font"],
            text_size=self.settings["quit_button_text_size"],
            screen=self.screen,
            button_color=tuple(self.settings["quit_button_color"]),
            text_color=tuple(self.settings["quit_button_text_color"]))

        self.copyright_button = Button(
            text=self.settings["copyright_button_text"],
            width=self.settings["copyright_button_width"],
            height=self.settings["copyright_button_height"],
            position_x=self.settings["copyright_button_pos_x"],
            position_y=self.settings["copyright_button_pos_y"],
            text_font=self.settings["copyright_button_text_font"],
            text_size=self.settings["copyright_button_text_size"],
            screen=self.screen,
            button_color=tuple(self.settings["copyright_button_color"]),
            text_color=tuple(self.settings["copyright_button_text_color"]))

        self.game_title.draw_text()
        self.play_button.draw_button()
        self.rules_button.draw_button()
        self.copyright_button.draw_button()
        self.quit_button.draw_button()
        pygame.display.flip()