Ejemplo n.º 1
0
    def __activate_no_connection_screen(self):
        """
        Warning screen about - No connection Available
        :return:
        """
        # Menu Background
        self.bckg_image = get_background(picture_path='pictures/menu_background.png')
        self.add_widget(self.bckg_image)

        # No connection label text
        no_connection_l = Label(text='[b]No Internet connection available ![/b]', markup=True)
        no_connection_l.font_size = FONT_SIZE_HEADLINES
        no_connection_l.bold = True
        no_connection_l.color = [0.8, 0.8, 0.8, 0.5]
        no_connection_l.pos_hint = {'x': .0, 'y': .3}
        self.add_widget(no_connection_l)

        # No connection label description
        no_connection_l = Label(text='Please check or activate your data connection.')
        no_connection_l.font_size = 47
        no_connection_l.bold = True
        no_connection_l.color = [0.8, 0.8, 0.8, 0.5]
        no_connection_l.pos_hint = {'x': .0, 'y': .0}
        self.add_widget(no_connection_l)

        # Main menu button
        self.main_menu_b = Button(text='Main menu', font_size=FONT_SIZE_BUTTON, size_hint=SIZE_HINT_BUTTON_LEVELS,
                                  pos_hint={'x': .4, 'y': .2})
        self.main_menu_b.bind(on_press=self.__activate_menu)
        self.add_widget(self.main_menu_b)
Ejemplo n.º 2
0
 def makeMilestoneLayout(self, tid, milestone = None, oldScore=None):
     milestone2 = getPreviousMilestone(tid, milestone)
     newScore = getScore(tid, milestone2, milestone)
     if oldScore is None:
         oldScore = newScore
     scoreLayout = GridLayout(cols=1, spacing=10, size_hint_y = None)
     milestoneButton = Button(text=getDateString(milestone, False), font_size='16sp', size_hint_y = None, height=50)
     milestoneButton.bind(on_press=self.milestoneMenu(tid, milestone))
     scoreLayout.add_widget(milestoneButton)
     progressLayout = BoxLayout(orientation='horizontal')
     prevScoreMilestone = Label(text=getScoreText(oldScore))
     prevScoreMilestone.color = (1,1-float(prevScoreMilestone.text[:-1])/100,1-float(prevScoreMilestone.text[:-1])/100,1)
     progressLayout.add_widget(prevScoreMilestone)
     scoreProgress = ProgressBar(max=0.1)
     scoreProgress.value = oldScore % 0.1
     progressLayout.add_widget(scoreProgress)
     nextScoreMilestone = Label(text=getScoreText(oldScore, True))
     nextScoreMilestone.color = (1,1-float(nextScoreMilestone.text[:-1])/100,1-float(nextScoreMilestone.text[:-1])/100,1)
     nextScoreMilestone.bold = nextScoreMilestone.text == '100%'
     progressLayout.add_widget(nextScoreMilestone)       
     Clock.schedule_interval(self.incrementScoreProgress(scoreProgress, prevScoreMilestone, nextScoreMilestone, oldScore, newScore), 0.1)
     scoreLayout.add_widget(progressLayout)
     scoreLabel = Label(text=str(int(100*newScore))+"%")
     if getNextMilestone(tid) == milestone:
         #expScore = newScore * (milestone-time.time()) / (time.time()-milestone2)
         idealScore = newScore + (milestone-time.time())/(milestone-milestone2)            
         scoreLabel.text += ' ('+ str(int(100*idealScore))+"%)"
     scoreLabel.color = (1,1-newScore,1-newScore,1)
     scoreLabel.bold = newScore>=0.99
     scoreLayout.add_widget(scoreLabel)
     return scoreLayout
Ejemplo n.º 3
0
    def __init__(self, **kw):
        """Constructor: Makes a new Panel for drawing shapes
        
        Precondition: **kw are Kivy key-word arguments"""
        # Pass Kivy arguments to super class.
        super(Panel, self).__init__(**kw)

        # Need kivy.metrics to handle retina Macs properly
        rsize = [0, 0]
        rsize[0] = self.size[0] * dp(1)
        rsize[1] = self.size[0] * dp(1)

        # Make the background solid white
        color = Color(1.0, 1.0, 1.0, 1.0)
        self.canvas.add(color)
        rect = Rectangle(pos=self.pos, size=rsize)
        self.canvas.add(rect)

        # Add the label
        label = Label(text="Hello World!")
        label.color = [0.0, 0.0, 0.0, 1.0]
        label.size_hint = (1, 1)
        label.font_size = 48 * dp(1)  # Again, retina Macs
        label.bold = True
        self.add_widget(label)
