Thank you for taking a look at the video! If you want to use your own weapon graphics you would change this part of the code: self.img = PhotoImage(file="Your Image File Path") Let me know if this answered your question or if you have any other questions!
FINAL CODE
from tkinter import *
class Root(Tk):
def __init__(self):
super().__init__()
self.title("Weapon Wheel")
self.weapon_wheel = WeaponWheel(self)
class WeaponWheel(Canvas):
def __init__(self, parent):
super().__init__(parent, width=500, height=500)
self.weapons = [
Sword(),
]
#Canvas Dimensions
can_w = self.winfo_reqwidth()
can_h = self.winfo_reqheight()
#Weapon Label
self.weapon_var = StringVar()
self.weapon_var.set("Weapon:")
self.weapon_lbl = Label(self, textvariable=self.weapon_var)
self.create_window(can_w // 2, can_h // 4 - 25, window=self.weapon_lbl)
#Outer Circle
out_circle_x = can_w // 4
out_circle_y = can_h // 4
out_circle_x1 = can_w - out_circle_x
out_circle_y1 = can_h - out_circle_y
self.out_circle = self.create_oval(out_circle_x, out_circle_y, out_circle_x1, out_circle_y1, tags="out_circle", width=2)
#Weapon Arcs
if len(self.weapons) == 1:
weapon = self.weapons[0]
self.create_image(can_w // 2, can_h // 2, image=weapon.img, tags=weapon.tag + "_img")
self.pack()
class Weapon:
def __init__(self):
self.name = "Weapon"
self.img = None
self.fill_color = "gray"
self.tag = "weapon"
class Sword(Weapon):
def __init__(self):
super().__init__()
self.name = "Sword"
self.img = PhotoImage(file="Sword 50x50.png")
self.fill_color = "red"
self.tag = "sword"
if ___name___ == "__main__":
root = Root()
root.mainloop()
this was a useful video .
by the way if i have some custom graphics how can i replace those
i am new into coding in py
Thank you for taking a look at the video!
If you want to use your own weapon graphics you would change this part of the code:
self.img = PhotoImage(file="Your Image File Path")
Let me know if this answered your question or if you have any other questions!