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
|
||||
bins = None
|
||||
blocked = False
|
||||
exportFrame = None
|
||||
saveBinsButton = None
|
||||
showKeyButton = None
|
||||
exportHeightEntry = None
|
||||
|
|
@ -110,14 +111,13 @@ def focus_results():
|
|||
# bring results window forward
|
||||
if results is not None and 'normal' == results.state():
|
||||
results.focus_set()
|
||||
results.geometry("")
|
||||
|
||||
return
|
||||
|
||||
|
||||
# run slices, show export window
|
||||
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()
|
||||
|
||||
|
|
@ -170,7 +170,7 @@ def go():
|
|||
|
||||
exportFrame = tk.Frame(results)
|
||||
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)
|
||||
viewFrame.pack(pady=5)
|
||||
|
|
@ -188,11 +188,14 @@ def go():
|
|||
exportKerf.pack(side=LEFT)
|
||||
exportKerfEntry.pack(side=LEFT)
|
||||
|
||||
exportFileButton.pack(padx=1)
|
||||
exportFrame.pack(pady=5, padx=5)
|
||||
exportFileButton.pack(pady=(0, 5), padx=1)
|
||||
|
||||
saveBinsButton.pack(side=LEFT, padx=1)
|
||||
showKeyButton.pack(side=LEFT, padx=1)
|
||||
|
||||
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()
|
||||
resultWinHeight = results.winfo_height()
|
||||
|
|
@ -258,20 +261,17 @@ def export():
|
|||
def checkPrepared(args=None):
|
||||
shouldRemove = False
|
||||
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:
|
||||
shouldRemove = True
|
||||
finally:
|
||||
if shouldRemove:
|
||||
saveBinsButton.pack_forget()
|
||||
showKeyButton.pack_forget()
|
||||
|
||||
results.geometry(f"{resultWinHeight}x{resultWinHeight}")
|
||||
exportFrame.pack_forget()
|
||||
else:
|
||||
if not saveBinsButton.winfo_ismapped():
|
||||
results.geometry("")
|
||||
saveBinsButton.pack(side=LEFT, padx=1)
|
||||
showKeyButton.pack(side=LEFT)
|
||||
if not exportFrame.winfo_ismapped():
|
||||
exportFrame.pack(pady=(0, 5), padx=5)
|
||||
|
||||
|
||||
# prepares bins for export, performs bin packing
|
||||
# arguments: bin height, bin width, kerf
|
||||
|
|
@ -407,8 +407,7 @@ def exportFile(h, w, k):
|
|||
displayCombine.show()
|
||||
|
||||
# now that export has been prepared, show save buttons
|
||||
saveBinsButton.pack(side=LEFT, padx=1)
|
||||
showKeyButton.pack(side=LEFT)
|
||||
exportFrame.pack(pady=(0, 5), padx=5)
|
||||
|
||||
exportWidthEntry.bind('<KeyRelease>', checkPrepared)
|
||||
exportHeightEntry.bind('<KeyRelease>', checkPrepared)
|
||||
|
|
@ -419,7 +418,21 @@ def exportFile(h, w, k):
|
|||
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():
|
||||
global blocked
|
||||
|
||||
|
|
@ -436,11 +449,6 @@ def saveFiles():
|
|||
|
||||
focus_results()
|
||||
|
||||
# show key
|
||||
if (showKey.get()):
|
||||
pdfCombine = np.sum(pdfSections)
|
||||
pdfCombine.show()
|
||||
|
||||
blocked = False
|
||||
|
||||
|
||||
|
|
@ -472,7 +480,7 @@ results = None
|
|||
|
||||
# create base window
|
||||
root = tk.Tk()
|
||||
root.title("3DSlicer")
|
||||
root.title("Strato")
|
||||
root.option_add('*Font', '19')
|
||||
root.attributes("-toolwindow", 1)
|
||||
p1 = tk.PhotoImage(file=resource_path('icon.png'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue