def _addButton(self, parent, name, source, size, pos, action_func, on_top=False):
     button = Image(source=source)
     button.size = size
     button.on_top = on_top
     button.pos = pos
     button.scale = 1.
     button.rotation = 0.
     button.action = action_func
     button.name = name
     self.objects.update({name: {'obj': button}})
     parent.add_widget(button)
     
     return button
Exemple #2
0
	def on_touch_down(self, touch):
		userdata = touch.ud
		(w, h) = Window.size
		sc = max(float(w)/FSW,float(h)/FSH)
		# start collecting points in touch.ud
		self.canvas.clear
		gimg = Image(source=GOAL_IMG)
		self.add_widget(gimg)
		bimg = Image(source=BALL_IMG)
		self.add_widget(bimg)
		(xpos, ypos) = (int(touch.x)-w/2, int(touch.y)-h/2)
		bimg.size = (10,10) #(int(60.0*sc), int(60.0*sc))
		bimg.pos = (xpos, ypos)
		#print '{0} and {1}'.format(float(w)/FSW,float(h)/FSH) 2115
		#print sc
		print '{0} and {1}'.format(touch.x, touch.y)
		#print '{0} and {1}'.format(xpos, ypos)
		if touch.x > FSW/20 and touch.x < w-FSW/20 and touch.y > h*0.2 and touch.y < h*0.88:
			print "GOAL!"
			mimg = Image(source=MSG_IMG)
			self.add_widget(mimg)
		#with self.canvas:
			#Color(1, 1, 1)
			#d = 60.
			#Ellipse(pos=(touch.x - d/2, touch.y - d/2), size=(d, d))
		return True
Exemple #3
0
 def __init__(self, side="right", **kwargs):
     super(TrashCan, self).__init__(**kwargs)
     self.opacity = 0.5
     if side == "top":
         self.size_hint = 1, None
         self.height = self.img_size
         self.pos_hint = {"x": 0, "y": 1}
     elif side == "bottom":
         self.size_hint = 1, None
         self.height = self.img_size
         self.pos_hint = {"x": 0, "y": 0}
     elif side == "right":
         self.orientation = "vertical"
         self.size_hint = None, 1
         self.width = self.img_size
         self.pos_hint = {"x": 1, "y": 0}
     elif side == "left":
         self.orientation = "vertical"
         self.size_hint = None, 1
         self.width = self.img_size
         self.pos_hint = {"x": 0, "y": 0}
     b1 = BoxLayout()
     img = Image(source="trashcan.png")
     img.size = self.img_size, self.img_size
     img.size_hint = None, None
     b2 = BoxLayout()
     self.add_widget(b1)
     self.add_widget(img)
     self.add_widget(b2)
    def on_labels(self, instance, value):
        self.reset()
        image_view = self.ids.image_view

        for i, label in enumerate(value):
            # Make an image for this mask
            image = Image(source="", keep_ratio=True, allow_stretch=True)
            imgIO = io.BytesIO()
            mask_img = np.zeros((*label.mask.shape, 4))
            mask_img[:, :, :3] = np.array(
                PAINTBRUSH_COLORS[i % len(PAINTBRUSH_COLORS)])
            mask_img[:, :,
                     3] = np.where(np.isnan(label.mask), 0.0, label.mask) * 0.6
            pil_img = PILImage.fromarray(
                (mask_img * 255).astype(np.uint8),
                mode='RGBA').resize(image_view.image_size)
            pil_img.save(imgIO, format='png')
            imgIO.seek(0)
            imgData = io.BytesIO(imgIO.read())
            image.texture = CoreImage(imgData, ext='png').texture
            image.reload()

            self.ids.paintbrush_parent.add_widget(image)
            self.paintbrushes.append(image)
            image.pos = self.ids.paintbrush_parent.pos
            image.size = self.ids.paintbrush_parent.size

            for center, stroke in zip(label.centers, label.strokes):
                # Label
                center = image_view.convert_point_from_image(center)
                lw = Label(pos=(int(center[0] + self.ids.label_parent.pos[0]),
                                int(center[1] + self.ids.label_parent.pos[1])),
                           text=label.label)
                self.label_widgets.append(lw)
                self.ids.label_parent.add_widget(lw)