Ejemplo n.º 4
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.orientation = 'vertical'

        # simple label
        label1 = Label()
        label1.text = 'Hello Florian, \nWhat\'s up ?'
        label1.font_size = 42
        label1.bold = True
        label1.underline = True
        label1.halign = 'center'
        label1.color = (0, 1, 0, 1)
        self.add_widget(label1)

        # markup text
        label2 = Label()
        label2.text = '[size=30]I try to [u]code[/u] a [b]kivy app[/b] ![/size]'
        label2.halign = 'center'
        label2.markup = True
        label2.color = (0, 0, 1, 1)
        self.add_widget(label2)

        # unicode text
        label3 = Label()
        label3.text = 'هل يمكن تأجير عربات للأطفال؟'
        label3.font_name = 'DejaVuSans'
        self.add_widget(label3)

        # Icons text
        label4 = Label()
        label4.font_size = 60
        label4.text = '\uF00A'
        label4.font_name = 'Icons'
        self.add_widget(label4)
Ejemplo n.º 5
0
 def widgetWithSuccessMessage(message):
     widget = Label(text=message)
     widget.font_size = 45
     widget.bold = True
     widget.color = (0, 1, 0, 0.75)
     widget.pos_hint = {"top": .66}
     return widget
Ejemplo n.º 6
0
 def errorWidget(message):
     widget = Label(text=message)
     widget.font_size = 45
     widget.bold = True
     widget.color = (1, 0, 0, 0.75)
     widget.pos_hint = {"top": .66}
     return widget
Ejemplo n.º 7
0
def build():
	lb = Label()
	lb.text = "Curso de Python e Kivy"
	lb.bold = True
	lb.font_size = 50
	lb.pos = (0, 200)
	return lb
    def build(self):
        c = CustomLayout()
        c.add_widget(
            AsyncImage(
                source="Login/background-login.jpg"))

        lbl = Label(text='Bem vindo')
        lbl.font_size= '60sp'
        lbl.bold= True
        lbl.color= [1,1,1,1]
        lbl.size_hint = None, None
        lbl.height = 30
        lbl.width = 300
        lbl.y = 370
        lbl.x = 250

        bt = Button(text="Iniciar captura de face")
        bt.size_hint = None, None
        bt.height = 50
        bt.width = 200
        bt.y = 210
        bt.x = 300
        def callback(self):
#inserir codigo de reconhecimento facial-captura de fotos
            bt.bind(on_press=callback)


        bt2 = Button(text="Iniciar Treino")
        bt2.size_hint = None, None
        bt2.height = 50
        bt2.width = 200
        bt2.y = 150
        bt2.x = 300
        def callback(self):
# inserir codigo de treino
            bt2.bind(on_press=callback)


        bt3 = Button(text="Iniciar Reconhecimento")
        bt3.size_hint = None, None
        bt3.height = 50
        bt3.width = 200
        bt3.y = 90
        bt3.x = 300


        def callback(self):
# inserir codigo de visualização do reconhecimento
            bt3.bind(on_press=callback)

        c.add_widget(lbl)
        c.add_widget(bt)
        c.add_widget(bt2)
        c.add_widget(bt3)

        return c
Ejemplo n.º 9
0
 def __init__(self, capture, fps, **kwargs):
     super(KivyCamera, self).__init__(**kwargs)
     self.capture = capture
     lbl = Label(text=kwargs.get('text', ''))
     lbl.font_size = '60sp'
     lbl.bold = True
     lbl.color = [0, 0, 1, 0.5]
     self.add_widget(lbl)
     self.orientation = 'vertical'
     Clock.schedule_interval(self.update, 1.0 / fps)
Ejemplo n.º 10
0
 def buildWaves(self):
     x = 1
     for wave in Player.player.waveTypeList:
         lbl = Label(size_hint=(None, None),
                     font_size=__main__.app.root.scrwid * .012,
                     text=str(x) + '. ' + wave[0],
                     id='wave' + str(x),
                     text_size=(None, None),
                     size=(Map.mapvar.squsize * 4, Map.mapvar.squsize),
                     color=[0, 0, 0, 1],
                     texture_size=self.size,
                     halign='left')
         x += 1
         if wave[1]:  # if boss
             lbl.bold = True
             lbl.color = [1, 0, 0, 1]
         __main__.app.root.ids.wavelist.add_widget(lbl)
