Exemplo n.º 1
0
    def __init__(self, master, im):
        if isinstance(im, list):
            # list of images
            self.im = im[1:]
            im = self.im[0]
        else:
            # sequence
            self.im = im

        if im.mode == "1":
            self.image = ImageTk.BitmapImage(im, foreground="white")
        else:
            self.image = ImageTk.PhotoImage(im)

        Label.__init__(self, master, image=self.image, bg="black", bd=0)

        self.update()

        try:
            duration = im.info["duration"]
        except KeyError:
            duration = 100
        self.after(duration, self.next)
Exemplo n.º 2
0
    def __init__(self, master, player_info, *args, **kwargs):
        super().__init__(master, *args, **kwargs)
        self.master = master

        self.info = player_info

        config_grids(self, rows=[1, 1], columns=[1, 1])

        self.player_number_label = tk.Label(self, text=f'Player {self.info["number"]}', bg=self['background'])
        self.player_number_label.grid(row=0, column=0, sticky='nsw', padx=10)

        self.character_name_label = tk.Label(
            self, text=f'Character: {self.info["character_name"].title()}', bg=self['background']
        )
        self.character_name_label.grid(row=0, column=1, sticky='nsw', padx=10)

        self.gsp_label = tk.Label(self, text=f'GSP: {self.info["gsp"]}', bg=self['background'])
        self.gsp_label.grid(row=1, column=0, sticky='nsw', padx=10)

        arr = np.array(self.info['player_name_image'])
        try:
            img = Image.fromarray(arr.astype('uint8'))
            img = img.resize((200, 30), Image.NEAREST)
            img = img.convert('1').tobitmap()
            bitmap = ImageTk.BitmapImage(data=img)
            self.player_name_label = tk.Label(self, image=bitmap, bg=self.master['background'])
            self.player_name_label.image = bitmap
            self.player_name_label.grid(row=1, column=1, sticky='nw', padx=10)
        except TypeError:
            _print(arr)
            _print('Image data corrupted')
            try:
                ut.dump_image_data(arr)
                _print('Image data successfully dumped')
            except:
                _print('Failed to dump image data')
Exemplo n.º 3
0
 def update(self, data):
     image = Image.frombytes('1', (self.width, self.height), data, 'raw', '1;R')
     self.tkimage = ImageTk.BitmapImage(
         image.resize((self.w, self.h)), foreground='white')
     self.canvas.itemconfig(self.cimage, image=self.tkimage)
     self.tk.update()
Exemplo n.º 4
0
    def __init__(self,master):
        self.master=master

        self.w=esper.World()

        #base game window

        

        self._map='map1.xml'

        self.faction_list=[{'name':'Military1',
                            'bg':'',
                            'icon_dir':'Military_textures',
                            'fg':'blue',
                            'visible':'true',
                            'Units':{'Infantry':{
                                     'icon':'infantry.xbm',
                                     'movable':'true',
                                     #'visi_radius':'4',
                                     'speed':'2',
                                     'auto_scripts':{'visibility':['1','1','4']},
                                     'move_mod':'4'}}},

                           
                            {'name':'Items',
                            'bg':'',
                            'icon_dir':'Item_textures',
                            'fg':'yellow',
                            'visible':'',
                            'Units':{'Item1':{
                                     'icon':'item1.xbm',
                                     'movable':'',
                                     'visi_radius':'0',
                                     'speed':'0',
                                     #'auto_scripts':{'visibility':['1','1','4']},
                                     'auto_scripts':{},
                                     'move_mod':'4'}}}]




        


        
        for i in self.faction_list:
            for j in i['Units']:
               


                

                img0=Image.open(plib.Path(Add._d['unit_t_dir'],i['icon_dir'],i['Units'][j]['icon']))

                
                img=ImageTk.BitmapImage(image=img0,background=i['bg'],foreground=i['fg'])

                                        
                i['Units'][j]['image']=img
                
                
        



        self.comm_list=[['faction1','player',[self.faction_list[0]['name']]]]


        

        self.ui=self.w.create_entity()

        self.w.add_component(self.ui,
                             game_windows(self.master,'window'))




        self.w.add_component(self.ui,Game_Manager(self.w,self._map))

        self.control=self.w.component_for_entity(self.ui,Game_Manager)

        self.w.add_processor(Movement(self.w,self.control))


        

        self.w.add_processor(Visibility(self.w,self.ui))
        self.control.scripts['visibility']=self.w.get_processor(Visibility).process



        


        self.w.add_processor(Auto_Scripts(self.w,self.ui))



        self.w.add_processor(TickRate(self.w,self.ui))

        



        self.create_factions()
        self.create_commands()

        #def add_unit(self,faction,unit_name,x0,y0)

        self.control.add_unit('Military1','Infantry',10,2)

        self.control.add_unit('Military1','Infantry',5,2)

        for i in range(10):

            self.control.add_unit('Items','Item1',random.randrange(10),random.randrange(10))
