def __init__(self,
              card: Card,
              aspect_ratio: float = 24 / 37,
              path: Optional[str] = None,
              **kwargs):
     """
 Instantiates a new CardWidget.
 :param card: The card value to associate to this widget.
 :param aspect_ratio: The aspect ratio that will be enforced.
 :param path: The path to the folder containing the card images.
 :param kwargs: Parameters to be forwarded to the base class' constructor.
 """
     super().__init__(**kwargs)
     self._card = card
     self._path = path or GameOptions().cards_path
     self._visible = True
     self._grayed_out = False
     self._touch_down_pos: Optional[Tuple[int, int]] = None
     self._shadow_image = _get_drop_shadow_filename(self._path)
     self._shadow_enabled = _SHADOW_STRENGTH
     self.auto_bring_to_front = True
     image = Image(source=_get_card_filename(card, self._path))
     image.keep_ratio = False
     image.allow_stretch = True
     self.fbind("size", image.setter("size"))
     self.add_widget(image)
     self._ratio = aspect_ratio
     self.width = self.height * self._ratio
     self.size_hint = None, None
     self.register_event_type("on_double_tap")
     self.register_event_type("on_card_moved")
     self._check_aspect_ratio = True
     # noinspection PyUnreachableCode
     if __debug__:
         self.fbind("size", self._assert_aspect_ratio)
Beispiel #2
0
    def build(self):

        main_layout = BoxLayout(padding=(10, 0), orientation="vertical")

        wimg = Image(source='s.png')
        wimg.allow_stretch = True
        wimg.keep_ratio = False
        wimg.size_hint_x = 1
        wimg.size_hint_y = 0.2

        scroll_container = BoxLayout(orientation="vertical",
                                     size_hint=(1, 0.90))
        self.layout = BoxLayout(padding=(15, 10),
                                orientation="vertical",
                                spacing=50,
                                size_hint_y=None)
        self.layout.bind(minimum_height=self.layout.setter('height'))

        colors = [red, green, blue, purple]

        root = ScrollView(size_hint=(1, None),
                          size=(Window.width, Window.height * 0.70))

        root.add_widget(self.layout)

        bottom_layout = BoxLayout(padding=10,
                                  orientation="horizontal",
                                  size_hint=(1, 0.1))

        self.textinput = TextInput(hint_text="Say something ",
                                   background_color=random.choice(colors),
                                   size_hint=(0.8, 1))

        btn3 = Button(text="Send",
                      background_color=random.choice(colors),
                      size_hint=(0.2, 1))

        btn3.bind(on_press=self.sent)

        bottom_layout.add_widget(self.textinput)
        bottom_layout.add_widget(btn3)

        scroll_container.add_widget(root)
        main_layout.add_widget(wimg)
        main_layout.add_widget(scroll_container)
        main_layout.add_widget(bottom_layout)
        Window.bind(on_key_down=self.on_key_down)

        btn = Label(padding=(0, 0),
                    text="Bot> " + random.choice(ice_breakers),
                    color=(1, 0, 1, 1),
                    size_hint=(1.0, 1.0),
                    halign="left",
                    valign="middle")
        btn.bind(size=btn.setter('text_size'))

        self.layout.add_widget(btn)

        return main_layout
    def handleGoal(self):
        def go_next_callback(instance):
            self.popup.dismiss()
            main.switchLevel()
            return False
            
        if self.isToolOnGoal and self.isPersonOnGoal:
            if self.activeTool.isGoal and self.activePerson.isGoal:
                print "FINISHED? ",isFinished
                while not isFinished: #notwendig, weil sonst 2 mal aufgerufen (touch_events feuern alle 2 mal)
                    global isFinished
                    isFinished = True
                    
                    btnBGSource = ''
                         
                    if currentLevel <= len(levels)-1:
                        btnBGSource = unichr(61518)
                    else:
                        btnBGSource = unichr(61470)
                                           
                    box = AnchorLayout(size_hint=(1, 1), anchor_x= "right", anchor_y= "bottom")     
                    btn = Button(font_size=100, font_name= 'res/fontawesome-webfont.ttf', text=btnBGSource, background_color = [0,0,0,0.7])
                    btn.bind(on_press=go_next_callback)
                    
                    #vid = Video(source=self.levelInfos[levelProps[3]], play=True)                    
                    #box.add_widget(vid)
                    
                    #instead of laggy video insert just an image
                    img = Image(source=self.levelInfos[levelProps[3]])
                    img.allow_stretch = True
                    box.add_widget(img)
                    imgBtn = Button(font_size=60, font_name= 'res/fontawesome-webfont.ttf', text=btnBGSource, background_color = [0,0,0,0], size_hint= (0.15, 0.15))
                    imgBtn.bind(on_press=go_next_callback)
                    box.add_widget(imgBtn)
                    
                    def end_of_vid(video, eos):
                        logging.info("endofvid")
                        #video.play=False #not working on android...
                        box.add_widget(btn)
                        #video.unload() #not working on android...
                        #logging.info("video unloaded")
                        
                    def showit():
                        print "showing video popup"
                        self.popup.open()
                        if self.winSound:
                            self.winSound.play()

                    #vid.bind(loaded=lambda foo,bar: showit())
                    #vid.bind(eos=lambda video,eos:end_of_vid(video,eos))
                                                                          
                         
                    self.popup = Popup(content=box,size_hint=(0.8, 0.7),auto_dismiss=False)
                    
                    self.hidePopupTitle(self.popup)
                    
                    showit()
                    Clock.schedule_once(lambda wumpe:box.add_widget(btn), 8)
