def _on_keyboard_up(self, keyboard, keycode): key_str = keycode[1] if not funcs.check_possibility_to_move(self.game_field_matrix): popup = ModalView(size_hint=(None, None), size=(200, 50), background_color=(1, .7, .2, .4)) popup.add_widget( Button(text='You LOSE!', font_size='25sp', background_color=(1, .7, .2, 1))) popup.open() keyboard.release() state, updated_field = funcs.process_game_step(self.game_field_matrix, key_str) if state != funcs.WRONG_USER_INPUT: self.game_field_matrix = updated_field self.generate_random_number() updated_field = funcs.to_one_dim(self.game_field_matrix)[::-1] for index in range(len(updated_field)): self.children[index].text = str(updated_field[index]) if self.look_for_game_win_state and state == funcs.GAME_WON: self.look_for_game_win_state = False popup = ModalView(size_hint=(None, None), size=(200, 50), background_color=(1, .7, .2, .4)) popup.add_widget( Button(text='You WON!', font_size='25sp', background_color=(1, .7, .2, 1))) popup.open() return True
def check_board(self): values = [[self.get_value(row, col) for col in range(9)] for row in range(9)] if solver.check_board(values): win = ModalView(size_hint=(None, None), size=(300, 100)) win.add_widget(Label(text='Congratualtions', font_size=20)) win.open() else: loss = ModalView(size_hint=(None, None), size=(300, 100)) loss.add_widget(Label(text='You have some mistakes', font_size=20)) loss.open()
def card(content, title=None, background_color=None, size=(0.7, 0.5)): """Вывод диалоговых окон с кастомным контентом.""" if not background_color: background_color = [1.0, 1.0, 1.0, 1] card = MDCard(size_hint=(1, 1), padding=5) # , background_color=background_color) if title: box = BoxLayout(orientation="vertical", padding=dp(8)) box.add_widget( MDLabel( text=title, theme_text_color="Secondary", font_style="Title", size_hint_y=None, height=dp(36), )) box.add_widget(MDSeparator(height=dp(1))) box.add_widget(content) card.add_widget(box) else: card.add_widget(content) dialog = ModalView(size_hint=size, background_color=[0, 0, 0, 0.2]) dialog.add_widget(card) # dialog.open() return dialog
def show_modalview(self, src): self.textbox_log.text += u"pressed %s button\n" % src.text confirmation_text = u"""この設定を送信しても 良いですか? Is it really OK to send message with this configuration?""" self.modalview = ModalView(size_hint=(0.5, 0.5), auto_dismiss=False) boxlayout = BoxLayout(orientation='vertical', padding=20, spacing=10) boxlayout.add_widget( Label(size_hint_y=0.6, text=confirmation_text, font_name=self.font_name_ja, halign='center', valign='middle')) button_ok = Button(size_hint_y=0.2, text="OK", padding=[20, 20]) button_ok.id = src.id button_no = Button(size_hint_y=0.2, text="NO", id="no", padding=[20, 20]) boxlayout.add_widget(button_ok) boxlayout.add_widget(button_no) self.modalview.add_widget(boxlayout) button_ok.bind(on_press=self.dismiss_modalview) button_no.bind(on_press=self.dismiss_modalview) self.modalview.open()
def reset(self, *args): self.status = [0 for _ in range(9)] for child in self.children: child.text = '' child.background_color = (1, 1, 1, 1) self.current_player = 1 winner = None if -3 in sums: winner = 'Выиграли крестики' elif 3 in sums: winner = 'Выиграли нолики' elif 0 not in self.status: winner = 'Ничья' if winner: popup = ModalView(size_hint=(0.75, 0.5)) victory_label = Label(text=winner, font_size=50) popup.add_widget(victory_label) popup.bind(on_dismiss=self.reset) popup.open() for row in range(3): for column in range(3): grid_entry = GridEntry(coords=(row, column)) grid_entry.bind(on_release=self.button_pressed) self.add_widget(grid_entry)
def callback(instance): from pages import leaveReq leaveReq.Data.append([user, id, department]) view = ModalView(size_hint=(0.5, 0.75), background_color=(0, 0, 0, 0.6)) view.add_widget(leaveReq.LeaveLayout()) view.open()
def show_loading_popup(max=1): popup_window = ModalView(size_hint=(0.2, 0.1), auto_dismiss=False) popup_layout = LoadingPopup(popup_window, max) popup_window.add_widget(popup_layout) popup_window.open() return popup_layout
def show_question_popup(question, condition_function): popup_window = ModalView(size_hint=(0.3, 0.3), auto_dismiss=False) popup_layout = YesNoPopup(popup_window, condition_function, question) popup_window.add_widget(popup_layout) popup_window.open() return popup_window
def pokazDodanieObiektu(self, *args): view = ModalView(size_hint=(None, None), size=(640, 480)) box = BoxLayout(orientation="vertical", spacing=10) scrollView = ScrollView(bar_margin=10, bar_color=[1, 1, 1, 1]) viewWrapper = GridLayout(cols=2, row_default_height=40, size_hint_y=None, padding=[-20, 20, 20, 20]) viewWrapper.bind(minimum_height=viewWrapper.setter('height')) listaTextBoxow = [] for i in range(len(self.sharedInstance.data.temp)): l = Label(text=self.sharedInstance.data.temp[i], halign="left", width=50) #textPlaceHolder = 'Tutaj wpisz wartosc dla {0}'.format(self.sharedInstance.data.temp[i]) #textPlaceHolder,multiline=False, ) textinput = TextInput(multiline=False, text="0", focus=True) listaTextBoxow.append(textinput) viewWrapper.add_widget(l) viewWrapper.add_widget(textinput) #background_color=[51/255.0, 181.0/255, 229/255.0,1] scrollView.add_widget(viewWrapper) box.add_widget(scrollView) box.add_widget( Button(text='Dodaj', font_size=14, on_press=partial(self.dodajObiekt, view, listaTextBoxow), size_hint=(1, .1))) view.add_widget(box) view.open() return view
def encode(self): # img = input("Enter image name(with extension): ") img = self.ids.pathLabel.text image = Image.open(img, 'r') # data = input("Enter data to be encoded : ") data = self.ids.messageInput.text if (len(data) == 0): raise ValueError('Data is empty') newimg = image.copy() self.encode_enc(newimg, data) # new_img_name = input("Enter the name of new image(with extension): ") # Sets the encoded image to the original image path new_img_name = img # Saves the image newimg.save(new_img_name, self.check_file_type(new_img_name)) message = ModalView(size_hint=(None, None), size=(400, 400)) messageLabel = Label(text="Message Encoded to:\n" + img, text_size=(message.width - 50, None)) message.add_widget(messageLabel) message.open() print('done')
def Load(self): """ Load from the Disk Button > Load() """ from functools import partial from kivy.uix import filechooser from kivy.uix.filechooser import FileChooserListView, FileChooserIconView main = ModalView(size_hint=(.8, .8)) # everything on this Modal is 80% BL = BoxLayout(portrait="vertical") FLV = FileChooserListView(path="coreEngine/Saved", ) def cTexloader(instance): Selected = FLV.selection Selected_Attr = Selected LStoString = str(Selected_Attr[0]) self.Loader_NoErr(ctexSaved=LStoString, fixedPath=LStoString) Load_Btn = Button(text="Load this File") Load_Btn.bind(on_press=cTexloader) main.add_widget(BL) BL.add_widget(FLV) BL.add_widget(Load_Btn) main.open()
def on_status(self, instance, new_value): status = new_value # Sum each row, col and diag # Could be shorter, but let's be extra # clear what's going on sums = [#rows sum(status[0:3]), #columns sum(status[3:6]), sum(status[6:9]), sum(status[0::3]), #diagonals sum(status[1::3]), sum(status[2::3]), sum(status[::4]), sum(status[2:-2:2])] # Sums can only be +-3 if one player # filled the whole line winner = '' if 3 in sums: winner = '{} win!'.format('Nitya') elif -3 in sums: winner = '{} win!'.format('Pranav') elif 0 not in self.status: #Grid full winner = 'Draw...Nobody wins!' if winner: popup = ModalView(size_hint = (0.75 , 0.5 )) victory_label = Label(text = winner, font_size = 50) popup.add_widget(victory_label) popup.bind(on_dismiss = self.reset) popup.open()
def on_status(self, instance, new_value): status = new_value # updates the status property with new value # Sum each row, column and diagonal. # Could be shorter, but let’s be extra # clear what’s going on sums = [ sum(status[0:3]), sum(status[3:6]), sum(status[6:9]), # rows sum(status[0::3]), sum(status[1::3]), sum(status[2::3]), # columns sum(status[0::4]), sum(status[2:7:2]) # diagonals ] winner = None if 3 in sums: winner = 'Kolečka vítězí!' elif -3 in sums: winner = 'Křížky vítězí!' elif 0 not in status: winner = 'Remíza ... nikdo nezvítězil!' if winner: popup = ModalView(size_hint=(0.75, 0.5)) victory_label = Label(text=winner, font_size=50) popup.add_widget(victory_label) popup.bind(on_dismiss=self.reset) popup.open()
def on_status(self, instance, new_value): status = new_value sums = [ sum(status[0:3]), sum(status[3:6]), sum(status[6:9]), sum(status[0::3]), sum(status[1::3]), sum(status[2::3]), sum(status[::4]), sum(status[2:-2:2]) ] winner = None if 3 in sums: winner = "Os win!" elif -3 in sums: winner = "Xs win!" elif 0 not in self.status: winner = "Draw!" if winner: popup = ModalView(size_hint=(0.75, 0.5)) victory_label = Label(text=winner, font_size=50) popup.add_widget(victory_label) popup.bind(on_dismiss=self.reset) popup.open()
def account_changer(self, caller): self.popup_card = MDCard( size=(400, 400), size_hint=(None, None), md_bg_color=(0.1, 0.1, 0.1, 1), radius=(20, 20, 20, 20), ) self.layout = ModalView( size=(500, 500), size_hint=(None, None), background_color=(0, 0, 0, .9), background='atlas://data/images/defaulttheme/action_item') self.layout.add_widget(self.popup_card) #Create an object that holds the main ui using the template User_details self.user_details = User_Details() #set the current logged in user's username and password self.user_details.ids.user_name.text = current_user self.user_details.ids.password.text = current_password #bind the save function to the save button from the ui self.user_details.ids.save.bind( on_press=partial(user_menu_operations.saver, self, 1)) self.popup_card.add_widget(self.user_details) #dispay the popup self.layout.open()
def on_start(self): """ Sets the main window's size, opens airports database connection, decides to render the login window based on the saved settings, and initializes the data manager once the application starts. :return: None """ # Config.set('graphics', 'width', '1050') # Config.set('graphics', 'height', '800') # Config.write() Window.clearcolor = (0, 0, 0, 1) Window.size = (1200, 800) BASE_DIR = os.path.dirname(os.path.abspath(__file__)) db_path = os.path.join(BASE_DIR, "..", "DATA", "global_airports.db") self.airports_connection = sqlite3.connect(db_path) self.airports_cursor = self.airports_connection.cursor() db_path = os.path.join(BASE_DIR, "..", "DATA", "AIRCRAFT_COLLISION_FORECAST_SYSTEM.db") settings_connection = sqlite3.connect(db_path) settings_cursor = settings_connection.cursor() query = f"SELECT STATE FROM SETTINGS WHERE NAME = 'SHOW LOGIN WINDOW'" settings_cursor.execute(query) result = settings_cursor.fetchall() settings_connection.close() if result[0][0] == '1': login_window = ModalView(size_hint=(0.5, 0.5), auto_dismiss=False) login_window.add_widget(LoginView(login_window)) login_window.open() else: self.data_manager = DataManager(airport_id_index=2, airplane_id_index=0) Thread(target=self.data_manager.load_airports).start()
def permTime(self): global opDetail #p = leaveData.grant_perm(detail) view = ModalView(size_hint=(0.25, 0.25), background_color=(0, 0, 0, 0.6)) view.add_widget(userSettings.Permission(opDetail)) view.open()
def on_status(self, instance, new_value): status = new_value sums = [ sum(status[0:3]), sum(status[3:6]), sum(status[6:9]), sum(status[0::3]), sum(status[1::3]), sum(status[2::3]), sum(status[::4]), sum(status[2:-2:2]) ] resultado = None if -3 in sums: resultado = 'O Joogador 02 (X) ganhou!' elif 3 in sums: resultado = 'O Jogador 01 (O) ganhou!' elif 0 not in self.status: resultado = "Velhou!" if resultado: popup = ModalView(size_hint=(0.75, 0.5)) labelResultado = Label(text=resultado, font_size=50) popup.add_widget(labelResultado) popup.bind(on_dismiss=self.reset) popup.open()
def select_slot(self, index): selectedSlot = self.slotsData[index] modalview = ModalView(size_hint=(None, None), width=600, height=400) # view = ModalView(auto_dismiss=False) container = ColorBoxLayout(orientation='vertical', color=Color(1, 1, 1, 1)) headerLabel = Label(text='Confirm Booking', font_size=30, color=(0, 0, 0, 1)) dateLabel = Label(text='Date: {0}'.format(selectedSlot['date']), font_size=23, color=(0, 0, 0, 1), size_hint=(1, None), height=60) timeLabel = Label(text='Time: {0}'.format(selectedSlot['time']), font_size=23, color=(0, 0, 0, 1), size_hint=(1, None), height=60) costLabel = Label(text='Cost: {0} credits'.format(50), font_size=23, color=(0, 0, 0, 1), size_hint=(1, None), height=60) remaindingLabel = Label( text='Remainder: {0} credits'.format(self.student_data['credits'] - 50), font_size=23, color=(0, 0, 0, 1), size_hint=(1, None), height=60) buttonRow = BoxLayout(orientation='horizontal') cancelButton = Button(text='Cancel', size_hint=(None, None), width=300, height=80) cancelButton.on_press = self.close_modal confirmButton = Button(text='Confirm', size_hint=(None, None), width=300, height=80) confirmButton.on_press = partial(self.confirm_slot, selectedSlot['id']) buttonRow.add_widget(cancelButton) buttonRow.add_widget(confirmButton) container.add_widget(headerLabel) container.add_widget(dateLabel) container.add_widget(timeLabel) container.add_widget(costLabel) container.add_widget(remaindingLabel) container.add_widget(buttonRow) modalview.add_widget(container) self.modalview = modalview self.open_modal()
def buildRuleView(rule, *args): main_layout = FloatLayout() header = Label(text=rule.getName(), pos_hint={ 'center_x': .5, 'top': 1 }, size_hint=(.2, .1), font_size="30sp", bold=True, color=rgba('#0a5e00')) body = WrappedLabel(text=rule.getText(), font_size="20sp", pos_hint={ 'center_x': .5, 'center_y': .5 }, size_hint=(.9, .9)) main_layout.add_widget(header) main_layout.add_widget(body) rule_view = ModalView(size_hint=(.92, .98), background="Resources/262626.png", background_color=rgba('#0a5e00')) rule_view.add_widget(main_layout) rule_view.open()
def decode(self): # img = input("Enter image name(with extension) :") img = self.ids.pathLabel.text # Must let PIL know that its a JPEG file, currently using JPG # Just need to use the same if statement as before image = Image.open(img, 'r') data = '' imgdata = iter(image.getdata()) while (True): pixels = [ value for value in imgdata.__next__()[:3] + imgdata.__next__()[:3] + imgdata.__next__()[:3] ] # string of binary data binstr = '' for i in pixels[:8]: if (i % 2 == 0): binstr += '0' else: binstr += '1' data += chr(int(binstr, 2)) if (pixels[-1] % 2 != 0): dmessage = ModalView(size_hint=(None, None), size=(400, 400)) message_label = Label(text="Message:\n\n" + data, text_size=(dmessage.width - 50, None)) dmessage.add_widget(message_label) dmessage.open() return data
def helpView(self): """ Show Help/Guides modal (show when help button pressed) """ widgets = FloatLayout( size_hint=(None, None), size=(300, 300), background_color=parse_color("#FF9933"), ) sizer = NumericProperty(30) main = ModalView( title_color=parse_color("#FF9933"), title_size=(25), seperator_height=("9dp"), separator_color=parse_color("#FF9933"), #background_color=parse_color("#FF9933"), size_hint=(None, None), size=(400, 620), content=Image(source="coreEngine/Images/about.png"), ) white_bar = Image(source="coreEngine/Images/whitebar.png", pos=(123, 123), size=(400, 400)) logo = Image(source="coreEngine/Images/about.png") main.add_widget(logo, 1) main.open()
def __init__(self, **kwargs): super().__init__(color=Color(248/255,248/255,248/255,1),**kwargs) self.data = { 'name': 'nil', 'class': 'nil', 'student_id': 'nil' } details_container = BoxLayout(orientation='vertical', size_hint=(None, None), width=400, height=200, padding=[24, 0,0, 16]) self.idLabel = StudentDetailLabel(text='NO ID') self.nameLabel = StudentDetailLabel(text='NO NAME') self.classLabel = StudentDetailLabel(text='NO ID') self.creditsLabel = StudentDetailLabel(text='NO ID') details_container.add_widget(self.idLabel) details_container.add_widget(self.nameLabel) details_container.add_widget(self.classLabel) details_container.add_widget(self.creditsLabel) my_slots_button = Button(text='My Slots', on_press=self.show_my_slots, size_hint=(None,None), width=160, height=80, background_normal='', background_color=(0.5,0.5,0.5,1)) self.add_widget(details_container) self.add_widget(Widget()) self.add_widget(my_slots_button) modalview = ModalView() self.my_slots_widget = MySlotsWidget(back_callback=self.close_modal) modalview.add_widget(self.my_slots_widget) self.modalview = modalview
def aboutme(self, argc): view = ModalView(size_hint=(None, None), size=(320, 240)) box = GridLayout(cols=1, size_hint=(.33, 1)) box.add_widget(Image(source='icon/about.png', size_hint=(.9, .8))) box.add_widget(Label(text="Привет, создатель этой проги Денис! :3")) box.add_widget(Label(text="Спасибо сайту: https://icons8.ru")) view.add_widget(box) return view.open()
def complete(self, *args): source = 'resources/circuit_complete.png' texture = Image(source=source) height = dp((texture.texture_size[1] * self.width) / texture.texture_size[0]) complete_popup = ModalView(size_hint=(1, None), height=height, background=source, background_color=[0, 0, 0, .35], auto_dismiss=False, pos_hint={'center_y': .65}) complete_popup.open() Clock.schedule_once(lambda dt: self.back_home(popup=complete_popup), 7)
def open_settings_window(): """ Opens the settings window. :return: None """ settings_window = ModalView(size_hint=(0.5, 0.5), auto_dismiss=False) settings_window.add_widget(SettingsView(settings_window)) settings_window.open()
def my_callback2(instance): """ Функция для определения поведения всплывающего окна при его закрытии. """ view = ModalView() view.dismiss(force=True) self.logic() return False
def __init__(self, **kwargs): super().__init__(**kwargs) self.popup = ModalView(size_hint=[0.4, 0.4]) label = Label( text="This feature is not implemented yet" "\n\nClick outside this popup to dismiss it." ) self.popup.add_widget(label)
def launchSimpleModal(text): view = ModalView(size_hint=(0.4, 0.2)) content = SimpleModal(text=text) view.add_widget(content) # bind the on_press event of the button to the dismiss function content.bind(on_press=view.dismiss) # open the view view.open()
def get_modal(self, _type): # Create modals if not already created if _type == "test" and not self.modals[_type]: test_modal = ModalView() self.test_grid = GridLayout(cols=1) test_datasets = os.listdir("./test-data") for _set in test_datasets: btn = Button(text=_set) btn.bind(on_press=self.load_data) self.test_grid.add_widget(btn) test_modal.add_widget(self.test_grid) self.modals[_type] = test_modal elif _type == "storage" and not self.modals[_type]: if not self.modals[_type]: fc = FileChooserWindow(load_callback=self.load_data) self.modals[_type] = fc elif _type == "url" and not self.modals[_type]: url_modal = ModalView() layout = RelativeLayout() self.url_inp = TextInput(hint_text='URL', size_hint=(.3, .1), pos_hint={ 'center_x': .5, 'center_y': .5 }) submit_btn = Button(text="Submit", size_hint=(.3, .1), pos_hint={ 'center_x': .5, 'center_y': .35 }) layout.add_widget(self.url_inp) submit_btn.bind(on_press=self.load_data) layout.add_widget(submit_btn) url_modal.add_widget(layout) self.modals[_type] = url_modal self._type = _type return self.modals[_type]