Ejemplo n.º 1
0
class AbilityImage(View):
	def handle_event(self, event):
		if event.kind == 'mouse_up':
			if self.position[0] <= event.position[0] <= self.position[0] + 40 and \
				 self.position[1] <= event.position[1] <= self.position[1] + 40:
				self.container.imageClicked(event.position)
		elif event.kind == 'mouse_move':
			self.container.mouseOverImage()
		
	def setupComponents(self):
		path = os.path.join("Data", "Pics", "Abilities", "Frame.png")
		self.border = Image(file = path)
		self.image = None
		
	def clearImage(self):
		self.image = None
		
	def setImage(self, imagePath):
		if imagePath:
			path = os.path.join("Data", "Pics", "Abilities", imagePath + ".png")
			self.image = Image(file = path)
		else:
			self.image = None
		
	def draw(self, c, r):
		main_image_pos = self.position
		src_rect = (0, 0, 40, 40)
		dst_rect = (main_image_pos[0], main_image_pos[1], 
								main_image_pos[0] + 40, 
								main_image_pos[1] + 40)
		if self.image:
			self.image.draw(c, src_rect, dst_rect)
		if self.border:
			self.border.draw(c, src_rect, dst_rect)
Ejemplo n.º 2
0
class AbilityImage(View):
    def handle_event(self, event):
        if event.kind == 'mouse_up':
            if self.position[0] <= event.position[0] <= self.position[0] + 40 and \
              self.position[1] <= event.position[1] <= self.position[1] + 40:
                self.container.imageClicked(event.position)
        elif event.kind == 'mouse_move':
            self.container.mouseOverImage()

    def setupComponents(self):
        path = os.path.join("Data", "Pics", "Abilities", "Frame.png")
        self.border = Image(file=path)
        self.image = None

    def clearImage(self):
        self.image = None

    def setImage(self, imagePath):
        if imagePath:
            path = os.path.join("Data", "Pics", "Abilities",
                                imagePath + ".png")
            self.image = Image(file=path)
        else:
            self.image = None

    def draw(self, c, r):
        main_image_pos = self.position
        src_rect = (0, 0, 40, 40)
        dst_rect = (main_image_pos[0], main_image_pos[1],
                    main_image_pos[0] + 40, main_image_pos[1] + 40)
        if self.image:
            self.image.draw(c, src_rect, dst_rect)
        if self.border:
            self.border.draw(c, src_rect, dst_rect)
Ejemplo n.º 3
0
 def setImage(self, imagePath):
     if imagePath:
         path = os.path.join("Data", "Pics", "Abilities",
                             imagePath + ".png")
         self.image = Image(file=path)
     else:
         self.image = None