Exemple #5
0
    def __init__(self, **kwargs):
        super(AboutScreen, self).__init__(**kwargs)

        layout = FloatLayout()
        layout.width = Window.width
        layout.height = Window.height
        layout.x = Window.width / 2 - layout.width / 2
        layout.y = Window.height / 2 - layout.height / 2
        self.add_widget(layout)

        img = Image(source=self.aboutImage)
        img.size = (Window.width * 1.0, Window.height * 1.0)
        img.pos = (-Window.width * 0.0, -Window.height * 0.0)
        img.opacity = 0.4
        self.add_widget(img)

        aboutText = Label(
            text=
            'GravBox is the interface application for the Augmented Reality (AR) Sandbox for gravitational dynamics simulations designed and built\nby Dr. Hai Fu\'s Introduction to Astrophysics class during the 2016-2017 academic year and beyond.\nGravBox itself was designed by Zachary Luppen, Erin Maier, and Mason Reed.\n\nAR Sandbox is the result of an NSF-funded project on informal science education for freshwater lake and watershed science developed by the\nUC Davis\' W.M. Keck Center for Active Visualization in the Earth Sciences (KeckCAVES),\ntogether with the UC Davis Tahoe Environmental Research Center, Lawrence Hall of Science, and ECHO Lake Aquarium and Science Center.',
            halign='center',
            valign='center')
        aboutText.pos = (.25, .25)
        self.add_widget(aboutText)

        backBtn = MyButton(text='BACK')  # back button
        backBtn.size_hint = (.1, .1)
        backBtn.pos_hint = {'x': 0, 'y': .90}
        backBtn.background_color = [.4, .4, .4, 1]
        backBtn.bind(
            on_release=self.backButton
        )  #when the button is released the callback function is called
        self.add_widget(backBtn)
Exemple #6
0
	def __init__(self, team, next = False, **kwargs):
		super(crestButton,self).__init__(**kwargs)

		self.team = team
		self.size_hint = (None,None)
		self.size = (90,90)

		if next == True:
			self.background_normal = './data/images/crest_'+team['name']+'.png'
			self.background_down = './data/images/crest_'+team['name']+'.png'
		else:
			self.background_normal = './data/images/crest_'+team['name']+'_no.png'
			self.background_down = './data/images/crest_'+team['name']+'_no.png'

		position_list = [(-48+180-45,150+320-45),(48+180-45,150+320-45), (-48+180-45,56+320-45), (48+180-45,56+320-45)]
		self.pos = position_list[g.save.tournament['teams'].index(team)]

		if team['result'] is not '':
			sign = Image(source='./data/images/crest-marker-'+team['result']+'.png')
			sign.size_hint = (None,None)
			sign.size = (90,90)
			sign.pos = position_list[g.save.tournament['teams'].index(team)]
			self.add_widget(sign)

		self.bind(on_release = self.crest_click)
Exemple #7
0
def get_module_resource_path(file_name, size, resource_package=__name__):
    import os
    regex = re.compile(
        r'^(?:http|ftp)s?://'  # http:// or https://
        r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|'  # domain...
        r'localhost|'  # localhost...
        r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'  # ...or ip
        r'(?::\d+)?'  # optional port
        r'(?:/?|[/?]\S+)$',
        re.IGNORECASE)

    if regex.match(file_name) or os.path.isfile(file_name):
        image = Image(source=file_name)
    else:
        __requires__ = ["CherryPy < 3"
                        ]  # Must be set before pkg_resources import
        import pkg_resources
        resource_path = '/' + file_name

        reader = pkg_resources.resource_stream(resource_package, resource_path)
        if reader:
            stream = io.BytesIO(reader.read())
        _, file_extension = os.path.splitext(file_name)

        im = CoreImage(stream, ext=file_extension[1:])

        image = Image(source="")
        image.texture = im.texture
        image.reload()
        image.size = size
    return image
Exemple #8
0
    def __init__(self, **kwargs):
        super(Note, self).__init__(**kwargs)
        self.opacity = 0
        #Show
        anim = Animation(opacity=1.0, duration=0.3)
        anim.start(self)
        create_image = kwargs.get('create_image', False)

        self.request_del = False
        text_editor = TextInput(size=(120, 90))
        close = Button(size=(20, 20), text="x")
        image = Image(source="./data/imgs/background.jpg",
                      allow_stretch=True,
                      keep_ratio=False)

        self.add_widget(image)
        self.add_widget(text_editor)
        self.add_widget(close)

        if create_image:
            image_front = Image(source="./data/imgs/faust_github.jpg",
                                size=(120, 70),
                                allow_stretch=True,
                                keep_ratio=False)
            self.add_widget(image_front)

        self.size = (120, 120)
        self.size_hint = (None, None)
        image.size = (120, 120)
        text_editor.pos = (0, 10)
        close.pos = (100, 100)
        self.pos = kwargs.get('pos', (100, 400))

        close.bind(on_release=self.close_request)
Exemple #9
0
    def __init__(self, **kwargs):
        super(UiowaScreen, self).__init__(**kwargs)

        layout = FloatLayout()
        layout.width = Window.width
        layout.height = Window.height
        layout.x = Window.width / 2 - layout.width / 2
        layout.y = Window.height / 2 - layout.height / 2
        self.add_widget(layout)

        img = Image(source=self.uiowaImage)
        img.size = (Window.width * 1.0, Window.height * 1.0)
        img.pos = (-Window.width * 0.0, -Window.height * 0.0)
        img.opacity = 0.4
        self.add_widget(img)

        aboutText = Label(text='UIOWA INFO HERE')
        aboutText.pos = (.25, .25)
        self.add_widget(aboutText)

        backBtn = MyButton(text='BACK')  #start button
        backBtn.size_hint = (.1, .1)
        backBtn.pos_hint = {'x': 0, 'y': .9}
        backBtn.background_color = [.4, .4, .4, 1]
        backBtn.bind(
            on_release=self.backButton
        )  #when the button is released the backButton function is called
        layout.add_widget(backBtn)
Exemple #10
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
    def initialize_background_image(self, width, height):
        background_image = Image(source="dashboard/serpent.png")

        background_image.size = (height, height)
        background_image.opacity = 0.1
        background_image.pos = ((width / 2) - (height / 2),
                                self.size[1] - height)

        self.add_widget(background_image)
    def __init__(self, name, offset):
        super().__init__()

        player = Image(
            source=f'../../res/characters/{name}/{name}_preview.png',
            keep_ratio=False,
            allow_stretch=True)
        player.size = (200, 200)
        player.pos = (200 + offset, 45)

        self.add_widget(player)

        frame = Image(
            source=
            '../../res/uix/screens/dungeon_battle/special_background.png',
            keep_ratio=False,
            allow_stretch=True)
        frame.size = (200, 220)
        frame.pos = (200 + offset, 25)
        self.add_widget(frame)

        health = Image(
            source=
            '../../res/uix/screens/dungeon_battle/special_background.png',
            keep_ratio=False,
            allow_stretch=True)
        health.size = (200, 220)
        health.pos = (200 + offset, 25)
        self.add_widget(health)

        mana = Image(
            source=
            '../../res/uix/screens/dungeon_battle/special_foreground.png',
            keep_ratio=False,
            allow_stretch=True)
        mana.size = (200, 220)
        mana.pos = (200 + offset, 25)
        self.add_widget(mana)

        self.node = LWFNode.create('../../res/lwf/character_active.lwf')
        self.node.pos = (300 + offset, 145)
        self.node.lwf.scale_for_width(10 * 200 / 180, 10 * 200 / 180)
        self.add_widget(self.node)
Exemple #13
0
    def __init__(self, **kwargs):
        super(AboutScreen, self).__init__(**kwargs)

        self.layout = FloatLayout()
        self.layout.width = Window.width
        self.layout.height = Window.height
        self.layout.x = 0
        self.layout.y = 0
        self.add_widget(self.layout)

        img = Image(source=self.aboutImage)
        img.size = (Window.width * 1.0, Window.height * 1.0)
        img.pos = (0, 0)
        img.opacity = .8
        self.add_widget(img, 1)

        with self.layout.canvas:  #sets canvas instructions for the rightlayout
            Color(1, 1, 1, .7)  #BLUE
            Rectangle(pos=(.05 * self.layout.height, .05 * self.layout.height),
                      size=(.45 * self.layout.width, .9 * self.layout.height))

        group = Image(source=self.groupPhoto)
        group.size_hint = (.5, .5)
        group.pos = (Window.width * .49, Window.height * .37)
        self.add_widget(group)

        nameLabel = Label(
            text=
            'From left to right: Jianbo Lu, Jacob Isbell, Sophie Deam, Wyatt Bettis, Ross McCurdy, Erin Maier, Sadie Moore, Zachary Luppen, Mason Reed',
            text_size=(.45 * self.layout.width, .3 * self.layout.height),
            halign='center',
            font_size='18sp',
            color=(0, 0, 0, 1))
        nameLabel.pos = (Window.width * .24, Window.height * -.10)
        self.add_widget(nameLabel)

        aboutText = Label(
            text=
            'GravBox is the interface application for the Augmented Reality (AR) Sandbox for gravitational dynamics simulations designed and built at the University of Iowa by Dr. Hai Fu\'s 2016-2017 Introduction to Astrophysics class. \n\nThe GravBox application was developed by Zachary Luppen, Erin Maier, and Mason Reed. The sandbox was designed and built by Wyatt Bettis, Ross McCurdy, and Sadie Moore. The gravitational algorithm was written by Sophie Deam, Jacob Isbell, and Jianbo Lu. Graphic design was contributed by Jeremy Swanston. \n\nThe original AR Sandbox is the result of an NSF-funded project on informal science education for freshwater lake and watershed science developed by the UC Davis\' W.M. Keck Center for Active Visualization in the Earth Sciences, together with the UC Davis Tahoe Environmental Research Center, Lawrence Hall of Science, and ECHO Lake Aquarium and Science Center.\n\n To learn more about the GravBox project, contact Hai Fu at [email protected], or visit our Github at https://github.com/GravBoxInterface/GravBox',
            valign='middle',
            halign='center',
            font_size='19sp',
            text_size=(.4 * self.layout.width, None),
            color=(0, 0, 0, 1))
        aboutText.pos = (-.39 * self.layout.height, 0)
        self.add_widget(aboutText)

        backBtn = MyButton(text='BACK')  # back button
        backBtn.size_hint = (.1, .1)
        backBtn.pos_hint = {'x': .69, 'y': .12}
        backBtn.background_color = [.4, .4, .4, 1]
        backBtn.bind(
            on_release=self.backButton
        )  #when the button is released the callback function is called
        self.add_widget(backBtn)