Exemplo n.º 5
0
			# PIL's IOError is missing the filename
			e = IOError(*(e.args + (filename,)))
			raise e
	elif isinstance(image, ImageTk.PhotoImage) \
	  or isinstance(image, ImageTk.BitmapImage):
		return image
	elif not isinstance(image, Image.Image):
		raise TypeError, "image must be filename or Image"

	if master == None:
		master = Tk._default_root

	r, g, b = master.winfo_rgb(master["background"])
	rgb = r / 255, g / 255, b / 255
	if image.mode == "1":
		imtk = ImageTk.BitmapImage(image, master=master)
	elif image.mode == "P" and image.info.has_key("transparency"):
		# palette + transparency property (GIF, PNG, XPM).
		# create a transparency mask, and paste the image
		# onto a solid background through that mask.
		lut = [255] * 256
		lut[image.info["transparency"]] = 0
		i = Image.new("RGB", image.size, rgb)
		i.paste(image, None, image.point(lut, "1"))
		imtk = ImageTk.PhotoImage(i, master=master)
	elif image.mode == "RGBA":
		# true color with transparency (PNG, TIFF).  Simpily
		# paste it onto a background image
		i = Image.new("RGB", image.size, rgb)
		i.paste(image, None, image)
		imtk = ImageTk.PhotoImage(i, master=master)
Exemplo n.º 6
0
entry_field = tkinter.Entry(top, textvariable=my_msg)
entry_field.bind("<Return>", send)
entry_field.pack()
send_button = tkinter.Button(top, text="Send", command=send)
send_button.pack()
cart_frame = tkinter.Frame(top)
cart_frame.pack(side=tkinter.LEFT, anchor=tkinter.CENTER)

###GANAR BOTON
bottomframe = tkinter.Frame(top)
bottomframe.pack(side=tkinter.BOTTOM, anchor=tkinter.SE)

imname = "assets/spoon.png"
origin = Image.open(imname).convert("1")
size = (origin.width // 3, origin.height // 3)
origin = ImageTk.BitmapImage(origin.resize(size))
spoon = ImageTk.PhotoImage(Image.open(imname).resize(size))
win_button = tkinter.Button(bottomframe, image=spoon, state=tkinter.DISABLED)
#win_button = tkinter.Button(bottomframe, image = spoon, state=tkinter.DISABLED, command = show_msg("Felicidades", "¡Ganaste el juego!"))
win_button.pack(side=tkinter.RIGHT)

upperframe = tkinter.Frame(top)
upperframe.pack(side=tkinter.TOP, anchor=tkinter.NE)

helpim = "assets/help.png"
originim = Image.open(helpim).convert("1")
sizes = (originim.width // 10, originim.height // 10)
originim = ImageTk.BitmapImage(originim.resize(sizes))
halpicon = ImageTk.PhotoImage(Image.open(helpim).resize(sizes))
halpbutton = tkinter.Button(upperframe, image=halpicon, command=popupHalp)
halpbutton.pack(side=tkinter.RIGHT)
Exemplo n.º 7
0
 def updateDisplay(self):
     img = ImageTk.BitmapImage(self.menu.generateView())
     self.panel.configure(image=img)
     self.panel.image = img
Exemplo n.º 8
0
def _get_dot(color=COLOR_GRAY):
    "create an image of a small square rectangle"
    return ImageTk.BitmapImage(background=color, data=IMG_DOT)
Exemplo n.º 9
0
def convert_to_tkimage_bitmap(img):
    return ImageTk.BitmapImage(img)
Exemplo n.º 10
0
def getIconImageTk(imageStr):
    imSize = int((len(4 * imageStr))**0.5)
    imString = imageStr.decode('hex')
    im = Image.fromstring('1', (imSize, imSize), imString)
    im = ImageTk.BitmapImage(im)
    return im