Show key labels for assembly
This commit is contained in:
parent
557f5ef5fc
commit
f66e0e209e
3 changed files with 1370 additions and 1362 deletions
56
main.py
56
main.py
|
|
@ -26,6 +26,7 @@ pdfSections = None
|
||||||
combined = None
|
combined = None
|
||||||
bins = None
|
bins = None
|
||||||
blocked = False
|
blocked = False
|
||||||
|
exportFrame = None
|
||||||
saveBinsButton = None
|
saveBinsButton = None
|
||||||
showKeyButton = None
|
showKeyButton = None
|
||||||
exportHeightEntry = None
|
exportHeightEntry = None
|
||||||
|
|
@ -110,14 +111,13 @@ def focus_results():
|
||||||
# bring results window forward
|
# bring results window forward
|
||||||
if results is not None and 'normal' == results.state():
|
if results is not None and 'normal' == results.state():
|
||||||
results.focus_set()
|
results.focus_set()
|
||||||
results.geometry("")
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
# run slices, show export window
|
# run slices, show export window
|
||||||
def go():
|
def go():
|
||||||
global combined, sections, results, saveBinsButton, showKeyButton, showKey, exportHeightEntry, exportWidthEntry, exportKerfEntry, resultWinWidth, resultWinHeight
|
global combined, sections, results, exportFrame, showKeyButton, saveBinsButton, exportHeightEntry, exportWidthEntry, exportKerfEntry, resultWinWidth, resultWinHeight
|
||||||
|
|
||||||
focus_results()
|
focus_results()
|
||||||
|
|
||||||
|
|
@ -170,7 +170,7 @@ def go():
|
||||||
|
|
||||||
exportFrame = tk.Frame(results)
|
exportFrame = tk.Frame(results)
|
||||||
saveBinsButton = tk.Button(exportFrame, text="Export Cut Files", command=saveFiles)
|
saveBinsButton = tk.Button(exportFrame, text="Export Cut Files", command=saveFiles)
|
||||||
showKeyButton = tk.Checkbutton(exportFrame, text='Key?', variable=showKey, onvalue=True, offvalue=False)
|
showKeyButton = tk.Button(exportFrame, text='View Key', command=showKey)
|
||||||
|
|
||||||
buttonFrame.pack(pady=10, padx=5)
|
buttonFrame.pack(pady=10, padx=5)
|
||||||
viewFrame.pack(pady=5)
|
viewFrame.pack(pady=5)
|
||||||
|
|
@ -188,11 +188,14 @@ def go():
|
||||||
exportKerf.pack(side=LEFT)
|
exportKerf.pack(side=LEFT)
|
||||||
exportKerfEntry.pack(side=LEFT)
|
exportKerfEntry.pack(side=LEFT)
|
||||||
|
|
||||||
exportFileButton.pack(padx=1)
|
exportFileButton.pack(pady=(0, 5), padx=1)
|
||||||
exportFrame.pack(pady=5, padx=5)
|
|
||||||
|
saveBinsButton.pack(side=LEFT, padx=1)
|
||||||
|
showKeyButton.pack(side=LEFT, padx=1)
|
||||||
|
|
||||||
results.update()
|
results.update()
|
||||||
results.geometry(f'+{root.winfo_rootx()+int((root.winfo_width()-results.winfo_width())/2)}+{root.winfo_rooty()+int((root.winfo_height()-results.winfo_height())/2)}')
|
results.geometry(
|
||||||
|
f'+{root.winfo_rootx() + int((root.winfo_width() - results.winfo_width()) / 2)}+{root.winfo_rooty() + int((root.winfo_height() - results.winfo_height()) / 2)}')
|
||||||
|
|
||||||
resultWinWidth = results.winfo_width()
|
resultWinWidth = results.winfo_width()
|
||||||
resultWinHeight = results.winfo_height()
|
resultWinHeight = results.winfo_height()
|
||||||
|
|
@ -258,20 +261,17 @@ def export():
|
||||||
def checkPrepared(args=None):
|
def checkPrepared(args=None):
|
||||||
shouldRemove = False
|
shouldRemove = False
|
||||||
try:
|
try:
|
||||||
shouldRemove = float(exportWidthEntry.get()) != lastW or float(exportHeightEntry.get()) != lastH or float(exportKerfEntry.get()) != lastK
|
shouldRemove = float(exportWidthEntry.get()) != lastW or float(exportHeightEntry.get()) != lastH or float(
|
||||||
|
exportKerfEntry.get()) != lastK
|
||||||
except ValueError:
|
except ValueError:
|
||||||
shouldRemove = True
|
shouldRemove = True
|
||||||
finally:
|
finally:
|
||||||
if shouldRemove:
|
if shouldRemove:
|
||||||
saveBinsButton.pack_forget()
|
exportFrame.pack_forget()
|
||||||
showKeyButton.pack_forget()
|
|
||||||
|
|
||||||
results.geometry(f"{resultWinHeight}x{resultWinHeight}")
|
|
||||||
else:
|
else:
|
||||||
if not saveBinsButton.winfo_ismapped():
|
if not exportFrame.winfo_ismapped():
|
||||||
results.geometry("")
|
exportFrame.pack(pady=(0, 5), padx=5)
|
||||||
saveBinsButton.pack(side=LEFT, padx=1)
|
|
||||||
showKeyButton.pack(side=LEFT)
|
|
||||||
|
|
||||||
# prepares bins for export, performs bin packing
|
# prepares bins for export, performs bin packing
|
||||||
# arguments: bin height, bin width, kerf
|
# arguments: bin height, bin width, kerf
|
||||||
|
|
@ -407,8 +407,7 @@ def exportFile(h, w, k):
|
||||||
displayCombine.show()
|
displayCombine.show()
|
||||||
|
|
||||||
# now that export has been prepared, show save buttons
|
# now that export has been prepared, show save buttons
|
||||||
saveBinsButton.pack(side=LEFT, padx=1)
|
exportFrame.pack(pady=(0, 5), padx=5)
|
||||||
showKeyButton.pack(side=LEFT)
|
|
||||||
|
|
||||||
exportWidthEntry.bind('<KeyRelease>', checkPrepared)
|
exportWidthEntry.bind('<KeyRelease>', checkPrepared)
|
||||||
exportHeightEntry.bind('<KeyRelease>', checkPrepared)
|
exportHeightEntry.bind('<KeyRelease>', checkPrepared)
|
||||||
|
|
@ -419,7 +418,21 @@ def exportFile(h, w, k):
|
||||||
blocked = False
|
blocked = False
|
||||||
|
|
||||||
|
|
||||||
# save bins and show key
|
# show puzzle key
|
||||||
|
def showKey():
|
||||||
|
print("hi")
|
||||||
|
global blocked
|
||||||
|
|
||||||
|
if not blocked:
|
||||||
|
blocked = True
|
||||||
|
|
||||||
|
pdfCombine = np.sum(pdfSections)
|
||||||
|
pdfCombine.show()
|
||||||
|
|
||||||
|
blocked = False
|
||||||
|
|
||||||
|
|
||||||
|
# save bins
|
||||||
def saveFiles():
|
def saveFiles():
|
||||||
global blocked
|
global blocked
|
||||||
|
|
||||||
|
|
@ -436,11 +449,6 @@ def saveFiles():
|
||||||
|
|
||||||
focus_results()
|
focus_results()
|
||||||
|
|
||||||
# show key
|
|
||||||
if (showKey.get()):
|
|
||||||
pdfCombine = np.sum(pdfSections)
|
|
||||||
pdfCombine.show()
|
|
||||||
|
|
||||||
blocked = False
|
blocked = False
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -472,7 +480,7 @@ results = None
|
||||||
|
|
||||||
# create base window
|
# create base window
|
||||||
root = tk.Tk()
|
root = tk.Tk()
|
||||||
root.title("3DSlicer")
|
root.title("Strato")
|
||||||
root.option_add('*Font', '19')
|
root.option_add('*Font', '19')
|
||||||
root.attributes("-toolwindow", 1)
|
root.attributes("-toolwindow", 1)
|
||||||
p1 = tk.PhotoImage(file=resource_path('icon.png'))
|
p1 = tk.PhotoImage(file=resource_path('icon.png'))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue