所以我过去几天一直在制作一个程序但是我认为这个问题很容易解决,但事实证明它并不那么容易......
这是我的代码:
print("Loading...")
from threading import *
from tkinter import *
import time
root = Tk()
root.title("Card Revealer BETA")
root.resizable(False, False)
image1 = PhotoImage(file="images\core\GUI.png")
w = image1.width()
h = image1.height()
root.geometry("%dx%d+0+0" % (w, h))
panel1 = Label(root, image=image1)
panel1.pack(side='top', fill='both', expand='yes')
Card1Image = PhotoImage(file="images\core\_blank.png")
Card1 = Label(panel1, image=Card1Image, width=80, height=100)
Card1.place(x=60, y=482)
Card2Image = PhotoImage(file="images\core\_blank.png")
Card2 = Label(panel1, image=Card2Image, width=80, height=100)
Card2.place(x=200, y=482)
Card3Image = PhotoImage(file="images\core\_blank.png")
Card3 = Label(panel1, image=Card3Image, width=80, height=100)
Card3.place(x=340, y=482)
Card4Image = PhotoImage(file="images\core\_blank.png")
Card4 = Label(panel1, image=Card4Image, width=80, height=100)
Card4.place(x=490, y=482)
Card5Image = PhotoImage(file="images\core\_blank.png")
Card5 = Label(panel1, image=Card5Image, width=80, height=100)
Card5.place(x=650, y=482)
from scapy.all import *
print("Finished loading.")
Deck = []
pick = None
picked = False
Side = ""
def PlaceCards(cards):
global Card1Image
global Card2Image
global Card3Image
global Card4Image
global Card5Image
Card1Image = PhotoImage(file="images\Cards\_%s.png"%(cards[0]))
Card2Image = PhotoImage(file="images\Cards\_%s.png"%(cards[1]))
Card3Image = PhotoImage(file="images\Cards\_%s.png"%(cards[2]))
Card4Image = PhotoImage(file="images\Cards\_%s.png"%(cards[3]))
Card5Image = PhotoImage(file="images\Cards\_%s.png"%(cards[4]))
def action(packet):
global Deck
global Side
global pick
global picked
global switchcount
c = 0
try:
if (packet[IP].src == "149.202.87.103"):
rawdata = packet.payload.payload.load
rawdata = str(rawdata)
if (rawdata[2:8] == "%xt%zm"):
if (IsOpponent(rawdata) == True):
if (IsDeck(rawdata) == True and picked == True):
rawdata = ClearFirstBit(rawdata)
NewCard = GetIDs(rawdata)
MoveUpdate(Deck[pick], NewCard)
print("Opponent New Deck:\n ", Deck)
picked == False
elif (IsDeck(rawdata) == True):
rawdata = ClearFirstBit(rawdata)
Deck = GetIDs(rawdata)
PlaceCards(Deck)
picked = True
print("Opponent Deck:\n ", Deck)
elif (IsPick(rawdata) == True):
pick = GetPick(rawdata)
print("Opponent chosen card:\n ", Deck[pick])
picked = True
if (rawdata[2:8] == "%xt%jz"):
setside(rawdata[2:])
print("Side detected: %s"%(Side))
except Exception as e:
print(e)
def sniffer():
sniff(prn=action)
sniffthread = Thread(target=sniffer)
sniffthread.daemon = True
sniffthread.start()
PlaceCards([1, 1, 1, 1, 1])
root.mainloop()
该程序应该嗅到你的互联网,并尝试在游戏中找出卡片ID(这是一个游戏作弊)。它能够获得所有的卡ID并将其放入阵列就好了,我创建了一个文件夹,其中所有的卡片图像都被命名为id,这样程序就可以轻松地将卡片放在gui上。它能够很好地定位图像,但出于某种原因它显示为白色图像,所以如果有人知道为什么这将是非常有帮助的!此外,错误不是gui,gui工作正常。问题在于PlaceCards功能
答案 0 :(得分:0)
我遇到了同样的问题。我这样解决了:
from PIL import Image, ImageTk
pathtophoto = Image.open("images\core\GUI.png")
image1 = ImageTk.PhotoImage(pathtophoto)
panel1 = Label(root, image=image1)
panel1.image = image1 #keep a reference
panel1.pack(side='top', fill='both', expand='yes')
您需要确保路径照片是root = Tk()
上的一行
我希望这有点帮助。