From 4e6865f8245dc563ecbb841ceba6574d79e9406c Mon Sep 17 00:00:00 2001 From: Thomas Herrmann Date: Thu, 21 Dec 2023 16:02:15 +0100 Subject: [PATCH] - Added Directory listbox selection - Added feed info - Added JOb progress - Added misc messages - Added new color scheme --- cnc_gerbil.py | 338 +++++++++++++++++++++++++++++++------------------- 1 file changed, 212 insertions(+), 126 deletions(-) diff --git a/cnc_gerbil.py b/cnc_gerbil.py index 2a009ac..34df9dc 100644 --- a/cnc_gerbil.py +++ b/cnc_gerbil.py @@ -1,10 +1,7 @@ -import serial import time -from tkinter import * -import serial.tools.list_ports +from tkinter import Button, Label, Variable, IntVar, Canvas, Frame, Listbox, Entry, Radiobutton, Tk, constants from tkinter import filedialog as fd import os -import threading from gerbil.gerbil import Gerbil @@ -16,6 +13,10 @@ class touchCNC: # 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'} # self.spindle, Coolant, Toolchange @@ -30,16 +31,19 @@ class touchCNC: } # GUI Color Scheme - self.attention = 'red' - self.loaded = 'green' - self.cooling = 'blue' - self.toolchange = 'yellow' - self.standard = '#254164' - self.feed = self.standard - self.transport = '#3A5F8B' + 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) + 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, @@ -53,25 +57,25 @@ class touchCNC: 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=1, command=lambda: self.directWrite('G10 P0 L20 X0'), - bd=self.BORDER) - self.zero_y = Button(root, text="zero Y", width=self.buttonsize_x, height=1, command=lambda: self.directWrite('G10 P0 L20 Y0'), - bd=self.BORDER) - self.zero_z = Button(root, text="zero Z", width=self.buttonsize_x, height=1, command=lambda: self.directWrite('G10 P0 L20 Z0'), - bd=self.BORDER) - self.zero_all = Button(root, text="zeroAll", width=self.buttonsize_x, height=3, command=lambda: self.latchWrite('G10'), - bd=self.BORDER, bg='magenta') + 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, - command=lambda: self.directWrite('G28.1'), bd=self.BORDER) - self.gozero = Button(root, text="GoPOS", width=self.buttonsize_x, height=self.buttonsize_y, command=lambda: self.directWrite('G28'), + 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='grey', bd=self.BORDER) + 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) - self.unlock = Button(root, text="Unlock", width=self.buttonsize_x, height=self.buttonsize_y, command=self.grblUnlock, + 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) @@ -82,9 +86,14 @@ class touchCNC: 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="GCODE", width=self.buttonsize_x, height=self.buttonsize_y, bg='grey', fg='black', + 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, @@ -102,42 +111,45 @@ class touchCNC: 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="