注意:要弄清楚这不仅是按钮问题,因为圆圈是具有相同问题的背景图像。
这些以透明背景导出,所以我不明白白色边框。
from tkinter import *
import tkinter as tk
import random
window = tk.Tk()
window.option_add('font', 'Impact 19')
window.title("Randomizer")
window.geometry("600x900")
back =Canvas(window, bg="#172E38", height=2000, width=1000)
# ----RANDOM SELECT GEN--------
def random_gen():
Champ = ['Aatrox',
'Zoe']
Lane = ['top', 'bottom', 'middle', 'support', 'jungle']
Build = ['AD', 'Tank', 'AP', 'Crit', 'Attack speed', 'Assassin']
x = random.choice(Build)
y = random.choice(Champ)
z = random.choice(Lane)
return (x, y, z)
# TEST FUNCTION-------------
def random_display():
result = random_gen()
label.config(text=result, bg="#172E38", fg="#C49E4E", font=1000)
# Background----------------
C = Canvas(window, borderwidth=0)
filename = PhotoImage(file="C:/Users/wrped/OneDrive/Desktop/button44-01.png")
background_label = Label(window, image=filename)
background_label.place(x=25, y=174)
# -----BUTTON---------------
label = Label(window, text="", font=1000, height=1, width=41, bg="#172E38")
label.place(x=120, y=425)
button = tk.Button(text="Goodluck!", command=random_display, font=500, borderwidth=-5, relief=FLAT)
img = PhotoImage(file="C:/Users/wrped/OneDrive/Desktop/button1t-01.png")
button.config(image=img)
button.place(x=188, y=613)
button = tk.Button(command=window.quit, borderwidth=0)
exit = PhotoImage(file="C:/Users/wrped/OneDrive/Desktop/exit-01.png")
button.config(image=exit)
button.place(x=228, y=690)
C.place(x=200, y=200)
back.pack()
window.mainloop()
P.S。我是新来的,我不知道该怎么做很容易解释,我可以用大量文字来描述,而且因为有太多代码,我也无法发表,所以有人可以给我一些提示很棒的帖子!