Ejemplo n.º 1
0
        Clock.unschedule(self.animate)
    
    def collide_page( self, page ):
        return page != self.start_page and \
                page.x - abs(self.xvel) <= -self.x <= page.x + abs(self.xvel)

    def x_shift(self, x):
        self.apply_transform( 
            self.transform.inverse().translate( x, 0, 0 )
        )

    def animate( self, dt ):
        for p in self.pages:
            if self.collide_page(p):
                self.stop_inertia()
                self.x_shift( -p.x )
                return 
        self.x += self.xvel
        self.x_shift( self.x )

                


if __name__ == '__main__':
    from kivy.base import runTouchApp
    
    swipe_plane = SwipePlane()
    for i in range(2):
        swipe_plane.add_page( Label( text=str(i) ) )
    runTouchApp( swipe_plane )
Ejemplo n.º 2
0
        def changeMode(mode, curDir, vel):
            actColor = "ffd700"
            stdColor = "111111"
            # Park
            if (state_car.breaking > 90) and (mode == "manual"):
                pColor = actColor
                rColor = stdColor
                mColor = stdColor
                jColor = stdColor
                cColor = stdColor
            # Return
            elif curDir == -1:
                pColor = stdColor
                rColor = actColor
                mColor = stdColor
                jColor = stdColor
                cColor = stdColor
            # Manual
            elif mode == "manual":
                pColor = stdColor
                rColor = stdColor
                mColor = actColor
                jColor = stdColor
                cColor = stdColor
            # Joy
            elif mode == "remote":
                pColor = stdColor
                rColor = stdColor
                mColor = stdColor
                jColor = actColor
                cColor = stdColor
            # Cruise Control
            elif mode == "cruise":
                pColor = stdColor
                rColor = stdColor
                mColor = stdColor
                jColor = stdColor
                cColor = actColor
            # Nothing active
            else:
                pColor = stdColor
                rColor = stdColor
                mColor = stdColor
                jColor = stdColor
                cColor = stdColor

            pLbl = Label(text="[color=%s]P[/color]" % pColor,
                         pos=(win_x / 2 - 120, win_y / 2 - 130),
                         font_size='45dp',
                         markup=True)
            rLbl = Label(text="[color=%s]R[/color]" % rColor,
                         pos=(win_x / 2 - 120, win_y / 2 - 130 - (scale)),
                         font_size='45dp',
                         markup=True)
            mLbl = Label(text="[color=%s]M[/color]" % mColor,
                         pos=(win_x / 2 - 120, win_y / 2 - 130 - (scale * 2)),
                         font_size='45dp',
                         markup=True)
            jLbl = Label(text="[color=%s]J[/color]" % jColor,
                         pos=(win_x / 2 - 120, win_y / 2 - 130 - (scale * 3)),
                         font_size='45dp',
                         markup=True)
            cLbl = Label(text="[color=%s]C[/color]" % cColor,
                         pos=(win_x / 2 - 120, win_y / 2 - 130 - (scale * 4)),
                         font_size='45dp',
                         markup=True)

            self.add_widget(pLbl)
            self.add_widget(rLbl)
            self.add_widget(mLbl)
            self.add_widget(jLbl)
            self.add_widget(cLbl)
    def __init__(self, **kwargs):
        super(mySlider, self).__init__(**kwargs)

        self.cols = 17
        object1_lev_slider = Slider(min=0,
                                    max=1,
                                    orientation='vertical',
                                    value=object_level[0])
        object1_pos_slider = Slider(min=-pos_range,
                                    max=pos_range,
                                    orientation='horizontal',
                                    value=object_pos[0])
        object2_lev_slider = Slider(min=0,
                                    max=1,
                                    orientation='vertical',
                                    value=object_level[1])
        object2_pos_slider = Slider(min=-pos_range,
                                    max=pos_range,
                                    orientation='horizontal',
                                    value=object_pos[1])
        object3_lev_slider = Slider(min=0,
                                    max=1,
                                    orientation='vertical',
                                    value=object_level[2])
        object3_pos_slider = Slider(min=-pos_range,
                                    max=pos_range,
                                    orientation='horizontal',
                                    value=object_pos[2])
        object4_lev_slider = Slider(min=0,
                                    max=1,
                                    orientation='vertical',
                                    value=object_level[3])
        object4_pos_slider = Slider(min=-pos_range,
                                    max=pos_range,
                                    orientation='horizontal',
                                    value=object_pos[3])
        object5_lev_slider = Slider(min=0,
                                    max=1,
                                    orientation='vertical',
                                    value=object_level[4])
        object5_pos_slider = Slider(min=-pos_range,
                                    max=pos_range,
                                    orientation='horizontal',
                                    value=object_pos[4])
        object6_lev_slider = Slider(min=0,
                                    max=1,
                                    orientation='vertical',
                                    value=object_level[5])
        object6_pos_slider = Slider(min=-pos_range,
                                    max=pos_range,
                                    orientation='horizontal',
                                    value=object_pos[5])
        object7_lev_slider = Slider(min=0,
                                    max=1,
                                    orientation='vertical',
                                    value=object_level[6])
        object7_pos_slider = Slider(min=-pos_range,
                                    max=pos_range,
                                    orientation='horizontal',
                                    value=object_pos[6])
        object8_lev_slider = Slider(min=0,
                                    max=1,
                                    orientation='vertical',
                                    value=object_level[7])
        object8_pos_slider = Slider(min=-pos_range,
                                    max=pos_range,
                                    orientation='horizontal',
                                    value=object_pos[7])
        object9_lev_slider = Slider(min=0,
                                    max=1,
                                    orientation='vertical',
                                    value=object_level[8])
        object9_pos_slider = Slider(min=-pos_range,
                                    max=pos_range,
                                    orientation='horizontal',
                                    value=object_pos[8])
        object10_lev_slider = Slider(min=0,
                                     max=1,
                                     orientation='vertical',
                                     value=object_level[9])
        object10_pos_slider = Slider(min=-pos_range,
                                     max=pos_range,
                                     orientation='horizontal',
                                     value=object_pos[9])
        object11_lev_slider = Slider(min=0,
                                     max=1,
                                     orientation='vertical',
                                     value=object_level[10])
        object11_pos_slider = Slider(min=-pos_range,
                                     max=pos_range,
                                     orientation='horizontal',
                                     value=object_pos[10])
        object12_lev_slider = Slider(min=0,
                                     max=1,
                                     orientation='vertical',
                                     value=object_level[11])
        object12_pos_slider = Slider(min=-pos_range,
                                     max=pos_range,
                                     orientation='horizontal',
                                     value=object_pos[11])
        object13_lev_slider = Slider(min=0,
                                     max=1,
                                     orientation='vertical',
                                     value=object_level[12])
        object13_pos_slider = Slider(min=-pos_range,
                                     max=pos_range,
                                     orientation='horizontal',
                                     value=object_pos[13])
        object14_lev_slider = Slider(min=0,
                                     max=1,
                                     orientation='vertical',
                                     value=object_level[13])
        object14_pos_slider = Slider(min=-pos_range,
                                     max=pos_range,
                                     orientation='horizontal',
                                     value=object_pos[14])
        object15_lev_slider = Slider(min=0,
                                     max=1,
                                     orientation='vertical',
                                     value=object_level[14])
        object15_pos_slider = Slider(min=-pos_range,
                                     max=pos_range,
                                     orientation='horizontal',
                                     value=object_pos[15])
        object16_lev_slider = Slider(min=0,
                                     max=1,
                                     orientation='vertical',
                                     value=object_level[15])
        object16_pos_slider = Slider(min=-pos_range,
                                     max=pos_range,
                                     orientation='horizontal')
        btn_toggle_renderer = ToggleButton(text="Switch renderer",
                                           state='down')
        btn_play = Button(text="PLAY")
        btn_stop = Button(text="STOP")
        object1_lev_slider.bind(value=self.set_object1_level)
        object1_pos_slider.bind(value=self.set_object1_pos)
        object2_lev_slider.bind(value=self.set_object2_level)
        object2_pos_slider.bind(value=self.set_object2_pos)
        object3_lev_slider.bind(value=self.set_object3_level)
        object3_pos_slider.bind(value=self.set_object3_pos)
        object4_lev_slider.bind(value=self.set_object4_level)
        object4_pos_slider.bind(value=self.set_object4_pos)
        object5_lev_slider.bind(value=self.set_object5_level)
        object5_pos_slider.bind(value=self.set_object5_pos)
        object6_lev_slider.bind(value=self.set_object6_level)
        object6_pos_slider.bind(value=self.set_object6_pos)
        object7_lev_slider.bind(value=self.set_object7_level)
        object7_pos_slider.bind(value=self.set_object7_pos)
        object8_lev_slider.bind(value=self.set_object8_level)
        object8_pos_slider.bind(value=self.set_object8_pos)
        object9_lev_slider.bind(value=self.set_object9_level)
        object9_pos_slider.bind(value=self.set_object9_pos)
        object10_lev_slider.bind(value=self.set_object10_level)
        object10_pos_slider.bind(value=self.set_object10_pos)
        object11_lev_slider.bind(value=self.set_object11_level)
        object11_pos_slider.bind(value=self.set_object11_pos)
        object12_lev_slider.bind(value=self.set_object12_level)
        object12_pos_slider.bind(value=self.set_object12_pos)
        object13_lev_slider.bind(value=self.set_object13_level)
        object13_pos_slider.bind(value=self.set_object13_pos)
        object14_lev_slider.bind(value=self.set_object14_level)
        object14_pos_slider.bind(value=self.set_object14_pos)
        object15_lev_slider.bind(value=self.set_object15_level)
        object15_pos_slider.bind(value=self.set_object15_pos)
        object16_lev_slider.bind(value=self.set_object16_level)
        object16_pos_slider.bind(value=self.set_object16_pos)
        btn_toggle_renderer.bind(state=self.switch_renderer)
        btn_play.bind(on_press=self.play)
        btn_stop.bind(on_press=self.stop)
        self.add_widget(Label(text=''))
        self.add_widget(Label(text='[b]Narrator[/b]', markup=True))
        self.add_widget(Label(text='[b]Isaac[/b]', markup=True))
        self.add_widget(Label(text='[b]Amelia[/b]', markup=True))
        self.add_widget(Label(text='[b]Creature voice[/b]', markup=True))
        self.add_widget(Label(text='[b]Creature feet[/b]', markup=True))
        self.add_widget(Label(text='[b]FX1[/b]', markup=True))
        self.add_widget(Label(text='[b]FX2[/b]', markup=True))
        self.add_widget(Label(text='[b]FX3[/b]', markup=True))
        self.add_widget(Label(text='[b]FX4[/b]', markup=True))
        self.add_widget(Label(text='[b]FX5[/b]', markup=True))
        self.add_widget(Label(text='[b]FX6[/b]', markup=True))
        self.add_widget(Label(text='[b]FX7[/b]', markup=True))
        self.add_widget(Label(text='[b]FX8[/b]', markup=True))
        self.add_widget(Label(text='[b]FX9[/b]', markup=True))
        self.add_widget(Label(text='[b]Music[/b]', markup=True))
        self.add_widget(Label(text='[b]Atmos[/b]', markup=True))
        self.add_widget(Label(text='[b]Level:[/b]', markup=True))
        self.add_widget(object1_lev_slider)
        self.add_widget(object2_lev_slider)
        self.add_widget(object3_lev_slider)
        self.add_widget(object4_lev_slider)
        self.add_widget(object5_lev_slider)
        self.add_widget(object6_lev_slider)
        self.add_widget(object7_lev_slider)
        self.add_widget(object8_lev_slider)
        self.add_widget(object9_lev_slider)
        self.add_widget(object10_lev_slider)
        self.add_widget(object11_lev_slider)
        self.add_widget(object12_lev_slider)
        self.add_widget(object13_lev_slider)
        self.add_widget(object14_lev_slider)
        self.add_widget(object15_lev_slider)
        self.add_widget(object16_lev_slider)
        self.add_widget(Label(text='[b]Position:[/b]', markup=True))
        self.add_widget(object1_pos_slider)
        self.add_widget(object2_pos_slider)
        self.add_widget(object3_pos_slider)
        self.add_widget(object4_pos_slider)
        self.add_widget(object5_pos_slider)
        self.add_widget(object6_pos_slider)
        self.add_widget(object7_pos_slider)
        self.add_widget(object8_pos_slider)
        self.add_widget(object9_pos_slider)
        self.add_widget(object10_pos_slider)
        self.add_widget(object11_pos_slider)
        self.add_widget(object12_pos_slider)
        self.add_widget(object13_pos_slider)
        self.add_widget(object14_pos_slider)
        self.add_widget(Label(text=''))
        self.add_widget(Label(text=''))
        self.add_widget(Label(text=''))
        self.add_widget(Label(text=''))
        self.add_widget(Label(text=''))
        self.add_widget(Label(text=''))
        self.add_widget(Label(text=''))
        self.add_widget(Label(text=''))
        self.add_widget(Label(text=''))
        self.add_widget(btn_toggle_renderer)
        self.add_widget(btn_play)
        self.add_widget(btn_stop)