Exemple #14
0
    def update_text(self, i):
        self.y = self.height * i

        ans = self.answer
        if ans.is_img:
            img = Image(source=ans.img_path)
            img.pos = self.pos
            img.size = self.size
            self.add_widget(img)
        else:
            self.text = ans.text
Exemple #15
0
    def question(self, que):
        self.restore_default()

        self._question = que
        if que.is_img:
            img = Image(source=que.img_path)
            img.pos = self.pos
            img.size = self.size
            self.add_widget(img)
        else:
            self.text = que.text
Exemple #16
0
    def IMAG(self):
        layout = RelativeLayout()
        widget3 = Widget()
        img2 = Image()
        img2.source = "img/text.png"
        x, y = 130, 370
        img2.pos = x + self.xo, y - 420 + self.yo
        img2.size = 300, 680

        widget3.add_widget(img2)
        self.widget1.add_widget(widget3)
Exemple #17
0
    def on_launch_cannon_ball(self, ship):
        x, y = ship.shape.pos
        cannon_ball = Image(source=IMAGES_PATH.format('cannon_ball.png'),
                            pos=(x + 50, y + 50))
        cannon_ball.size = cannon_ball.texture_size

        self.add_widget(cannon_ball)
        arc_animation = Animation(x=10, y=475, d=3)
        arc_animation.bind(on_complete=self.on_cannon_ball_complete)
        arc_animation.start(cannon_ball)

        return True
Exemple #18
0
    def IMAG2(self):
        layout = RelativeLayout()
        widget4 = Widget()
        img2 = Image()
        img2.source = "img/text.png"
        x, y = 140, -250
        img2.pos = x, y
        img2.size = 300, 680

        widget4.add_widget(img2)
        layout.add_widget(widget4)
        self.widget1.add_widget(layout)
Exemple #19
0
    def my_callback(screen, dt):
         global timeCountdown
         global pictureCounter
         timeCountdown = timeCountdown-1
         screen.ids.hsCountdown.text = str(timeCountdown)
         screen.ids.hsLabel.color = [1, 1, 0, 0] # black it out
         screen.ids.hsButton.color = [1, 1, 0, 0] # black it out
         screen.ids.hsButton.background_color = [1, 1, 0, 0] # black it out
         Logger.info(str(timeCountdown)) #screen.ids.hsDebug1.text = screen.ids.hsDebug1.text + str(timeCountdown)
         if (timeCountdown == 0):
              # start a new thread with the actual capturing process
             Thread(target=screen.captureImageThread, args=(screen.camera,screen.inspectImage,)).start()
             screen.ids.hsCountdown.text = ""
             timeCountdown = 5
#             screen.run_command('gphoto2 --camera "Canon EOS 60D" --capture-and-download --filename "hallo.jpg"')
              #screen.ids.hsDebug1.text = screen.ids.hsDebug1.text + str(cmd)	
             if (pictureCounter == 4):
                 preview04 = Image(source='preview04.jpg')
                 preview04.size = (400,240)
                 preview04.pos = (0,240)
                 screen.add_widget(preview04, 100)
                 Clock.unschedule(screen.my_callback)
             if (pictureCounter == 3): 
                 preview03 = Image(source='preview03.jpg')
                 preview03.size = (400,240)
                 preview03.pos = (400,0)
                 screen.add_widget(preview03, 100) # TODO move to layer 100
                 pictureCounter = 4
             if (pictureCounter == 2):
                 preview02 = Image(source='preview02.jpg')
                 preview02.size = (400,240)
                 preview02.pos = (0,0)
                 screen.add_widget(preview02, 100) # TODO move to layer 100
                 pictureCounter = 3
             if (pictureCounter == 1):
                 preview01 = Image(source='preview01.jpg')
                 preview01.size = (400,240)
                 preview01.pos = (400,240)
                 screen.add_widget(preview01, 100)
                 pictureCounter = 2
Exemple #20
0
 def Label2(self):
     widget3 = Widget()
     img2 = Image()
     img2.source = "img/text.png"
     x, y = 130, 370
     img2.pos = x + self.xo, y - 160 + self.yo
     img2.size = 300, 500
     lbl2 = Label()
     lbl2.pos = x + 90 + self.xo, y + 40 + self.yo
     lbl2.text = "            " + 'HACK-VISION DEMO\n                 Recibe GPS \n' + "          " + '      Blueetooth '
     widget3.add_widget(img2)
     widget3.add_widget(lbl2)
     self.widget1.add_widget(widget3)
Exemple #21
0
 def Label2(self):
     widget3 = Widget()
     img2 = Image()
     img2.source = "img/text.png"
     x, y = 130, 370
     img2.pos = x + self.xo, y - 160 + self.yo
     img2.size = 300, 500
     lbl2 = Label()
     lbl2.pos = x + 90 + self.xo, y + 40 + self.yo
     lbl2.text = "            " + 'HACK-VISION DEMO\n CLIENTE BLUETOOTH  ENVIO\n' + "          " + '            GPS'
     widget3.add_widget(img2)
     widget3.add_widget(lbl2)
     self.widget1.add_widget(widget3)
