第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

當(dāng)我使用 ImageTk 時(shí),我的圖像不透明

當(dāng)我使用 ImageTk 時(shí),我的圖像不透明

瀟湘沐 2023-08-22 10:17:49
ImageTk我正在嘗試使用和將圖像放入窗口中PhotoImage。下面是代碼:import tkinter as tkimport random as rfrom PIL import ImageTk, Imagewindow = tk.Tk()HEIGHT = window.winfo_screenwidth()WIDTH = window.winfo_screenheight()RESOL = str(str(HEIGHT) + "x" + str(WIDTH+7) + "+" + str(-7) + "+" + str(0))window.geometry(RESOL)x = int(HEIGHT)/2y = int(WIDTH)/2updatex = HEIGHT + (0.6 * HEIGHT)main = tk.Frame(window, height = WIDTH, width = HEIGHT)main.configure(bg = "white", highlightthickness = 0)main.place(x = x, y = y, anchor = "center")Map = tk.Canvas(window, height = int((900 - int(x))) + int(900), width = int((900 - int(y))) + int(900), bg = "#44b863", highlightthickness = 0)Map.place(x = updatex, y = int(y), anchor = "center")p = tk.PhotoImage(file = "TitleForGameReal.png")play_solo_image = tk.PhotoImage(file = "PlaySoloButton.png")play_duo_image = tk.PhotoImage(file = "PlayDuoButton.png")title = tk.Label(main, image = p, highlightthickness = 0, bd = 0)title.place(relx = 0.5, rely = 0.35, anchor = "center")class CustomButton:    def __init__(self, image, master, height, width, bordercolor):        self.master = master        self.frame = tk.Frame(master, height = height, width = width, highlightthickness = 0)        self.image = tk.Label(self.frame, image = image, borderwidth = 0, bg = "dark grey")        self.bordercolor = bordercolor    def put(self, x, y, command):        self.x, self.y = x, y        self.frame.place(relx = x, rely = y, anchor = "center")        self.image.pack()        def enter(event = "<Enter>"):            self.image.config(borderwidth = 3)        self.image.bind("<Enter>", enter)        def leave(event = "<Leave>"):            self.image.config(borderwidth = 0)        self.image.bind("<Leave>", leave)        def bind_command(event = "<Button-1>"):            command()        self.image.bind("<Button -1>", bind_command)我還將留下圖像作為參考,因?yàn)槲以?PhotoShop 中編輯了照片以嚴(yán)格使其具有透明背景:
查看完整描述

1 回答

?
森林海

TA貢獻(xiàn)2011條經(jīng)驗(yàn) 獲得超2個(gè)贊

問題是需要一個(gè) PhotoImage 實(shí)例image的選項(xiàng)Map.create_image(updatex, y, image = self.image),但你給它一個(gè)標(biāo)簽,所以要修復(fù)它只需說。


class Player:

    def __init__(self, hp, image):

        self.hp = hp

        self.image = image #creating an instance variable

        self.pic = ImageTk.PhotoImage(self.image) #making an photoimage instance

        self.cv = Map.create_image(updatex, y, image = self.pic) #passing the photo image instance

        self.pic.image = self.pic #keeping a reference to the image

希望這已經(jīng)解決了錯(cuò)誤,如果有任何錯(cuò)誤或疑問,請告訴我。


查看完整回答
反對 回復(fù) 2023-08-22
  • 1 回答
  • 0 關(guān)注
  • 179 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號