def package(request): sprite = {} if 'pokemon_name' in request.GET: # url = 'https://api.github.com/users/%s' % username pokemon_name = request.GET['pokemon_name'] sprite = {'url': pb.SpriteResource('pokemon', pokemon_name).url} return render(request, 'pokemaoc/package.html', {'sprite': sprite})
def update(self): commands = [self.LGPEReader.readActive, self.LGPEReader.readLegend] read_func = commands[self.type_var.get() - 1] try: pk7b = PK7b(read_func()) error = False except Exception as e: print(e) error = True while error: try: pk7b = PK7b(read_func()) error = False except: error = True if not pk7b.isValid or pk7b.ec == 0: print("Invalid or Not Present") self.last_info = "" self.image_display.config(image='') self.current_info_display.delete(1.0, tk.END) if pk7b.isValid and pk7b.ec != 0 and str(pk7b) != self.last_info: info = str(pk7b) s1 = pb.SpriteResource('pokemon', pk7b.species, shiny=pk7b.shinyType).img_data im = Image.open(io.BytesIO(s1)) image = ImageTk.PhotoImage(im) self.image = image self.image_display.config(image=image) self.last_info = info self.current_info_display.delete(1.0, tk.END) self.current_info_display.insert(1.0, info) self.after_token = self.after(1000, self.update)
def update(self): commands = [ self.SWSHReader.readWild, self.SWSHReader.readLegend, self.SWSHReader.readHorse ] read_func = commands[self.type_var.get() - 1] try: pk8 = PK8(read_func()) error = False except Exception as e: print(e) error = True while error: try: pk8 = PK8(read_func()) error = False except: error = True if not pk8.isValid() or pk8.ec() == 0: print("Invalid or Not Present") self.last_info = "" self.image_display.config(image='') self.mark_display.config(image='') self.current_info_display.delete(1.0, tk.END) if pk8.isValid( ) and pk8.ec() != 0 and pk8.toString() != self.last_info: info = pk8.toString() s1 = pb.SpriteResource('pokemon', pk8.species(), shiny=pk8.shinyType).img_data if self.type_var.get() - 1 == 0: try: print( f"https://www.serebii.net/swordshield/ribbons/{pk8.mark().lower()}mark.png" ) s2 = urllib.request.urlopen( f"https://www.serebii.net/swordshield/ribbons/{pk8.mark().lower()}mark.png" ).read() im2 = Image.open(io.BytesIO(s2)) image2 = ImageTk.PhotoImage(im2) self.image2 = image2 self.mark_display.config(image=image2) info += f"Mark: {pk8.mark()}" print(info) except Exception as e: print(e) else: self.mark_display.config(image='') im = Image.open(io.BytesIO(s1)) image = ImageTk.PhotoImage(im) self.image = image self.image_display.config(image=image) self.last_info = info self.current_info_display.delete(1.0, tk.END) self.current_info_display.insert(1.0, info) self.after_token = self.after(1000, self.update)
def pokemon(): PKMN = random.randint(1, 898) img = pb.SpriteResource('pokemon', PKMN) pkmnName = (pb.pokemon(PKMN).name).upper() client = mqtt.Client("Richi") client.connect(BROKER, 1883, 60) client.publish(TOPICO, img.url) messagebox.showinfo(TOPICO, "Se ah enviado el Pokemon: " + pkmnName + " al topico")
def package(request): sprite = {} if 'pokemon_name' in request.GET: # url = 'https://api.github.com/users/%s' % username pokemon_name = request.GET['pokemon_name'] sprite = {'url': pb.SpriteResource('pokemon', pokemon_name).url} return render(request, 'pokemaoc/package.html', {'sprite': sprite}) # https://dev.to/camerenisonfire/10-intriguing-public-rest-apis-for-your-next-project-2gbd # https://pokeapi.co/docs/v2#pokemon # https://github.com/PokeAPI/pokebase
async def pokemon(self, ctx, pokemon=None): if pokemon is None: return await ctx.send( "Please provide a pokemon to display information about") try: data = pb.pokemon(pokemon) except: return await ctx.send("The pokemon could not be found") pokemon_avatar = pb.SpriteResource('pokemon', data.id).url pokeEmbed = Embed() pokeEmbed.color = ctx.author.color pokeEmbed.title = f"Showing data about {data.name.title()}" pokeEmbed.url = f"https://bulbapedia.bulbagarden.net/wiki/{pokemon.title()}_(Pokémon)" pokeEmbed.set_footer(text=f"Requested by {ctx.author.display_name}", icon_url=ctx.author.avatar_url) pokeEmbed.set_thumbnail(url=pokemon_avatar) pokeEmbed.add_field(name="Pokedex Number", value=data.id) pokeEmbed.add_field(name="Height", value=f"{data.height} decimeters") pokeEmbed.add_field(name="Weight", value=f"{data.weight} hectograms") pokeEmbed.add_field( name="Types", value=", ".join([type.type.name.title() for type in data.types])) pokeEmbed.add_field(name="Base HP", value=data.stats[0].base_stat, inline=True) pokeEmbed.add_field(name="Base Attack", value=data.stats[1].base_stat, inline=True) pokeEmbed.add_field(name="Base Defense", value=data.stats[2].base_stat, inline=True) pokeEmbed.add_field(name="Base Special Attack", value=data.stats[3].base_stat, inline=True) pokeEmbed.add_field(name="Base Special Defense", value=data.stats[4].base_stat, inline=True) pokeEmbed.add_field(name="Base Speed", value=data.stats[5].base_stat, inline=True) pokeEmbed.add_field(name="Evolves From Species", value=data.species.evolves_from_species, inline=True) await ctx.send(embed=pokeEmbed)
def update(self): self.SWSHReader.KCoordinates = KCoordinates(self.SWSHReader.readKCoordinatesBlock()) pkms = self.SWSHReader.KCoordinates.ReadOwPokemonFromBlock() info = [] infocheck = [] for pkm in pkms: info.append(pkm) infocheck.append(pkm.toString()) if infocheck != self.last_info: i = 0 for display in self.displays: for widget in display: widget.grid_forget() self.displays = [] for pkm in info: self.displays.append([]) self.displays[i].append(tk.Text(self,height=5)) self.displays[i][0].grid(column=2+(5 if i%2 else 0), row=2+int((i*3)/2), columnspan=1, rowspan=2) self.displays[i].append(tk.Label(self)) self.displays[i][1].grid(column=0+(5 if i%2 else 0), row=2+int((i*3)/2), columnspan=2, rowspan=2) self.displays[i].append(tk.Label(self)) self.displays[i][2].grid(column=3+(5 if i%2 else 0), row=2+int((i*3)/2), columnspan=2, rowspan=2) s1 = pb.SpriteResource('pokemon', pkm.species, shiny=pkm.getShinyType((pkm.sid<<16) | pkm.tid, pkm.PID)).img_data try: s2 = urllib.request.urlopen(f"https://www.serebii.net/swordshield/ribbons/{pkm.Ribbons[pkm.mark].lower() if pkm.mark != 255 else ''}mark.png").read() im2 = Image.open(io.BytesIO(s2)) image2 = ImageTk.PhotoImage(im2) self.cache.append(image2) self.displays[i][2].config(image=image2) except Exception as e: pass im = Image.open(io.BytesIO(s1)) image = ImageTk.PhotoImage(im) self.cache.append(image) self.displays[i][1].config(image=image) self.last_info = pkm.toString() self.displays[i][0].delete(1.0, tk.END) self.displays[i][0].insert(1.0, pkm.toString()) i += 1 self.last_info = infocheck self.after_token = self.after(1000, self.update)
def get_pokemon(species,shiny): image_bytes = pb.SpriteResource('pokemon', species, shiny=shiny).img_data im = Image.open(io.BytesIO(image_bytes)) return ImageTk.PhotoImage(im)