Exemple #22
0
 def Label2(self):
     widget3 = Widget()
     img2 = Image()
     img2.source = "img/text.png"
     x, y = 50, 330
     img2.pos = x, y - 160
     img2.size = 300, 500
     lbl2 = Label()
     lbl2.pos = x + 90, y + 40
     lbl2.font_size = '18dp'
     lbl2.text = "   " + 'FReePS DEMO\n        Diego Alberto Parra  \n' + "          " + '             Bogota D.C.'
     widget3.add_widget(img2)
     widget3.add_widget(lbl2)
     Mprincipal.add_widget(widget3)
Exemple #23
0
    def __init__(self, **kwargs):
        super(UiowaScreen, self).__init__(**kwargs)

        self.layout = FloatLayout()
        self.layout.width = Window.width
        self.layout.height = Window.height
        self.layout.x = 0
        self.layout.y = 0
        self.add_widget(self.layout)

        img = Image(source=self.uiowaImage)
        img.size = (Window.width * 1.0, Window.height * 1.0)
        img.pos = (0, 0)
        img.opacity = .8
        self.add_widget(img, 1)

        with self.layout.canvas:  #sets canvas instructions for the rightlayout and draws a blue rect. filling the entire layout
            Color(1, 1, 1, .7)  #WHITE
            Rectangle(pos=(.15 * self.layout.height, .30 * self.layout.height),
                      size=(.45 * self.layout.width, .55 * self.layout.height))

        qr = Image(source=self.qrCode)
        qr.size_hint = (.39, .39)
        qr.pos_hint = {'x': .56, 'y': .12}
        self.add_widget(qr)

        logo = Image(source=self.uiLogo)
        logo.size_hint = (.33, .33)
        logo.pos_hint = {'x': .59, 'y': .58}
        self.add_widget(logo)

        uiowaText = Label(
            text=
            'The GravBox project is the result of the hard work of students of the University of Iowa\'s Physics and Astronomy Department. To learn more about physics and astronomy at the University of Iowa, and the research work being done in these areas, please scan the QR code to the right.',
            valign='middle',
            halign='center',
            font_size='24sp',
            text_size=(.4 * self.layout.width, None),
            color=(0, 0, 0, 1))
        uiowaText.pos_hint = {'x': -.18, 'y': .075}
        self.add_widget(uiowaText)

        backBtn = MyButton(text='BACK')  # back button
        backBtn.size_hint = (.1, .1)
        backBtn.pos_hint = {'x': .27, 'y': .16}
        backBtn.background_color = [.4, .4, .4, 1]
        backBtn.bind(
            on_release=self.backButton
        )  #when the button is released the callback function is called
        self.add_widget(backBtn)
Exemple #24
0
 def show_slip(self, *args):
     if not self.backend.book_obj.has_slip():
         return
     slip_image = Image(source=self.backend.book_obj.get_slip(full_path=True),
                        size_hint=(None, None),
                        allow_stretch=True,
                        )
     slip_image.size = slip_image.texture_size
     slip_name = self.backend.book_obj.get_slip_type()
     self.action = ShowGenericInfoAction(
         additional_content=slip_image,
         title='Slip type #{}'.format(slip_name)
     )
     self.action.display()
Exemple #25
0
 def Label1(self):
     global lbl1
     img2 = Image()
     img2.source = "img/text.png"
     #        img2.pos = 215, 140
     img2.pos = 400, 160
     img2.size = 400, 500
     lbl1 = Label()
     lbl1.text = "Esperando instrucciones:"
     #   lbl1.pos = 200,140
     lbl1.pos = 530, 380
     lbl1.font_size = "14dp"
     Mprincipal.add_widget(img2)
     Mprincipal.add_widget(lbl1)
     print "Esperando instrucciones:"
Exemple #26
0
    def __init__(self, **kwargs):
        super(WelcomeScreen, self).__init__(**kwargs)

        layout = FloatLayout(
        )  #Float Layout for positioning buttons and image anywhere on the screen
        layout.width = Window.width  #the float layout is the size of the window
        layout.height = Window.height
        layout.x = Window.width / 2 - layout.width / 2  #sets the x position of the layout to 0
        layout.y = Window.height / 2 - layout.height / 2  #sets the y position of the layout to 0
        self.add_widget(layout)  #adds the layout to the screen

        img = Image(source=self.welcomeImage)  #BACKGROUND IMAGE
        img.size = (Window.width * 1.0, Window.height * 1.0)
        img.pos = (-Window.width * 0.0, -Window.height * 0.0)
        img.opacity = 1.0  #alpha value between 0.0 - 1.0
        self.add_widget(img)  #adds the image to the screen

        startBtn = MyButton(text='')  #start button
        startBtn.size_hint = (.21, .09)
        startBtn.pos_hint = {'x': .395, 'y': .24}
        startBtn.background_color = [
            .306, .325, .4196, .4
        ]  #backgroundcolor of the button (this is grayish)
        startBtn.bind(
            on_release=self.changer
        )  #when the button is released the changer function is called
        self.add_widget(
            startBtn)  #adds the button called startButton to the floatlayout

        aboutBtn = MyButton(text='')  #about button
        aboutBtn.size_hint = (.08, .095)
        aboutBtn.pos_hint = {'x': .618, 'y': 0}
        aboutBtn.background_color = [.4, .4, .4, .4]
        aboutBtn.bind(
            on_release=self.about
        )  #when the button is released the about function is called
        self.add_widget(
            aboutBtn)  #adds the button called aboutBtn to the floatlayout

        uiowaBtn = MyButton(text='')  #uiowa button
        uiowaBtn.size_hint = (.08, .095)
        uiowaBtn.pos_hint = {'x': .7, 'y': 0}
        uiowaBtn.background_color = [.4, .4, .4, .4]
        uiowaBtn.bind(
            on_release=self.uiowa
        )  #when the button is released the uiowa function is called
        self.add_widget(
            uiowaBtn)  #adds the button called uiowaBtn to the floatlayout