Ejemplo n.º 11
0
    def activate_help(self, event):
        """
        Activate Help for game
        :return:
        """
        self.clear_widgets()

        # Menu Background
        self.bckg_image = get_background(picture_path='pictures/menu_background.png')
        self.add_widget(self.bckg_image)

        # Levels label
        help_l = Label(text='[b]HELP[/b]', markup=True)
        help_l.font_size = FONT_SIZE_HEADLINES
        help_l.bold = True
        help_l.color = [0.8, 0.8, 0.8, 0.5]
        help_l.pos_hint = {'x': .0, 'y': .35}
        self.add_widget(help_l)

        # Help text
        text = \
        """
        [b]play game[/b]     - Goal of the game is to flight through galaxy without collision
                                 with another object
                               - Just touch the 'slider' in the bottom of the screen and move
                                 to the right or to the left side

        [b]speed[/b]          - In configuration screen you can choose among SLOW,
                                MEDIUM or FAST speed

        [b]sound[/b]          - In configuration screen you can switch sound ON or OFF
        """
        help_text = Label(text=text, markup=True)
        help_text.font_size = 22
        help_text.color = [0.97, 0.97, 0.97, 0.9]
        help_text.pos_hint = {'x': 0.0, 'y': 0.0}
        self.add_widget(help_text)

        # Main menu button
        self.main_menu_b = Button(text='Main menu', font_size=FONT_SIZE_BUTTON, size_hint=SIZE_HINT_BUTTON_NORMAL,
                                  pos_hint={'x': .4, 'y': .1})
        self.main_menu_b.bind(on_press=self.__activate_menu)
        self.add_widget(self.main_menu_b)
Ejemplo n.º 12
0
    def openPampaMT(self, project):
        
        self.clear_widgets()

        self.add_widget(self.image_back_ground)
        self.project = project

        lb_creating_the_project = Label()
        lb_creating_the_project.text = lang['Creating_the_Project']
        lb_creating_the_project.bold = True
        lb_creating_the_project.font_size = 17

        lb_creating_the_project.size_hint = None, None
        lb_creating_the_project.height = 30
        lb_creating_the_project.width = 150

        lb_creating_the_project.center_y = 250
        lb_creating_the_project.center_x = 400

        self.add_widget(lb_creating_the_project)

        self.progress_bar_finish = ProgressBar()
        self.progress_bar_finish.size_hint = None, None
        self.progress_bar_finish.width = 350
        self.progress_bar_finish.height = 10
        self.progress_bar_finish.value = 1
        self.progress_bar_finish.center_x = 400
        self.progress_bar_finish.center_y = 150
        self.add_widget(self.progress_bar_finish)

        self.lb_finish = Label(text=lang['Creating...'])
        self.lb_finish.size_hint = None, None
        self.lb_finish.width = 350
        self.lb_finish.height = 30
        self.lb_finish.center_x = 400
        self.lb_finish.center_y = 120
        self.add_widget(self.lb_finish)

        parallel_progress_bar = threading.Thread(target=self.finish_project)
        parallel_progress_bar.start()
Ejemplo n.º 13
0
    def openPampaMT(self, project):

        self.clear_widgets()

        self.add_widget(self.image_back_ground)
        self.project = project

        lb_creating_the_project = Label()
        lb_creating_the_project.text = lang['Creating_the_Project']
        lb_creating_the_project.bold = True
        lb_creating_the_project.font_size = 17

        lb_creating_the_project.size_hint = None, None
        lb_creating_the_project.height = 30
        lb_creating_the_project.width = 150

        lb_creating_the_project.center_y = 250
        lb_creating_the_project.center_x = 400

        self.add_widget(lb_creating_the_project)

        self.progress_bar_finish = ProgressBar()
        self.progress_bar_finish.size_hint = None, None
        self.progress_bar_finish.width = 350
        self.progress_bar_finish.height = 10
        self.progress_bar_finish.value = 1
        self.progress_bar_finish.center_x = 400
        self.progress_bar_finish.center_y = 150
        self.add_widget(self.progress_bar_finish)

        self.lb_finish = Label(text=lang['Creating...'])
        self.lb_finish.size_hint = None, None
        self.lb_finish.width = 350
        self.lb_finish.height = 30
        self.lb_finish.center_x = 400
        self.lb_finish.center_y = 120
        self.add_widget(self.lb_finish)

        parallel_progress_bar = threading.Thread(target=self.finish_project)
        parallel_progress_bar.start()