Ejemplo n.º 4
0
 def build(self):
     return Label()
Ejemplo n.º 5
0
 def esc_popup(self):
     self.escpop = Popup(title='', separator_height=0 , content=Label(text='Press Esc to exit'),size_hint=(None, None)\
                         ,pos_hint={'x': 10.0/Window.width,'y':250.0/Window.height}, size=(500,100),auto_dismiss=False)
     self.escpop.open()
     Clock.schedule_once(self.esc_dismiss, 4)
Ejemplo n.º 6
0
 def empty_popup(self):
     self.content = Label(text=' All fields must be Filled correctly!!!')
     self.popup = Popup(title='Warning!!!!',
                        content=self.content,
                        size_hint=(.4, .3))
     self.popup.open()
Ejemplo n.º 7
0
    def sentText(self, instance):

        print("inserted text!")
        s = str(self.a.text)
        s = s.replace('\n', '')
        print(s)

        reply = ""

        if commonVar.firstTime:
            reply = commonVar.mainChat.startIntro(s)
            commonVar.firstTime = False
        elif commonVar.end:
            affirmative = ["はい", "yes", "YES", "ok", "オッケー", "Yes", "OK"]
            if s in affirmative:
                commonVar.end = False
                reply = commonVar.mainChat.startIntro(
                    commonVar.mainChat.userName)
        else:
            commonVar.end, reply = commonVar.mainChat.getReply(s)

        # if String's length is not 0
        if len(s) != 0:
            # add images and Texts to gridlayout  as Image and Button
            # add speaker's talk
            self.wimg = Image(source=commonVar.myicon, size_hint_x=0.1)
            self.talk_button = Button(text=s,
                                      font_name='TakaoPMincho.ttf',
                                      color=(0, 0, 0, 1),
                                      size_hint_y=None,
                                      background_color=(255, 255, 255, 255),
                                      text_size=[self.width * 0.8, None])
            self.name_label = Label(text=commonVar.mainChat.userName,
                                    font_name='TakaoPMincho.ttf',
                                    size_hint_x=0.1,
                                    font_size=15,
                                    color=(0, 0, 0, 1))
            self.empty_label = Label(text="")

            self.container.add_widget(self.wimg)
            self.container.add_widget(self.talk_button)
            self.container.add_widget(self.name_label)
            self.container.add_widget(self.empty_label)

            # add 野獣先輩's talk
            self.wimg = Image(source='icon.jpg', size_hint_x=0.1)
            self.talk_button = Button(text=reply,
                                      font_name='TakaoPMincho.ttf',
                                      color=(0, 0, 0, 1),
                                      size_hint_y=None,
                                      background_color=(255, 255, 255, 255),
                                      text_size=[self.width * 0.8, None])
            self.name_label = Label(text="野獣先輩",
                                    font_name='TakaoPMincho.ttf',
                                    size_hint_x=0.1,
                                    font_size=15,
                                    color=(0, 0, 0, 1))
            self.empty_label = Label(text="")

            self.container.add_widget(self.wimg)
            self.container.add_widget(self.talk_button)
            self.container.add_widget(self.name_label)
            self.container.add_widget(self.empty_label)

        if commonVar.end:
            # add 野獣先輩's talk
            self.wimg = Image(source='icon.jpg', size_hint_x=0.1)
            self.talk_button = Button(text="リスタート?",
                                      font_name='TakaoPMincho.ttf',
                                      color=(0, 0, 0, 1),
                                      size_hint_y=None,
                                      background_color=(255, 255, 255, 255),
                                      text_size=[self.width * 0.8, None])
            self.name_label = Label(text="野獣先輩",
                                    font_name='TakaoPMincho.ttf',
                                    size_hint_x=0.1,
                                    font_size=15,
                                    color=(0, 0, 0, 1))
            self.empty_label = Label(text="")

            self.container.add_widget(self.wimg)
            self.container.add_widget(self.talk_button)
            self.container.add_widget(self.name_label)
            self.container.add_widget(self.empty_label)
Ejemplo n.º 8
0
 def invalidLogin(self):
     pop = Popup(title='Login Invalido',
                 content=Label(text='Usuario o password Invalido.'),
                 size_hint=(None, None),
                 size=(400, 400))
     pop.open()
Ejemplo n.º 9
0
 def build(self):
     x = Label(text='[i]Salut[/i] \n [size=32][b] Lume![/b][/size]',
               markup=True)
     return x