Ejemplo n.º 4
0
        def draw(self, c, r):
            c.backcolor = view_backcolor
            c.erase_rect(r)

            # Background image
            image_pos = ((player_name_label.left - player_background.width)/2, 5)
            src_rect = player_background.bounds
            dst_rect = Geometry.offset_rect(src_rect, image_pos)
            player_background.draw(c, src_rect, dst_rect)

            # Lines between summary stats
            c.forecolor = stat_line_color
            c.fill_rect((dst_rect[0]+22, dst_rect[1]+stat_line_y,
                         dst_rect[2]-22, dst_rect[1]+stat_line_y+1))
            c.fill_rect((dst_rect[0]+22, dst_rect[1]+stat_line_y+stat_line_spacing,
                         dst_rect[2]-22, dst_rect[1]+stat_line_y+stat_line_spacing+1))

            # Headshot
            image_pos = (image_pos[0]+player_headshot_pos[0], player_headshot_pos[1])
            src_rect = player_headshot.bounds
            headshot_dst_rect = Geometry.offset_rect(src_rect, image_pos)
            player_headshot.draw(c, src_rect, headshot_dst_rect)

            # Club
            if 'normal' in player['club']['imageUrls']:
                image_url = player['club']['imageUrls']['normal']['large']
            # FIFA 15 compatibility
            elif 'dark' in player['club']['imageUrls']:
                image_url = player['club']['imageUrls']['dark']['large']
            ratio = 0.75
            image_file_name = 'club_' + str(player['club']['id']) + '_' + str(ratio)
            image_file_name = save_small_image(image_url, image_file_name, ratio)
            club_image = Image(file=image_file_name)
            club_image_pos = club_pos
            club_rect = club_image.bounds
            club_dst_rect = Geometry.offset_rect(club_rect, club_image_pos)
            club_image.draw(c, club_rect, club_dst_rect)

            # Nation
            if 'imageUrls' in player['nation']:
                image_url = player['nation']['imageUrls']['large']
            # FIFA 15 compatibility
            elif 'imageUrl' in player['nation']:
                image_url = player['nation']['imgUrl']
            ratio = 0.75
            image_file_name = 'nation_' + str(player['nation']['id']) + '_' + str(ratio)
            image_file_name = save_small_image(image_url, image_file_name, ratio)
            nation_image = Image(file=image_file_name)
            nation_image_pos = (club_image_pos[0], club_image_pos[1]+club_image.size[1]+nation_spacing)
            nation_rect = nation_image.bounds
            nation_dst_rect = Geometry.offset_rect(nation_rect, nation_image_pos)
            nation_image.draw(c, nation_rect, nation_dst_rect)

            # Coins symbol
            image_file_name = 'Images/coins.png'
            coins_image = Image(file=image_file_name)
            coins_image_pos = coins_pos
            coins_rect = coins_image.bounds
            coins_dst_rect = Geometry.offset_rect(coins_rect, coins_image_pos)
            coins_image.draw(c, coins_rect, coins_dst_rect)
Ejemplo n.º 5
0
 def draw(self, c, r):
     here = sys.path[0]
     image_path = os.path.join(here, "test.png")
     image = Image(file=image_path)
     c.backcolor = yellow
     c.erase_rect(r)
     main_image_pos = (30, btn1.bottom + 30)
     src_rect = (0, 0, 571, 416)
     #say("Image bounds =", src_rect)
     dst_rect = offset_rect(src_rect, main_image_pos)
     #say("Drawing", src_rect, "in", dst_rect)
     image.draw(c, src_rect, dst_rect)
Ejemplo n.º 6
0
def image_from_ndarray(array, format, size = None):
    """
    Creates an Image from a numpy ndarray object. The format
    may be 'RGB' or 'RGBA'. If a size is specified, the array
    will be implicitly reshaped to that size, otherwise the size
    is inferred from the first two dimensions of the array.
    """
    if array.itemsize <> 1:
        raise ValueError("Color component size must be 1 byte")
    if size is None:
        shape = array.shape
        if len(shape) <> 3:
            raise ValueError("Array has wrong number of dimensions")
        width, height, pixel_size = shape
        if pixel_size <> len(format):
            raise ValueError("Last dimension of array does not match format")
    else:
        width, height = size
        pixel_size = len(format)
        data_size = array.size
        if data_size <> width * height * pixel_size:
            raise ValueError("Array has wrong shape for specified size and format")
    alpha = pixel_size == 4
    gdk_pixbuf = gdk.pixbuf_new_from_data(array, gdk.COLORSPACE_RGB, alpha,
        8, width, height, width * pixel_size)
    image = Image._from_gdk_pixbuf(gdk_pixbuf)
    #image._data = array ###
    return image