Ejemplo n.º 14
0
    def keyspop(self):
        box = BoxLayout(orientation="vertical")
        # box.add_widget(Image(source='images/appic.png', allow_stretch=False, keep_ratio=False, ))
        keysdata = "[color=f000ff]F11[/color]: \n" \
                   "[color=00ff00]Rotate the Window through 0, 90, 180 and 270 degrees[/color]\n\n" \
                   "[color=f000ff]Shift + F11[/color]: \n" \
                   "[color=00ff00]Switches between portrait and landscape on desktops[/color]\n\n" \
                   "[color=f000ff]F12[/color]: \n[color=00ff00]Take a screenshot[/color]\n\n"
        lb1 = Label(text=keysdata, markup=True)
        lb1.font_name = "fonts/DroidSans-Bold.ttf"
        lb1.bold = True
        box.add_widget(lb1)
        content2 = box
        self.popup = Popup(title="Special Keys",
                           content=content2,
                           size_hint=(None, None),
                           size=(500, 300))

        self.popup.background = "images/im2.png"
        self.popup.title_size = 30

        self.popup.title_color = [1, 1, 0, 1]
        self.popup.title_font = "fonts/actionis.ttf"
        self.popup.open()
Ejemplo n.º 15
0
def standardTitle(text):
    title = Label()
    title.text = text
    title.bold = True
    title.font_size = 26
    return title
Ejemplo n.º 16
0
    def init(self):
        global poker_width, poker_height
        poker_width = game.width / 10
        poker_height = game.width / 7

        with self.canvas:
            Color(rgb = [0.0, 0.3, 0.0])
            Rectangle(size = self.size)

        score_pad_hint = Label(text = "NS\nEW")
        score_pad_hint.size = self.width / 16, self.height / 7
        score_pad_hint.bold = True
        score_pad_hint.font_size = 30
        score_pad_hint.color = [1, 1, 1, 1]
        score_pad_hint.pos = 0, self.height - score_pad_hint.height
        self.add_widget(score_pad_hint)

        self.score_pad = ScorePad()
        self.score_pad.size = score_pad_hint.size
        self.score_pad.bold = True
        self.score_pad.font_size = 30
        self.score_pad.color = score_pad_hint.color
        self.score_pad.pos = score_pad_hint.pos[0] + score_pad_hint.width, score_pad_hint.pos[1]
        self.add_widget(self.score_pad)

        self.player_list = []
        for name in "nsew":
            player = Player(name)
            setattr(self, "player_" + name, player)
            self.player_list.append(player)
        self.player_n.next = self.player_w
        self.player_w.next = self.player_s
        self.player_s.next = self.player_e
        self.player_e.next = self.player_n
        self.player_n.buddy = self.player_s
        self.player_s.buddy = self.player_n
        self.player_w.buddy = self.player_e
        self.player_e.buddy = self.player_w

        self.score_pad.refresh()

        self.pk_list = []
        pk_seq = (["s5"] + [c + "j" for c in "rb"] + [c + "5" for c in "hcd"] + [c + n for n in "32" for c in "shcd"] +
                  [c + n for c in "shcd" for n in "akqjt98764"])
        for i, pk_name in enumerate(pk_seq):
            for j in xrange(2):
                pk = Poker(i * 2 + j, pk_name, source = os.path.join("image", "%s.bmp" % pk_name))
                self.add_widget(pk)
                self.pk_list.append(pk)

        self.ok_button = OkButton(text = "OK", font_size = 30)
        self.ok_button.size = self.width / 16, self.width / 32
        self.ok_button.pos = self.width - self.ok_button.width * 2, 20 + poker_height + 30
        self.add_widget(self.ok_button)

        self.thinking_pad = Label(text = "THINKING")
        self.thinking_pad.size = poker_width * 3 / 2, 50
        self.thinking_pad.bold = True
        self.thinking_pad.font_size = 20
        self.thinking_pad.color = [1, 1, 1, 1]
        self.thinking_pad.pos = self.width, self.height
        self.add_widget(self.thinking_pad)

        self.turn = None
        self.start_game()
Ejemplo n.º 17
0
    def make_server_tab(self):
        server_tab = TabbedPanelHeader(text="Server")
        server_widget = Widget()

        self.bob = None
        self.send = False
        self.msg = ""
        self.done_auth = False

        # Console
        txt_console = TextInput(multiline=True)
        txt_console.pos = (75, 75)
        txt_console.size = (650, 200)
        txt_console.readonly = True
        server_widget.add_widget(txt_console)

        def print_console(msg):
            txt_console.text = txt_console.text + "\n" + msg
            txt_console.cursor = (999, 999)

        # Config label
        lbl_config = Label(text="Server Config")
        lbl_config.pos = (75, 525)
        lbl_config.size = (100, 40)
        lbl_config.halign = "left"
        lbl_config.text_size = lbl_config.size
        lbl_config.bold = True
        server_widget.add_widget(lbl_config)

        # Port label
        lbl_port = Label(text="Port")
        lbl_port.pos = (125, 450)
        lbl_port.size = (100, 30)
        lbl_port.halign = "right"
        lbl_port.valign = "middle"
        lbl_port.text_size = lbl_port.size
        server_widget.add_widget(lbl_port)

        # Port input
        txt_port = TextInput(multiline=False, text="9001")
        txt_port.pos = (250, 450)
        txt_port.size = (150, 30)
        server_widget.add_widget(txt_port)

        # Secret label
        lbl_secret = Label(text="Secret")
        lbl_secret.pos = (125, 400)
        lbl_secret.size = (100, 30)
        lbl_secret.halign = "right"
        lbl_secret.valign = "middle"
        lbl_secret.text_size = lbl_secret.size
        server_widget.add_widget(lbl_secret)

        # Secret input
        txt_secret = TextInput(multiline=False, text="foobar")
        txt_secret.pos = (250, 400)
        txt_secret.size = (150, 30)
        server_widget.add_widget(txt_secret)

        # Start button
        def on_server_btn_start(instance):
            btn_start.disabled = True
            txt_secret.readonly = True
            txt_port.readonly = True

            print_console("Starting Server on port " + txt_port.text)
            self.bob = None
            while self.bob is None:
                try:
                    self.bob = ChatClientServer("0.0.0.0", int(txt_port.text))
                except socket.error as e:
                    log(
                        logging.warning,
                        self,
                        self.make_server_tab,
                        "Error occurred while trying to connect: " "socket.error: {}; retrying...".format(e),
                    )
                    sleep(1)
            print_console("Setting shared key to " + txt_secret.text)
            self.bob.set_shared_key(txt_secret.text.encode())

        btn_start = Button(text="Start Server")
        btn_start.pos = (500, 395)
        btn_start.size = (200, 100)
        btn_start.bind(on_release=on_server_btn_start)
        server_widget.add_widget(btn_start)

        # Separator line
        with server_widget.canvas:
            Rectangle(pos=(75, 350), size=(650, 2))

        # Communication label
        lbl_comm = Label(text="Server Communication")
        lbl_comm.pos = (75, 300)
        lbl_comm.size = (400, 40)
        lbl_comm.halign = "left"
        lbl_comm.text_size = lbl_comm.size
        lbl_comm.bold = True
        server_widget.add_widget(lbl_comm)

        # Message box
        txt_message = TextInput(multiline=False)
        txt_message.pos = (75, 25)
        txt_message.size = (450, 30)
        server_widget.add_widget(txt_message)

        # Send button
        def on_server_btn_send(instance):
            if self.done_auth:
                self.send = True
                self.msg = txt_message.text
                btn_send.disabled = True
                txt_message.text = ""
                print_console("Will send [" + self.msg + "] on next 'Continue'")
            else:
                print_console("Finish authentication first!")

        btn_send = Button(text="Send")
        btn_send.pos = (535, 25)
        btn_send.size = (90, 30)
        btn_send.bind(on_release=on_server_btn_send)
        server_widget.add_widget(btn_send)

        # Continue button
        def on_server_btn_continue(instance):
            if self.bob is not None:
                if self.done_auth:
                    try:
                        if self.send:
                            print_console("Sending [" + self.msg + "]")
                            self.bob.send(self.msg.encode())
                            self.send = False
                            btn_send.disabled = False
                            self.msg = ""
                        else:
                            data = self.bob.recv(nb=True)
                            if data is not None:
                                print_console("Received [" + data + "]")
                            else:
                                print_console("No data to receive")
                    except NoAuthentication:
                        print_console("We are not authenticated. Reset authentication steps.")
                        self.bob.mutauth_step(reset=True)
                    except DataIntegrityException:
                        print_console(
                            "Either Trudy is attacking or more than one message was received. Not going to display the message. Tell your friend to send only one message at a time."
                        )
                else:
                    try:
                        print_console("Performing a mutual authentication step")
                        self.bob.mutauth_step()
                    except BeingAttacked:
                        print_console("We are being attacked! Reset authentication steps.")
                        self.bob.mutauth_step(reset=True)
                    except NoSharedKey:
                        print_console("Shared key is not yet shared. Please share first")
                        self.bob.mutauth_step(reset=True)
                    except StopIteration:
                        print_console("Successfully Authenticated")
                        self.done_auth = True

        btn_continue = Button(text="Continue")
        btn_continue.pos = (635, 25)
        btn_continue.size = (90, 30)
        btn_continue.bind(on_release=on_server_btn_continue)
        server_widget.add_widget(btn_continue)

        server_tab.content = server_widget
        return server_tab
    def build(self):
        c = CustomLayout()
        c.add_widget(AsyncImage(source="background-login.jpg"))

        lbl = Label(text='Capture Face')
        lbl.font_size = '60sp'
        lbl.bold = True
        lbl.color = [1, 1, 1, 1]
        lbl.size_hint = None, None
        lbl.height = 30
        lbl.width = 300
        lbl.y = 370
        lbl.x = 250

        lbl2 = Label(text='Entre abaixo com seu usuário:')
        lbl2.font_size = '20sp'
        lbl2.bold = True
        lbl2.color = [1, 1, 1, 1]
        lbl2.size_hint = None, None
        lbl2.height = 30
        lbl2.width = 300
        lbl2.y = 290
        lbl2.x = 250

        lbl3 = Label(text='Agora digite sua senha, está quase lá!')
        lbl3.font_size = '20sp'
        lbl3.bold = True
        lbl3.color = [1, 1, 1, 1]
        lbl3.size_hint = None, None
        lbl3.height = 30
        lbl3.width = 300
        lbl3.y = 220
        lbl3.x = 255

        usuario = TextInput()
        usuario.size_hint = None, None
        usuario.height = 30
        usuario.width = 300
        usuario.y = 250
        usuario.x = 250

        senha = TextInput()
        senha.size_hint = None, None
        senha.height = 30
        senha.width = 300
        senha.y = 180
        senha.x = 250
        senha.password = True

        bt = Button(text="Acessar")
        bt.size_hint = None, None
        bt.height = 50
        bt.width = 200
        bt.y = 90
        bt.x = 300

        c.add_widget(lbl)
        c.add_widget(lbl2)
        c.add_widget(lbl3)
        c.add_widget(usuario)
        c.add_widget(senha)
        c.add_widget(bt)

        def callback(self):

            cursor = db.cursor()
            # Executa a consulta na tabela selecionada
            cursor.execute(
                "SELECT * FROM inteligenciaArtificialDB.tb_usuarios")
            # Laco for para retornar os valores, ex.: row[0] primeira coluna, row[1] segunda coluna, row[2] terceira coluna, etc.
            for row in cursor.fetchall():
                if usuario.text == row[1] and senha.text == row[2]:
                    popup = Popup(
                        title='Logado',
                        content=Label(text='Logon realizado com sucesso!'),
                        size_hint=(None, None),
                        size=(250, 150),
                        auto_dismiss=True)
                    popup.open()
                    #abre janela principal
                    Principal().run()

        bt.bind(on_press=callback)

        return c
