#Copyright 2023 Bellkitsu. #This program is released free of charge for you to use. Permission is granted to use the software for any purpose under the following conditions: #- You may not redistribute this program in any way. #Thank you Compiled Dragon for giving advice to me. import tkinter as tk from tkinter import ttk root = tk.Tk() frame = tk.Frame(root) frame.pack() #Name = tk.Frame(Frame) #Name.pack(side = Side) TabTool = tk.Frame(root) TabTool.pack(side = tk.TOP) Bottom = tk.Frame(root) Bottom.pack(side = tk.BOTTOM) CanvasArea = ttk.Frame(Bottom) CanvasArea.pack(side = tk.LEFT) LeftGrid = tk.Frame(CanvasArea) LeftGrid.pack(side = tk.LEFT) IconSave = tk.PhotoImage(file = "Icons\Icon-Save.png") IconSaveAs = tk.PhotoImage(file = r"Icons\Icon-SaveAs.png") IconOpen = tk.PhotoImage(file = r"Icons\Icon-Open.png") IconNew = tk.PhotoImage(file = r"Icons\Icon-New.png") IconCopy = tk.PhotoImage(file = r"Icons\Icon-Copy.png") IconPaste = tk.PhotoImage(file = r"Icons\Icon-Paste.png") IconUndo = tk.PhotoImage(file = r"Icons\Icon-Undo.png") IconRectangle = tk.PhotoImage(file = r"Icons\Icon-Rectangle.png") IconOval = tk.PhotoImage(file = r"Icons\Icon-Oval.png") IconEmpty = tk.PhotoImage(file = r"Icons\Icon-Empty.png") def Label(Frame, Name, Text): Name = tk.Label(Frame, text = Text) Name.pack(side = tk.LEFT) def Button(Frame, Name, Text, Image, Command, Pack): Name = tk.Button(Frame, text = Text, image = Image, command = Command) Name.pack(side = Pack) def GridButton(Frame, Name, Text, Image, Command, Row, Column): Name = tk.Button(Frame, text = Text, image = Image, command = Command) Name.grid(row = Row, column = Column) CW = 600 CH = 450 LXM = (CW / 2) LYM = (CH / 2) TLX = tk.IntVar() TLY = tk.IntVar() TSX = tk.IntVar() TSY = tk.IntVar() LLX = tk.Label(LeftGrid, text = 'X:') LLX.grid(row = 2, column = 1) TLXInput = ttk.Entry(LeftGrid, textvariable = TLX) TLXInput.grid(row = 2, column = 2) LLY = tk.Label(LeftGrid, text = 'Y:') LLY.grid(row = 3, column = 1) TLYInput = ttk.Entry(LeftGrid, textvariable = TLY) TLYInput.grid(row = 3, column = 2) LSX = tk.Label(LeftGrid, text = 'Scale X:') LSX.grid(row = 4, column = 1) TSXInput = ttk.Entry(LeftGrid, textvariable = TSX) TSXInput.grid(row = 4, column = 2) LSY = tk.Label(LeftGrid, text = 'Scale Y:') LSY.grid(row = 5, column = 1) TSYInput = ttk.Entry(LeftGrid, textvariable = TSY) TSYInput.grid(row = 5, column = 2) MCLabel = tk.Label(LeftGrid, text = 'Main Color:') MCLabel.grid(row = 6, column = 1) MainColor = tk.Entry(LeftGrid, text = 'Main Color') MainColor.grid(row = 6, column = 2) LCLabel = tk.Label(LeftGrid, text = 'Line Color:') LCLabel.grid(row = 7, column = 1) LineColor = tk.Entry(LeftGrid, text = 'Line Color') LineColor.grid(row = 7, column = 2) LWLabel = tk.Label(LeftGrid, text = 'Line Width:') LWLabel.grid(row = 8, column = 1) LineWidth = tk.Entry(LeftGrid, text = 'Line Width') LineWidth.grid(row = 8, column = 2) MainCanvas = tk.Canvas(CanvasArea, bg = 'white', height = CH, width = CW) MainCanvas.pack(side = tk.LEFT) N = 0 ObjectList = [0] #def Rectangle(Name, Canvas, LX, LY, SX, SY, MC, LO, LT): # Canvas.create_rectangle((LX + SX), (LY + SY), (LX - SX), (LY - SY), fill = MC, outline = LO, width = LT, tags = Name) #def Circle(Name, Canvas, LX, LY, SX, SY, MC, LO, LT): def MakeRect(): Pum = N ObjectList.insert(Pum, MainCanvas.create_rectangle(((LXM + TLX.get()) + TSX.get()), ((LYM + TLY.get()) + TSY.get()), ((LXM + TLX.get()) - TSX.get()), ((LYM + TLY.get()) - TSY.get()), fill = MainColor.get(), outline = LineColor.get(), width = LineWidth.get(), tags = Pum)) Pum = N + 1 return Pum def MakeOval(): Pum = N ObjectList.insert(Pum, MainCanvas.create_oval(((LXM + TLX.get()) + TSX.get()), ((LYM + TLY.get()) + TSY.get()), ((LXM + TLX.get()) - TSX.get()), ((LYM + TLY.get()) - TSY.get()), fill = MainColor.get(), outline = LineColor.get(), width = LineWidth.get(), tags = Pum)) Pum = N + 1 return Pum def DeleteObj(): Pum = N MainCanvas.delete(ObjectList[Pum]) del ObjectList[Pum] Pum = N - 1 return Pum WidFrame = tk.Frame(TabTool) WidFrame.pack(side = tk.LEFT) WidFrame1 = tk.Frame(WidFrame) WidFrame1.pack(side = tk.TOP) WidFrame2 = tk.Frame(WidFrame) WidFrame2.pack(side = tk.TOP) Button(WidFrame1 ,'SV' ,'Save' ,IconSave ,None ,tk.LEFT) Button(WidFrame2 ,'SA' ,'Save As' ,IconSaveAs ,None ,tk.LEFT) Button(WidFrame1 ,'FO' ,'Open' ,IconOpen ,None ,tk.LEFT) Button(WidFrame2 ,'NF' ,'New File' ,IconNew ,None ,tk.LEFT) Button(WidFrame1 ,'CP' ,'Copy' ,IconCopy ,None ,tk.LEFT) Button(WidFrame2 ,'PS' ,'Paste' ,IconPaste ,None ,tk.LEFT) Button(WidFrame1 ,'UN' ,'Undo' ,IconUndo ,DeleteObj ,tk.LEFT) Button(WidFrame2 ,'EY' ,'Paste' ,IconEmpty ,None ,tk.LEFT) TabFrame = tk.Frame(TabTool) TabFrame.pack(side = tk.RIGHT) Tab = ttk.Notebook(TabFrame) Tab.pack(side = tk.RIGHT) TabFrame1 = ttk.Frame(Tab) Tab.add(TabFrame1, text = "Canvas") CCInput = tk.Entry(TabFrame1, text = 'Canvas Color') CCInput.pack(side = tk.LEFT) Button(TabFrame1, 'CC', 'Change Canvas Color', None, lambda: MainCanvas.configure(bg = CCInput.get()), tk.LEFT) TabFrame2 = ttk.Frame(Tab) Tab.add(TabFrame2, text = "Insert") Button(TabFrame2, 'RT', 'Rectangle', IconRectangle, MakeRect ,tk.LEFT) Button(TabFrame2, 'OV', 'Oval', IconOval, MakeOval ,tk.LEFT) TabFrame3 = ttk.Frame(Tab) Tab.add(TabFrame3, text = "Info") Label(TabFrame3, 'Notice', 'Current Version: v1.0. Vavfig ©Bellkitsu. Thanks Compiled Dragon for helping me.') root.mainloop()