updated libraries and cleaned up code.

This commit is contained in:
Jeremy McClure 2024-01-20 07:24:14 -05:00
parent 2689b6e384
commit 161d6d2686
2 changed files with 593 additions and 535 deletions

593
main.py Normal file
View File

@ -0,0 +1,593 @@
from customtkinter import CTk, CTkFrame, CTkLabel, CTkEntry, CTkButton, CTkToplevel
global firstNumber
global mathType
class App(CTk):
WIDTH = 800
HEIGHT = 480
calcPaddingX = 2
calcPaddingY = 2
calcWidth = 71
calcHeight = 40
calcNumberFG = "#134266"
calcMathFG = "#0C2940"
calcClearFG = "#990000"
buttonFont = "Roboto Medium"
buttonFontSize = 16
numberBoxFont = "Roboto Medium"
numberBoxFontSize = 37
PRE_B_WIDTH = 90
PRE_B_HEIGHT = 40
def __init__(self):
super().__init__()
self.geometry(f"{App.WIDTH}x{App.HEIGHT}")
self.resizable(False, False)
self.grid_columnconfigure(2, weight=1)
self.grid_rowconfigure(0, weight=1)
self.title("Table Saw Controls")
def format_number(num):
if num % 1 == 0:
return int(num)
else:
return num
def button_click(number):
current = self.numberBox.get()
self.numberBox.delete("0", "end")
self.numberBox.insert(0, str(current) + str(number))
def convert(scale_type):
if not self.numberBox.get():
c_num = 0.00
else:
c_num = float(self.numberBox.get())
if scale_type == "mm":
ans_in_mm = float(c_num) * 25.4
self.numberBox.delete("0", "end")
self.numberBox.insert(0, ans_in_mm)
if scale_type == "in":
ans_in_inch = float(c_num) / 25.4
self.numberBox.delete("0", "end")
self.numberBox.insert(0, ans_in_inch)
def import_to(option, location):
if not self.numberBox.get():
c_num = 0.00
else:
c_num = float(self.numberBox.get())
c_num = round(c_num, 3)
self.numberBox.delete("0", "end")
if option == "fence":
if location == "current_location":
self.fenceLocation.delete("0", "end")
self.fenceLocation.insert(0, c_num)
clear("calc")
if location == "destination_location":
self.fenceDestination.delete("0", "end")
self.fenceDestination.insert(0, c_num)
clear("calc")
if option == "angle":
if location == "current_location":
self.angleCurrentNumber.delete("0", "end")
self.angleCurrentNumber.insert(0, c_num)
clear("calc")
if location == "destination_location":
self.angleDestinationNumber.delete("0", "end")
self.angleDestinationNumber.insert(0, c_num)
clear("calc")
if option == "height":
if location == "current_location":
self.heightCurrentNumber.delete("0", "end")
self.heightCurrentNumber.insert(0, c_num)
clear("calc")
if location == "destination_location":
self.heightDestinationNumber.delete("0", "end")
self.heightDestinationNumber.insert(0, c_num)
clear("calc")
def clear(location):
if location == "calc":
self.numberBox.delete("0", "end")
self.numberBox.configure(placeholder_text="0")
if location == "fence_cur":
self.fenceLocation.delete("0", "end")
if location == "fence_destination":
self.fenceDestination.delete("0", "end")
if location == "angle_cur":
self.angleCurrentNumber.delete("0", "end")
if location == "angle_destination":
self.angleDestinationNumber.delete("0", "end")
if location == "height_cur":
self.heightCurrentNumber.delete("0", "end")
if location == "height_destination":
self.heightDestinationNumber.delete("0", "end")
def calculate(math_type):
if math_type == "add" or "sub" or "mult" or "div":
if not self.numberBox.get():
first_number = 0.00
else:
first_number = self.numberBox.get()
global firstNumber
global mathType
# f_num = float(first_number)
firstNumber = first_number
if math_type == "add":
mathType = "addition"
ph_string = f'{first_number} + '
self.numberBox.configure(placeholder_text=ph_string)
if math_type == "sub":
mathType = "subtraction"
ph_string = f'{first_number} - '
self.numberBox.configure(placeholder_text=ph_string)
if math_type == "mult":
mathType = "multiplication"
ph_string = f'{first_number} x '
self.numberBox.configure(placeholder_text=ph_string)
if math_type == "div":
mathType = "division"
ph_string = f'{first_number} ÷ '
self.numberBox.configure(placeholder_text=ph_string)
firstNumber = float(first_number)
self.numberBox.delete("0", "end")
def button_percent():
first_number = self.numberBox.get()
global firstNumber
global mathType
mathType = "percent"
firstNumber = float(first_number)
self.numberBox.delete("0", "end")
def button_equal():
global firstNumber
if not self.numberBox.get():
second_number = 0.00
else:
second_number = self.numberBox.get()
self.numberBox.delete("0", "end")
if mathType == "addition":
total = firstNumber + float(second_number)
formatted = format_number(total)
self.numberBox.insert(0, formatted)
firstNumber = 0
if mathType == "subtraction":
total = firstNumber - float(second_number)
formatted = format_number(total)
self.numberBox.insert(0, formatted)
firstNumber = 0
if mathType == "multiplication":
total = firstNumber * float(second_number)
formatted = format_number(total)
self.numberBox.insert(0, formatted)
firstNumber = 0
if mathType == "division":
total = firstNumber / float(second_number)
formatted = format_number(total)
self.numberBox.insert(0, formatted)
firstNumber = 0
if mathType == "percent":
total = firstNumber / float(second_number) * 100
formatted = format_number(total)
self.numberBox.insert(0, formatted)
firstNumber = 0
# Calculator Frame
self.calcFrame = CTkFrame(self)
self.calcFrame.configure(width=300, height=480, corner_radius=10)
self.calcFrame.grid(row=0, column=0, sticky="n")
self.calcLabel = CTkLabel(self.calcFrame)
self.calcLabel.configure(justify="center", font=(App.numberBoxFont, 19), text="Total")
self.calcLabel.grid(row=0, column=0, columnspan=4)
self.numberBox = CTkEntry(self.calcFrame)
self.numberBox.configure(height=75, width=300, insertborderwidth=0, font=(App.numberBoxFont,
App.numberBoxFontSize),
state="normal", justify="center", placeholder_text="0")
self.numberBox.grid(row=1, column=0, columnspan=4)
self.calc_label_con = CTkLabel(self.calcFrame)
self.calc_label_con.configure(justify="center", font=(App.numberBoxFont, 12), text="Conversions")
self.calc_label_con.grid(row=2, column=0, columnspan=4)
self.cal_conv_m = CTkButton(self.calcFrame)
self.cal_conv_m.configure(text="MM → IN", width=146, height=30, font=(App.buttonFont, App.buttonFontSize),
fg_color=App.calcMathFG, command=lambda: convert("in"))
self.cal_conv_m.grid(row=3, column=2, padx=App.calcPaddingX, pady=App.calcPaddingY, columnspan=2)
self.cal_conv_i = CTkButton(self.calcFrame)
self.cal_conv_i.configure(text="IN → MM", width=146, height=30, font=(App.buttonFont, App.buttonFontSize),
fg_color=App.calcMathFG, command=lambda: convert("mm"))
self.cal_conv_i.grid(row=3, column=0, padx=App.calcPaddingX, pady=App.calcPaddingY, columnspan=2)
self.calc_label_keypad = CTkLabel(self.calcFrame)
self.calc_label_keypad.configure(justify="center", font=(App.numberBoxFont, 12), text="Keypad")
self.calc_label_keypad.grid(row=4, column=0, columnspan=4)
self.cal_1 = CTkButton(self.calcFrame)
self.cal_1.configure(text="1", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize), fg_color=App.calcNumberFG,
command=lambda: button_click(1))
self.cal_1.grid(row=7, column=0, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.cal_2 = CTkButton(self.calcFrame)
self.cal_2.configure(text="2", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize), fg_color=App.calcNumberFG,
command=lambda: button_click(2))
self.cal_2.grid(row=7, column=1, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.cal_3 = CTkButton(self.calcFrame)
self.cal_3.configure(text="3", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize), fg_color=App.calcNumberFG,
command=lambda: button_click(3))
self.cal_3.grid(row=7, column=2, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.cal_4 = CTkButton(self.calcFrame)
self.cal_4.configure(text="4", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize), fg_color=App.calcNumberFG,
command=lambda: button_click(4))
self.cal_4.grid(row=6, column=0, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.cal_5 = CTkButton(self.calcFrame)
self.cal_5.configure(text="5", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize), fg_color=App.calcNumberFG,
command=lambda: button_click(5))
self.cal_5.grid(row=6, column=1, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.cal_6 = CTkButton(self.calcFrame)
self.cal_6.configure(text="6", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize), fg_color=App.calcNumberFG,
command=lambda: button_click(6))
self.cal_6.grid(row=6, column=2, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.cal_7 = CTkButton(self.calcFrame)
self.cal_7.configure(text="7", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize), fg_color=App.calcNumberFG,
command=lambda: button_click(7))
self.cal_7.grid(row=5, column=0, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.cal_8 = CTkButton(self.calcFrame)
self.cal_8.configure(text="8", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize), fg_color=App.calcNumberFG,
command=lambda: button_click(8))
self.cal_8.grid(row=5, column=1, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.cal_9 = CTkButton(self.calcFrame)
self.cal_9.configure(text="9", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize), fg_color=App.calcNumberFG,
command=lambda: button_click(9))
self.cal_9.grid(row=5, column=2, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.cal_0 = CTkButton(self.calcFrame)
self.cal_0.configure(text="0", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize), fg_color=App.calcNumberFG,
command=lambda: button_click(0))
self.cal_0.grid(row=8, column=1, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.cal_dec = CTkButton(self.calcFrame)
self.cal_dec.configure(text=".", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize), fg_color=App.calcNumberFG,
command=lambda: button_click('.'))
self.cal_dec.grid(row=8, column=2, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.cal_perc = CTkButton(self.calcFrame)
self.cal_perc.configure(text="%", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize), fg_color=App.calcNumberFG,
command=button_percent)
self.cal_perc.grid(row=8, column=0, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.cal_div = CTkButton(self.calcFrame)
self.cal_div.configure(text="÷", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize), fg_color=App.calcMathFG,
command=lambda: calculate("div"))
self.cal_div.grid(row=8, column=3, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.cal_mult = CTkButton(self.calcFrame)
self.cal_mult.configure(text="x", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize), fg_color=App.calcMathFG,
command=lambda: calculate("mult"))
self.cal_mult.grid(row=5, column=3, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.cal_sub = CTkButton(self.calcFrame)
self.cal_sub.configure(text="-", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize), fg_color=App.calcMathFG,
command=lambda: calculate("sub"))
self.cal_sub.grid(row=6, column=3, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.cal_add = CTkButton(self.calcFrame)
self.cal_add.configure(text="+", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize), fg_color=App.calcMathFG,
command=lambda: calculate("add"))
self.cal_add.grid(row=7, column=3, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.cal_clear = CTkButton(self.calcFrame)
self.cal_clear.configure(text="CLEAR", width=146, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize), fg_color=App.calcClearFG,
command=lambda: clear("calc"))
self.cal_clear.grid(row=9, column=0, padx=App.calcPaddingX, pady=App.calcPaddingY, columnspan=2)
self.cal_equal = CTkButton(self.calcFrame)
self.cal_equal.configure(text="=", width=146, height=App.calcHeight, font=(App.buttonFont, App.buttonFontSize),
command=button_equal)
self.cal_equal.grid(row=9, column=2, padx=App.calcPaddingX, pady=App.calcPaddingY, columnspan=2)
self.calc_label_frac = CTkLabel(self.calcFrame)
self.calc_label_frac.configure(justify="center", font=(App.numberBoxFont, 12), text="Fractions")
self.calc_label_frac.grid(row=10, column=0, columnspan=4)
self.cal_eighth = CTkButton(self.calcFrame)
self.cal_eighth.configure(text="", width=App.calcWidth, height=5, font=(App.buttonFont, 12),
command=lambda: button_click(".125"))
self.cal_eighth.grid(row=11, column=0, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.cal_quarter = CTkButton(self.calcFrame)
self.cal_quarter.configure(text="¼", width=App.calcWidth, height=5, font=(App.buttonFont, 12),
command=lambda: button_click(".25"))
self.cal_quarter.grid(row=11, column=1, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.cal_half = CTkButton(self.calcFrame)
self.cal_half.configure(text="½", width=App.calcWidth, height=5, font=(App.buttonFont, 12),
command=lambda: button_click(".5"))
self.cal_half.grid(row=11, column=2, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.cal_inch = CTkButton(self.calcFrame)
self.cal_inch.configure(text="¾", width=App.calcWidth, height=5, font=(App.buttonFont, 12),
command=lambda: button_click(".75"))
self.cal_inch.grid(row=11, column=3, padx=App.calcPaddingX, pady=App.calcPaddingY)
# END Calculator Frame
# Adjustments Frame
self.adjustments = CTkFrame(self)
self.adjustments.configure(width=370, height=160, corner_radius=10)
self.adjustments.grid(row=0, column=1, sticky="nw")
# Fence Frame
self.adjustments.frame_fence = CTkFrame(self.adjustments)
self.adjustments.frame_fence.configure(width=500, height=160, corner_radius=10)
self.adjustments.frame_fence.grid(row=0, column=1, sticky="nw")
self.fence_label = CTkLabel(self.adjustments.frame_fence)
self.fence_label.configure(justify="center", font=(App.numberBoxFont, 19), text="Fence")
self.fence_label.grid(row=0, column=0, columnspan=2)
self.fence_label_location = CTkLabel(self.adjustments.frame_fence)
self.fence_label_location.configure(justify="center", font=(App.numberBoxFont, 12), text="Current")
self.fence_label_location.grid(row=1, column=0, columnspan=1)
self.fence_label_final = CTkLabel(self.adjustments.frame_fence)
self.fence_label_final.configure(justify="center", font=(App.numberBoxFont, 12), text="Destination")
self.fence_label_final.grid(row=1, column=1, columnspan=1)
self.fenceLocation = CTkEntry(self.adjustments.frame_fence)
self.fenceLocation.configure(height=40, width=100, font=(App.numberBoxFont, 12), state="normal",
justify="center", placeholder_text="0")
self.fenceLocation.grid(row=2, column=0, columnspan=1)
self.fenceDestination = CTkEntry(self.adjustments.frame_fence)
self.fenceDestination.configure(height=40, width=100, font=(App.numberBoxFont, 12), state="normal",
justify="center", placeholder_text="0")
self.fenceDestination.grid(row=2, column=1, columnspan=1)
self.fenceGrabLocation = CTkButton(self.adjustments.frame_fence)
self.fenceGrabLocation.configure(text="→ Current", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize),
command=lambda: import_to("fence", "current_location"))
self.fenceGrabLocation.grid(row=3, column=0, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.fenceGrabGo = CTkButton(self.adjustments.frame_fence, )
self.fenceGrabGo.configure(text="→ Destination", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize),
command=lambda: import_to("fence", "destination_location"))
self.fenceGrabGo.grid(row=3, column=1, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.fenceGo = CTkButton(self.adjustments.frame_fence)
self.fenceGo.configure(text="GO!!", fg_color="green", hover_color="darkgreen", width=App.calcWidth,
height=App.calcHeight, font=(App.buttonFont, App.buttonFontSize), command=self.settings)
self.fenceGo.grid(row=2, column=2, padx=App.calcPaddingX, pady=App.calcPaddingY)
# END Fence Frame
# Angle Frame
self.adjustments.frame_angle = CTkFrame(self.adjustments)
self.adjustments.frame_angle.configure(width=500, height=160, corner_radius=10)
self.adjustments.frame_angle.grid(row=1, column=1, sticky="nw")
self.angleLabel = CTkLabel(self.adjustments.frame_angle)
self.angleLabel.configure(justify="center", font=(App.numberBoxFont, 19), text="Angle")
self.angleLabel.grid(row=0, column=0, columnspan=2)
self.angleLabelCurrent = CTkLabel(self.adjustments.frame_angle)
self.angleLabelCurrent.configure(justify="center", font=(App.numberBoxFont, 12), text="Current")
self.angleLabelCurrent.grid(row=1, column=0, columnspan=1)
self.angleLabelDestination = CTkLabel(self.adjustments.frame_angle)
self.angleLabelDestination.configure(justify="center", font=(App.numberBoxFont, 12), text="Destination")
self.angleLabelDestination.grid(row=1, column=1, columnspan=1)
self.angleCurrentNumber = CTkEntry(self.adjustments.frame_angle)
self.angleCurrentNumber.configure(height=40, width=100, font=(App.numberBoxFont, 12), state="normal",
justify="center", placeholder_text="0")
self.angleCurrentNumber.grid(row=2, column=0, columnspan=1)
self.angleDestinationNumber = CTkEntry(self.adjustments.frame_angle)
self.angleDestinationNumber.grid(row=2, column=1, columnspan=1)
self.angleDestinationNumber.configure(height=40, width=100, font=(App.numberBoxFont, 12), state="normal",
justify="center", placeholder_text="0")
self.angleGrabCurrent = CTkButton(self.adjustments.frame_angle)
self.angleGrabCurrent.configure(text="→ Current", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize),
command=lambda: import_to("angle", "current_location"))
self.angleGrabCurrent.grid(row=3, column=0, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.angleGrabGo = CTkButton(self.adjustments.frame_angle)
self.angleGrabGo.configure(text="→ Destination", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize),
command=lambda: import_to("angle", "destination_location"))
self.angleGrabGo.grid(row=3, column=1, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.angleGoZero = CTkButton(self.adjustments.frame_angle)
self.angleGoZero.configure(text="", fg_color="green", hover_color="darkgreen", width=App.calcWidth,
height=App.calcHeight, font=(App.buttonFont, App.buttonFontSize),
command=self.settings)
self.angleGoZero.grid(row=1, column=2, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.angleGo45 = CTkButton(self.adjustments.frame_angle, text="45", width=App.calcWidth,
height=App.calcHeight, font=(App.buttonFont, App.buttonFontSize),
command=self.settings)
self.angleGo45.configure(text="45°", fg_color="green", hover_color="darkgreen", width=App.calcWidth,
height=App.calcHeight, font=(App.buttonFont, App.buttonFontSize),
command=self.settings)
self.angleGo45.grid(row=2, column=2, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.angleGo = CTkButton(self.adjustments.frame_angle)
self.angleGo.configure(text="GO!!", fg_color="green", hover_color="darkgreen", width=App.calcWidth,
height=App.calcHeight, font=(App.buttonFont, App.buttonFontSize), command=self.settings)
self.angleGo.grid(row=3, column=2, padx=App.calcPaddingX, pady=App.calcPaddingY)
# END Angle Frame
# Height Frame
self.adjustments.frame_height = CTkFrame(self.adjustments)
self.adjustments.frame_height.configure(width=500, height=160, corner_radius=10)
self.adjustments.frame_height.grid(row=2, column=1, sticky="nw")
self.heightLabel = CTkLabel(self.adjustments.frame_height, justify="center", font=(App.numberBoxFont, 19),
text="Height")
self.heightLabel.configure(justify="center", font=(App.numberBoxFont, 19), text="Height")
self.heightLabel.grid(row=0, column=0, columnspan=2)
self.heightLabelCurrent = CTkLabel(self.adjustments.frame_height, justify="center",
font=(App.numberBoxFont, 12), text="Current")
self.heightLabelCurrent.configure(justify="center", font=(App.numberBoxFont, 12), text="Current")
self.heightLabelCurrent.grid(row=1, column=0, columnspan=1)
self.heightLabelDestination = CTkLabel(self.adjustments.frame_height)
self.heightLabelDestination.configure(justify="center", font=(App.numberBoxFont, 12), text="Destination")
self.heightLabelDestination.grid(row=1, column=1, columnspan=1)
self.heightCurrentNumber = CTkEntry(self.adjustments.frame_height)
self.heightCurrentNumber.configure(height=40, width=100, font=(App.numberBoxFont, 12), state="normal",
justify="center", placeholder_text="0")
self.heightCurrentNumber.grid(row=2, column=0, columnspan=1)
self.heightDestinationNumber = CTkEntry(self.adjustments.frame_height)
self.heightDestinationNumber.configure(height=40, width=100, font=(App.numberBoxFont, 12), state="normal",
justify="center", placeholder_text="0")
self.heightDestinationNumber.grid(row=2, column=1, columnspan=1)
self.heightGrabCurrent = CTkButton(self.adjustments.frame_height)
self.heightGrabCurrent.configure(text="→ Current", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize),
command=lambda: import_to("height", "current_location"))
self.heightGrabCurrent.grid(row=3, column=0, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.heightGrabGo = CTkButton(self.adjustments.frame_height)
self.heightGrabGo.configure(text="→ Destination", width=App.calcWidth, height=App.calcHeight,
font=(App.buttonFont, App.buttonFontSize),
command=lambda: import_to("height", "destination_location"))
self.heightGrabGo.grid(row=3, column=1, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.heightGoZero = CTkButton(self.adjustments.frame_height)
self.heightGoZero.configure(text="0''", fg_color="green", hover_color="darkgreen", width=App.calcWidth,
height=App.calcHeight, font=(App.buttonFont, App.buttonFontSize),
command=self.settings)
self.heightGoZero.grid(row=1, column=2, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.heightGo01 = CTkButton(self.adjustments.frame_height)
self.heightGo01.configure(text="1''", fg_color="green", hover_color="darkgreen", width=App.calcWidth,
height=App.calcHeight, font=(App.buttonFont, App.buttonFontSize),
command=self.settings)
self.heightGo01.grid(row=2, column=2, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.heightGo = CTkButton(self.adjustments.frame_height)
self.heightGo.configure(text="GO!!", fg_color="green", hover_color="darkgreen", width=App.calcWidth,
height=App.calcHeight, font=(App.buttonFont, App.buttonFontSize), command=self.settings)
self.heightGo.grid(row=3, column=2, padx=App.calcPaddingX, pady=App.calcPaddingY)
# END Height Frame
# END Adjustments Frame
# Presets Frame
self.presetsFrame = CTkFrame(self)
self.presetsFrame.configure(width=130, height=480, corner_radius=10)
self.presetsFrame.grid(row=0, column=2, sticky="n")
self.presetsLabel = CTkLabel(self.presetsFrame)
self.presetsLabel.configure(justify="center", font=(App.numberBoxFont, 19), text="Presets")
self.presetsLabel.grid(row=0, column=0, columnspan=1)
self.preset01 = CTkButton(self.presetsFrame)
self.preset01.configure(text="1", width=App.PRE_B_WIDTH, height=App.PRE_B_HEIGHT,
font=(App.buttonFont, App.buttonFontSize), command=self.settings)
self.preset01.grid(row=1, column=0, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.preset02 = CTkButton(self.presetsFrame)
self.preset02.configure(text="2", width=App.PRE_B_WIDTH, height=App.PRE_B_HEIGHT,
font=(App.buttonFont, App.buttonFontSize), command=self.settings)
self.preset02.grid(row=2, column=0, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.preset03 = CTkButton(self.presetsFrame)
self.preset03.configure(text="3", width=App.PRE_B_WIDTH, height=App.PRE_B_HEIGHT,
font=(App.buttonFont, App.buttonFontSize), command=self.settings)
self.preset03.grid(row=3, column=0, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.preset04 = CTkButton(self.presetsFrame)
self.preset04.configure(text="4", width=App.PRE_B_WIDTH, height=App.PRE_B_HEIGHT,
font=(App.buttonFont, App.buttonFontSize), command=self.settings)
self.preset04.grid(row=4, column=0, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.preset05 = CTkButton(self.presetsFrame)
self.preset05.configure(text="5", width=App.PRE_B_WIDTH, height=App.PRE_B_HEIGHT,
font=(App.buttonFont, App.buttonFontSize), command=self.settings)
self.preset05.grid(row=5, column=0, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.preset06 = CTkButton(self.presetsFrame)
self.preset06.configure(text="6", width=App.PRE_B_WIDTH, height=App.PRE_B_HEIGHT,
font=(App.buttonFont, App.buttonFontSize), command=self.settings)
self.preset06.grid(row=6, column=0, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.preset07 = CTkButton(self.presetsFrame)
self.preset07.configure(text="7", width=App.PRE_B_WIDTH, height=App.PRE_B_HEIGHT,
font=(App.buttonFont, App.buttonFontSize), command=self.settings)
self.preset07.grid(row=7, column=0, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.preset08 = CTkButton(self.presetsFrame)
self.preset08.configure(text="8", width=App.PRE_B_WIDTH, height=App.PRE_B_HEIGHT,
font=(App.buttonFont, App.buttonFontSize), command=self.settings)
self.preset08.grid(row=8, column=0, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.preset09 = CTkButton(self.presetsFrame)
self.preset09.configure(text="9", width=App.PRE_B_WIDTH, height=App.PRE_B_HEIGHT,
font=(App.buttonFont, App.buttonFontSize), command=self.settings)
self.preset09.grid(row=9, column=0, padx=App.calcPaddingX, pady=App.calcPaddingY)
self.preset10 = CTkButton(self.presetsFrame)
self.preset10.configure(text="10", width=App.PRE_B_WIDTH, height=App.PRE_B_HEIGHT,
font=(App.buttonFont, App.buttonFontSize), command=self.settings)
self.preset10.grid(row=10, column=0, padx=App.calcPaddingX, pady=App.calcPaddingY)
def settings(self):
def close_set():
settings.destroy()
settings = CTkToplevel(self)
settings.geometry("400x200")
# create label on CTkToplevel window
label = CTkLabel(settings, text="Settings")
label.pack(side="top", fill="both", expand=True, padx=40, pady=40)
settings.s_quit = CTkButton(settings, text="Quit", command=close_set)
settings.s_quit.pack(side="top", padx=40, pady=40)
if __name__ == '__main__':
app = App()
app.mainloop()

View File

@ -1,535 +0,0 @@
from faulthandler import disable
from tkinter import END
from customtkinter import CTk, CTkFrame, CTkLabel, CTkEntry, CTkButton
class App(CTk):
WIDTH = 800
HEIGHT = 480
CAL_PADX = 2
CAL_PADY = 2
CAL_WIDTH = 71
CAL_HEIGHT = 40
CAL_NUM_FG = "#134266"
CAL_MATH_FG = "#0C2940"
CAL_CLEAR_FG = "#990000"
BUT_FONT = "Roboto Medium"
BUT_FONT_S = 16
NUMBOX_FONT = "Roboto Medium"
NUMBOX_FONT_S = 37
PRE_B_WIDTH = 90
PRE_B_HEIGHT = 40
def __init__(self):
super().__init__()
self.geometry(f"{App.WIDTH}x{App.HEIGHT}")
self.resizable(width=0, height=0)
self.grid_columnconfigure(2, weight=1)
self.grid_rowconfigure(0, weight=1)
self.title("Table Saw Controls")
def formatNumber(num):
if num % 1 == 0:
return int(num)
else:
return num
def button_click(number):
current = self.numbox.get()
self.numbox.delete("0", "end")
self.numbox.insert(0, str(current) + str(number))
def convert(type):
if not self.numbox.get():
C_num = 0.00
else:
C_num= float(self.numbox.get())
if type == "mm":
ans_in_mm = float(C_num) * 25.4
self.numbox.delete("0", "end")
self.numbox.insert(0, ans_in_mm)
if type =="in":
ans_in_inch = float(C_num) / 25.4
self.numbox.delete("0", "end")
self.numbox.insert(0, ans_in_inch)
def import_to(option, location):
if not self.numbox.get():
C_num = 0.00
else:
C_num= float(self.numbox.get())
C_num = round(C_num, 3)
self.numbox.delete("0", "end")
if option == "fence":
if location == "cur":
self.fence_cur_num.delete("0", "end")
self.fence_cur_num.insert(0, C_num)
clear("calc")
if location == "dest":
self.fence_dest_num.delete("0", "end")
self.fence_dest_num.insert(0, C_num)
clear("calc")
if option == "angle":
if location == "cur":
self.angle_cur_num.delete("0", "end")
self.angle_cur_num.insert(0, C_num)
clear("calc")
if location == "dest":
self.angle_dest_num.delete("0", "end")
self.angle_dest_num.insert(0, C_num)
clear("calc")
if option == "height":
if location == "cur":
self.height_cur_num.delete("0", "end")
self.height_cur_num.insert(0, C_num)
clear("calc")
if location == "dest":
self.height_dest_num.delete("0", "end")
self.height_dest_num.insert(0, C_num)
clear("calc")
def clear(location):
if location == "calc":
self.numbox.delete("0", "end")
self.numbox.configure(placeholder_text="0")
if location == "fence_cur":
self.fence_cur_num.delete("0", "end")
if location == "fence_dest":
self.fence_dest_num.delete("0", "end")
if location == "angle_cur":
self.angle_cur_num.delete("0", "end")
if location == "angle_dest":
self.angle_dest_num.delete("0", "end")
if location == "height_cur":
self.height_cur_num.delete("0", "end")
if location == "height_dest":
self.height_dest_num.delete("0", "end")
def calculate(type):
if type == "add" or "sub" or "mult" or "div":
if not self.numbox.get():
first_number = 0.00
else:
first_number = self.numbox.get()
global f_num
global math
# f_num = float(first_number)
f_num = first_number
if type == "add":
math = "addition"
ph_string = f'{first_number} + '
self.numbox.configure(placeholder_text=ph_string)
if type == "sub":
math = "subtraction"
ph_string = f'{first_number} - '
self.numbox.configure(placeholder_text=ph_string)
if type == "mult":
math = "multiplication"
ph_string = f'{first_number} x '
self.numbox.configure(placeholder_text=ph_string)
if type == "div":
math = "division"
ph_string = f'{first_number} ÷ '
self.numbox.configure(placeholder_text=ph_string)
f_num = float(first_number)
self.numbox.delete("0", "end")
def button_percent():
first_number = self.numbox.get()
global f_num
global math
math = "percent"
f_num = float(first_number)
self.numbox.delete("0", "end")
def button_equal():
global f_num
if not self.numbox.get():
second_number = 0.00
else:
second_number = self.numbox.get()
self.numbox.delete("0", "end")
if math == "addition":
total = f_num + float(second_number)
formatted = formatNumber(total)
self.numbox.insert(0, formatted)
f_num = 0
if math == "subtraction":
total = f_num - float(second_number)
formatted = formatNumber(total)
self.numbox.insert(0, formatted)
f_num = 0
if math == "multiplication":
total = f_num * float(second_number)
formatted = formatNumber(total)
self.numbox.insert(0, formatted)
f_num = 0
if math == "division":
total = f_num / float(second_number)
formatted = formatNumber(total)
self.numbox.insert(0, formatted)
f_num = 0
if math == "percent":
total = f_num / float(second_number) * 100
formatted = formatNumber(total)
self.numbox.insert(0, formatted)
f_num = 0
def button_subtract():
first_number = self.numbox.get()
global f_num
global math
math = "subtraction"
f_num = float(first_number)
self.numbox.delete("0", "end")
def button_multiply():
first_number = self.numbox.get()
global f_num
global math
math = "multiplication"
f_num = float(first_number)
self.numbox.delete("0", "end")
def button_divide():
first_number = self.numbox.get()
global f_num
global math
math = "division"
f_num = float(first_number)
self.numbox.delete("0", "end")
#Calculator Frame
self.calc_f = CTkFrame(self)
self.calc_f.configure(width=300, height=480, corner_radius=10)
self.calc_f.grid(row=0, column=0, sticky="n")
self.calc_label = CTkLabel(self.calc_f)
self.calc_label.configure(justify="center", text_font=(App.NUMBOX_FONT, 19), text="Total")
self.calc_label.grid(row=0, column=0, columnspan=4)
# self.button = CTkButton(self.calc_f, text="Settings", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, command=self.settings)
# self.button.grid(row=7, column=0)
self.numbox = CTkEntry(self.calc_f)
self.numbox.configure(height=75, width=300, borderwidth=0, text_font=(App.NUMBOX_FONT, App.NUMBOX_FONT_S), state="normal", justify="center", placeholder_text="0")
self.numbox.grid(row=1, column=0, columnspan=4)
#self.numbox.insert("0", "0")
self.calc_label_con = CTkLabel(self.calc_f)
self.calc_label_con.configure(justify="center", text_font=(App.NUMBOX_FONT, 12), text="Conversions")
self.calc_label_con.grid(row=2, column=0, columnspan=4)
self.cal_conv_m = CTkButton(self.calc_f)
self.cal_conv_m.configure(text="MM → IN", width=146, height=30, text_font=(App.BUT_FONT, App.BUT_FONT_S), fg_color=App.CAL_MATH_FG, command=lambda: convert("in"))
self.cal_conv_m.grid(row=3, column=2, padx=App.CAL_PADX, pady=App.CAL_PADY, columnspan=2)
self.cal_conv_i = CTkButton(self.calc_f)
self.cal_conv_i.configure(text="IN → MM", width=146, height=30, text_font=(App.BUT_FONT, App.BUT_FONT_S), fg_color=App.CAL_MATH_FG, command=lambda: convert("mm"))
self.cal_conv_i.grid(row=3, column=0, padx=App.CAL_PADX, pady=App.CAL_PADY, columnspan=2)
self.calc_label_keypad = CTkLabel(self.calc_f)
self.calc_label_keypad.configure(justify="center", text_font=(App.NUMBOX_FONT, 12), text="Keypad")
self.calc_label_keypad.grid(row=4, column=0, columnspan=4)
self.cal_1 = CTkButton(self.calc_f)
self.cal_1.configure(text="1", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), fg_color=App.CAL_NUM_FG, command=lambda: button_click(1))
self.cal_1.grid(row=7, column=0, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.cal_2 = CTkButton(self.calc_f)
self.cal_2.configure(text="2", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), fg_color=App.CAL_NUM_FG, command=lambda: button_click(2))
self.cal_2.grid(row=7, column=1, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.cal_3 = CTkButton(self.calc_f)
self.cal_3.configure(text="3", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), fg_color=App.CAL_NUM_FG, command=lambda: button_click(3))
self.cal_3.grid(row=7, column=2, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.cal_4 = CTkButton(self.calc_f)
self.cal_4.configure(text="4", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), fg_color=App.CAL_NUM_FG, command=lambda: button_click(4))
self.cal_4.grid(row=6, column=0, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.cal_5 = CTkButton(self.calc_f)
self.cal_5.configure(text="5", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), fg_color=App.CAL_NUM_FG, command=lambda: button_click(5))
self.cal_5.grid(row=6, column=1, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.cal_6 = CTkButton(self.calc_f)
self.cal_6.configure(text="6", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), fg_color=App.CAL_NUM_FG, command=lambda: button_click(6))
self.cal_6.grid(row=6, column=2, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.cal_7 = CTkButton(self.calc_f)
self.cal_7.configure(text="7", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), fg_color=App.CAL_NUM_FG, command=lambda: button_click(7))
self.cal_7.grid(row=5, column=0, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.cal_8 = CTkButton(self.calc_f)
self.cal_8.configure(text="8", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), fg_color=App.CAL_NUM_FG, command=lambda: button_click(8))
self.cal_8.grid(row=5, column=1, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.cal_9 = CTkButton(self.calc_f)
self.cal_9.configure(text="9", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), fg_color=App.CAL_NUM_FG, command=lambda: button_click(9))
self.cal_9.grid(row=5, column=2, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.cal_0 = CTkButton(self.calc_f)
self.cal_0.configure(text="0", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), fg_color=App.CAL_NUM_FG, command=lambda: button_click(0))
self.cal_0.grid(row=8, column=1, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.cal_dec = CTkButton(self.calc_f)
self.cal_dec.configure(text=".", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), fg_color=App.CAL_NUM_FG, command=lambda: button_click('.'))
self.cal_dec.grid(row=8, column=2, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.cal_perc = CTkButton(self.calc_f)
self.cal_perc.configure(text="%", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), fg_color=App.CAL_NUM_FG, command=button_percent)
self.cal_perc.grid(row=8, column=0, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.cal_div = CTkButton(self.calc_f)
self.cal_div.configure(text="÷", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), fg_color=App.CAL_MATH_FG, command=lambda: calculate("div"))
self.cal_div.grid(row=8, column=3, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.cal_mult = CTkButton(self.calc_f)
self.cal_mult.configure(text="x", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), fg_color=App.CAL_MATH_FG, command=lambda: calculate("mult"))
self.cal_mult.grid(row=5, column=3, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.cal_sub = CTkButton(self.calc_f)
self.cal_sub.configure(text="-", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), fg_color=App.CAL_MATH_FG, command=lambda: calculate("sub"))
self.cal_sub.grid(row=6, column=3, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.cal_add = CTkButton(self.calc_f)
self.cal_add.configure(text="+", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), fg_color=App.CAL_MATH_FG, command=lambda: calculate("add"))
self.cal_add.grid(row=7, column=3, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.cal_clear = CTkButton(self.calc_f)
self.cal_clear.configure(text="CLEAR", width=146, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), fg_color=App.CAL_CLEAR_FG, command=lambda: clear("calc"))
self.cal_clear.grid(row=9, column=0, padx=App.CAL_PADX, pady=App.CAL_PADY, columnspan=2)
self.cal_equal = CTkButton(self.calc_f)
self.cal_equal.configure(text="=", width=146, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=button_equal)
self.cal_equal.grid(row=9, column=2, padx=App.CAL_PADX, pady=App.CAL_PADY, columnspan=2)
self.calc_label_frac = CTkLabel(self.calc_f)
self.calc_label_frac.configure(justify="center", text_font=(App.NUMBOX_FONT, 12), text="Fractions")
self.calc_label_frac.grid(row=10, column=0, columnspan=4)
self.cal_eighth = CTkButton(self.calc_f)
self.cal_eighth.configure(text="", width=App.CAL_WIDTH, height=5, text_font=(App.BUT_FONT, 12), command=lambda: button_click(".125"))
self.cal_eighth.grid(row=11, column=0, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.cal_quarter = CTkButton(self.calc_f)
self.cal_quarter.configure(text="¼", width=App.CAL_WIDTH, height=5, text_font=(App.BUT_FONT, 12), command=lambda: button_click(".25"))
self.cal_quarter.grid(row=11, column=1, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.cal_half = CTkButton(self.calc_f)
self.cal_half.configure(text="½", width=App.CAL_WIDTH, height=5, text_font=(App.BUT_FONT, 12), command=lambda: button_click(".5"))
self.cal_half.grid(row=11, column=2, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.cal_inch = CTkButton(self.calc_f)
self.cal_inch.configure(text="¾", width=App.CAL_WIDTH, height=5, text_font=(App.BUT_FONT, 12), command=lambda: button_click(".75"))
self.cal_inch.grid(row=11, column=3, padx=App.CAL_PADX, pady=App.CAL_PADY)
#END Calculator Frame
# Adjustments Frame
self.adjustments = CTkFrame(self)
self.adjustments.configure(width=370, height=160, corner_radius=10)
self.adjustments.grid(row=0, column=1, sticky="nw")
# Fence Frame
self.adjustments.frame_fence = CTkFrame(self.adjustments)
self.adjustments.frame_fence.configure(width=500, height=160, corner_radius=10)
self.adjustments.frame_fence.grid(row=0, column=1, sticky="nw")
self.fence_label = CTkLabel(self.adjustments.frame_fence)
self.fence_label.configure(justify="center", text_font=(App.NUMBOX_FONT, 19), text="Fence")
self.fence_label.grid(row=0, column=0, columnspan=2)
self.fence_label_cur = CTkLabel(self.adjustments.frame_fence)
self.fence_label_cur.configure(justify="center", text_font=(App.NUMBOX_FONT, 12), text="Current")
self.fence_label_cur.grid(row=1, column=0, columnspan=1)
self.fence_label_dest = CTkLabel(self.adjustments.frame_fence)
self.fence_label_dest.configure(justify="center", text_font=(App.NUMBOX_FONT, 12), text="Destination")
self.fence_label_dest.grid(row=1, column=1, columnspan=1)
self.fence_cur_num = CTkEntry(self.adjustments.frame_fence)
self.fence_cur_num.configure(height=40, width=100, text_font=(App.NUMBOX_FONT, 12), state="normal", justify="center", placeholder_text="0")
self.fence_cur_num.grid(row=2, column=0, columnspan=1)
self.fence_dest_num = CTkEntry(self.adjustments.frame_fence)
self.fence_dest_num.configure(height=40, width=100, text_font=(App.NUMBOX_FONT, 12), state="normal", justify="center", placeholder_text="0")
self.fence_dest_num.grid(row=2, column=1, columnspan=1)
self.fence_grab_cur = CTkButton(self.adjustments.frame_fence)
self.fence_grab_cur.configure(text="→ Current", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=lambda: import_to("fence", "cur"))
self.fence_grab_cur.grid(row=3, column=0, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.fence_grab_go = CTkButton(self.adjustments.frame_fence,)
self.fence_grab_go.configure(text="→ Desitnation", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=lambda: import_to("fence", "dest"))
self.fence_grab_go.grid(row=3, column=1, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.fence_go = CTkButton(self.adjustments.frame_fence)
self.fence_go.configure(text="GO!!", fg_color="green", hover_color="darkgreen", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=self.settings)
self.fence_go.grid(row=2, column=2, padx=App.CAL_PADX, pady=App.CAL_PADY)
# END Fence Frame
# Angle Frame
self.adjustments.frame_angle = CTkFrame(self.adjustments)
self.adjustments.frame_angle.configure(width=500, height=160, corner_radius=10)
self.adjustments.frame_angle.grid(row=1, column=1, sticky="nw")
self.angle_label = CTkLabel(self.adjustments.frame_angle)
self.angle_label.configure(justify="center", text_font=(App.NUMBOX_FONT, 19), text="Angle")
self.angle_label.grid(row=0, column=0, columnspan=2)
self.angle_label_cur = CTkLabel(self.adjustments.frame_angle)
self.angle_label_cur.configure(justify="center", text_font=(App.NUMBOX_FONT, 12), text="Current")
self.angle_label_cur.grid(row=1, column=0, columnspan=1)
self.angle_label_dest = CTkLabel(self.adjustments.frame_angle)
self.angle_label_dest.configure(justify="center", text_font=(App.NUMBOX_FONT, 12), text="Destination")
self.angle_label_dest.grid(row=1, column=1, columnspan=1)
self.angle_cur_num = CTkEntry(self.adjustments.frame_angle)
self.angle_cur_num.configure(height=40, width=100, text_font=(App.NUMBOX_FONT, 12), state="normal", justify="center", placeholder_text="0")
self.angle_cur_num.grid(row=2, column=0, columnspan=1)
self.angle_dest_num = CTkEntry(self.adjustments.frame_angle)
self.angle_dest_num.grid(row=2, column=1, columnspan=1)
self.angle_dest_num.configure(height=40, width=100, text_font=(App.NUMBOX_FONT, 12), state="normal", justify="center", placeholder_text="0")
self.angle_grab_cur = CTkButton(self.adjustments.frame_angle)
self.angle_grab_cur.configure(text="→ Current", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=lambda: import_to("angle", "cur"))
self.angle_grab_cur.grid(row=3, column=0, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.angle_grab_go = CTkButton(self.adjustments.frame_angle)
self.angle_grab_go.configure(text="→ Desitnation", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=lambda: import_to("angle", "dest"))
self.angle_grab_go.grid(row=3, column=1, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.angle_go_zero = CTkButton(self.adjustments.frame_angle)
self.angle_go_zero.configure(text="", fg_color="green", hover_color="darkgreen", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=self.settings)
self.angle_go_zero.grid(row=1, column=2, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.angle_go_45 = CTkButton(self.adjustments.frame_angle, text="45", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=self.settings)
self.angle_go_45.configure(text="45°", fg_color="green", hover_color="darkgreen", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=self.settings)
self.angle_go_45.grid(row=2, column=2, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.angle_go = CTkButton(self.adjustments.frame_angle)
self.angle_go.configure(text="GO!!", fg_color="green", hover_color="darkgreen", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=self.settings)
self.angle_go.grid(row=3, column=2, padx=App.CAL_PADX, pady=App.CAL_PADY)
# END Angle Frame
# Height Frame
self.adjustments.frame_height = CTkFrame(self.adjustments)
self.adjustments.frame_height.configure(width=500, height=160, corner_radius=10)
self.adjustments.frame_height.grid(row=2, column=1, sticky="nw")
self.height_label = CTkLabel(self.adjustments.frame_height, justify="center", text_font=(App.NUMBOX_FONT, 19), text="Height")
self.height_label.configure(justify="center", text_font=(App.NUMBOX_FONT, 19), text="Height")
self.height_label.grid(row=0, column=0, columnspan=2)
self.height_label_cur = CTkLabel(self.adjustments.frame_height, justify="center", text_font=(App.NUMBOX_FONT, 12), text="Current")
self.height_label_cur.configure(justify="center", text_font=(App.NUMBOX_FONT, 12), text="Current")
self.height_label_cur.grid(row=1, column=0, columnspan=1)
self.height_label_dest = CTkLabel(self.adjustments.frame_height)
self.height_label_dest.configure(justify="center", text_font=(App.NUMBOX_FONT, 12), text="Destination")
self.height_label_dest.grid(row=1, column=1, columnspan=1)
self.height_cur_num = CTkEntry(self.adjustments.frame_height)
self.height_cur_num.configure(height=40, width=100, text_font=(App.NUMBOX_FONT, 12), state="normal", justify="center", placeholder_text="0")
self.height_cur_num.grid(row=2, column=0, columnspan=1)
self.height_dest_num = CTkEntry(self.adjustments.frame_height)
self.height_dest_num.configure(height=40, width=100, text_font=(App.NUMBOX_FONT, 12), state="normal", justify="center", placeholder_text="0")
self.height_dest_num.grid(row=2, column=1, columnspan=1)
self.height_grab_cur = CTkButton(self.adjustments.frame_height)
self.height_grab_cur.configure(text="→ Current", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=lambda: import_to("height", "cur"))
self.height_grab_cur.grid(row=3, column=0, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.height_grab_go = CTkButton(self.adjustments.frame_height)
self.height_grab_go.configure(text="→ Desitnation", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=lambda: import_to("height", "dest"))
self.height_grab_go.grid(row=3, column=1, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.height_go_zero = CTkButton(self.adjustments.frame_height)
self.height_go_zero.configure(text="0''", fg_color="green", hover_color="darkgreen", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=self.settings)
self.height_go_zero.grid(row=1, column=2, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.height_go_1 = CTkButton(self.adjustments.frame_height)
self.height_go_1.configure(text="1''", fg_color="green", hover_color="darkgreen", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=self.settings)
self.height_go_1.grid(row=2, column=2, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.height_go = CTkButton(self.adjustments.frame_height)
self.height_go.configure(text="GO!!", fg_color="green", hover_color="darkgreen", width=App.CAL_WIDTH, height=App.CAL_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=self.settings)
self.height_go.grid(row=3, column=2, padx=App.CAL_PADX, pady=App.CAL_PADY)
# END Height Frame
# END Adjustments Frame
# Presets Frame
self.presets = CTkFrame(self)
self.presets.configure(width=130, height=480, corner_radius=10)
self.presets.grid(row=0, column=2, sticky="n")
self.presets_label = CTkLabel(self.presets)
self.presets_label.configure(justify="center", text_font=(App.NUMBOX_FONT, 19), text="Presets")
self.presets_label.grid(row=0, column=0, columnspan=1)
self.presets_1 = CTkButton(self.presets)
self.presets_1.configure(text="1", width=App.PRE_B_WIDTH, height=App.PRE_B_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=self.settings)
self.presets_1.grid(row=1, column=0, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.presets_2 = CTkButton(self.presets)
self.presets_2.configure(text="2", width=App.PRE_B_WIDTH, height=App.PRE_B_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=self.settings)
self.presets_2.grid(row=2, column=0, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.presets_3 = CTkButton(self.presets)
self.presets_3.configure(text="3", width=App.PRE_B_WIDTH, height=App.PRE_B_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=self.settings)
self.presets_3.grid(row=3, column=0, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.presets_4 = CTkButton(self.presets)
self.presets_4.configure(text="4", width=App.PRE_B_WIDTH, height=App.PRE_B_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=self.settings)
self.presets_4.grid(row=4, column=0, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.presets_5 = CTkButton(self.presets)
self.presets_5.configure(text="5", width=App.PRE_B_WIDTH, height=App.PRE_B_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=self.settings)
self.presets_5.grid(row=5, column=0, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.presets_6 = CTkButton(self.presets)
self.presets_6.configure(text="6", width=App.PRE_B_WIDTH, height=App.PRE_B_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=self.settings)
self.presets_6.grid(row=6, column=0, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.presets_7 = CTkButton(self.presets)
self.presets_7.configure(text="7", width=App.PRE_B_WIDTH, height=App.PRE_B_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=self.settings)
self.presets_7.grid(row=7, column=0, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.presets_8 = CTkButton(self.presets)
self.presets_8.configure(text="8", width=App.PRE_B_WIDTH, height=App.PRE_B_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=self.settings)
self.presets_8.grid(row=8, column=0, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.presets_9 = CTkButton(self.presets)
self.presets_9.configure(text="9", width=App.PRE_B_WIDTH, height=App.PRE_B_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=self.settings)
self.presets_9.grid(row=9, column=0, padx=App.CAL_PADX, pady=App.CAL_PADY)
self.presets_10 = CTkButton(self.presets)
self.presets_10.configure(text="10", width=App.PRE_B_WIDTH, height=App.PRE_B_HEIGHT, text_font=(App.BUT_FONT, App.BUT_FONT_S), command=self.settings)
self.presets_10.grid(row=10, column=0, padx=App.CAL_PADX, pady=App.CAL_PADY)
def settings(self):
def close_set():
settings.destroy()
settings = CTkToplevel(self)
settings.geometry("400x200")
# create label on CTkToplevel window
label = CTkLabel(settings, text="Settings")
label.pack(side="top", fill="both", expand=True, padx=40, pady=40)
settings.s_quit = CTkButton(settings, text="Quit", command=close_set)
settings.s_quit.pack(side="top", padx=40, pady=40)
app = App()
app.mainloop()