Exemple #27
0
    def show_game(self, running):
        Animation.cancel_all(self)
        self.canvas.clear()

        if not running:
            return

        self.add_widget(self._background)
        with self.canvas:
            # Load & configure the flock of bird animation frames
            birds = Image(source=IMAGES_PATH.format('birds.zip'),
                          pos=(Window.width, 400),
                          anim_delay=1)
            birds.size = birds.texture_size

            # Setup the flock of birds to move in wave pattern
            up_down = (Animation(y=375, d=5, t=self._sin_transition) +
                       Animation(y=425, d=5, t=self._sin_transition))
            up_down.repeat = True
            bird_animation = Animation(x=-birds.width, d=30) & up_down
            bird_animation.start(birds)
            bird_animation.bind(on_complete=self.on_birds_complete)

            # Initialize and draw the Mirror Cannon onto the canvas based on its state
            self._game.mirror.shape = Image(
                pos=(150, 260),
                source=ATLAS_PATH.format(
                    f'{self._game.mirror.id}-{self._game.mirror.state}'))
            self._game.mirror.shape.size = self._game.mirror.shape.texture_size

            # Change the color and display the incident
            # sun rays on the canvas
            self.canvas.add(self._game.sun_rays.color)
            self.canvas.add(self._game.sun_rays)

            # Change the color and display the death sun rays on the canvas
            self.canvas.add(
                Color(LIGHT_COLOR_MAX_RED, LIGHT_COLOR_MAX_GREEN,
                      LIGHT_COLOR_MAX_BLUE, 0.7))
            self.canvas.add(self._game.death_rays)

        # Add the Health Bar for the Castle/Island
        self.add_widget(self._hp_bar)

        # Add the Score display
        self.add_widget(self._score)
        self.add_widget(self.pause_btn)
Exemple #28
0
    def move_piece(self, from_row, from_col, to_row, to_col, moved_piece_color):
        """
        To be called when the client receives a "piece_moved" command
        :return:
        """
        app = App.get_running_app()
        # Clear the image that showed where the last piece moved from
        self.clear_just_moved_indicator()

        # Need to mirror the rows and columns if the player isn't the client
        if moved_piece_color == "red" and app.player.is_red or moved_piece_color == 'black' and not app.player.is_red:
            pass
        else:
            # Mirror the movements
            from_row = self.mirror_row(from_row)
            from_col = self.mirror_col(from_col)
            to_row = self.mirror_row(to_row)
            to_col = self.mirror_col(to_col)

        # Get the widget being moved
        moving_piece = app.board_helper.get_widget_at(from_row, from_col)
        piece_being_entered = app.board_helper.get_widget_at(to_row, to_col)
        #print("Moving piece", moving_piece.id())



        # Animate the motion
        animation_widget = Image(source=moving_piece.source,
                                 color=moving_piece.color,
                                 keep_ratio=False, allow_stretch=True)
        animation_widget.size_hint = (None, None)
        animation_widget.size = moving_piece.size
        animation_widget.pos = self.to_window(*moving_piece.pos)
        Window.add_widget(animation_widget)
        new_pos = piece_being_entered.pos
        moving_piece.opacity = 0
        app.is_animating = True
        anim = Animation(pos=new_pos, transition='out_expo')#, duration=0)
        anim.bind(on_complete=partial(self.finish_piece_movement, piece_being_entered, moving_piece))
        anim.start(animation_widget)

        # Move the turn indicator
        self.move_turn_indicator()
    def update_test_image(self, *_):
        """Regenerate the watermark preview image."""

        if self.watermark_settings:
            test_image = self.watermark_settings.ids['testImage']
            test_image.clear_widgets()
            if os.path.isfile(self.watermark_image):
                image = KivyImage(source=self.watermark_image)
                size_x = test_image.size[0] * (self.watermark_size / 100)
                size_y = test_image.size[1] * (self.watermark_size / 100)
                image.size = (size_x, size_y)
                image.size_hint = (None, None)
                image.opacity = self.watermark_opacity / 100
                x_pos = test_image.pos[0] + ((test_image.size[0] - size_x) *
                                             (self.watermark_horizontal / 100))
                y_pos = test_image.pos[1] + ((test_image.size[1] - size_y) *
                                             (self.watermark_vertical / 100))
                image.pos = (x_pos, y_pos)
                test_image.add_widget(image)
 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