Beispiel #4
0
def get_background(picture_path='pictures/background_bigger.png'):
    """
    Set and return full screen Image background
    :return:
    """
    bckg_image = Image(source=picture_path)
    bckg_image.allow_stretch = True
    bckg_image.size = Window.size
    return bckg_image
Beispiel #5
0
    def __init__(self, name):
        super(Galerija, self).__init__()

        self.name = name
        # DISPLAY
        path = os.path.dirname(os.path.abspath(__file__))
        img = Image(source=os.path.join(path, "128.png"), nocache=True)
        img.allow_stretch = False
        Clock.schedule_interval(lambda dt: img.reload(), 0.2)
        self.add_widget(img)
Beispiel #6
0
 def resimleriEkle(self, dosyalar):
     self.root.ids.karinca.clear_widgets()
     for dosya in dosyalar:
         if os.path.isfile(dosya):
             if imghdr.what(dosya):
                 resim=Image(source=dosya)
                 resim.allow_stretch=True
                 resim.keep_ratio=False
                 self.root.ids.karinca.add_widget(resim)
 
     if self.root.ids.karinca.slides:
         self.root.ids.slyat_dugme.disabled=False
     else:
         self.root.ids.slyat_dugme.disabled=True
Beispiel #7
0
    def resimleriEkle(self, dosyalar):
        self.root.ids.karinca.clear_widgets()
        for dosya in dosyalar:
            if os.path.isfile(dosya):
                if imghdr.what(dosya):
                    resim = Image(source=dosya)
                    resim.allow_stretch = True
                    resim.keep_ratio = False
                    self.root.ids.karinca.add_widget(resim)

        if self.root.ids.karinca.slides:
            self.root.ids.slyat_dugme.disabled = False
        else:
            self.root.ids.slyat_dugme.disabled = True
	def placeWorldItems(self):
		for each in requiredItems:
			x = Image(source=self.resource_path('artAssets/{}.png'.format(each)))
			x.allow_stretch = True
			x.keep_ratio = True
			x.size_hint = (.03,.03)
			if(allWorldItems[each] in lightWorldLocations):
				x.pos_hint = {'center_x':lightWorldLocations[allWorldItems[each]][0],'center_y':lightWorldLocations[allWorldItems[each]][1]}
				x.text = '{}:{}'.format(each, allWorldItems[each])
				x.reload()
				self.ids.lightScatter.add_widget(x,0)
			elif(allWorldItems[each] in darkWorldLocations):
				x.pos_hint = {'center_x':darkWorldLocations[allWorldItems[each]][0],'center_y':darkWorldLocations[allWorldItems[each]][1]}
				x.reload()
				self.ids.darkScatter.add_widget(x,0)
			else:
				pass
Beispiel #9
0
	def move_to_exhibit(self, dt=0, index=None):
		if index is None:
			index = self.currentindex

		data = self.exhibits[index]
		label = Label(text=data['description'], font_size=self.root.ids.MainButton.font_size)
		label.size_hint_y = 0.3
		image = Image(source=data['visualurl'], scale=2)
		image.allow_stretch = True
		self.show(label, image)

		reqstring = HOST + '?' + str(data['x']) + '&' + str(data['y']) + '&' + str(data['phi'])
		req = UrlRequest(reqstring)

		sleep(int((int(data['x']) ** 2 + int(data['y']) ** 2) ** 0.5 / float(SPEED)))
		self.sound = SoundLoader.load(data['audiourl'])
		self.sound.play() 
		Clock.schedule_once(self.scheduler, self.sound.length + 7)