Ejemplo n.º 19
0
    def add_unit(self,num):
        print('fffffffffff')
        self.QuestionList.append(BoxLayout())
        self.QuestionList[-1].orientation = 'vertical'
        self.QuestionList[-1].size_hint = (None,None)
        self.QuestionList[-1].size = self.unitSize
        self.QuestionList[-1].center_x = self.center_x
        self.QuestionList[-1].canvas.add(Color(0.5,0.5,0.5))
        self.QuestionList[-1].rect = Rectangle(size=self.unitSize,pos=(self.padding[0],self.top-self.padding[1]-len(self.QuestionList)*self.unitheight-(len(self.QuestionList)-1)*self.spacing[1]))
        self.QuestionList[-1].canvas.add(self.QuestionList[-1].rect)
        self.QuestionList[-1].opacity = 0.01
        self.QuestionList[-1].chagingopacity = 1
        self.QuestionList[-1].opacitypace = 2/fps

        BaseElement = self.BaseSearch(num)
        CurNum = str(self.QuestionCounter)
        self.QuestionList[-1].CurNum = self.QuestionCounter
        self.QuestionList[-1].IdInBase = num
        self.QuestionCounter += 1
        TextNumberLabel = Label()
        TextNumberLabel.italic = True
        TextNumberLabel.markup = True
        TextNumberLabel.text = str("[color=292929]Question  [/color]" + CurNum + ".") if BaseElement['isQuest'] else str("Diag")
        TextNumberLabel.color = (0,0,0,0.2) if BaseElement['isQuest'] else (0.5,0,0.08,0.6)
        TextNumberLabel.bold = False if BaseElement['isQuest'] else True
        TextNumberLabel.font_size = Window.size[1]*0.025
        self.QuestionList[-1].TextNumberLabel = TextNumberLabel
        self.QuestionList[-1].add_widget(TextNumberLabel)

        QuestLabel = Label()
        QuestLabel.text = self.BaseSearch(num)['text'] if BaseElement['isQuest'] else '                                                              '+self.BaseSearch(num)['text']
        QuestLabel.color = (1,1,1,0.9)
        QuestLabel.font_size = Window.size[1]*0.03
        QuestLabel.text_size = (self.unitwidth*0.9,None)
        QuestLabel.size_hint_y = 0.9 if BaseElement['isQuest'] else 0.1
        QuestLabel.bold = False if BaseElement['isQuest'] else True
        self.QuestionList[-1].QuestLabel = QuestLabel
        self.QuestionList[-1].add_widget(QuestLabel)

        JustBlueLine = Widget()
        JustBlueLine.size_hint_y = 1 if BaseElement['isQuest'] else 1
        self.QuestionList[-1].bluelinerect = Rectangle(size=(self.unitwidth*0.98,self.unitheight*0.025),pos=(self.padding[0]+self.unitwidth*0.01,self.QuestionList[-1].rect.pos[1]+self.unitheight*0.28))
        JustBlueLine.canvas.add(Color(0.26, 0.63, 0.75))
        JustBlueLine.canvas.add(self.QuestionList[-1].bluelinerect)
        self.QuestionList[-1].JustBlueLine = JustBlueLine
        self.QuestionList[-1].add_widget(JustBlueLine)

        FakeWidget = Widget(size_hint_y = 0.5)
        self.QuestionList[-1].add_widget(FakeWidget)


        if(BaseElement['isQuest'] == True):
            CheckBoxGroup=BoxLayout(size_hint_y=1.4)
            CheckBoxGroup.orientation = "horizontal"
            CheckBoxGroup.id = "checkgroup"
            CheckBoxGroup.IdInBase = num
            CheckBoxYes = CheckBox(group="ilness"+CurNum)
            CheckBoxYes.bind(active=self.MakeChoice)
            CheckBoxYes.type = 'yes'
            CheckBoxNo = CheckBox(group="ilness"+CurNum)
            CheckBoxNo.bind(active=self.MakeChoice)
            CheckBoxNo.type = 'no'
            CheckBoxNotStated = CheckBox(group="ilness"+CurNum)
            CheckBoxNotStated.bind(active=self.MakeChoice)
            CheckBoxNotStated.type = 'notstated'
            CheckBoxFlaseWidget = Widget()  
            CheckBoxGroup.add_widget(CheckBoxYes)
            CheckBoxGroup.add_widget(Label(text="Yes.",color = (1,1,1,0.6),font_size=Window.size[1]*0.026,bold=True,halign='left'))
            CheckBoxGroup.add_widget(copy.copy(CheckBoxFlaseWidget))
            CheckBoxGroup.add_widget(CheckBoxNo)
            CheckBoxGroup.add_widget(Label(text="No.",color = (1,1,1,0.6),font_size=Window.size[1]*0.026,bold=True))
            CheckBoxGroup.add_widget(copy.copy(CheckBoxFlaseWidget))
            CheckBoxGroup.add_widget(CheckBoxNotStated)
            CheckBoxGroup.add_widget(Label(text="NaN",color = (1,1,1,0.5),font_size=Window.size[1]*0.026,bold=False,size_hint_x=2))
            CheckBoxGroup.add_widget(Widget(size_hint_x=0.4))
            self.QuestionList[-1].add_widget(CheckBoxGroup)

        else:
            a = self.unitSize
            ButtonGroup = BoxLayout(orientation='horizontal',spacing=self.unitwidth*0.1,padding=(a[0]*0.05,a[1]*0.05,a[0]*0.05,a[1]*0.05))
            BackToMenu = Button()
            BackToMenu.text = "main"
            BackToMenu.color = (0,0,0,1)
            BackToMenu.font_size = fullapp.size[1]*0.025
            BackToMenu.italic = True
            BackToMenu.on_press = self.MenuButton.return_menu
            RestartSearch = Button()
            RestartSearch.text = 'exit'
            RestartSearch.color = (0,0,0,1)
            RestartSearch.font_size = fullapp.size[1]*0.025
            RestartSearch.italic = True
            RestartSearch.on_press = self.restart

            ButtonGroup.add_widget(BackToMenu)
            ButtonGroup.add_widget(RestartSearch)
            self.QuestionList[-1].add_widget(ButtonGroup)

        self.add_widget(self.QuestionList[-1])