Exemple #31
0
 def on_hover_in(self, sprite_name):
     if self.hover_popup.get_parent_window():
         return
     gc.collect()
     main_scr = App.get_running_app().get_main_screen()
     char = main_scr.user.get_char()
     user_handler = App.get_running_app().get_user_handler()
     sprite_option = user_handler.get_chosen_sprite_option()
     sprite = char.get_sprite(sprite_name)
     main_scr.sprite_settings.apply_post_processing(sprite, sprite_option)
     sprite_texture = char.get_sprite(sprite_name).get_texture()
     sprite_size = sprite_texture.size
     # Can't use absolute position so it uses a workaround
     hover_x = self.right / Window.width
     hover_y = self.y / Window.height
     sprite_size = sprite_size[0] * 0.8, sprite_size[1] * 0.8
     im = Image()
     im.texture = sprite_texture
     im.size = sprite_texture.size
     self.hover_popup.add_widget(im)
     self.hover_popup.size = sprite_size
     self.hover_popup.pos_hint = {'x': hover_x, 'y': hover_y}
     self.hover_popup.open()
    def __init__(self, **kwargs):
        super(MainWindow, self).__init__(**kwargs)

        ImageViewer = Image(source="")  # the interactive writing window
        ImageViewer.size_hint = (None, None)
        ImageViewer.size = (1021, 576)
        ImageViewer.pos = (0, 240 - 152)
        self.add_widget(ImageViewer)

        # The reason to put the interactive texts and the TextField in the MainWindow is that MainWindow is updated immediately
        # workpanel is static

        LabelReminder = Label(font_size="15sp",
                              text="",
                              color=(1, .3, .3, 1),
                              halign='left',
                              text_size=(300, 150))
        LabelReminder.size_hint = (
            None, None)  # the interactive text, which is initially set to red
        LabelReminder.size = (300, 150)
        LabelReminder.valign = 'top'
        LabelReminder.text = ""
        LabelReminder.pos = (1050, 210 - 152)
        self.add_widget(LabelReminder)

        textinput = TextInput(multiline=False)  #the TextField
        textinput.size_hint = (None, None)
        textinput.size = (300, 40)
        textinput.pos = (1040, 250 - 152)
        self.add_widget(textinput)

        self.uievents = UIEvents(ImageViewer, LabelReminder, textinput)

        WorkingPanel = WorkPanel(self.uievents)
        WorkingPanel.pos = (0, 240)
        self.add_widget(WorkingPanel)
Exemple #33
0
 def on_pre_enter(self):
     interior_img = Image(source=shipimage.ship_dict[self.ship.shipclass]['prefix']+ '/ShipRooms.png',color=[0.5,0.5,0.5,1.], allow_stretch=True, size_hint= [None, None])
     interior_img.size = densFix(interior_img.texture.size)
     interior_img.pos_hint= {'center_x': .5, 'center_y': .5}
     self.ids['shiplayout'].add_widget(interior_img)
     self.ids['shiplayout'].size = (np.array(interior_img.size)+100).tolist()
     
     #add rooms
     for r in self.ship.rooms:
         #mimg = r['module'].module_image()
         rimg = RoomImage( room_entry=r )
         #butt.text = str(r['size'])
         #room_name = 'room'+str(r['size'])+'_'
         #room_name += 'empty.png' if not r['module'] else 'full.png'
         b_center = np.array(self.ids['shiplayout'].center)+np.array(r['loc'])*Metrics.density        
         #print r_center, np.array(self.ids['shiplayout'].center),np.array(r['loc'])       
         #room_img = Image(source='img/room/'+room_name, center = r_center.tolist(), size=[40,40], size_hint= [None, None])
         #rimg.center = b_center.tolist()
         rimg.go_to_loc(b_center.tolist())
         #rimg.ids['sizeimg'].pos_hint = 0.5,0.5
         self.ids['shiplayout'].add_widget(rimg)
         
     self.ids['shipscroll'].scroll_x = 0.5
     self.ids['shipscroll'].scroll_y = 0.5
    def build(self):

        #Window.size = (1920,1080)
        #Window.size = (1200,900)
        self.lists={}
        self.counters={}
        self.buttons={}
        self.labels={}
        self.on=False
        self.phase=""
        diplayLayout=currentDir+"kivyDisplay.txt"

        global displayLock
        displayLock = DisplayLock()
        
        self.layout=[]
        with open(diplayLayout, 'rb') as layoutFile:
            #layoutReader = csv.reader(layoutFile, delimiter=',', quotechar='|')
            for row in layoutFile:
                i=row.rstrip('\n')
                j=i.rstrip('\r')
                k=j.split(",")
                if len(k)==6:
                    self.layout.append(j.split(","))
                else:
                    print "INVALID LAYOUT LINE:",k


        self.relativeLayout = RelativeLayout()
        self.relativeLayout.size_hint=(None, None)
        #self.relativeLayout.pos_hint={'x':0,'y':0}

        background = Image(source="background.jpg", allow_stretch=True, keep_ratio=True)
        background.size= (Window.height*background.image_ratio, Window.height)
        self.relativeLayout.add_widget(background)
        
        self.tableau=0
        
        CardList.setDisplay(self)
        CardPile.setDisplay(self)
        CardCounter.setDisplay(self)
        
        deck = Deck(currentDir+"classes.txt",currentDir+"soldiers.txt",KivyCard)


        numberPlayers=1

        self.tableau = Tableau(deck,numberPlayers,self,KivyCardPile,KivyCardList,KivyCardCounter)

        engine = GameEngine(self.tableau)

        
        
        self.initDisplay()

        global looking
        global lookingCard
        looking = False
        lookingCard = False
        self.buttons["look"].enable(True,True)
        
        engineThread=EngineThread(engine)
        engineThread.start()
        
        return self.relativeLayout