Beispiel #10
0
    def __init__(self, scatter, root):
        self.scatter = scatter
        self.root = root
        self.current_popup_menu = 0
        try:
            with open(main_page.file_dir + main_page.file_name, 'r') as f:
                self.obstacle_list = json.load(f)
                for obstacle in self.obstacle_list['obstacle_list']:
                    image = Image(source=main_page.icon_dir +
                                  obstacle['image'],
                                  size=obstacle['size'][:2])
                    image.center_x = obstacle['position'][0]
                    image.center_y = obstacle['position'][1]
                    image.allow_stretch = True
                    image.size_hint = None, None
                    self.scatter.add_widget(image, index=1)

                    OBSTACLE_IMAGE[obstacle['id']] = image
        except Exception, e:
            self.obstacle_list = {"obstacle_list": []}
    def __init__(self, **kwargs):
        super(RootWidget, self).__init__(**kwargs)

        if bHooking:
            print "bHooking is true"
            self.hm = hooklib.HookManager()
            print "HookManager set to self.hm"
            self.hm.HookKeyboard()
            self.hm.KeyDown = self.OnKeyDownEvent
            self.hm.start()

        self.photos = []
        self.shown = []
        self.photos = glob.glob(strDir + "*.jpg")
        global intCount
        #global sngInterval
        intCount = len(self.photos)
        strImage = random.choice(self.photos)
        img = Image(source=strImage, id='MainImage')
        img.nocache = True
        #img.canvas.color = (1, 1, 1)
        #Turn on allow_stretch to upscale smaller images to fullscreen
        img.allow_stretch = True
        
        self.add_widget(img)

        if True:
            cb = CustomBtn(size_hint=(1,1), font_size=strFontSize)
            cb.bind(pressed=self.btn_pressed)
            #cb.text = 'This is a test.'
            cb.id = 'MainButton'
            cb.bind(texture_size=cb.setter('size'))
            cb.bind(size=cb.setter('text_size')) 
            self.add_widget(cb)
        
        self.show_next_image()
        if not bReschedule:
            Clock.unschedule(self.show_next_image)
            Clock.schedule_interval(self.show_next_image, sngInterval)
        if bUseLCD:
            Clock.schedule_interval(self.CheckLCD, 0.1)
 def showInitialHelp(self):        
     def go_next_callback(instance):
         self.ids.popupanchor.remove_widget(self.helpPopup)
         return False
     
     box = AnchorLayout(size_hint=(1, 1), anchor_x= "right", anchor_y= "bottom")
     
     img = Image(source='res/help.zip')
         
     img.anim_delay= 0.05
     box.add_widget(img)
     skipBtn = Button(font_size=80, font_name= 'res/fontawesome-webfont.ttf',markup=True, text='[color=49E449]'+unichr(61764)+'[/color]', background_color = [0,0,0,0], size_hint= (0.2, 0.2))
     skipBtn.bind(on_press=go_next_callback)
     box.add_widget(skipBtn)
     
     self.helpPopup = Popup(content=box,size_hint=(0.8, 0.7),auto_dismiss=False)
     self.hidePopupTitle(self.helpPopup)
     
     self.ids.popupanchor.add_widget(self.helpPopup)
     self.helpPopup.open()
     img.size=self.ids.popupanchor.size
     img.allow_stretch = True
Beispiel #13
0
 def __init__(self, **kwargs):
     super(RootWidget, self).__init__(**kwargs)
     self.photos = []
     self.shown = []
     self.photos = glob.glob(strDir + "*.jpg")
     global intCount
     #global sngInterval
     intCount = len(self.photos)
     strImage = random.choice(self.photos)
     img = Image(source=strImage, id='MainImage')
     #Turn on allow_stretch to upscale smaller images to fullscreen
     img.allow_stretch = True
     self.add_widget(img)
     cb = CustomBtn(size_hint=(1,1), font_size=strFontSize)
     cb.bind(pressed=self.btn_pressed)
     #cb.text = 'This is a test.'
     cb.id = 'MainButton'
     cb.bind(texture_size=cb.setter('size'))
     cb.bind(size=cb.setter('text_size')) 
     self.add_widget(cb)
     self.next_image()
     if not bReschedule:
         Clock.schedule_interval(self.next_image, sngInterval)