Ejemplo n.º 20
0
    def winner(self, obj):
        pdata = ""
        title = ""

        sound = SoundLoader.load("sound/Sax.ogg")
        box = BoxLayout(orientation="vertical")
        box.add_widget(
            Image(
                source='images/gamepad3.png',
                allow_stretch=False,
                keep_ratio=False,
            ))
        if lista == standx or listb == standx or listc == standx or listd == standx or liste == standx or listf == standx or listg == standx or listh == standx:
            pdata = "[color=00ff00]Game over[/color]: [color=0000ff] player 1 win[/color]"
            title = "Congratulations player1"
            lb1 = Label(text=pdata, markup=True, font_size=25)
            lb1.font_name = "fonts/DroidSans-Bold.ttf"
            lb1.bold = True
            butt1 = Button(text="Play Again")
            box.add_widget(lb1)
            box.add_widget(butt1)
            content2 = box
            popup = Popup(title=title,
                          content=content2,
                          size_hint=(None, None),
                          size=(400, 400))

            popup.background = "images/au.jpg"
            popup.title_size = 30

            popup.title_color = [1, 1, 0, 1]
            popup.title_font = "fonts/actionis.ttf"
            butt1.background_color = [1, 1, 0, 1]
            butt1.bind(on_release=self.reset)
            butt1.bind(on_release=popup.dismiss)

            popup.open()
            anim = Animation(x=50) + Animation(size=(300, 300), duration=2.)
            anim.start(popup)

            sound.play()
            Clock.unschedule(self.winner, .1)
            lista.clear(), listb.clear(), listc.clear(), listd.clear(
            ), liste.clear(), listf.clear(), listg.clear(), listh.clear()

        elif lista == stando or listb == stando or listc == stando or listd == stando or liste == stando or listf == stando or listg == stando or listh == stando:
            pdata = "[color=00ff00]Game over[/color]:[color=ff0000] player 2 win[/color]"
            title = "Congratulations player2"
            lb1 = Label(text=pdata, markup=True, font_size=25)
            lb1.font_name = "fonts/DroidSans-Bold.ttf"
            lb1.bold = True
            butt1 = Button(text="Play Again")
            box.add_widget(lb1)
            box.add_widget(butt1)
            content2 = box
            popup = Popup(title=title,
                          content=content2,
                          size_hint=(None, None),
                          size=(400, 400))

            popup.background = "images/au.jpg"
            popup.title_size = 30

            popup.title_color = [1, 1, 0, 1]
            popup.title_font = "fonts/actionis.ttf"
            butt1.background_color = [1, 1, 0, 1]

            butt1.bind(on_release=self.reset)
            butt1.bind(on_release=popup.dismiss)

            popup.open()
            anim = Animation(x=50) + Animation(size=(300, 300), duration=2.)
            anim.start(popup)

            sound.play()
            lista.clear(), listb.clear(), listc.clear(), listd.clear(
            ), liste.clear(), listf.clear(), listg.clear(), listh.clear()

        elif self.ids.click1.disabled == True and self.ids.click2.disabled == True and self.ids.click3.disabled == True and self.ids.click4.disabled == True and self.ids.click5.disabled == True and self.ids.click6.disabled == True and self.ids.click7.disabled == True and self.ids.click8.disabled == True and self.ids.click9.disabled == True:

            pdata = "[color=00ff00]Game over[/color]: [color=f0ff00] Drwa [/color]"
            title = "No Winner"
            lb1 = Label(text=pdata, markup=True, font_size=25)
            lb1.font_name = "fonts/DroidSans-Bold.ttf"
            lb1.bold = True
            butt1 = Button(text="Play Again")
            box.add_widget(lb1)
            box.add_widget(butt1)
            content2 = box
            popup = Popup(title=title,
                          content=content2,
                          size_hint=(None, None),
                          size=(400, 400))

            popup.background = "images/au.jpg"
            popup.title_size = 30

            popup.title_color = [1, 1, 0, 1]
            popup.title_font = "fonts/actionis.ttf"
            butt1.background_color = [1, 1, 0, 1]

            butt1.bind(on_release=self.reset)
            butt1.bind(on_release=popup.dismiss)

            popup.open()
            anim = Animation(x=50) + Animation(size=(300, 300), duration=2.)
            anim.start(popup)

            sound.play()
            lista.clear(), listb.clear(), listc.clear(), listd.clear(
            ), liste.clear(), listf.clear(), listg.clear(), listh.clear()