def setup_widgets(self): self.main_layout.add_widget( FontFittingButton( text='Wyloguj', on_release=lambda a: App.get_running_app().root.logout(), **self.button_properties)) self.main_layout.add_widget( FontFittingButton(text='Zmien haslo', on_release=lambda a: PasswordChanger().open(), **self.button_properties)) if App.get_running_app().root.logged_user.privileges == 'Admin': self.main_layout.add_widget( FontFittingButton( text='Dodaj uzytkownika', on_release=lambda a: UserAddingPopup().open(), **self.button_properties)) self.main_layout.add_widget( FontFittingButton( text='Usun uzytkownika', on_release=lambda a: UserRemovingPopup().open(), **self.button_properties)) self.main_layout.add_widget( FontFittingButton( text='Zmien uprawnienia', on_release=lambda a: PermissionChanger().open(), **self.button_properties))
def create_month_chooser(self): month_chooser = BoxLayout(orientation="horizontal", size_hint=(1, 0.1)) displayed_year = self.currently_displayed_month month_chooser.add_widget( FontFittingButton(text="Poprzedni", on_release=lambda a: self.previous_month())) month_chooser.add_widget( FontFittingLabel(text="{} {}".format( months_of_the_year[displayed_year[1]], displayed_year[0]), color=self.month_header_font_color)) month_chooser.add_widget( FontFittingButton(text="Nastepny", on_release=lambda a: self.next_month())) return month_chooser
def create_main_layout(self, wrong_login=False): if wrong_login: self.main_layout.add_widget( FontFittingLabel( markup=True, color=(1, 1, 1, 1), size_hint_y=0.20, text="[b][color=FF0000]Zły login lub hasło![/color][/b]")) self.__username_input = TextInput( multiline=False, id='Username', focus=False, size_hint_y=0.20, on_text_validate=lambda a: self.focus_password()) self.__password_input = TextInput( multiline=False, id='Password', focus=False, size_hint_y=0.20, password=True, on_text_validate=lambda a: self.parent.handle_login( self.__username_input.text, str(hash(a.text)))) self.main_layout.add_widget( FontFittingLabel(text="Login:"******"Hasło:", **self.credential_label_properties)) self.main_layout.add_widget(self.__password_input) self.main_layout.add_widget( FontFittingButton(on_press=lambda a: self.parent.handle_login( self.__username_input.text, self.__password), **self.loginbutton_properties)) self.__password_input.text = self.__username_input.text = ''
def assign_users(self, users): self.main_layout.add_widget(FontFittingLabel(text='Wybierz użytkownika:')) super(UserRemovingPopup, self).assign_users(users) self.confirm_button = FontFittingButton(text="Usuń konto", size_hint=(1, 1), on_press=lambda a: ConfirmationPopup(confirmed_function=self.remove_choosen, func_args=tuple([self.choosen])).open()) self.main_layout.add_widget(self.confirm_button)
def setup_option_buttons(self): today = "{}/{}/{}".format(gmtime().tm_year, gmtime().tm_mon, gmtime().tm_mday) self.main_layout.add_widget(FontFittingLabel(text='Grafik z dnia {}'.format(self.day), size_hint_y=None, height=self.buttons_height, color=self.header_font_color)) self.main_layout.add_widget(FontFittingButton(text='Pokaz dzisiejszy', size_hint_y=None, height=self.buttons_height, on_press=lambda a: self.refresh(today), **self.configuration_buttons_properties))
def setup_widgets(self): super(UserAddingPopup, self).setup_widgets() self.setup_input_fields() self.main_layout.add_widget(FontFittingButton(text="Zatwierdz", on_press=lambda a: schedule_task( CreateUser(firstname=self.get_child('firstname').text, lastname=self.get_child('lastname').text, login=self.get_child('login').text), instance=self)))
def create_main_layout(self): layout = BoxLayout(orientation='vertical', size_hint=(0.8, 0.8)) layout.add_widget( FontFittingLabel(text=self.error_msg, text_size=self.size)) layout.add_widget( FontFittingButton(text="X", text_size=self.size, on_press=lambda a: self.exit())) return layout
def assign_permissions(self): privilege_chooser = DropDown() for privilege in privileges: privilege_chooser.add_widget(FontFittingButton(text="{}".format(privilege), size_hint_y=None, height=privilege_chooser.height, on_release=lambda a: privilege_chooser.select(a.text))) self.choosen_privilege = FontFittingButton(id='privilege_chooser', text="Wybierz uprawnienia", size_hint=(1, 1), user=None) self.choosen_privilege.bind(on_release=lambda a: privilege_chooser.open(self.choosen_privilege)) privilege_chooser.bind(on_select=lambda instance, choosen: setattr(self.choosen_privilege, 'text', choosen)) self.main_layout.add_widget(self.choosen_privilege) self.confirm_button = FontFittingButton(text="Zmień uprawnienia", size_hint=(1, 1), on_press=lambda a: ConfirmationPopup( confirmed_function=schedule_task, func_args=ChangePermissions(self.choosen.user, self.choosen_privilege.text), func_kwargs={'instance': self}).open()) self.main_layout.add_widget(self.confirm_button)
def setup_widgets(self): for hour in range(9, 21): if hour > time.gmtime().tm_hour: self.main_layout.add_widget( FontFittingButton( text="{}.00 - {}.50".format(hour, hour), id="{}".format(hour), size_hint_y=None, height=self.dropdown_height, on_press=lambda a: self.display_unoccupied(a), **self.button_properties))
def add_days_of_month(self, displayed_month, month): for week_object in displayed_month: for day_object in week_object: intensivity = 1 if day_object.month == month else 0.75 complete_date = (day_object.year, day_object.month, day_object.day) self.month_layout.add_widget( FontFittingButton( id='{}/{}/{}'.format(*complete_date), text="{}".format(day_object.day), color=self.days_button_color, background_color=(1, 1, 1, intensivity), on_release=lambda instance: self.on_choose(instance)))
class PermissionChanger(UserModifyingPopup): def __init__(self, **kwargs): super(PermissionChanger, self).__init__(title='Zmień uprawnienia', **kwargs) self.choosen_privilege = None def assign_users(self, users): self.main_layout.add_widget(FontFittingLabel(text='Wybierz uzytkownika i uprawnienia')) super(PermissionChanger, self).assign_users(users) self.assign_permissions() def assign_permissions(self): privilege_chooser = DropDown() for privilege in privileges: privilege_chooser.add_widget(FontFittingButton(text="{}".format(privilege), size_hint_y=None, height=privilege_chooser.height, on_release=lambda a: privilege_chooser.select(a.text))) self.choosen_privilege = FontFittingButton(id='privilege_chooser', text="Wybierz uprawnienia", size_hint=(1, 1), user=None) self.choosen_privilege.bind(on_release=lambda a: privilege_chooser.open(self.choosen_privilege)) privilege_chooser.bind(on_select=lambda instance, choosen: setattr(self.choosen_privilege, 'text', choosen)) self.main_layout.add_widget(self.choosen_privilege) self.confirm_button = FontFittingButton(text="Zmień uprawnienia", size_hint=(1, 1), on_press=lambda a: ConfirmationPopup( confirmed_function=schedule_task, func_args=ChangePermissions(self.choosen.user, self.choosen_privilege.text), func_kwargs={'instance': self}).open()) self.main_layout.add_widget(self.confirm_button) def display_results(self, changed_successfully, *args): msg = 'Wybierz odpowiednie uprawnienia i uzytkownika' if changed_successfully is None \ else 'Nie udało się zmienić uprawnień' super(PermissionChanger, self).display_results(success=changed_successfully, success_msg='Uprawnienia zostały zmienione', failure_msg=msg)
def setup_lessons_buttons(self, busy_hours): for hour in range(9, 21): try: lesson_info, lesson_id = busy_hours[hour] properties = self.busy_buttons_properties except KeyError: lesson_info = '{}.00 - {}.50'.format(hour, hour) lesson_id = "0" properties = self.free_buttons_properties finally: self.main_layout.add_widget(FontFittingButton(text='{}'.format(lesson_info), id="{}".format(lesson_id), on_press=lambda a: self.show_lesson_details(a), size_hint_y=None, height=self.buttons_height, **properties))
def __init__(self, caller, **kwargs): super(OtherDatePopup, self).__init__(title="Podaj date (rok/miesiac/dzien)", auto_dismiss=True, size_hint=(0.75, 0.5), **kwargs) self.caller = caller main_layout = BoxLayout(orientation='vertical') self.input = TextInput( focus=False, multiline=False, size_hint=(1, 1), on_text_validate=lambda a: self.display_choosen()) self.input.focus = True main_layout.add_widget(self.input) main_layout.add_widget( FontFittingButton(text="Wyswietl", size_hint=(1, 1), on_press=lambda a: self.display_choosen())) self.add_widget(main_layout)
def setup_period_chooser(self): period_chooser = DropDown() for x in self.dates: period_chooser.add_widget( FontFittingButton( text="{}".format(x), size_hint_y=None, height=self.dropdown_height, on_release=lambda a: period_chooser.select(a.text), **self.dropdown_buttons_properties)) self.choosen = FontFittingButton(text="Dzis", size_hint=(1, 1), **self.button_properties) self.choosen.bind( on_release=lambda a: period_chooser.open(self.choosen)) period_chooser.bind( on_select=lambda instance, z: setattr(self.choosen, 'text', z)) self.main_layout.add_widget( FontFittingLabel(text="Wybierz okres rozliczeniowy:", size_hint=(1, 1), color=self.header_font_color)) self.main_layout.add_widget(self.choosen) self.main_layout.add_widget( FontFittingButton(text="Wybierz inny dzień", size_hint=(1, 1), on_press=lambda a: self.choose_other_date(), **self.button_properties)) self.main_layout.add_widget( FontFittingButton(text="Wyswietl", size_hint=(1, 1), on_press=lambda a: self.display_choosen(), **self.button_properties)) if App.get_running_app().root.logged_user.privileges == 'Admin': self.main_layout.add_widget( FontFittingButton( text="Wyswietl łączne zarobki", size_hint=(1, 1), on_press=lambda a: self.display_choosen(all_users=True), **self.button_properties))
def setup_widgets(self): super(ConfirmationPopup, self).setup_widgets() self.main_layout.add_widget(FontFittingLabel(text='Jestes pewien?')) self.main_layout.add_widget(FontFittingButton(text='Tak', on_press=lambda a: self.confirm())) self.main_layout.add_widget(FontFittingButton(text='Nie', on_press=lambda a: self.dismiss()))
def on_successful_change(self): self.main_layout.clear_widgets() self.main_layout.add_widget(FontFittingLabel(text="[color=00FF00]Hasło zostało zmienione poprawnie.[/color]", markup=True)) self.bind(on_dismiss=App.get_running_app().root.logout) self.main_layout.add_widget(FontFittingButton(text="Ok", on_release=lambda a: self.dismiss()))
class EarningsScreen( ScrollableScreen ): # TODO issue with Dropdown not opening after choosed once def __init__(self, **kwargs): self.today = "{}/{}/{}".format(gmtime().tm_year, gmtime().tm_mon, gmtime().tm_mday) self.header_font_color = kwargs.pop('header_font_color', (1, 1, 1, 1)) self.button_properties = kwargs.pop('buttons_properties', dict()) self.dropdown_buttons_properties = kwargs.pop( 'dropdown_buttons_properties', dict()) self.dropdown_height = Window.height / 10 if Window.height > Window.width else Window.width / 10 super(EarningsScreen, self).__init__(**kwargs) @property def dates(self): current_monday = (datetime.now() - timedelta(gmtime().tm_wday, 0)) current_month = datetime.now().month current_year = gmtime().tm_year first_year = current_year if current_month > 7 else current_year - 1 previous_month = '{}/{}'.format( current_year, current_month - 1) if current_month != 1 else '{}/{}'.format(current_year - 1, 12) dates = { "Dzis": ("day", datetime.now()), "Wczoraj": ("day", (datetime.now() - timedelta(1, 0))), "Ten tydzien": ("week", current_monday, current_monday + timedelta(6, 0)), "Poprzedni Tydzien": ("week", current_monday - timedelta(7, 0), current_monday - timedelta(1, 0)), "Obecny miesiac": ("month", '{}/{}'.format(current_year, current_month)), "Poprzedni miesiac": ("month", previous_month), "Obecny sezon": ("season", "{}/{}".format(first_year, first_year + 1)), "Poprzedni sezon": ("season", "{}/{}".format(first_year - 1, first_year)) } return dates def setup_widgets(self): self.setup_period_chooser() def setup_period_chooser(self): period_chooser = DropDown() for x in self.dates: period_chooser.add_widget( FontFittingButton( text="{}".format(x), size_hint_y=None, height=self.dropdown_height, on_release=lambda a: period_chooser.select(a.text), **self.dropdown_buttons_properties)) self.choosen = FontFittingButton(text="Dzis", size_hint=(1, 1), **self.button_properties) self.choosen.bind( on_release=lambda a: period_chooser.open(self.choosen)) period_chooser.bind( on_select=lambda instance, z: setattr(self.choosen, 'text', z)) self.main_layout.add_widget( FontFittingLabel(text="Wybierz okres rozliczeniowy:", size_hint=(1, 1), color=self.header_font_color)) self.main_layout.add_widget(self.choosen) self.main_layout.add_widget( FontFittingButton(text="Wybierz inny dzień", size_hint=(1, 1), on_press=lambda a: self.choose_other_date(), **self.button_properties)) self.main_layout.add_widget( FontFittingButton(text="Wyswietl", size_hint=(1, 1), on_press=lambda a: self.display_choosen(), **self.button_properties)) if App.get_running_app().root.logged_user.privileges == 'Admin': self.main_layout.add_widget( FontFittingButton( text="Wyswietl łączne zarobki", size_hint=(1, 1), on_press=lambda a: self.display_choosen(all_users=True), **self.button_properties)) def choose_other_date(self): OtherDatePopup(caller=self).open() def display_choosen(self, period=None, all_users=False): if period is None: period = self.dates[self.choosen.text] db_kwargs = { 'period': period, 'user': App.get_running_app().root.choosen_user if not all_users else None } schedule_task(callback=GetEarnings(**db_kwargs), instance=self) def show_earnings(self, total_earns): period = self.choosen.text self.main_layout.clear_widgets() self.setup_widgets() if total_earns is None: total_earns = 0 self.main_layout.add_widget( FontFittingLabel(text="Okres: {}".format(period), color=self.header_font_color)) self.main_layout.add_widget( FontFittingLabel(text="Zarobione łącznie: {}".format(total_earns), color=self.header_font_color)) self.main_layout.add_widget( FontFittingLabel(text="Na czysto: {}".format(total_earns / 2), color=self.header_font_color)) def display_error(self, msg): self.main_layout.clear_widgets() self.main_layout.add_widget( FontFittingLabel( text="[b][color=FF0000]{}[/color][/b]".format(msg), markup=True)) self.setup_widgets()
def setup_widgets(self): esc_layout = BoxLayout(size_hint_x=0.2, pos_hint={"x": 0.8}) esc_layout.add_widget(FontFittingButton(text="X", on_press=lambda a: self.dismiss())) self.main_layout.add_widget(esc_layout)
def setup_widgets(self): super(PasswordChanger, self).setup_widgets() self.setup_input_fields() self.main_layout.add_widget(FontFittingButton(text="Zatwierdz", on_press=lambda a: self.confirm()))