Beispiel #14
0
    def conn(self, dt):
        try:
            post
            getnode
        except:
            from uuid import getnode
            from requests import post
        try:
            ip = str(getnode())
            url = "http://10.0.0.109:5000/register"
            json = {"user_ip": ip, "user_resoluction": "1280x299"}
            headers = {"Content-Type": "application/json"}
            response = post(
                url=url, json=json, headers=headers,
                verify=True)  # envia token + json ignorando SSl(certificado)
            self.text = str(response.json())
        except:
            print("timeout")
            try:
                Clock
            except:
                from kivy.clock import Clock
            Clock.schedule_once(self.conn, 6)
        else:
            '''main_layout_title = Label(text="Fight Battle", font_name="source/font/mv-boli.ttf", color=(0, 0, 0, 1),
                                      size_hint=(0.23, 0.3), font_size=sp(82 * Window.size[1] / 600))
            main_layout_title.pos_hint = {"x": 0.523 - (main_layout_title.size_hint_x / 2), "y": 0.653}'''

            main_layout_btn_jogar_image = Image(
                source="source/img/bg_botao.jpg",
                size_hint=(.255, .109),
                allow_stretch=True,
                keep_ratio=False)
            main_layout_btn_opcoes_image = Image(
                source="source/img/bg_btn_opcoes.jpg",
                size_hint=(.255, .109),
                allow_stretch=True,
                keep_ratio=False)

            main_btn_jogar = Button(text="jogar",
                                    opacity=0.0,
                                    size_hint=(.255, .109),
                                    on_press=main.jogar)
            main_layout_btn_jogar_image.pos_hint = main_btn_jogar.pos_hint = {
                "x": 0.522 - float(main_btn_jogar.size_hint_x / 2),
                "y": 0.415
            }

            main_btn_opcao = Button(text="opções",
                                    opacity=0.0,
                                    size_hint=(.255, .109),
                                    on_press=main.opcoes)
            main_layout_btn_opcoes_image.pos_hint = main_btn_opcao.pos_hint = {
                "x": 0.522 - float(main_btn_opcao.size_hint_x / 2),
                "y": 0.29
            }

            main_image = Image(source="source/img/tela_bg.jpg")
            main_image.allow_stretch = True
            main_image.keep_ratio = False
            main_layout = FloatLayout()
            main_layout.add_widget(main_image)
            main_layout.add_widget(main_layout_btn_jogar_image)
            main_layout.add_widget(main_layout_btn_opcoes_image)
            main_layout.add_widget(main_btn_jogar)
            main_layout.add_widget(main_btn_opcao)
            #main_layout.add_widget(main_layout_title)
            main.add_widget(main_layout)
            screen_manager.current = "main"
Beispiel #15
0
    def on_touch_down(self, touch):

        print "TOUCH", touch.pos

        if main_page.current_obstacle == {}:
            return

        x, y = touch.pos
        image = Image(source=main_page.icon_dir +
                      main_page.current_obstacle['Image'],
                      size=main_page.current_obstacle['Initial_Size'][:2])
        image.center_x = touch.pos[0]
        image.center_y = touch.pos[1]
        image.size_hint = None, None
        image.allow_stretch = True
        print type(self.root)
        print self.root.pos, self.root.size
        if self.root.pos[0] + image.width / 2 <= x and x <= self.root.pos[
                0] + self.root.size[0] - image.width / 2:
            if self.root.pos[1] + image.height / 2 <= y and y <= self.root.pos[
                    1] + self.root.size[1] - image.height / 2:
                not_collision, collide_obstacle = collision_detect(
                    self.obstacle_list, image, touch.pos)

                if check_button_clicked(self.root, self.current_popup_menu,
                                        touch.pos):
                    if self.current_popup_menu != 0:
                        for item in self.current_popup_menu:
                            self.root.remove_widget(item)
                        self.current_popup_menu = 0

                elif not_collision:
                    if self.current_popup_menu != 0:
                        for item in self.current_popup_menu:
                            self.root.remove_widget(item)
                        self.current_popup_menu = 0

                    self.scatter.add_widget(image, index=1)
                    obstacle = {}
                    obstacle['title'] = main_page.current_obstacle['Name']
                    obstacle['position'] = touch.pos
                    obstacle['size'] = main_page.current_obstacle[
                        'Initial_Size']
                    obstacle['image'] = main_page.current_obstacle['Image']
                    obstacle['id'] = hashlib.sha256(
                        str(touch.pos[0]) + str(touch.pos[1])).hexdigest()
                    OBSTACLE_IMAGE[obstacle['id']] = image
                    self.obstacle_list['obstacle_list'].append(obstacle)
                    with open(main_page.file_dir + main_page.file_name,
                              'w') as f:
                        json.dump(self.obstacle_list, f)

                else:
                    if self.current_popup_menu != 0:
                        for item in self.current_popup_menu:
                            self.root.remove_widget(item)
                        self.current_popup_menu = 0

                    menu = []

                    for idx in range(NUM_MENU):
                        tmp_btn = Button(text="Delete",
                                         background_color=(0x81, 0xd4, 0xfa),
                                         size_hint=(.1, .1))
                        tmp_btn.pos = [
                            touch.pos[0], touch.pos[1] - tmp_btn.size[1] -
                            idx * tmp_btn.size[1]
                        ]
                        tmp_btn.id = collide_obstacle['id'] + "," + str(idx)
                        print tmp_btn.id
                        menu.append(tmp_btn)
                    self.current_popup_menu = menu

                    for item in menu:
                        self.root.add_widget(item)