def __init__(self, multiplayer=False, sm=None, **kwargs): super().__init__(**kwargs) self.btns = [] # 0 = kruzok ; 1 = iksko self.turn = randint(0, 1) if multiplayer else 1 self.__multi = multiplayer content = BoxLayout(orientation='vertical') self.status_label = Label(text=str(self.status)) content.add_widget(self.status_label) dismiss_btns = BoxLayout(orientation='horizontal') dismiss_btns.add_widget( Button(text='RESTART', on_press=lambda i: self.restart())) dismiss_btns.add_widget( Button(text='EXIT', on_press=lambda i: self.exit(sm))) content.add_widget(dismiss_btns) self.pop = Popup(title='GAME OVER', content=content, size_hint=(0.5, 0.2), pos_hint={'y': 0.75}, auto_dismiss=False) main_layout = BoxLayout(orientation='vertical') row_1 = BoxLayout(orientation='horizontal', spacing=20) self.X = Label(text='X', font_size=50) self.X.underline = True if self.turn == 1 else False row_1.add_widget(self.X) self.O = Label(text='O', font_size=50) self.O.underline = True if self.turn == 0 else False row_1.add_widget(self.O) main_layout.add_widget(row_1) row_2 = GridLayout(rows=3, cols=3) row_2.size_hint = (0.5, 1.0) row_2.pos_hint = {'x': 0.25} for i in range(9): btn = Button(font_size=30) btn.bind(on_press=self.key_stroke) self.btns.append(btn) row_2.add_widget(btn) main_layout.add_widget(row_2) row_3 = BoxLayout(orientation='horizontal') self._player1_label = Label(text=str(self.player1)) self._player1_label.font_size = 40 row_3.add_widget(self._player1_label) self._player2_label = Label(text=str(self.player2)) self._player2_label.font_size = 40 row_3.add_widget(self._player2_label) main_layout.add_widget(row_3) self.add_widget(main_layout)
def __init__(self, *args, **kwargs): super(HostScreen, self).__init__(**kwargs) self.name = "host" gdlayout = GridLayout(cols=1, rows=2, spacing=[dp(5)]) btn_continue = Button(text="Continue", on_release=lambda *args: setattr( Globals.app.root, "current", "status")) btn_debug = Button(text="Debug", on_release=self._on_button_debug) gdlayout.add_widget(btn_continue) gdlayout.add_widget(btn_debug) self.add_widget(gdlayout) gdlayout.size_hint = (.5, .3) gdlayout.pos_hint = {"center_x": .5, "center_y": .5}
def __init__(self, *args, **kwargs): super(ExtrasScreen, self).__init__(**kwargs) self.name = "extras" btn_kick = Button(text="Kick Drivers", on_release=self.on_kick_driver_button) btn_messages = Button(text="Messages", on_release=self.on_message_button) btn_bookings = Button(text="Bookings", on_release=self.on_bookings_button_press) btn_log = Button(text="Log", on_release=self.on_log_button_press) btn_about = Button(text="About", on_release=self.on_about_button_press) grid_layout = GridLayout(cols=1, rows=5) grid_layout.size_hint = (.5, .5) grid_layout.pos_hint = {"center_x": .5, "center_y": .5} grid_layout.add_widget(btn_kick) grid_layout.add_widget(btn_messages) grid_layout.add_widget(btn_bookings) grid_layout.add_widget(btn_log) grid_layout.add_widget(btn_about) self.add_widget(grid_layout)
def jogar(self, btn): print("selecao") try: GridLayout TextInput except: from kivy.uix.textinput import TextInput from kivy.uix.gridlayout import GridLayout self.sel_txti = TextInput(size_hint=(0.285, 0.085), multiline=False) self.sel_txti.pos_hint = { "x": 0.5 - self.sel_txti.size_hint_x, "y": 0.67 } self.sel_txti.text = "Nome do personagem" self.sel_txti.bind(focus=self.clean, text=self.change_txti) self.sel_btn_check = Button(id="false", text="check", size_hint=(0.1285, 0.085), pos_hint={ "x": 0.5, "y": 0.67 }, on_press=self.check) sel_btn_icone = Button(size_hint=(0.155, 0.17), on_press=selecao.opcoes, opacity=0.3) sel_btn_icone.pos_hint = { "x": 0.5 + self.sel_btn_check.size_hint_x, "y": 0.67 } self.sel_icone = Image(source="source/img/icone/img_vazia.jpg", size_hint=sel_btn_icone.size_hint, pos_hint=sel_btn_icone.pos_hint) self.sel_icone.allow_stretch = True self.sel_icone.keep_ratio = False sel_grid_image = Image(source="source/img/fundo_grid.jpg", size_hint=(0.57, 0.5), allow_stretch=True, keep_ratio=False) sel_grid_image.pos_hint = { "x": 0.5 - (sel_grid_image.size_hint_x / 2), "y": 0.17 } sel_grid = GridLayout(cols=2, size_hint=(0.57, 0.5)) sel_grid.pos_hint = {"x": 0.5 - (sel_grid.size_hint_x / 2), "y": 0.17} for i in range(1, 3 + 1): sel_grid.add_widget(Label(text="Server" + str(i))) sel_grid.add_widget( Button(id=str(i), text="Entrar" + str(i), on_press=self.join)) sel_image = Image(source="source/img/fundo.jpg", allow_stretch=True, keep_ratio=False) sel_layout = FloatLayout() sel_layout.add_widget(sel_image) sel_layout.add_widget(self.sel_txti) sel_layout.add_widget(self.sel_btn_check) sel_layout.add_widget(self.sel_icone) sel_layout.add_widget(sel_btn_icone) sel_layout.add_widget(sel_grid_image) sel_layout.add_widget(sel_grid) selecao.add_widget(sel_layout) screen_manager.current = selecao.name