import time from tkinter import Button, Label, Variable, IntVar, Canvas, Frame, Listbox, Entry, Radiobutton, Tk, constants, LEFT from tkinter import filedialog as fd import os from gerbil.gerbil import Gerbil class touchCNC: def __init__(self, root): self.root = root # GUI Main self.buttonsize_x = 5 self.buttonsize_y = 3 self.buttonsize_y_s = 1 self.pady_var = 5 self.file_list = [] self.list_items = Variable(value=self.file_list) self.increments = 0 self.BORDER = 2 self.states = {'M3': '0', 'M8': '0', 'M6': '0', 'G10': '0', '32' :0} # self.spindle, Coolant, Toolchange self.dict_GCODE = {'G': '0', 'X': '0', 'Y': '0', 'Z': '0', 'I': '0', 'J': '0', 'F': '0' } # GUI Color Scheme self.attention = '#ED217C' self.special = '#EC058E' self.loaded = '#90E39A' self.cooling = '#86BBD8' self.toolchange = '#ADE25D' self.secondary = '#B9A44C' self.standard = '#6DB1BF' #F5F5F5' self.feed = self.secondary self.transport = '#FA7921' self.increments = IntVar() self.movement = Frame(root, relief='ridge', bd=self.BORDER, padx=10, pady=10) self.left = Button(root, text="-X", width=self.buttonsize_x, height=self.buttonsize_y, command=lambda: self.jogWrite('X', '-1', self.increments), bd=self.BORDER, bg=self.standard) self.right = Button(root, text="+X", width=self.buttonsize_x, height=self.buttonsize_y, command=lambda: self.jogWrite('X', '1', self.increments), bd=self.BORDER, bg=self.standard) self.up = Button(root, text="+Y", width=self.buttonsize_x, height=self.buttonsize_y, command=lambda: self.jogWrite('Y', '1', self.increments), bd=self.BORDER, bg=self.standard) self.down = Button(root, text="-Y", width=self.buttonsize_x, height=self.buttonsize_y, command=lambda: self.jogWrite('Y', '-1', self.increments), bd=self.BORDER, bg=self.standard) self.z_up = Button(root, text="+Z", width=self.buttonsize_x, height=self.buttonsize_y, command=lambda: self.jogWrite('Z', '1', self.increments), bd=self.BORDER, bg=self.standard) self.z_down = Button(root, text="-Z", width=self.buttonsize_x, height=self.buttonsize_y, command=lambda: self.jogWrite('Z', '-1', self.increments), bd=self.BORDER, bg=self.standard) self.zero_x = Button(root, text="zero X", width=self.buttonsize_x, height=self.buttonsize_y_s, command=lambda: self.directWrite('G10 P0 L20 X0'), bd=self.BORDER, bg=self.secondary) self.zero_y = Button(root, text="zero Y", width=self.buttonsize_x, height=self.buttonsize_y_s, command=lambda: self.directWrite('G10 P0 L20 Y0'), bd=self.BORDER, bg=self.secondary) self.zero_z = Button(root, text="zero Z", width=self.buttonsize_x, height=self.buttonsize_y_s, command=lambda: self.directWrite('G10 P0 L20 Z0'), bd=self.BORDER, bg=self.secondary) self.zero_all = Button(root, text="zeroAll", width=self.buttonsize_x, height=self.buttonsize_y_s, command=lambda: self.latchWrite('G10'), bd=self.BORDER, bg=self.special) self.setzero = Button(root, text="SetPOS", width=self.buttonsize_x, height=self.buttonsize_y_s, command=lambda: self.directWrite('G28.1'), bd=self.BORDER, bg= self.standard) self.gozero = Button(root, text="GoPOS", width=self.buttonsize_x, height=self.buttonsize_y_s, command=lambda: self.directWrite('G28'), bd=self.BORDER , bg= self.attention) self.connect_ser = Button(root, text="Cnnct", width=self.buttonsize_x, height=self.buttonsize_y, command=self.grblConnect2, bg=self.standard, bd=self.BORDER) self.discon_ser = Button(root, text="Dsconct", width=self.buttonsize_x, height=self.buttonsize_y, command= self.grblClose, bd=self.BORDER, bg=self.standard) self.unlock = Button(root, text="Unlock", width=self.buttonsize_x, height=1, command=self.grblUnlock, bd=self.BORDER) self.start = Button(root, text="START", width=self.buttonsize_x, height=self.buttonsize_y, bg=self.attention, command=self.grblWrite, bd=self.BORDER) self.stop = Button(root, text="STOP", width=self.buttonsize_x, height=self.buttonsize_y, bd=self.BORDER, bg=self.transport, command=self.grblStop) self.pause = Button(root, text="PAUSE", width=self.buttonsize_x, height=self.buttonsize_y, bd=self.BORDER, bg=self.transport, command=self.grblPause) self.resume = Button(root, text="RESUME", width=self.buttonsize_x, height=self.buttonsize_y, bd=self.BORDER, bg=self.transport, command=self.grblResume) self.fopen = Button(root, text="OPEN", width=self.buttonsize_x, height=self.buttonsize_y, bg=self.standard, fg='black', command=self.openGCODE, bd=self.BORDER) self.fopendir = Button(root, text="DIR", width=self.buttonsize_x, height=self.buttonsize_y, bg=self.standard, fg='black', command=self.openDir, bd=self.BORDER) self.spindle = Button(root, text="Spindle", width=self.buttonsize_x, height=self.buttonsize_y, bg=self.standard, command=lambda: self.latchWrite('M3')) self.coolant = Button(root, text="Coolant", width=self.buttonsize_x, height=self.buttonsize_y, bg=self.standard, command=lambda: self.latchWrite('M8')) self.tool = Button(root, text="Tool", width=self.buttonsize_x, height=self.buttonsize_y, bg=self.standard, command=lambda: self.latchWrite('M6')) self.macro = Button(root, text="Laser", width=self.buttonsize_x, height=self.buttonsize_y, bg=self.standard, command=lambda: self.latchWrite('32')) #self.directWrite(' G91 G0 X10 Y10 Z50 F1000')) self.inc1 = Button(root, text="Inc 1%", width=self.buttonsize_x, height=self.buttonsize_y, command=lambda: self.directWrite('‘'), bg=self.feed) self.inc10 = Button(root, text="Inc 10%", width=self.buttonsize_x, height=self.buttonsize_y, command=lambda: self.directWrite('“'), bg=self.feed) self.dec1 = Button(root, text="Dec 1%", width=self.buttonsize_x, height=self.buttonsize_y, command=lambda: self.directWrite('”'), bg=self.feed) self.dec10 = Button(root, text="Dec 10%", width=self.buttonsize_x, height=self.buttonsize_y, command=lambda: self.directWrite('’'), bg=self.feed) self.reset = Button(root, text="