Ejemplo n.º 10
0
    def __init__(self, level, notes, goal_values, gear_values, **kwargs):
        super(LevelEasyMediumScreen, self).__init__(**kwargs)

        # set up notes for the level
        self.notes = notes

        # set up gear values for the levels
        self.goal_values = goal_values

        # set up gear values for the levels
        self.gear_values = gear_values

        self.level = level

        # only turn on tutorial for level 1
        if self.level == 1:
            self.use_tutorial = True
            self.tutorial_screen = 'A'
            self.goal_play_status = None
            self.gear_play_status = None
            self.size_dim = min(Window.width / 6, Window.height / 6)
            self.tutorial_full_overlay = CRectangle(cpos=(Window.width / 2,
                                                          Window.height / 2),
                                                    csize=(Window.width,
                                                           Window.height))
            self.tutorial_options_overlay = Rectangle(
                pos=(0, 0),
                size=(Window.width, self.size_dim + Window.height / 25))
            self.tutorial_musicbox_overlay = Rectangle(
                pos=(Window.width // 2, self.size_dim + Window.height / 25),
                size=(Window.width / 2,
                      Window.height - (self.size_dim + Window.height / 25)))
            self.tutorial_gearbox_overlay = Rectangle(
                pos=(0, self.size_dim + Window.height / 25),
                size=(Window.width / 2,
                      Window.height - (self.size_dim + Window.height / 25)))
            self.skip_image = CoreImage('images/skip_tutorial.png')
            self.tutorial_skip_button = Rectangle(
                pos=(0.98 * Window.width -
                     (self.skip_image.width * self.size_dim / 300),
                     0.98 * Window.height -
                     self.skip_image.height * self.size_dim / 300),
                size=(self.skip_image.width * self.size_dim / 300,
                      self.skip_image.height * self.size_dim / 300),
                texture=self.skip_image.texture)
        else:
            self.use_tutorial = False

        ############################################
        ###              GOAL MUSIC              ###
        ############################################
        self.goal_audio = Audio(2)
        self.goal_synth = Synth('./data/FluidR3_GM.sf2')

        # create TempoMap, AudioScheduler
        self.goal_tempo_map = SimpleTempoMap(120)
        self.goal_sched = AudioScheduler(self.goal_tempo_map)

        # connect scheduler into audio system
        self.goal_audio.set_generator(self.goal_sched)
        self.goal_sched.set_generator(self.goal_synth)

        # generate goal music
        self.goal_music = MusicPlayer(notes=self.notes,
                                      sched=self.goal_sched,
                                      synth=self.goal_synth,
                                      channel=1,
                                      tempo_map=self.goal_tempo_map)
        self.goal_music.update_tempo(self.goal_values[0])
        self.goal_music.update_instrument(self.goal_values[1])
        self.goal_music.update_pitch(self.goal_values[2])
        self.goal_music.update_volume(self.goal_values[3])

        self.goal_music_seq = self.goal_music.generate()

        ############################################
        ###              GEAR MUSIC              ###
        ############################################
        self.gear_audio = Audio(2)
        self.gear_synth = Synth('./data/FluidR3_GM.sf2')

        # create TempoMap, AudioScheduler
        self.gear_tempo_map = SimpleTempoMap(120)
        self.gear_sched = AudioScheduler(self.gear_tempo_map)

        # connect scheduler into audio system
        self.gear_audio.set_generator(self.gear_sched)
        self.gear_sched.set_generator(self.gear_synth)

        # generate gear music
        self.gear_music = MusicPlayer(notes=self.notes,
                                      sched=self.gear_sched,
                                      synth=self.gear_synth,
                                      channel=1,
                                      tempo_map=self.gear_tempo_map)
        self.gear_music_seq = None

        ############################################
        ###       BACKGROUND UI COMPONENTS       ###
        ############################################
        self.gear_area = GearArea()
        self.canvas.add(self.gear_area)

        self.music_box_area = MusicBoxArea()
        self.canvas.add(self.music_box_area)

        self.options = LevelOptions(
            level=level,
            goal_music_seq=self.goal_music_seq,
            duration=self.goal_music.duration,
            edit_goal_play_status=self.edit_goal_play_status)
        self.canvas.add(self.options)

        self.label = Label(text=kwargs['name'],
                           font_name='./fonts/PassionOne-Regular',
                           color=(.165, .718, .792, 1))
        self.add_widget(self.label)

        ###########################################
        ###             GEAR LABELS             ###
        ###########################################
        self.tempo_label = Label(text='Tempo (bpm)',
                                 font_name='./fonts/PassionOne-Regular',
                                 color=(0.7254901960784313, 0.5529411764705883,
                                        0.8196078431372549, 1),
                                 center_x=(Window.width / 4),
                                 center_y=(Window.height / 5.25 * (0.5 + 0.5) +
                                           self.gear_area.position[1]),
                                 font_size=str(Window.width // 50) + 'sp')
        self.instrument_label = Label(
            text='Instrument',
            font_name='./fonts/PassionOne-Regular',
            color=(0.996078431372549, 0.8431372549019608, 0.4, 1),
            center_x=(Window.width / 4),
            center_y=(Window.height / 5.25 * (1.5 + 0.5) +
                      self.gear_area.position[1]),
            font_size=str(Window.width // 50) + 'sp')
        self.pitch_label = Label(text='Pitch (semitones)',
                                 font_name='./fonts/PassionOne-Regular',
                                 color=(1.0, 0.6509803921568628,
                                        0.09019607843137255, 1),
                                 center_x=(Window.width / 4),
                                 center_y=(Window.height / 5.25 * (2.5 + 0.5) +
                                           self.gear_area.position[1]),
                                 font_size=str(Window.width // 50) + 'sp')
        self.volume_label = Label(
            text='Volume',
            font_name='./fonts/PassionOne-Regular',
            color=(0.9254901960784314, 0.32941176470588235, 0.3176470588235294,
                   1),
            center_x=(Window.width / 4),
            center_y=(Window.height / 5.25 * (3.5 + 0.5) +
                      self.gear_area.position[1]),
            font_size=str(Window.width // 50) + 'sp')
        self.add_widget(self.volume_label)
        self.add_widget(self.pitch_label)
        self.add_widget(self.instrument_label)
        self.add_widget(self.tempo_label)

        ###########################################
        ###          GEAR CONSTRUCTION          ###
        ###########################################

        self.gears = []
        self.gear_centers = []
        self.gears_group = AnimGroup()
        self.canvas.add(self.gears_group)

        ###########################################
        ###                GEARS                ###
        ###########################################
        self.gear_storage_locations = []
        self.gear_music_locations = []
        self.gear_labels = []
        self.set_up_gears()

        ###########################################
        ###           PARTICLE EFFECT           ###
        ###########################################
        self.win_ps = ParticleSystem('particles/star_particle.pex')
        self.win_ps.emitter_x = Window.width / 2
        self.win_ps.emitter_y = Window.height / 2
        self.add_widget(self.win_ps)
        self.you_win_label = Label(text=' ',
                                   font_name='./fonts/PassionOne-Regular',
                                   color=(0.5843137254901961,
                                          0.796078431372549,
                                          0.37254901960784315, 1),
                                   center_x=Window.width / 2,
                                   center_y=Window.height / 2,
                                   font_size=str(Window.width // 10) + 'sp')
        self.add_widget(self.you_win_label)

        self.lose_ps = ParticleSystem('particles/lose_particle.pex')
        self.lose_ps.emitter_x = Window.width / 2
        self.lose_ps.emitter_y = Window.height / 2
        self.add_widget(self.lose_ps)
        self.you_lose_label = Label(text=' ',
                                    font_name='./fonts/PassionOne-Regular',
                                    color=(0.9254901960784314,
                                           0.32941176470588235,
                                           0.3176470588235294, 1),
                                    center_x=Window.width / 2,
                                    center_y=Window.height / 2,
                                    font_size=str(Window.width // 10) + 'sp')
        self.add_widget(self.you_lose_label)

        ###########################################
        ###            ERROR MESSAGE            ###
        ###########################################
        self.error_msg = Label(text=' ',
                               font_name='./fonts/PassionOne-Regular',
                               color=(0.9254901960784314, 0.32941176470588235,
                                      0.3176470588235294, 1),
                               center_x=Window.width / 2,
                               center_y=Window.height / 2,
                               font_size=str(Window.width // 20) + 'sp')
        self.add_widget(self.error_msg)

        # ###########################################
        # ###        ADD TUTORIAL OVERLAYS        ###
        # ###########################################
        if self.use_tutorial:
            self.canvas.add(Color(rgba=(0, 0, 0, 0.85)))
            self.canvas.add(self.tutorial_full_overlay)
            self.tutorial_label = Label(
                markup=True,
                text=
                "[font=./fonts/lato-bold]Welcome to the\n[/font] [font=./fonts/options-icons]|[/font] [font=./fonts/PassionOne-Regular]Play It By Gear Tutorial[/font] [font=./fonts/options-icons]|[/font] [font=./fonts/lato-bold]\n\nThe goal of this game is to make the \n goal song match the song you create by \nplacing the correct gears in a music box \n\n[/font] [font=./fonts/lato-light] (click to see the next \nstep of the tutorial)[/font]",
                color=(86 / 255, 189 / 255, 205 / 255, 1),
                center_x=Window.width / 2,
                center_y=Window.height / 2,
                font_size=str(Window.width // 40) + 'sp',
                halign='center')
            self.add_widget(self.tutorial_label)
            self.canvas.add(self.tutorial_skip_button)

        self.on_layout((Window.width, Window.height))
Ejemplo n.º 11
0
    def set_up_gears(self):
        self.gears = []
        self.gears_group.remove_all()
        center_gear_location = (Window.width / 6 * 4.5,
                                Window.height / 4 * 2.5)
        center_gear_size = min(Window.width / 10, Window.height / 10)
        self.center_gear = Gear(None, None, center_gear_size, 10, 'center', 0,
                                center_gear_location, center_gear_location, 1,
                                colors['dark_grey'])
        self.canvas.add(self.center_gear.color)
        self.gears_group.add(self.center_gear)

        self.center_gear_center = GearCenter(None, None, center_gear_location,
                                             center_gear_location, 'center',
                                             center_gear_size / 2,
                                             colors['dark_grey'])
        self.canvas.add(colors['dark_grey'])
        self.canvas.add(self.center_gear_center)

        self.play_center_gear = False

        self.music_gears = []

        tempo_location = (center_gear_location[0], center_gear_location[1] +
                          center_gear_size + center_gear_size / 5)
        instrument_location = (center_gear_location[0],
                               center_gear_location[1] - center_gear_size -
                               center_gear_size / 5)
        pitch_location = (center_gear_location[0] + center_gear_size +
                          center_gear_size / 5, center_gear_location[1])
        volume_location = (center_gear_location[0] - center_gear_size -
                           center_gear_size / 5, center_gear_location[1])

        self.music_box_gear_locations = [
            tempo_location, instrument_location, pitch_location,
            volume_location
        ]

        counter = 0

        label_font_size = min(Window.width // 80, Window.height // 80)
        for y in range(0, 4):
            for x in range(len(self.gear_values) // 4):
                gear_type = gear_type_map[y]
                size = min(Window.width / 10, Window.height / 10)

                music_pos = self.music_box_gear_locations[y]
                scaled_x, scaled_y = self.get_scaled_x_y(
                    (Window.width, Window.height), x, y)

                gear = Gear(x, y, size, 8, gear_type,
                            self.gear_values[counter], (scaled_x, scaled_y),
                            music_pos, 0, colors['dark_grey'])
                self.gears.append(gear)
                self.canvas.add(gear.color)
                self.gears_group.add(gear)

                gear_center = GearCenter(x, y, (scaled_x, scaled_y), music_pos,
                                         gear_type, size / 2,
                                         colors['dark_grey'])
                self.gear_centers.append(gear_center)
                self.canvas.add(gear_center)

                ## white dots for storage purposes
                gear_loc = GearLocation((scaled_x, scaled_y), size / 2, x, y,
                                        gear_type)
                self.gear_storage_locations.append(gear_loc)
                self.canvas.add(gear_loc)

                text = str(self.gear_values[counter])
                font_name = './fonts/PassionOne-Regular'
                if y == 3:
                    # get volume as percent
                    text = str(100 * self.gear_values[counter] // 127) + '%'
                if y == 1:
                    # get icon for instrument
                    font_name = './fonts/music-instruments'
                    text = instruments[self.gear_values[counter]]

                label = Label(text=text,
                              font_name=font_name,
                              color=(0, 0, 0, 1),
                              center_x=scaled_x,
                              center_y=scaled_y,
                              font_size=str(label_font_size) + 'sp')
                self.gear_labels.append(label)
                self.add_widget(label)

                counter += 1

        for indx, loc in enumerate(self.music_box_gear_locations):
            gear_type = gear_type_map[indx % 4]
            gear_loc = GearLocation(loc, center_gear_size / 2, None, None,
                                    gear_type)
            self.gear_music_locations.append(gear_loc)
            self.canvas.add(gear_loc)
Ejemplo n.º 12
0
    def SecurityConfLocalUsernameDatabaseExecute(self):

        #Try statement to ensure that any errors connecting and configuring the device are handled gracefully and the user is informed of what the potential error was using popups
        try:

            privilege_level = self.ids._Security_Conf_Local_Username_Database_Layout_.ids.SecurityConfLocalUsernameDatabasePrivilegeLayout.ids.PrivilegeLevelSpinner.text
            new_username = self.ids._Security_Conf_Local_Username_Database_Layout_.ids.SecurityConfLocalUsernameDatabaseUserAndPassLayout.ids.UsernameTextInput.text
            new_password = self.ids._Security_Conf_Local_Username_Database_Layout_.ids.SecurityConfLocalUsernameDatabaseUserAndPassLayout.ids.PasswordTextInput.text

            #Try statement to ensure the IP address entered is valid. If it is an invalid address the ipaddress module will raise a value error, at which point the user is informed that a valid IP address is required using a popup
            try:

                device_ip_address = self.ids._IPv4_Target_Device_Layout_.ids.IPv4AddressTextInput.text
                ipaddress.ip_address(device_ip_address)

            #ipaddress raises a value error when an invalid IP address is used
            except ValueError:

                Factory.InvalidIPAddressPopup().open()
                return  #Exit from the function

            #If statement to ensure user has entered a username or password
            if App.get_running_app(
            ).device_username == '' or App.get_running_app(
            ).device_password == '':

                Factory.NoUserOrPassPopup().open()
                return  #Exit from the function

            else:

                device_username = App.get_running_app().device_username
                device_password = App.get_running_app().device_password

            device = {
                'device_type': 'cisco_ios',
                'ip': device_ip_address,
                'username': device_username,
                'password': device_password,
            }

            priv_check = self.ids._Security_Conf_Local_Username_Database_Layout_.ids.SecurityConfLocalUsernameDatabasePrivilegeLayout.ids.PrivilegeLevelSpinner.text
            secret_check = self.ids._Security_Conf_Local_Username_Database_Layout_.ids.SecurityConfLocalUsernameDatabaseSecretLayout.ids.SecretPasswordTrue.active

            if secret_check == True and priv_check != 'No Privilege Required':  #Priv and Secret
                config_commands = [
                    "username " + new_username + " privilege " +
                    privilege_level + " secret " + new_password
                ]
            elif priv_check != 'No Privilege Required':  #Priv and password
                config_commands = [
                    "username " + new_username + " privilege " +
                    privilege_level + " password " + new_password
                ]
            elif secret_check == True:  #Secret
                config_commands = [
                    "username " + new_username + " secret " + new_password
                ]
            else:
                config_commands = [
                    "username " + new_username + " password " + new_password
                ]  #Standard

            net_connect = ConnectHandler(**device)

            net_connect.send_config_set(config_commands)

            #Set the password and username back to empty after completion of configuration
            App.get_running_app().device_username = ''
            App.get_running_app().device_password = ''

            #Create and display a popup to inform the user of the successful configuration
            popup = Popup(
                title='',
                content=Label(markup=True,
                              text="Successfully added new user '[b]" +
                              new_username +
                              "[/b]' to device with IP address '[b]" +
                              device_ip_address + "[/b]'"),
                size_hint=(0.8, 0.3))
            popup.open()

        #Except error to catch when Credentials are incorrect, informs the user of the error using a popup defined in the MainApplication.kv
        except AuthenticationException:

            Factory.NetmikoAuthenticateFailurePopup().open()

        #Except error to catch when Netmiko timeouts and is unable to connect to device, informs the user of the error using a popup defined in the MainApplication.kv
        except NetMikoTimeoutException:

            Factory.NetmikoTimeoutPopup().open()
Ejemplo n.º 13
0
    def SecurityConfAuxVtyConLinesExecute(self):

        #Try statement to ensure that any errors connecting and configuring the device are handled gracefully and the user is informed of what the potential error was using popups
        try:

            #Define the three potential commands as empty variables

            transport_command = ''
            login_command = ''
            exec_timeout_command = ''

            #Else if to find out which line the user wishes to configure

            if self.ids._Security_Conf_Aux_Vty_Con_Lines_Layout_.ids.SecurityConfAuxVtyConLinesSelectLineLayout.ids.ConTrue.active == True:
                line_to_configure = 'Console'
            elif self.ids._Security_Conf_Aux_Vty_Con_Lines_Layout_.ids.SecurityConfAuxVtyConLinesSelectLineLayout.ids.AuxTrue.active == True:
                line_to_configure = 'Aux'
            else:
                line_to_configure = 'Vty'

            #Else if to find out the line_range the user wishes to configure, if console or auxiliary is the line to configure set line to 0

            if self.ids._Security_Conf_Aux_Vty_Con_Lines_Layout_.ids.SecurityConfAuxVtyConLinesSelectLineLayout.ids.ConTrue.active == True or self.ids._Security_Conf_Aux_Vty_Con_Lines_Layout_.ids.SecurityConfAuxVtyConLinesSelectLineLayout.ids.AuxTrue.active == True:
                line_range = '0'
            else:
                start_line_range = self.ids._Security_Conf_Aux_Vty_Con_Lines_Layout_.ids.SecurityConfAuxVtyConLinesLineRangeLayout.ids.LineRangeStartTextInput.text
                end_line_range = self.ids._Security_Conf_Aux_Vty_Con_Lines_Layout_.ids.SecurityConfAuxVtyConLinesLineRangeLayout.ids.LineRangeEndTextInput.text

                line_range = start_line_range + ' ' + end_line_range  #Define the line_range variable from reading user input from the two text inputs

            line_command = "line " + line_to_configure + ' ' + line_range  #Create a variable to store the command to enter the line to improve ease of reading further down

            #If statement to check if user has selected Transport Method checkbox, if so the command will be created and inserted into the variable. Else the variable will be left blank

            if self.ids._Security_Conf_Aux_Vty_Con_Lines_Function_Select_.ids.TransportMethodCheckbox.active == True:

                #Creates the variable for input/output dependent on user choice
                transport_type = self.ids._Security_Conf_Aux_Vty_Con_Lines_Layout_.ids.SecurityConfAuxVtyConLinesTransportOptionsLayout.ids.TransportInputOutputSpinner.text  # Defines wheter the user wants to configure input or output transport method

                #If statement for handling if a user does not change method 1 - It will default to ssh

                if self.ids._Security_Conf_Aux_Vty_Con_Lines_Layout_.ids.SecurityConfAuxVtyConLinesTransportOptionsLayout.ids.TransportMethodNo1Spinner.text == 'Method 1':
                    transport_method1 = 'SSH'
                else:
                    transport_method1 = self.ids._Security_Conf_Aux_Vty_Con_Lines_Layout_.ids.SecurityConfAuxVtyConLinesTransportOptionsLayout.ids.TransportMethodNo1Spinner.text

                #If statement for handling if a user does not change method 2 or if N/A was selected. Or if a user has entered 'none' as the value in method 1 - It will default to blank

                if self.ids._Security_Conf_Aux_Vty_Con_Lines_Layout_.ids.SecurityConfAuxVtyConLinesTransportOptionsLayout.ids.TransportMethodNo2Spinner.text == 'Method 2' or self.ids._Security_Conf_Aux_Vty_Con_Lines_Layout_.ids.SecurityConfAuxVtyConLinesTransportOptionsLayout.ids.TransportMethodNo2Spinner.text == 'N/A' or transport_method1 == 'none':
                    transport_method2 = ''
                else:
                    transport_method2 = self.ids._Security_Conf_Aux_Vty_Con_Lines_Layout_.ids.SecurityConfAuxVtyConLinesTransportOptionsLayout.ids.TransportMethodNo2Spinner.text

                #Combines the three variables to create the final command

                transport_command = 'transport ' + transport_type + ' ' + transport_method1 + ' ' + transport_method2  # Creates the final Transport Command

            else:
                pass

            #If statement to check if user has selected Login Type checkbox, if so the command will be created and inserted into the variable. Else the variable will be left blank

            if self.ids._Security_Conf_Aux_Vty_Con_Lines_Function_Select_.ids.LoginTypeCheckbox.active == True:

                #If statement to check if user has selected to login using the local user database or a custom password and set the login_type_command variable accordingly
                if self.ids._Security_Conf_Aux_Vty_Con_Lines_Layout_.ids.SecurityConfAuxVtyConLinesLoginOptionsLayout.ids.LoginLocalTrue.active == True:
                    login_command = 'login local'
                else:
                    login_command = 'password ' + self.ids._Security_Conf_Aux_Vty_Con_Lines_Layout_.ids.SecurityConfAuxVtyConLinesLoginOptionsLayout.ids.LineLoginPasswordTextInput.text

            else:
                pass

            #If statement to check if user has selected Exec Timeout checkbox, if so the command will be created and inserted into the variable. Else the variable will be left blank

            if self.ids._Security_Conf_Aux_Vty_Con_Lines_Function_Select_.ids.ExecTimeoutCheckbox.active == True:

                exec_timeout_command = 'exec-timeout ' + self.ids._Security_Conf_Aux_Vty_Con_Lines_Layout_.ids.SecurityConfAuxVtyConLinesExecTimeoutOptionsLayout.ids.LineExecTimeoutMinutesTextInput.text + ' ' + self.ids._Security_Conf_Aux_Vty_Con_Lines_Layout_.ids.SecurityConfAuxVtyConLinesExecTimeoutOptionsLayout.ids.LineExecTimeoutSecondsTextInput.text

            else:
                pass

            #Try statement to ensure the IP address entered is valid. If it is an invalid address the ipaddress module will raise a value error, at which point the user is informed that a valid IP address is required using a popup
            try:

                device_ip_address = self.ids._IPv4_Target_Device_Layout_.ids.IPv4AddressTextInput.text
                ipaddress.ip_address(device_ip_address)

            #ipaddress raises a value error when an invalid IP address is used
            except ValueError:

                Factory.InvalidIPAddressPopup().open()
                return  #Exit from the function

            #If statement to ensure user has entered a username or password
            if App.get_running_app(
            ).device_username == '' or App.get_running_app(
            ).device_password == '':

                Factory.NoUserOrPassPopup().open()
                return  #Exit from the function

            else:

                device_username = App.get_running_app().device_username
                device_password = App.get_running_app().device_password

            device = {
                'device_type': 'cisco_ios',
                'ip': device_ip_address,
                'username': device_username,
                'password': device_password,
            }

            config_commands = [
                line_command, transport_command, login_command,
                exec_timeout_command
            ]

            net_connect = ConnectHandler(**device)

            net_connect.send_config_set(config_commands)

            #Set the password and username back to empty after completion of configuration
            App.get_running_app().device_username = ''
            App.get_running_app().device_password = ''

            #If statement to check if VTY was the selected function, and then display the text with a line range, else it will display it as line 0
            if self.ids._Security_Conf_Aux_Vty_Con_Lines_Layout_.ids.SecurityConfAuxVtyConLinesSelectLineLayout.ids.VtyTrue.active == True:

                #Create and display a popup to inform the user of the successful configuration
                popup = Popup(
                    title='',
                    content=Label(markup=True,
                                  text="Successfully configured '[b]" +
                                  line_to_configure + "[/b]' Lines '[b]" +
                                  start_line_range + " - " + end_line_range +
                                  "[/b]' on device with IP address '[b]" +
                                  device_ip_address + "[/b]'"),
                    size_hint=(0.8, 0.3))
                popup.open()

            else:

                #Create and display a popup to inform the user of the successful configuration
                popup = Popup(
                    title='',
                    content=Label(markup=True,
                                  text="Successfully configured '[b]" +
                                  line_to_configure + "[/b]' Line '[b]" +
                                  line_range +
                                  "[/b]' on device with IP address '[b]" +
                                  device_ip_address + "[/b]'"),
                    size_hint=(0.8, 0.3))
                popup.open()

        #Except error to catch when Credentials are incorrect, informs the user of the error using a popup defined in the MainApplication.kv
        except AuthenticationException:

            Factory.NetmikoAuthenticateFailurePopup().open()

        #Except error to catch when Netmiko timeouts and is unable to connect to device, informs the user of the error using a popup defined in the MainApplication.kv
        except NetMikoTimeoutException:

            Factory.NetmikoTimeoutPopup().open()
Ejemplo n.º 14
0
    def SecurityConfPasswordEncryptionExecute(self):

        #Try statement to ensure that any errors connecting and configuring the device are handled gracefully and the user is informed of what the potential error was using popups
        try:

            #Try statement to ensure the IP address entered is valid. If it is an invalid address the ipaddress module will raise a value error, at which point the user is informed that a valid IP address is required using a popup
            try:

                device_ip_address = self.ids._IPv4_Target_Device_Layout_.ids.IPv4AddressTextInput.text
                ipaddress.ip_address(device_ip_address)

            #ipaddress raises a value error when an invalid IP address is used
            except ValueError:

                Factory.InvalidIPAddressPopup().open()
                return  #Exit from the function

            #If statement to ensure user has entered a username or password
            if App.get_running_app(
            ).device_username == '' or App.get_running_app(
            ).device_password == '':

                Factory.NoUserOrPassPopup().open()
                return  #Exit from the function

            else:

                device_username = App.get_running_app().device_username
                device_password = App.get_running_app().device_password

            device = {
                'device_type': 'cisco_ios',
                'ip': device_ip_address,
                'username': device_username,
                'password': device_password,
            }

            if self.ids._Security_Conf_Password_Encryption_Layout_.ids.EnableToggle.state == 'down':
                config_commands = ["service password-encryption"]
                encryption_type = "Enabled"
            else:
                config_commands = ["no service password-encryption"]
                encryption_type = "Disabled"

            net_connect = ConnectHandler(**device)

            net_connect.send_config_set(config_commands)

            #Set the password and username back to empty after completion of configuration
            App.get_running_app().device_username = ''
            App.get_running_app().device_password = ''

            #Create and display a popup to inform the user of the successful configuration
            popup = Popup(
                title='',
                content=Label(
                    markup=True,
                    text="Successfully '[b]" + encryption_type +
                    "[/b]' password encryption on device with IP address '[b]"
                    + device_ip_address + "[/b]'"),
                size_hint=(0.8, 0.3))
            popup.open()

        #Except error to catch when Credentials are incorrect, informs the user of the error using a popup defined in the MainApplication.kv
        except AuthenticationException:

            Factory.NetmikoAuthenticateFailurePopup().open()

        #Except error to catch when Netmiko timeouts and is unable to connect to device, informs the user of the error using a popup defined in the MainApplication.kv
        except NetMikoTimeoutException:

            Factory.NetmikoTimeoutPopup().open()
Ejemplo n.º 15
0
 def save_popup(self):
     self.content = Label(text=' Data not saved!!!')
     self.popup = Popup(title='Error!!!!',
                        content=self.content,
                        size_hint=(.4, .3))
     self.popup.open()
Ejemplo n.º 16
0
 def finish(self, request, result):
     threading.Thread(target=self.unzip_content).start()
     self.ids['progress_area'].clear_widgets()
     self.ids['progress_area'].add_widget(Label(text='Unzipping...'))
Ejemplo n.º 17
0
 def save_succefull(self):
     self.content = Label(text=' Registration Successfull!!!!')
     self.popup = Popup(title='Applause!!',
                        content=self.content,
                        size_hint=(.4, .3))
     self.popup.open()
Ejemplo n.º 18
0
    def ref(self, value):
        game.refresh_game()
        pWindow.dismiss()

    def change_to_menu(self, value):
        sm.transition.direction = 'left'
        sm.current = 'menu'
        pWindow.dismiss()

        game.refresh_game()


pw = PauseWindow()
pause_lbl = Label(text="Game is Paused",
                  size_hint=(0.6, 0.2),
                  pos_hint={
                      "x": 0.2,
                      "top": 1
                  })
cont_btn = Button(text="Continue",
                  size_hint=(0.6, 0.2),
                  pos_hint={
                      "x": 0.2,
                      "top": 0.2
                  },
                  on_release=pw.cont)
restart_btn = Button(text="Restart",
                     size_hint=(0.6, 0.2),
                     pos_hint={
                         "x": 0.2,
                         "top": 0.4
                     },
Ejemplo n.º 19
0
 def create_labels(self):
     for name in self.label_name_list:
         print(name)
         temp_label = Label(text=name, id=name)
         print(temp_label)
         self.root.ids.output_label.add_widget(temp_label)
Ejemplo n.º 20
0
    def __init__(self, **kwargs):
        Screen.__init__(self, **kwargs)
        self.layout = BoxLayout(orientation='vertical',
                                spacing=10,
                                padding=[0, 50, 0, 50])

        # Setting the background of the menu screen
        with self.canvas.before:

            Rectangle(source='assets/startmenubg.png',
                      size=(Window.width, Window.height),
                      color=(255, 255, 255, 1))
            # Label(text = "Welcome to this game", pos_hint = {"center_x":0.5})

        # Title
        self.tit = Label(text="Last Stand",
                         font_name="Halo3",
                         font_size=100,
                         size_hint=(1, 1),
                         size=(600, 300),
                         pos_hint={"center_x": 0.5},
                         color=(1, 0, 0, 1))

        # Start Button
        self.btn_start = Button(background_normal='assets/startbutton2.png',
                                text='Start Game',
                                font_size=50,
                                on_release=self.change_to_start,
                                color=(1, 1, 1, 1),
                                size_hint=(None, None),
                                size=(600, 200),
                                pos_hint={"center_x": 0.5},
                                font_name="Halo3")

        # High Score Button
        self.btn_hs = Button(text='High Score',
                             background_normal='assets/startbutton2.png',
                             font_name="Halo3",
                             size=(600, 200),
                             size_hint=(None, None),
                             font_size=50,
                             on_release=self.open_hs,
                             pos_hint={
                                 "center_x": 0.5,
                                 "y": 0.3
                             })

        # Quit button
        self.btn_quit = Button(text='Quit Game',
                               background_normal='assets/startbutton2.png',
                               font_name="Halo3",
                               size=(600, 200),
                               font_size=50,
                               size_hint=(None, None),
                               on_release=self.quit_game,
                               pos_hint={
                                   "center_x": 0.5,
                                   "y": 0.3
                               })

        self.layout.add_widget(self.tit)
        self.layout.add_widget(self.btn_start)
        self.layout.add_widget(self.btn_hs)

        self.layout.add_widget(self.btn_quit)
        # self.layout.add_widget(self.tit)

        self.add_widget(self.layout)
Ejemplo n.º 21
0
    def build(self):
        # quadrante principal
        box = BoxLayout(orientation="vertical")
        # primeiro quadrante
        box2 = BoxLayout(orientation="horizontal")

        box.add_widget(box2)
        # segundo quadrante
        box8 = BoxLayout()
        box.add_widget(box8)

        box4 = BoxLayout(orientation="vertical")
        label1 = Label(text="animal")
        label2 = Label(text="alavanca")
        label3 = Label(text="Tempo")
        box4.add_widget(label1)
        box4.add_widget(label2)
        box4.add_widget(label3)
        #box2.add_widget(label2)

        box2.add_widget(box4)

        box3 = BoxLayout(orientation="vertical")
        label1 = Label(text=" ")
        textinput1 = TextInput(text='', multiline=False)
        label2 = Label(text=" ")
        textinput2 = TextInput(text='', multiline=False)
        label3 = Label(text=" ")
        textinput3 = TextInput(text='', multiline=False)

        box3.add_widget(label1)
        box3.add_widget(textinput1)
        box3.add_widget(label2)
        box3.add_widget(textinput2)
        box3.add_widget(label3)
        box3.add_widget(textinput3)

        box2.add_widget(box3)

        box4 = BoxLayout(orientation="vertical")
        label1 = Label(text="escolha uma opcao")
        button3 = Button(text="teste01")
        label2 = Label(text=" ")
        button4 = Button(text="teste02")
        label3 = Label(text=" ")
        button5 = Button(text="teste03")

        box4.add_widget(label1)
        box4.add_widget(button3)
        box4.add_widget(label2)
        box4.add_widget(button4)
        box4.add_widget(label3)
        box4.add_widget(button5)

        box2.add_widget(box4)

        # --------------------------------  segundo quadrante -------------------

        box5 = BoxLayout(orientation="vertical")
        label1 = Label(text="ANIMAL:")
        label2 = Label(text="TOQUES NA DIREITA:")
        label3 = Label(text="TOQUES NA ESQUERDA:")
        box5.add_widget(label1)
        box5.add_widget(label2)
        box5.add_widget(label3)
        #box2.add_widget(label2)

        box8.add_widget(box5)

        box6 = BoxLayout(orientation="vertical")
        label1 = Label(text="sagui 01")
        label2 = Label(text="05")
        label3 = Label(text="03")

        box6.add_widget(label1)
        #box6.add_widget(textinput1)
        box6.add_widget(label2)
        #box6.add_widget(textinput2)
        box6.add_widget(label3)
        #box6.add_widget(textinput3)
        #box6.add_widget(label4)

        box8.add_widget(box6)

        box7 = BoxLayout(orientation="vertical")
        label1 = Label(text="TEMPO DO TESTE: ")
        label2 = Label(text="HORA DE INICIO: ")
        label3 = Label(text="HORA DE TERMINO: ")

        box7.add_widget(label1)
        box7.add_widget(label2)
        box7.add_widget(label3)

        box8.add_widget(box7)

        box9 = BoxLayout(orientation="vertical")
        label1 = Label(text="1 minuto")
        label2 = Label(text="15:12:25")
        label3 = Label(text="15:13:25")

        box9.add_widget(label1)
        box9.add_widget(label2)
        box9.add_widget(label3)

        box8.add_widget(box9)
        #quadrante 03
        box10 = BoxLayout()
        label = Label(text="inserir script")

        box10.add_widget(label)

        box.add_widget(box10)

        #quadrante 04
        box11 = BoxLayout()
        box.add_widget(box11)

        box12 = BoxLayout(orientation="vertical")
        label1 = Label(text=" ")
        label2 = Label(text=" ")
        label3 = Label(text=" ")

        textinput = TextInput(text='', multiline=False)
        label4 = Label(text=" ")
        label5 = Label(text=" ")
        label6 = Label(text=" ")

        box12.add_widget(label1)
        box12.add_widget(label2)

        box12.add_widget(textinput)

        box12.add_widget(label5)
        box12.add_widget(label6)
        box10.add_widget(box12)

        box13 = BoxLayout(orientation="vertical")
        label1 = Label(text=" ")
        label2 = Label(text=" ")

        button = Button(text='Carregar')
        label4 = Label(text=" ")

        label5 = Label(text=" ")

        box13.add_widget(label1)
        box13.add_widget(label2)

        box13.add_widget(button)

        box13.add_widget(label4)
        box13.add_widget(label5)

        box10.add_widget(box13)

        box14 = BoxLayout(orientation="vertical")

        button1 = Button(text='Faltam 20 segundos')
        label2 = Label(text=" ")

        button2 = Button(text='Reiniciar Testes')
        label4 = Label(text=" ")

        button3 = Button(text='Sair')
        label5 = Label(text=" ")

        box14.add_widget(button1)
        box14.add_widget(label2)

        box14.add_widget(button2)
        box14.add_widget(label3)

        box14.add_widget(button3)
        box14.add_widget(label4)

        box11.add_widget(box14)

        return box
Ejemplo n.º 22
0
 def do_action(self):
     def Or(q, p):
         if q == 'True' or p == 'True':
             return 'True'
         else:
             return 'False'
     def And(q, p):
         if q == 'True' and p == 'True':
             return 'True'
         else:
             return 'False'
     def Not(q):
         if q == 'True':
             return 'False'
         else:
             return 'True'
     def NAnd(q, p):
         if q == 'True' and p == 'True':
             return 'False'
         else:
             return 'True'
     def NOr(q, p):
         if q == 'False' and p == 'False':
             return 'True'
         else:
             return 'False'
     def XOr(q, p):
         if q != p:
             return 'True'
         else:
             return 'False'
     def XNOr(q, p):
         if q == p:
             return 'True'
         else:
             return 'False'
     L_input = self.user_input
     array_1 = []
     L_input_CT = 0
     while (L_input_CT < len(L_input)):
         if L_input[L_input_CT] == "(":
             array_1.append('(')
         if L_input[L_input_CT] == ")":
             array_1.append(')')
         if L_input[L_input_CT] == "T":
             if L_input[L_input_CT + 1] == "r":
                 if L_input[L_input_CT + 2] == "u":
                     if L_input[L_input_CT + 3] == "e":
                         array_1.append('True')
         if L_input[L_input_CT] == "F":
             if L_input[L_input_CT + 1] == "a":
                 if L_input[L_input_CT + 2] == "l":
                     if L_input[L_input_CT + 3] == "s":
                         if L_input[L_input_CT + 4] == "e":
                             array_1.append('False')
         if L_input[L_input_CT] == "\'":
             array_1.append('\'')
         if L_input[L_input_CT] == "X":
             if L_input[L_input_CT + 1] == "n":
                 if L_input[L_input_CT + 2] == "o":
                     if L_input[L_input_CT + 3] == "r":
                         array_1.append('Xnor')
         if L_input[L_input_CT] == "X":
             if L_input[L_input_CT + 1] == "o":
                 if L_input[L_input_CT + 2] == "r":
                     array_1.append('Xor')
         if L_input[L_input_CT] == "N":
             if L_input[L_input_CT + 1] == "o":
                 if L_input[L_input_CT + 2] == "r":
                     array_1.append('Nor')
         if L_input[L_input_CT] == "N":
             if L_input[L_input_CT + 1] == "a":
                 if L_input[L_input_CT + 2] == "n":
                     if L_input[L_input_CT + 3] == "d":
                         array_1.append('Nand')
         if L_input[L_input_CT] == "A":
             if L_input[L_input_CT + 1] == "n":
                 if L_input[L_input_CT + 2] == "d":
                     array_1.append('And')
         if L_input[L_input_CT] == "O":
             if L_input[L_input_CT + 1] == "r":
                 array_1.append('Or')
         L_input_CT += 1
     i = 0
     temp = 0
     while (i < len(array_1)):
         if array_1[i] == "(" and array_1[i + 2] == ")":
             array_2 = array_1[:]
             array_2[i] = array_1[i + 1]
             array_2.pop(i + 2)
             array_2.pop(i + 1)
             array_1 = array_2[:]
             i = -1
         else:
             if array_1[i] == "(":
                 temp = i
             if array_1[i] == ")":
                 j = temp
                 while (j < i):
                     if array_1[j] == "\'":
                         q = array_1[j - 1]
                         array_2 = array_1[:]
                         array_2[j - 1] = str(Not(q))
                         array_2.pop(j)
                         array_1 = array_2[:]
                         i -= 1
                         if array_1[j - 2] == "(" and array_1[j] == ")":
                             array_2 = array_1[:]
                             array_2[j - 2] = array_1[j - 1]
                             array_2.pop(j - 2)
                             array_2.pop(j - 1)
                             array_1 = array_2[:]
                             i = -1
                         j = temp
                     j += 1
                 j = temp
                 while (j < i):
                     if array_1[j] == "Xnor":
                         q = array_1[j - 1]
                         p = array_1[j + 1]
                         array_2 = array_1[:]
                         array_2[j - 1] = str(XNOr(q, p))
                         array_2.pop(j + 1)
                         array_2.pop(j)
                         array_1 = array_2[:]
                         i -= 2
                         if array_1[j - 2] == "(" and array_1[j] == ")":
                             array_2 = array_1[:]
                             array_2[j - 2] = array_1[j - 1]
                             array_2.pop(j - 2)
                             array_2.pop(j - 1)
                             array_1 = array_2[:]
                             i = -1
                         j = temp
                     if array_1[j] == "Xor":
                         q = array_1[j - 1]
                         p = array_1[j + 1]
                         array_2 = array_1[:]
                         array_2[j - 1] = str(XOr(q, p))
                         array_2.pop(j + 1)
                         array_2.pop(j)
                         array_1 = array_2[:]
                         i -= 2
                         if array_1[j - 2] == "(" and array_1[j] == ")":
                             array_2 = array_1[:]
                             array_2[j - 2] = array_1[j - 1]
                             array_2.pop(j - 2)
                             array_2.pop(j - 1)
                             array_1 = array_2[:]
                             i = -1
                         j = temp
                     if array_1[j] == "Nor":
                         q = array_1[j - 1]
                         p = array_1[j + 1]
                         array_2 = array_1[:]
                         array_2[j - 1] = str(NOr(q, p))
                         array_2.pop(j + 1)
                         array_2.pop(j)
                         array_1 = array_2[:]
                         i -= 2
                         if array_1[j - 2] == "(" and array_1[j] == ")":
                             array_2 = array_1[:]
                             array_2[j - 2] = array_1[j - 1]
                             array_2.pop(j - 2)
                             array_2.pop(j - 1)
                             array_1 = array_2[:]
                             i = -1
                         j = temp
                     if array_1[j] == "Nand":
                         q = array_1[j - 1]
                         p = array_1[j + 1]
                         array_2 = array_1[:]
                         array_2[j - 1] = str(NAnd(q, p))
                         array_2.pop(j + 1)
                         array_2.pop(j)
                         array_1 = array_2[:]
                         i -= 2
                         if array_1[j - 2] == "(" and array_1[j] == ")":
                             array_2 = array_1[:]
                             array_2[j - 2] = array_1[j - 1]
                             array_2.pop(j - 2)
                             array_2.pop(j - 1)
                             array_1 = array_2[:]
                             i = -1
                         j = temp
                     j += 1
                 j = temp
                 while (j < i):
                     if array_1[j] == "And":
                         q = array_1[j - 1]
                         p = array_1[j + 1]
                         array_2 = array_1[:]
                         array_2[j - 1] = str(And(q, p))
                         array_2.pop(j + 1)
                         array_2.pop(j)
                         array_1 = array_2[:]
                         i -= 2
                         if array_1[j - 2] == "(" and array_1[j] == ")":
                             array_2 = array_1[:]
                             array_2[j - 2] = array_1[j - 1]
                             array_2.pop(j - 2)
                             array_2.pop(j - 1)
                             array_1 = array_2[:]
                             i = -1
                         j = temp
                     j += 1
                 j = temp
                 while (j < i):
                     if array_1[j] == "Or":
                         q = array_1[j - 1]
                         p = array_1[j + 1]
                         array_2 = array_1[:]
                         array_2[j - 1] = str(Or(q, p))
                         array_2.pop(j + 1)
                         array_2.pop(j)
                         array_1 = array_2[:]
                         i -= 2
                         if array_1[j - 2] == "(" and array_1[j] == ")":
                             array_2 = array_1[:]
                             array_2[j - 2] = array_1[j - 1]
                             array_2.pop(j - 2)
                             array_2.pop(j - 1)
                             array_1 = array_2[:]
                             i = -1
                         j = temp
                     j += 1
         i += 1
     i = -1
     while (i < len(array_1)):
         if array_1[i] == "\'":
             q = array_1[i - 1]
             array_2 = array_1[:]
             array_2[i - 1] = str(Not(q))
             array_2.pop(i)
             array_1 = array_2[:]
             i = 0
         i += 1
     i = -1
     while (i < len(array_1)):
         if array_1[i] == "Xnor":
             q = array_1[i - 1]
             p = array_1[i + 1]
             array_2 = array_1[:]
             array_2[i - 1] = str(XNOr(q, p))
             array_2.pop(i + 1)
             array_2.pop(i)
             array_1 = array_2[:]
             i = 0
         if array_1[i] == "Nor":
             q = array_1[i - 1]
             p = array_1[i + 1]
             array_2 = array_1[:]
             array_2[i - 1] = str(NOr(q, p))
             array_2.pop(i + 1)
             array_2.pop(i)
             array_1 = array_2[:]
             i = 0
         if array_1[i] == "Xor":
             q = array_1[i - 1]
             p = array_1[i + 1]
             array_2 = array_1[:]
             array_2[i - 1] = str(XOr(q, p))
             array_2.pop(i + 1)
             array_2.pop(i)
             array_1 = array_2[:]
             i = 0
         if array_1[i] == "Nand":
             q = array_1[i - 1]
             p = array_1[i + 1]
             array_2 = array_1[:]
             array_2[i - 1] = str(NAnd(q, p))
             array_2.pop(i + 1)
             array_2.pop(i)
             array_1 = array_2[:]
             i = 0
         i += 1
     i = -1
     while (i < len(array_1)):
         if array_1[i] == "And":
             q = array_1[i - 1]
             p = array_1[i + 1]
             array_2 = array_1[:]
             array_2[i - 1] = str(And(q, p))
             array_2.pop(i + 1)
             array_2.pop(i)
             array_1 = array_2[:]
             i = 0
         i += 1
     i = -1
     while (i < len(array_1)):
         if array_1[i] == "Or":
             q = array_1[i - 1]
             p = array_1[i + 1]
             array_2 = array_1[:]
             array_2[i - 1] = str(Or(q, p))
             array_2.pop(i + 1)
             array_2.pop(i)
             array_1 = array_2[:]
             i = 0
         i += 1
     print(array_1)
     popup = Popup(title='Problem SOLVED!',
                   content=Label(text=str(array_1)),
                   size_hint=(None, None), size=(200, 100))
     popup.open()
     return
Ejemplo n.º 23
0
 def build(self):
     return Label(text='Bienvenidos a Jewel App')
 def build(self):
     return Label(text='Hello World', font_size=72)
Ejemplo n.º 25
0
    def update(self, dt):
        self.clear_widgets()

        global state_car

        curTime = datetime.datetime.now()

        timeString = curTime.strftime("%H:%M")
        timeLbl = Label(text='[color=111111] %s [/color]' % timeString,
                        pos=(win_x / 2 - 70, win_y / 2 - 20),
                        font_size='30dp',
                        markup=True)

        dateString = curTime.strftime("%d, %b.")
        dateLbl = Label(text='[color=111111] %s [/color]' % dateString,
                        font_size='20dp',
                        pos=(win_x / 2 - 70, win_y / 2 - 45),
                        markup=True)

        def decSpeed(self):
            state_gui.targetVelocity = -1

        def incSpeed(self):
            state_gui.targetVelocity = 1

        # CSpeed Labels and Target velocity + Buttons
        speedLbl = Label(text="[color=111111][b]%d[/b][/color]" %
                         state_car.targetVelocity,
                         pos_hint={'top': 1.25},
                         font_size="70dp",
                         markup=True)

        targetVel = Label(text="[color=111111][b]%d[/b][/color]" %
                          state_car.velocity,
                          pos_hint={'top': 1.1},
                          font_size="120dp",
                          markup=True)

        speedMinus = Button(text="[color=111111][b]-[/b][/color]",
                            pos=(330, 280),
                            size_hint=(.15, .2),
                            font_size="100dp",
                            markup=True,
                            background_color=(0, 0, 0, 0))
        speedMinus.bind(on_press=decSpeed)

        speedPlus = Button(text="[color=111111][b]+[/b][/color]",
                           pos=(550, 280),
                           size_hint=(.15, .2),
                           font_size="80dp",
                           markup=True,
                           background_color=(0, 0, 0, 0))
        speedPlus.bind(on_press=incSpeed)

        einheitLbl = Label(text="[color=111111][b]km/h[/b][/color]",
                           pos_hint={'top': 0.97},
                           font_size="45dp",
                           markup=True)

        # DrivingMode:
        scale = 60

        # Define current modes and set / change on press
        def changeMode(mode, curDir, vel):
            actColor = "ffd700"
            stdColor = "111111"
            # Park
            if (state_car.breaking > 90) and (mode == "manual"):
                pColor = actColor
                rColor = stdColor
                mColor = stdColor
                jColor = stdColor
                cColor = stdColor
            # Return
            elif curDir == -1:
                pColor = stdColor
                rColor = actColor
                mColor = stdColor
                jColor = stdColor
                cColor = stdColor
            # Manual
            elif mode == "manual":
                pColor = stdColor
                rColor = stdColor
                mColor = actColor
                jColor = stdColor
                cColor = stdColor
            # Joy
            elif mode == "remote":
                pColor = stdColor
                rColor = stdColor
                mColor = stdColor
                jColor = actColor
                cColor = stdColor
            # Cruise Control
            elif mode == "cruise":
                pColor = stdColor
                rColor = stdColor
                mColor = stdColor
                jColor = stdColor
                cColor = actColor
            # Nothing active
            else:
                pColor = stdColor
                rColor = stdColor
                mColor = stdColor
                jColor = stdColor
                cColor = stdColor

            pLbl = Label(text="[color=%s]P[/color]" % pColor,
                         pos=(win_x / 2 - 120, win_y / 2 - 130),
                         font_size='45dp',
                         markup=True)
            rLbl = Label(text="[color=%s]R[/color]" % rColor,
                         pos=(win_x / 2 - 120, win_y / 2 - 130 - (scale)),
                         font_size='45dp',
                         markup=True)
            mLbl = Label(text="[color=%s]M[/color]" % mColor,
                         pos=(win_x / 2 - 120, win_y / 2 - 130 - (scale * 2)),
                         font_size='45dp',
                         markup=True)
            jLbl = Label(text="[color=%s]J[/color]" % jColor,
                         pos=(win_x / 2 - 120, win_y / 2 - 130 - (scale * 3)),
                         font_size='45dp',
                         markup=True)
            cLbl = Label(text="[color=%s]C[/color]" % cColor,
                         pos=(win_x / 2 - 120, win_y / 2 - 130 - (scale * 4)),
                         font_size='45dp',
                         markup=True)

            self.add_widget(pLbl)
            self.add_widget(rLbl)
            self.add_widget(mLbl)
            self.add_widget(jLbl)
            self.add_widget(cLbl)

        changeMode(state_car.mode, state_car.direction, state_car.velocity)

        # Menu Buttons
        def screenMap(self):
            sm.transition = SlideTransition(direction='left')
            sm.current = "MAP"

        def screenCam(self):
            sm.transition = SlideTransition(direction='left')
            sm.current = "CAV"

        def screenLog(self):
            sm.transition = SlideTransition(direction='right')
            sm.current = "LOG"

        mapBtn = Button(text="[b]MAP[/b]",
                        font_size="20sp",
                        pos=(0, 0),
                        size_hint=(.3, .12),
                        markup=True)
        mapBtn.bind(on_press=screenMap)

        camBtn = Button(text="[b]CAM[/b]",
                        font_size="20sp",
                        pos=(win_x / 2 - (win_x * 0.15), 0),
                        size_hint=(.3, .12),
                        markup=True)
        camBtn.bind(on_press=screenCam)

        logBtn = Button(text="[b]LOG[/b]",
                        font_size="20sp",
                        pos=(0, (win_y) - 70),
                        size_hint=(.3, .12),
                        markup=True)
        logBtn.bind(on_press=screenLog)

        # Lane indicators and Lights
        def switchLights(left, right, light):
            # left = "left-arrow"
            leftPath = '../assets/data/%s.png' % left
            rightPath = '../assets/data/%s.png' % right
            lightPath = '../assets/data/%s.png' % light

            leftImg = Image(source=leftPath,
                            size_hint=(.07, .07),
                            pos=(win_x / 2 - 120, win_y / 2 - 130))
            rightImg = Image(source=rightPath,
                             size_hint=(.07, .07),
                             pos=(win_x / 2 + 55, win_y / 2 - 130))
            lightImg = Image(source=lightPath,
                             size_hint=(.07, .07),
                             pos=(win_x / 2 - 30, win_y / 2 - 130))

            self.add_widget(leftImg)
            self.add_widget(rightImg)
            self.add_widget(lightImg)

        # Activate lights and indicators on-press
        if leftOn:
            leftStr = "left-arrow-act"
        else:
            leftStr = "left-arrow"

        if rightOn:
            rightStr = "right-arrow-act"
        else:
            rightStr = "right-arrow"

        if state_car.light:
            lightStr = "car-light-act"
        else:
            lightStr = "car-light"

        switchLights(leftStr, rightStr, lightStr)

        def indicLeft(self):
            global leftOn, rightOn
            leftOn = not leftOn
            if leftOn:
                state_gui.indicate = "Left"
                rightOn = False
            else:
                state_gui.indicate = "None"

        def indicRight(self):
            global leftOn, rightOn
            rightOn = not rightOn
            if rightOn:
                state_gui.indicate = "Right"
                leftOn = False
            else:
                state_gui.indicate = "None"

        def carLight(self):
            state_gui.light = True

        # Place Buttons
        indicLeftBtn = Button(pos=(win_x / 2 - 120, win_y / 2 - 130),
                              size_hint=(.05, .10),
                              font_size="80dp",
                              markup=True,
                              background_color=(0, 0, 0, 0))
        indicLeftBtn.bind(on_press=indicLeft)

        indicRightBtn = Button(pos=(win_x / 2 + 55, win_y / 2 - 130),
                               size_hint=(.05, .10),
                               font_size="80dp",
                               markup=True,
                               background_color=(0, 0, 0, 0))
        indicRightBtn.bind(on_press=indicRight)

        carLightBtn = Button(pos=(win_x / 2 - 30, win_y / 2 - 130),
                             size_hint=(.05, .10),
                             font_size="80dp",
                             markup=True,
                             background_color=(0, 0, 0, 0))
        carLightBtn.bind(on_press=carLight)

        # Toggle Cruise Control
        def toggleCruise(self):
            state_gui.mode = "cruise"

        cruiseBtn = Button(text="[b]CRUISE CONTROL[/b]",
                           font_size="20sp",
                           pos=(win_x - (win_x * 0.3), 0),
                           size_hint=(.3, .12),
                           markup=True)
        cruiseBtn.bind(on_press=toggleCruise)

        # Throttle Slider
        throttleSlider = Slider(min=0,
                                max=100,
                                value=state_car.throttle,
                                orientation="vertical",
                                value_track=True,
                                pos=(-win_x / 3, win_y / 4),
                                size_hint=(1, 0.5),
                                cursor_image='../assets/data/brake32.png')

        # Add all widgets to the screen
        self.add_widget(throttleSlider)
        self.add_widget(speedMinus)
        self.add_widget(speedPlus)
        self.add_widget(mapBtn)
        self.add_widget(camBtn)
        self.add_widget(logBtn)
        self.add_widget(timeLbl)
        self.add_widget(speedLbl)
        self.add_widget(dateLbl)
        self.add_widget(cruiseBtn)
        self.add_widget(indicLeftBtn)
        self.add_widget(indicRightBtn)
        self.add_widget(carLightBtn)
        self.add_widget(targetVel)

        state_pub.publish(state_gui)
        state_gui.targetVelocity = 0
        state_gui.light = False
        state_gui.mode = "manual"
Ejemplo n.º 26
0
def erro_login():
    pop = Popup(title='Erro',
                content=Label(text='Senha ou Email incorretos.'),
                size_hint=(None, None),
                size=(400, 400))
    pop.open()
Ejemplo n.º 27
0
 def hataGoster(self, hata):
     icerik = Label(text=hata, markup=True)
     popup = Popup(title='Yapamadım !', content=icerik)
     popup.size_hint = (0.7, 0.7)
     icerik.bind(on_touch_down=popup.dismiss)
     popup.open()
    def display(self):
        self.palindromeList = palindromeList
        '''Function to display sub-strings go here'''
        #Clearing the entire area
        self.add_widget(Image(source='images/clear.png'))
        self.add_widget(Image(source='images/clear.png', x=0, y=90))

        numPal = len(self.palindromeList)

        #When there is only one sub-string
        if numPal == 1:
            self.add_widget(
                Label(text="The possible palindromic sub-string in" + " '" +
                      userInput + "' " + "is:",
                      x=-15,
                      y=40))
            label = Label(text=self.palindromeList[0],
                          x=-10,
                          y=15,
                          font_size=35)
            self.add_widget(label)
            self.animate(label)

        #When there are 2 sub-strings
        if numPal == 2:
            #Position
            x = -60
            y = 5

            #Font Size
            fontSize = 35

            self.add_widget(
                Label(text="The possible palindromic sub-strings in" + " '" +
                      userInput + "' " + "are:",
                      x=-15,
                      y=40))

            for i in range(0, numPal):
                label = Label(text=self.palindromeList[i],
                              x=x,
                              y=y,
                              font_size=fontSize)
                self.add_widget(label)
                self.animate(label)
                x += 70

        #When there are 3 sub-strings
        if numPal == 3:
            #Position
            x = -80
            y = 5

            #Font Size
            fontSize = 35

            self.add_widget(
                Label(text="The possible palindromic sub-strings in" + " '" +
                      userInput + "' " + "are:",
                      x=-15,
                      y=40))

            for i in range(0, numPal):
                label = Label(text=self.palindromeList[i],
                              x=x,
                              y=y,
                              font_size=fontSize)
                self.add_widget(label)
                self.animate(label)

                x += 70

        #When there are 4 sub-strings
        if numPal == 4:
            #Position
            x = -100
            y = 5

            #Font Size
            fontSize = 35

            self.add_widget(
                Label(text="The possible palindromic sub-strings in" + " '" +
                      userInput + "' " + "are:",
                      x=-15,
                      y=40))

            for i in range(0, numPal):
                label = Label(text=self.palindromeList[i],
                              x=x,
                              y=y,
                              font_size=fontSize)
                self.add_widget(label)
                self.animate(label)

                x += 70

        #When there are between 5 and 10 sub-strings
        if numPal >= 5 and numPal <= 10:
            #Position
            x = -190
            y = 110

            #Font Size
            fontSize = 35

            #Counter
            count = 0

            self.add_widget(
                Label(text="The possible palindromic sub-strings in" + " '" +
                      userInput + "' " + "are:",
                      x=-15,
                      y=180))

            for i in range(0, numPal):
                label = Label(text=self.palindromeList[i],
                              x=x,
                              y=y,
                              font_size=fontSize)
                self.add_widget(label)
                self.animate(label)

                x += 170

                #Count increments
                count += 1

                if count == 3:
                    x = -190
                    y -= 70

                if count == 6:
                    x = -190
                    y -= 70

                if count == 9:
                    x = -190
                    y -= 70

        #When there are between 10 and 20 sub-strings
        if numPal > 10 and numPal <= 20:
            #Position
            x = -190
            y = 150

            #Font Size
            fontSize = 25

            #Counter
            count = 0

            self.add_widget(
                Label(text="The possible palindromic sub-strings in" + " '" +
                      userInput + "' " + "are:",
                      x=-15,
                      y=180))

            for i in range(0, numPal):
                label = Label(text=self.palindromeList[i],
                              x=x,
                              y=y,
                              font_size=fontSize)
                self.add_widget(label)
                self.animate(label)

                x += 170

                #Count increments
                count += 1

                if count == 3:
                    x = -190
                    y -= 45

                if count == 6:
                    x = -190
                    y -= 45

                if count == 9:
                    x = -190
                    y -= 45

                if count == 12:
                    x = -190
                    y -= 45

                if count == 15:
                    x = -190
                    y -= 45

                if count == 18:
                    x = -190
                    y -= 45

        #When there are 20 or more sub-strings
        if numPal > 20:
            #Position
            x = -190
            y = 160

            #Font Size
            fontSize = 17

            #Counter
            count = 0

            self.add_widget(
                Label(text="The possible palindromic sub-strings in" + " '" +
                      userInput + "' " + "are:",
                      x=-15,
                      y=180))

            for i in range(0, numPal):
                label = Label(text=self.palindromeList[i],
                              x=x,
                              y=y,
                              font_size=fontSize)
                self.add_widget(label)
                self.animate(label)

                x += 170

                #Count increments
                count += 1

                if count == 3:
                    x = -190
                    y -= 30

                if count == 6:
                    x = -190
                    y -= 30

                if count == 9:
                    x = -190
                    y -= 30

                if count == 12:
                    x = -190
                    y -= 30

                if count == 15:
                    x = -190
                    y -= 30

                if count == 18:
                    x = -190
                    y -= 30

                if count == 21:
                    x = -190
                    y -= 30

                if count == 24:
                    x = -190
                    y -= 30

                if count == 27:
                    x = -190
                    y -= 30

                if count == 30:
                    x = -190
                    y -= 30

                if count == 33:
                    x = -190
                    y -= 30

                if count == 36:
                    x = -190
                    y -= 30

                if count == 39:
                    x = -190
                    y -= 30

                if count == 42:
                    x = -190
                    y -= 30

                if count == 45:
                    x = -190
                    y -= 30

                if count == 48:
                    x = -190
                    y -= 30

                if count == 51:
                    x = -190
                    y -= 30
Ejemplo n.º 29
0
def build():
    return Label (text = "Hello World !!!") 
Ejemplo n.º 30
0
    def __init__(self, controleur, **kwargs):
        super(Vue, self).__init__(**kwargs)
        Window.size = (1024, 600)

        with self.canvas.before:
            self.rect = Rectangle(size=self.size,
                                  pos=self.pos,
                                  source='labyrinthC/Modeles/Background.png')
            self.wimg = Image(size=(1000, 1000),
                              pos=(0, 200),
                              source='labyrinthC/Modeles/Dungeon_Quest.png')

        self.controleur = controleur
        #self.racine = FloatLayout(size=Constante.TAILLE_FENETRE)
        #bottom
        self.panelPrincipale = BoxLayout(padding=10)
        self.panelAccueil = BoxLayout(orientation='vertical',
                                      spacing=10,
                                      size_hint=(1, 0.3),
                                      pos_hint={
                                          'center_x': 0.5,
                                          'center_y': 0.4
                                      })
        self.panelServeur = BoxLayout(orientation='vertical',
                                      spacing=10,
                                      size_hint=(1, 0.4),
                                      pos_hint={
                                          'center_x': 0.5,
                                          'center_y': 0.4
                                      })
        self.panelAdresseServeur = BoxLayout(orientation='vertical',
                                             spacing=10,
                                             size_hint=(1, 0.4),
                                             pos_hint={
                                                 'center_x': 0.5,
                                                 'center_y': 0.4
                                             })
        self.panelNom = BoxLayout(orientation='vertical',
                                  spacing=10,
                                  size_hint=(1, 0.4),
                                  pos_hint={
                                      'center_x': 0.5,
                                      'center_y': 0.4
                                  })
        self.panelDefaite = BoxLayout(orientation='vertical',
                                      spacing=10,
                                      size_hint=(1, 0.4),
                                      pos_hint={
                                          'center_x': 0.5,
                                          'center_y': 0.4
                                      })
        self.panelVictoire = BoxLayout(orientation='vertical',
                                       spacing=10,
                                       size_hint=(1, 0.4),
                                       pos_hint={
                                           'center_x': 0.5,
                                           'center_y': 0.4
                                       })

        self.buttonJoueur = Button(
            text='Joueur',
            background_normal='labyrinthC/Modeles/Button_normal.png',
            background_down='labyrinthC/Modeles/Button_down.png',
            font_size=20,
            size_hint=(0.3, 1),
            pos_hint={'center_x': 0.5})
        self.buttonHost = Button(
            text='Host',
            background_normal='labyrinthC/Modeles/Button_normal.png',
            background_down='labyrinthC/Modeles/Button_down.png',
            font_size=20,
            size_hint=(0.3, 1),
            pos_hint={'center_x': 0.5})
        #self.buttonConfirmeNom = Button(text='Start Partie', background_normal='Button_normal.png', background_down='Button_down.png', font_size=20, size_hint=(0.3,1), pos_hint={'center_x': 0.5})
        self.buttonConfirmeServeur = Button(
            text='Ok',
            background_normal='labyrinthC/Modeles/Button_normal.png',
            background_down='labyrinthC/Modeles/Button_down.png',
            font_size=20,
            size_hint=(0.3, 1),
            pos_hint={'center_x': 0.5})
        self.buttonStartServer = Button(
            text='Start',
            background_normal='labyrinthC/Modeles/Button_normal.png',
            background_down='labyrinthC/Modeles/Button_down.png',
            font_size=20,
            size_hint=(0.3, 1),
            pos_hint={'center_x': 0.5})
        self.buttonStopServer = Button(
            text='Stop',
            background_normal='labyrinthC/Modeles/Button_normal.png',
            background_down='labyrinthC/Modeles/Button_down.png',
            font_size=20,
            size_hint=(0.3, 1),
            pos_hint={'center_x': 0.5})
        self.buttonConfirmeAdresse = Button(
            text='Ok',
            background_normal='labyrinthC/Modeles/Button_normal.png',
            background_down='labyrinthC/Modeles/Button_down.png',
            font_size=20,
            size_hint=(0.3, 1),
            pos_hint={'center_x': 0.5})
        self.buttonStartPartie = Button(
            text='Start Partie',
            background_normal='labyrinthC/Modeles/Button_normal.png',
            background_down='labyrinthC/Modeles/Button_down.png',
            font_size=20,
            size_hint=(0.3, 1),
            pos_hint={'center_x': 0.5})
        self.buttonRetourAccueil = Button(
            text='Retour Accueil',
            background_normal='labyrinthC/Modeles/Button_normal.png',
            background_down='labyrinthC/Modeles/Button_down.png',
            font_size=20,
            size_hint=(0.3, 1),
            pos_hint={'center_x': 0.5})
        self.buttonRetourAccueil1 = Button(
            text='Retour Accueil',
            background_normal='labyrinthC/Modeles/Button_normal.png',
            background_down='labyrinthC/Modeles/Button_down.png',
            font_size=20,
            size_hint=(0.3, 1),
            pos_hint={'center_x': 0.5})
        self.buttonRetourAccueil2 = Button(
            text='Retour Accueil',
            background_normal='labyrinthC/Modeles/Button_normal.png',
            background_down='labyrinthC/Modeles/Button_down.png',
            font_size=20,
            size_hint=(0.3, 1),
            pos_hint={'center_x': 0.5})

        self.textAdresseServeur = TextInput(text='127.0.0.1',
                                            padding=(10, 10, 0, 0),
                                            font_size=20,
                                            size_hint=(0.3, 1),
                                            pos_hint={'center_x': 0.5})
        self.textAdresseServeur.multiline = False
        self.textNom = TextInput(text='',
                                 padding=(10, 10, 0, 0),
                                 font_size=20,
                                 size_hint=(0.3, 1),
                                 pos_hint={'center_x': 0.5})
        self.textNom.multiline = False

        self.labelAccueil = Label(text='Bienvenue à toi Aventurier !',
                                  font_size=30,
                                  bold=True,
                                  pos_hint={'center_x': 0.5})
        self.labelServeur = Label(text='Démarrer / Arrêter le serveur',
                                  font_size=30,
                                  bold=True,
                                  pos_hint={'center_x': 0.5})
        self.labelAdresse = Label(text='Rentrer l\'adresse du serveur :',
                                  font_size=30,
                                  bold=True,
                                  pos_hint={'center_x': 0.5})
        self.labelNom = Label(text='Rentrer votre pseudo :',
                              font_size=30,
                              bold=True,
                              pos_hint={'center_x': 0.5})

        self.panelAccueil.add_widget(self.labelAccueil)
        self.panelAccueil.add_widget(self.buttonJoueur)
        self.panelAccueil.add_widget(self.buttonHost)

        self.anim = Animation(x=0, y=-50) + Animation(x=0, y=-20)
        self.anim.repeat = True
        self.anim.start(self.wimg)

        self.panelNom.add_widget(self.labelNom)
        self.panelNom.add_widget(self.textNom)
        self.panelNom.add_widget(self.buttonStartPartie)
        self.panelNom.add_widget(self.buttonRetourAccueil)

        self.panelServeur.add_widget(self.labelServeur)
        self.panelServeur.add_widget(self.buttonStartServer)
        self.panelServeur.add_widget(self.buttonStopServer)
        self.panelServeur.add_widget(self.buttonRetourAccueil1)

        self.panelAdresseServeur.add_widget(self.labelAdresse)
        self.panelAdresseServeur.add_widget(self.textAdresseServeur)
        self.panelAdresseServeur.add_widget(self.buttonConfirmeAdresse)
        self.panelAdresseServeur.add_widget(self.buttonRetourAccueil2)

        self.add_widget(self.panelPrincipale)

        self.affichePanelAccueil()

        self.imageSource = 'pac8.png'
        self.joueur = None
        self.but = None
        self.tailleCase = None
        self.orientation = 0
        self.marche = 0

        print('Trying to get keyboard')
        self.keyboard = Window.request_keyboard(self._keyboard_closed, self,
                                                'text')
        print('Trying to get keyboard done')