Exemple #35
0
	def reload_image(self):
		new_image = Image(source='./data/images/player-'+self.status_game+'-'+self.status_health+'.png')
		new_image.pos = (0,0)
		new_image.size = (36,36)
		self.add_widget(new_image)
Exemple #36
0
        def __init__(self, ms, **kwargs):
            super(MasterClient.Home, self).__init__(**kwargs)

            self.ms = ms

            # Float Layout Top Bar
            self.float_layout = FloatLayout()
            self.float_layout.size_hint = (None, None)
            # self.float_layout.pos_hint = (None, None) # Não pode definir no FloatLayout
            self.float_layout.size = (402, 85)
            self.float_layout.y = 630

            # Top Bar image
            self.top_bar = Image()
            self.float_layout.add_widget(self.top_bar)
            self.top_bar.source = ("interface/Home/top_bar1.png")
            self.top_bar.y = 630

            # AddContact button
            self.add_contact_btn = Button()
            self.float_layout.add_widget(self.add_contact_btn)
            self.add_contact_btn.size_hint = (None, None)
            self.add_contact_btn.size = (40, 40)
            self.add_contact_btn.pos = (345, 643)
            self.add_contact_btn.background_color = (1.0, 1.0, 1.0, 0)
            self.add_contact_btn.on_press = self.press_add_contact_button

            # Switch status button
            self.switch_status = Button()
            self.float_layout.add_widget(self.switch_status)
            self.switch_status.size_hint = (None, None)
            self.switch_status.size = (43, 24)
            self.switch_status.pos = (20, 651)
            self.switch_status.background_color = (1.0, 1.0, 1.0, 0)
            self.switch_status.on_press = self.press_switch_status

            # Switch status image
            self.switch_img = Image()
            self.add_widget(self.float_layout)
            self.switch_status.add_widget(self.switch_img)
            self.switch_img.source = ("interface/Home/switch_on.png")
            self.switch_img.size = (43, 24)
            self.switch_img.pos = (20, 651)

            # Scroll View
            self.scroll_view = ScrollView()
            self.add_widget(self.scroll_view)
            self.scroll_view.size_hint = (None, None)
            self.scroll_view.size = (402, 630)
            self.scroll_view.y = self.scroll_view.parent.x
            self.scroll_view.orientation = "vertical"
            self.scroll_view.background_color = (255, 0, 0, 1)

            # Box View chats
            self.box = BoxLayout()
            self.scroll_view.add_widget(self.box)
            self.box.id = "box"
            self.box.orientation = "vertical"
            self.box.size_hint_y = None
            self.box.bind(minimum_height=self.box.setter("height"))
            self.box.y = self.box.parent.y

            print(len(contacts))
            for contact in contacts:
                print("entrei aqui no coisa do bicho do negoço")
                print(contact)
                ###
                # Box button
                box_button = Button()
                self.box.add_widget(box_button)

                box_button.size_hint = (None, None)
                box_button.width = 402
                box_button.height = 80
                #box_button.background_color = (255, 255, 255, 1)

                # Contact photo image
                contact_photo = Image()
                box_button.add_widget(contact_photo)
                contact_photo.source = ("interface/Home/contact.png")
                contact_photo.size_hint = (None, None)
                contact_photo.pos_hint = (None, None)
                contact_photo.size = (80, 80)
                contact_photo.pos = (0, 0)

                # Contact status img
                contact_img_status = Image()
                box_button.add_widget(contact_img_status)
                contact_img_status.source = ("interface/online.png")
                contact_img_status.size_hint = (None, None)
                contact_img_status.pos_hint = (None, None)
                contact_img_status.size = (80, 80)
                contact_img_status.pos = (330, contact_img_status.parent.y)

                # Contact name label
                lbl_name = Label()
                box_button.add_widget(lbl_name)
                lbl_name.text = contact_name
                lbl_name.size = (15, 120)
                lbl_name.pos = (90, contact_img_status.parent.y)