From fa9b9a5a5ede43131924fc52fbb170eb0a337d83 Mon Sep 17 00:00:00 2001 From: Colin O'Flynn Date: Sat, 22 Nov 2014 13:07:23 -0400 Subject: [PATCH 1/6] Change python bin pointer for Linux --- g2g_gui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/g2g_gui.py b/g2g_gui.py index 482fa00..db38aae 100755 --- a/g2g_gui.py +++ b/g2g_gui.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python import Tkinter import tkMessageBox import tkFileDialog From ef54bd85c0cdafcf794bcb15ddcb74fc6281730b Mon Sep 17 00:00:00 2001 From: Colin O'Flynn Date: Sat, 22 Nov 2014 13:24:27 -0400 Subject: [PATCH 2/6] Add force test mode --- g2g_gui.py | 70 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 8 deletions(-) diff --git a/g2g_gui.py b/g2g_gui.py index db38aae..4411d0c 100755 --- a/g2g_gui.py +++ b/g2g_gui.py @@ -47,6 +47,57 @@ def floats(s): return map(float,string.split(s,',')) +def test_forces(): + + original_stdout = sys.stdout # keep a reference to STDOUT + + if Output_name.get(): + sys.stdout = open(Output_name.get(), 'w') + + if not offset_str.get(): + default_offset_str() + if not matrix_str.get(): + default_matrix_str() + if not speed_str.get(): + default_speed_str() + + + offset = floats(offset_str.get()) + matrix = floats(matrix_str.get()) + speed = floats(speed_str.get()) + + # + # main program + # + + import graphtec + import pic + import optimize + +# offset = (5, 1) +# matrix = (1, 0, 0, 1) + + g = graphtec.graphtec() + + g.start() + + g.set(offset=offset, matrix=matrix) + g.set(speed=speed) + + for i in range(0, 6): + for j in range(0, 5): + g.set(force=1 + j + 5 * i) + tx = 0.5 * j + ty = 0.5 * i + g.closed_path([(tx, ty), (tx + 0.3, ty), (tx + 0.3, ty + 0.3), (tx, ty + 0.3)]) + + g.end() + + if Output_name.get(): + sys.stdout = original_stdout # restore STDOUT back to its original value + tkMessageBox.showinfo("G2G_GUI Message", "File '%s' created" % (Output_name.get())) + + def main_program(): # # convert file to pic format @@ -76,7 +127,7 @@ def main_program(): if not os.path.exists(pstoedit_path.get()): tkMessageBox.showerror("G2G_GUI ERROR", "The path provided for pstoedit is invalid.") return - + if os.name=='nt': os.system("echo \"%s\" --export=pdf --output=%s --border=0 \"%s\" > \"%s\"" % (os.path.normpath(gerbv_path.get()),temp_pdf,os.path.normpath(Gerber_name.get()),temp_bat)) os.system("echo \"%s\" -q -f pic \"%s\" \"%s\" >> \"%s\"" % (os.path.normpath(pstoedit_path.get()),temp_pdf,temp_pic, temp_bat)) @@ -102,7 +153,7 @@ def main_program(): default_force_str() if not cut_mode_str.get(): default_cut_mode_str() - + offset = floats(offset_str.get()) border = floats(border_str.get()) matrix = floats(matrix_str.get()) @@ -179,7 +230,7 @@ def Send_to_Cutter(): if not Output_name.get(): return src=os.path.normpath(Output_name.get()) - + if not cutter_shared_name_str.get(): tkMessageBox.showerror("G2G_GUI ERROR", "The name of the cutter (as a shared printer) was not provided.") return @@ -187,7 +238,7 @@ def Send_to_Cutter(): #if not os.path.exists(cutter_shared_name_str.get()): # tkMessageBox.showerror("G2G_GUI ERROR", "The name of the cutter (as a shared printer) does not exist.") # return - + dst=os.path.normpath(cutter_shared_name_str.get()) if os.name=='nt': os.system("copy /B \"%s\" \"%s\"" % (src, dst)) @@ -216,10 +267,10 @@ def get_pstoedit_path(): def default_offset_str(): offset_str.set("4.0,0.5") - + def default_border_str(): border_str.set("1,1") - + def default_matrix_str(): matrix_str.set("1,0,0,1") @@ -228,7 +279,7 @@ def default_speed_str(): def default_force_str(): force_str.set("8,30") - + def default_cut_mode_str(): cut_mode_str.set("0") @@ -279,11 +330,14 @@ def default_cut_mode_str(): Label(top, text="Cutter Device Name").grid(row=11, column=0, sticky=W) Entry(top, bd =1, width=60, textvariable=cutter_shared_name_str).grid(row=11, column=1, sticky=E) -Tkinter.Button(top, width=40, text = "Create Graphtec File", command = main_program).grid(row=12, column=1) +Tkinter.Button(top, width=40, text = "Create Graphtec File from Gerber", command = main_program).grid(row=12, column=1) Tkinter.Button(top, width=40, text = "Send Graphtec File to Silhouette Cutter", command = Send_to_Cutter).grid(row=13, column=1) Tkinter.Button(top, width=40, text = "Save Configuration", command = Save_Configuration).grid(row=14, column=1) Tkinter.Button(top, width=40, text = "Exit", command = Just_Exit).grid(row=15, column=1) +Tkinter.Button(top, width=40, text="Create test_forces Graphtec file", command=test_forces).grid(row=17, column=1) + + if path.isfile(CONFPATH) and access(CONFPATH, R_OK): f = open(CONFPATH,'r') input_filename = f.readline() From 6367b353eb30889f6b57a62aedcf564f09849f68 Mon Sep 17 00:00:00 2001 From: Colin O'Flynn Date: Sat, 22 Nov 2014 13:54:53 -0400 Subject: [PATCH 3/6] Add button to show gerber file --- g2g_gui.py | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/g2g_gui.py b/g2g_gui.py index 4411d0c..b83882f 100755 --- a/g2g_gui.py +++ b/g2g_gui.py @@ -5,6 +5,7 @@ import sys import os import string +import subprocess from Tkinter import * from os import path, access, R_OK, W_OK @@ -98,6 +99,27 @@ def test_forces(): tkMessageBox.showinfo("G2G_GUI Message", "File '%s' created" % (Output_name.get())) +def show_gerber(): + + if not os.path.exists(Gerber_name.get()): + get_input_filename() + if not os.path.exists(Gerber_name.get()): + tkMessageBox.showerror("G2G_GUI ERROR", "The path provided for the input Gerber file is invalid.") + return + + head, tail = os.path.split(Gerber_name.get()) + + if os.name == 'nt': + if not os.path.exists(gerbv_path.get()): + tkMessageBox.showerror("G2G_GUI ERROR", "The path provided for gerbv is invalid.") + return + + if not os.path.exists(pstoedit_path.get()): + tkMessageBox.showerror("G2G_GUI ERROR", "The path provided for pstoedit is invalid.") + return + + subprocess.Popen([os.path.normpath(gerbv_path.get()), os.path.normpath(Gerber_name.get())]) + def main_program(): # # convert file to pic format @@ -330,10 +352,11 @@ def default_cut_mode_str(): Label(top, text="Cutter Device Name").grid(row=11, column=0, sticky=W) Entry(top, bd =1, width=60, textvariable=cutter_shared_name_str).grid(row=11, column=1, sticky=E) -Tkinter.Button(top, width=40, text = "Create Graphtec File from Gerber", command = main_program).grid(row=12, column=1) -Tkinter.Button(top, width=40, text = "Send Graphtec File to Silhouette Cutter", command = Send_to_Cutter).grid(row=13, column=1) -Tkinter.Button(top, width=40, text = "Save Configuration", command = Save_Configuration).grid(row=14, column=1) -Tkinter.Button(top, width=40, text = "Exit", command = Just_Exit).grid(row=15, column=1) +Tkinter.Button(top, width=40, text="Show Gerber in Gerbv", command=show_gerber).grid(row=12, column=1) +Tkinter.Button(top, width=40, text="Create Graphtec File from Gerber", command=main_program).grid(row=13, column=1) +Tkinter.Button(top, width=40, text="Send Graphtec File to Silhouette Cutter", command=Send_to_Cutter).grid(row=14, column=1) +Tkinter.Button(top, width=40, text="Save Configuration", command=Save_Configuration).grid(row=15, column=1) +Tkinter.Button(top, width=40, text="Exit", command=Just_Exit).grid(row=16, column=1) Tkinter.Button(top, width=40, text="Create test_forces Graphtec file", command=test_forces).grid(row=17, column=1) From 8d1b6d93d0fb43e939abc68fab3c9e13ad8cfb96 Mon Sep 17 00:00:00 2001 From: Colin O'Flynn Date: Wed, 3 Dec 2014 13:28:31 -0400 Subject: [PATCH 4/6] Change button name to say 'input' instead of 'Gerber' --- g2g_gui.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/g2g_gui.py b/g2g_gui.py index b83882f..d3ec7a0 100755 --- a/g2g_gui.py +++ b/g2g_gui.py @@ -353,11 +353,10 @@ def default_cut_mode_str(): Entry(top, bd =1, width=60, textvariable=cutter_shared_name_str).grid(row=11, column=1, sticky=E) Tkinter.Button(top, width=40, text="Show Gerber in Gerbv", command=show_gerber).grid(row=12, column=1) -Tkinter.Button(top, width=40, text="Create Graphtec File from Gerber", command=main_program).grid(row=13, column=1) +Tkinter.Button(top, width=40, text="Create Graphtec File from Input", command=main_program).grid(row=13, column=1) Tkinter.Button(top, width=40, text="Send Graphtec File to Silhouette Cutter", command=Send_to_Cutter).grid(row=14, column=1) Tkinter.Button(top, width=40, text="Save Configuration", command=Save_Configuration).grid(row=15, column=1) Tkinter.Button(top, width=40, text="Exit", command=Just_Exit).grid(row=16, column=1) - Tkinter.Button(top, width=40, text="Create test_forces Graphtec file", command=test_forces).grid(row=17, column=1) From 9e82ba7a50027cd3104773086b06d70b6852843d Mon Sep 17 00:00:00 2001 From: Colin O'Flynn Date: Wed, 3 Dec 2014 13:30:47 -0400 Subject: [PATCH 5/6] Revert "Change python bin pointer for Linux" This reverts commit fa9b9a5a5ede43131924fc52fbb170eb0a337d83. --- g2g_gui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/g2g_gui.py b/g2g_gui.py index d3ec7a0..9150e0e 100755 --- a/g2g_gui.py +++ b/g2g_gui.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python import Tkinter import tkMessageBox import tkFileDialog From f7ff59e8be1742b099a70153c3b03fd5f80b1c19 Mon Sep 17 00:00:00 2001 From: Colin O'Flynn Date: Wed, 7 Jan 2015 15:16:21 -0400 Subject: [PATCH 6/6] Remove unneeded NT-only check --- g2g_gui.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/g2g_gui.py b/g2g_gui.py index 9150e0e..4f64189 100755 --- a/g2g_gui.py +++ b/g2g_gui.py @@ -109,14 +109,13 @@ def show_gerber(): head, tail = os.path.split(Gerber_name.get()) - if os.name == 'nt': - if not os.path.exists(gerbv_path.get()): - tkMessageBox.showerror("G2G_GUI ERROR", "The path provided for gerbv is invalid.") - return + if not os.path.exists(gerbv_path.get()): + tkMessageBox.showerror("G2G_GUI ERROR", "The path provided for gerbv is invalid.") + return - if not os.path.exists(pstoedit_path.get()): - tkMessageBox.showerror("G2G_GUI ERROR", "The path provided for pstoedit is invalid.") - return + if not os.path.exists(pstoedit_path.get()): + tkMessageBox.showerror("G2G_GUI ERROR", "The path provided for pstoedit is invalid.") + return subprocess.Popen([os.path.normpath(gerbv_path.get()), os.path.normpath(Gerber_name.get())])