Ejemplo n.º 7
0
def image_from_ndarray(array, format, size = None):
    """
    Creates an Image from a numpy ndarray object. The format
    may be 'RGB' or 'RGBA'. If a size is specified, the array
    will be implicitly reshaped to that size, otherwise the size
    is inferred from the first two dimensions of the array.
    """
    if array.itemsize <> 1:
        raise ValueError("Color component size must be 1 byte")
    if size is not None:
        width, height = size
        data_size = array.size
        pixel_size = data_size // (width * height)
        if pixel_size <> len(format):
            raise ValueError("Array has wrong shape for specified size and format")
    else:
        height, width, pixel_size = array.shape
        if pixel_size <> len(format):
            raise ValueError("Array has wrong shape for specified format")
    bps = 8
    spp = pixel_size
    alpha = format.endswith("A")
    csp = NSCalibratedRGBColorSpace
    bpp = bps * spp
    bpr = width * pixel_size
    fmt = NSAlphaNonpremultipliedBitmapFormat
    ns_rep = NSBitmapImageRep.alloc()
    planes = planes_t(array.ctypes.data, 0, 0, 0, 0)
    ns_rep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(
        ctypes.addressof(planes), width, height, bps, spp, alpha, False, csp, fmt, bpr, bpp)
    image = Image.__new__(Image)
    image._init_from_ns_rep(ns_rep)
    image._data = array
    return image
Ejemplo n.º 8
0
def image_from_ndarray(array, format, size=None):
    """
    Creates an Image from a numpy ndarray object. The format
    may be 'RGB' or 'RGBA'. If a size is specified, the array
    will be implicitly reshaped to that size, otherwise the size
    is inferred from the first two dimensions of the array.
    """
    if array.itemsize <> 1:
        raise ValueError("Color component size must be 1 byte")
    if size is None:
        shape = array.shape
        if len(shape) <> 3:
            raise ValueError("Array has wrong number of dimensions")
        width, height, pixel_size = shape
        if pixel_size <> len(format):
            raise ValueError("Last dimension of array does not match format")
    else:
        width, height = size
        pixel_size = len(format)
        data_size = array.size
        if data_size <> width * height * pixel_size:
            raise ValueError(
                "Array has wrong shape for specified size and format")
    alpha = pixel_size == 4
    gdk_pixbuf = gdk.pixbuf_new_from_data(array, gdk.COLORSPACE_RGB, alpha, 8,
                                          width, height, width * pixel_size)
    image = Image._from_gdk_pixbuf(gdk_pixbuf)
    #image._data = array ###
    return image
Ejemplo n.º 9
0
class CharacterImage(View):
	def setupComponents(self):
		self.image = None
		
	def clearImage(self):
		self.image = None
		
	def setImage(self, imagePath):
		path = os.path.join("Data", "Pics", "Actors", imagePath + ".png")
		self.image = Image(file = path)
		
	def draw(self, c, r):
		if self.image:
			main_image_pos = self.position
			src_rect = (39, 0, 39*2, 39)
			dst_rect = (main_image_pos[0], main_image_pos[1], 
									main_image_pos[0] + src_rect[2] - src_rect[0], 
									main_image_pos[1] + src_rect[3] - src_rect[1])
			self.image.draw(c, src_rect, dst_rect)
Ejemplo n.º 10
0
def update_pic():
    here = sys.path[0]
    image_path = os.path.join(here, "test.png")
    image = Image(file=image_path)
    view = ImageTestView(size=win.size)
    view.add(btn1)
    view.add(btn5)
    win.add(image)
    view.become_target()
    win.show()
Ejemplo n.º 11
0
class CharacterImage(View):
    def setupComponents(self):
        self.image = None

    def clearImage(self):
        self.image = None

    def setImage(self, imagePath):
        path = os.path.join("Data", "Pics", "Actors", imagePath + ".png")
        self.image = Image(file=path)

    def draw(self, c, r):
        if self.image:
            main_image_pos = self.position
            src_rect = (39, 0, 39 * 2, 39)
            dst_rect = (main_image_pos[0], main_image_pos[1],
                        main_image_pos[0] + src_rect[2] - src_rect[0],
                        main_image_pos[1] + src_rect[3] - src_rect[1])
            self.image.draw(c, src_rect, dst_rect)
Ejemplo n.º 12
0
def image_from_pil_image(pil_image):
    """Creates an Image from a Python Imaging Library (PIL)
    Image object."""
    mode = pil_image.mode
    w, h = pil_image.size
    data = pil_image.tostring()
    alpha = False
    cmyk = False
    floating = False
    if mode == "1":
        bps = 1; spp = 1
    elif mode == "L":
        bps = 8; spp = 1
    elif mode == "RGB":
        bps = 8; spp = 3
    elif mode == "RGBA":
        bps = 8; spp = 4; alpha = True
    elif mode == "CMYK":
        bps = 8; spp = 4; cmyk = True
    elif mode == "I":
        bps = 32; spp = 1
    elif mode == "F":
        bps = 32; spp = 1; floating = True
    else:
        raise ValueError("Unsupported PIL image mode '%s'" % mode)
    if cmyk:
        csp = NSDeviceCMYKColorSpace
    else:
        csp = NSCalibratedRGBColorSpace
    fmt = NSAlphaNonpremultipliedBitmapFormat
    if floating:
        fmt |= NSFloatingPointSamplesBitmapFormat
    bpp = bps * spp
    bpr = w * ((bpp + 7) // 8)
    if debug_pil:
        print "GUI.PIL:"
        print "image size =", (w, h)
        print "data size =", len(data)
        print "bits per sample =", bps
        print "samples per pixel =", spp
        print "bits per pixel =", bpp
        print "bytes per row =", bpr
    hack_objc_sig()
    ns_rep = NSBitmapImageRep.alloc()
    planes = planes_t(data, "", "", "", "")
    ns_rep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(
        ctypes.addressof(planes), w, h, bps, spp, alpha, False, csp, fmt, bpr, bpp)
#	planes = (data, "", "", "", "")
#	ns_rep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel_(
#		planes, w, h, bps, spp, alpha, False, csp, bpr, bpp)
    image = Image.__new__(Image)
    image._init_from_ns_rep(ns_rep)
    image._data = data
    return image
Ejemplo n.º 13
0
def test():
	file = "grail_masked.tiff"
	#file = "spam_masked.tiff"
	image = Image(os.path.join(sys.path[0], file))
	cursor = Cursor(image)
	win = Window(title = "Image Cursor", width = 500, height = 400)
	view1 = TestDrawing(position = (20, 20), size = (100, 70), cursor = cursor)
	view2 = TestScrollableView(position = (140, 20), size = (200, 200),
		scrolling = 'hv')
	view2.cursor = cursor
	win.add(view1)
	win.place(view2, sticky = 'nsew')
	win.shrink_wrap((20, 20))
	win.show()
Ejemplo n.º 14
0
    def initializeImages(self, parent):
        self.images = []
        self.imageNames = []
        skins = [
            file for file in os.listdir(os.path.join("Data", "Pics", "Actors"))
            if file[len(file) - 4:].upper() == ".PNG"
        ]
        for skin in skins:
            self.images += [
                Image(file=os.path.join("Data", "Pics", "Actors", skin))
            ]
            self.imageNames += [skin]

        btn = Button(title="Back", action=self.backClicked, style='default')
        btn.position = ((self.width - btn.width) / 2,
                        self.height - btn.height - 10)
        self.add(btn)
Ejemplo n.º 15
0
def image_from_pil_image(pil_image):
    """Creates an Image from a Python Imaging Library (PIL)
    Image object."""
    mode = pil_image.mode
    w, h = pil_image.size
    data = pil_image.tostring()
    if mode == "RGB":
        bps = 3; alpha = False
    elif mode == "RGBA":
        bps = 4; alpha = True
    else:
        raise ValueError("Unsupported PIL image mode '%s'" % mode)
    bpr = w * bps
    image = Image.__new__(Image)
    image._gdk_pixbuf = gdk.pixbuf_new_from_data(data, COLORSPACE_RGB,
        alpha, 8, w, h, bpr)
    return image
Ejemplo n.º 16
0
def image_from_pil_image(pil_image):
    """Creates an Image from a Python Imaging Library (PIL)
	Image object."""
    mode = pil_image.mode
    w, h = pil_image.size
    data = pil_image.tostring()
    if mode == "RGB":
        bps = 3
        alpha = False
    elif mode == "RGBA":
        bps = 4
        alpha = True
    else:
        raise ValueError("Unsupported PIL image mode '%s'" % mode)
    bpr = w * bps
    image = Image.__new__(Image)
    image._gdk_pixbuf = gdk.pixbuf_new_from_data(data, COLORSPACE_RGB, alpha,
                                                 8, w, h, bpr)
    return image
Ejemplo n.º 17
0
def image_from_ndarray(array, format, size=None):
    """
    Creates an Image from a numpy ndarray object. The format
    may be 'RGB' or 'RGBA'. If a size is specified, the array
    will be implicitly reshaped to that size, otherwise the size
    is inferred from the first two dimensions of the array.
    """
    if array.itemsize != 1:
        raise ValueError("Color component size must be 1 byte")
    if size is None:
        shape = array.shape
        if len(shape) != 3:
            raise ValueError("Array has wrong number of dimensions")
        height, width, pixel_size = shape
        if pixel_size != len(format):
            raise ValueError("Last dimension of array does not match format")
    else:
        width, height = size
        pixel_size = len(format)
        data_size = array.size
        if data_size != width * height * pixel_size:
            raise ValueError(
                "Array has wrong shape for specified size and format")
        shape = (height, width, pixel_size)
        array = array.reshape(shape)
    swapped = ndarray(shape, uint8)
    swapped[..., 0] = array[..., 2]
    swapped[..., 1] = array[..., 1]
    swapped[..., 2] = array[..., 0]
    if pixel_size == 4:
        fmt = gdi.PixelFormat32bppARGB
        swapped[..., 3] = array[..., 3]
    else:
        fmt = gdi.PixelFormat24bppRGB
    data = swapped.tostring()
    bitmap = gdi.Bitmap.from_data(width, height, fmt, data)
    image = Image.__new__(Image)
    image._win_image = bitmap
    image._data = data
    return image
Ejemplo n.º 18
0
def image_from_ndarray(array, format, size = None):
    """
    Creates an Image from a numpy ndarray object. The format
    may be 'RGB' or 'RGBA'. If a size is specified, the array
    will be implicitly reshaped to that size, otherwise the size
    is inferred from the first two dimensions of the array.
    """
    if array.itemsize <> 1:
        raise ValueError("Color component size must be 1 byte")
    if size is None:
        shape = array.shape
        if len(shape) <> 3:
            raise ValueError("Array has wrong number of dimensions")
        height, width, pixel_size = shape
        if pixel_size <> len(format):
            raise ValueError("Last dimension of array does not match format")
    else:
        width, height = size
        pixel_size = len(format)
        data_size = array.size
        if data_size <> width * height * pixel_size:
            raise ValueError("Array has wrong shape for specified size and format")
        shape = (height, width, pixel_size)
        array = array.reshape(shape)
    swapped = ndarray(shape, uint8)
    swapped[..., 0] = array[..., 2]
    swapped[..., 1] = array[..., 1]
    swapped[..., 2] = array[..., 0]
    if pixel_size == 4:
        fmt = gdi.PixelFormat32bppARGB
        swapped[..., 3] = array[..., 3]
    else:
        fmt = gdi.PixelFormat24bppRGB
    data = swapped.tostring()
    bitmap = gdi.Bitmap.from_data(width, height, fmt, data)
    image = Image.__new__(Image)
    image._win_image = bitmap
    image._data = data
    return image
Ejemplo n.º 19
0
def image_from_pil_image(pil_image):
    """Creates an Image from a Python Imaging Library (PIL)
	Image object."""
    pil_image.load()
    mode = pil_image.mode
    w, h = pil_image.size
    if mode == "RGB":
        r, g, b = pil_image.split()
        pil_image = merge(mode, (b, g, r))
        fmt = gdi.PixelFormat24bppRGB
    elif mode == "RGBA":
        r, g, b, a = pil_image.split()
        pil_image = merge(mode, (b, g, r, a))
        fmt = gdi.PixelFormat32bppARGB
    else:
        raise ValueError("Unsupported PIL image mode '%s'" % mode)
    data = pil_image.tostring()
    bitmap = gdi.Bitmap.from_data(w, h, fmt, data)
    image = Image.__new__(Image)
    image._win_image = bitmap
    image._data = data
    return image
Ejemplo n.º 20
0
def image_from_ndarray(array, format, size=None):
    """
	Creates an Image from a numpy ndarray object. The format
	may be 'RGB' or 'RGBA'. If a size is specified, the array
	will be implicitly reshaped to that size, otherwise the size
	is inferred from the first two dimensions of the array.
	"""
    if array.itemsize <> 1:
        raise ValueError("Color component size must be 1 byte")
    if size is not None:
        width, height = size
        data_size = array.size
        pixel_size = data_size // (width * height)
        if pixel_size <> len(format):
            raise ValueError(
                "Array has wrong shape for specified size and format")
    else:
        height, width, pixel_size = array.shape
        if pixel_size <> len(format):
            raise ValueError("Array has wrong shape for specified format")
    bps = 8
    spp = pixel_size
    alpha = format.endswith("A")
    csp = NSCalibratedRGBColorSpace
    bpp = bps * spp
    bpr = width * pixel_size
    fmt = NSAlphaNonpremultipliedBitmapFormat
    ns_rep = NSBitmapImageRep.alloc()
    planes = planes_t(array.ctypes.data, 0, 0, 0, 0)
    ns_rep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(
        ctypes.addressof(planes), width, height, bps, spp, alpha, False, csp,
        fmt, bpr, bpp)
    image = Image.__new__(Image)
    image._init_from_ns_rep(ns_rep)
    image._data = array
    return image
Ejemplo n.º 21
0
 def setupComponents(self):
     path = os.path.join("Data", "Pics", "Equipment", "EmptySlot.png")
     self.border = Image(file=path)
     self.image = None
Ejemplo n.º 22
0
from GUI import View, Button, Image
Ejemplo n.º 23
0
	def setupComponents(self):
		path = os.path.join("Data", "Pics", "Abilities", "Frame.png")
		self.border = Image(file = path)
		self.image = None
Ejemplo n.º 24
0
def image_from_pil_image(pil_image):
    """Creates an Image from a Python Imaging Library (PIL)
	Image object."""
    mode = pil_image.mode
    w, h = pil_image.size
    data = pil_image.tostring()
    alpha = False
    cmyk = False
    floating = False
    if mode == "1":
        bps = 1
        spp = 1
    elif mode == "L":
        bps = 8
        spp = 1
    elif mode == "RGB":
        bps = 8
        spp = 3
    elif mode == "RGBA":
        bps = 8
        spp = 4
        alpha = True
    elif mode == "CMYK":
        bps = 8
        spp = 4
        cmyk = True
    elif mode == "I":
        bps = 32
        spp = 1
    elif mode == "F":
        bps = 32
        spp = 1
        floating = True
    else:
        raise ValueError("Unsupported PIL image mode '%s'" % mode)
    if cmyk:
        csp = NSDeviceCMYKColorSpace
    else:
        csp = NSCalibratedRGBColorSpace
    fmt = NSAlphaNonpremultipliedBitmapFormat
    if floating:
        fmt |= NSFloatingPointSamplesBitmapFormat
    bpp = bps * spp
    bpr = w * ((bpp + 7) // 8)
    if debug_pil:
        print "GUI.PIL:"
        print "image size =", (w, h)
        print "data size =", len(data)
        print "bits per sample =", bps
        print "samples per pixel =", spp
        print "bits per pixel =", bpp
        print "bytes per row =", bpr
    hack_objc_sig()
    ns_rep = NSBitmapImageRep.alloc()
    planes = planes_t(data, "", "", "", "")
    ns_rep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(
        ctypes.addressof(planes), w, h, bps, spp, alpha, False, csp, fmt, bpr,
        bpp)
    #	planes = (data, "", "", "", "")
    #	ns_rep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel_(
    #		planes, w, h, bps, spp, alpha, False, csp, bpr, bpp)
    image = Image.__new__(Image)
    image._init_from_ns_rep(ns_rep)
    image._data = data
    return image
Ejemplo n.º 25
0
	def setImage(self, imagePath):
		if imagePath:
			path = os.path.join("Data", "Pics", "Abilities", imagePath + ".png")
			self.image = Image(file = path)
		else:
			self.image = None
Ejemplo n.º 26
0
from GUI import Window, View, Image, application, Dialog, Label
from GUI.Geometry import offset_rect, rect_sized
from GUI.StdColors import white

import os, sys, serial, time, pyglet, wave
pyglet.options['audio'] = ('openal', 'silent')
f = serial.Serial('/dev/cu.usbmodemFD121', 9600, timeout=.3)

#open images
here = sys.path[0]
image_path = os.path.join(here, "room.jpg")
room = Image(file=image_path)
image_path = os.path.join(here, "m_off.png")
m_off = Image(file=image_path)
image_path = os.path.join(here, "m_on.png")
m_on = Image(file=image_path)
image_path = os.path.join(here, "n_off.png")
n_off = Image(file=image_path)
image_path = os.path.join(here, "n_on.png")
n_on = Image(file=image_path)
image_path = os.path.join(here, "p_off.png")
p_off = Image(file=image_path)
image_path = os.path.join(here, "p_on.png")
p_on = Image(file=image_path)


class dashboard(View):

    tags = 0
    present = False
    alarm = False
Ejemplo n.º 27
0
 def setupComponents(self):
     path = os.path.join("Data", "Pics", "Abilities", "Frame.png")
     self.border = Image(file=path)
     self.image = None
Ejemplo n.º 28
0
	def setupComponents(self):
		path = os.path.join("Data", "Pics", "Equipment", "EmptySlot.png")
		self.border = Image(file = path)
		self.image = None
Ejemplo n.º 29
0
		def load(path):
			image = Image.from_resource(name, **kwds)
			return cls(image, hotspot or _hotspot_for_resource(name))
Ejemplo n.º 30
0
	def setImage(self, imagePath):
		path = os.path.join("Data", "Pics", "Equipment", imagePath + ".png")
		self.image = Image(file = path)
Ejemplo n.º 31
0
 def setImage(self, imagePath):
     path = os.path.join("Data", "Pics", "Actors", imagePath + ".png")
     self.image = Image(file=path)
Ejemplo n.º 32
0
from GUI import View, Button, Image
Ejemplo n.º 33
0
 def load(path):
     image = Image.from_resource(name, **kwds)
     return cls(image, hotspot or _hotspot_for_resource(name))
Ejemplo n.º 34
0
	def _init_from_resource(self, resource_name, hotspot):
		image = Image(file = find_resource(resource_name))
		if not hotspot:
			hotspot = _hotspot_for_resource(resource_name)
		self._init_from_image(image, hotspot)
Ejemplo n.º 35
0
        dst_rect = rect_sized((10, 340), (150, 150))
        #say("Drawing", src_rect, "in", dst_rect)
        image.draw(c, src_rect, dst_rect)
        dst_rect = rect_sized((200, 340), (100, 100))
        #say("Drawing", src_rect, "in", dst_rect)
        image.draw(c, src_rect, dst_rect)
        dst_rect = rect_sized((340, 340), (50, 50))
        #say("Drawing", src_rect, "in", dst_rect)
        image.draw(c, src_rect, dst_rect)


import os, sys

here = sys.path[0]
image_path = os.path.join(here, "imac.jpg")
image = Image(file=image_path)

win = Window(size=(500, 500))
view = ImageTestView(size=win.size)
win.add(view)
view.become_target()
win.show()

instructions = """
There should be a 360x264 image of an iMac with a rectangle drawn
around part of the image. This part should appear at three different
sizes (150x150, 100x100, 50x50) below the main image.
"""

say(instructions)
application().run()