-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git: merge pull request #5 from /develop
- Loading branch information
Showing
15 changed files
with
349 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import customtkinter as ctk | ||
from modules.settings import * | ||
|
||
|
||
class Tabview(ctk.CTkTabview): | ||
def __init__(self, parent, **kwargs): | ||
super().__init__(master=parent, **kwargs) | ||
# defaults | ||
self.normal_font = ctk.CTkFont(family=FONT, size=FONT_SIZE) | ||
|
||
# setup layout | ||
self.grid( | ||
row=0, | ||
column=1, | ||
columnspan=2, | ||
padx=PADDING["medium"], | ||
pady=PADDING["none"], | ||
sticky="nsew", | ||
) | ||
self.grid_rowconfigure(3, weight=1) | ||
|
||
# add tabs | ||
self.add("G-Code Tools") | ||
self.add("CSV Tools") | ||
|
||
# setup tabs | ||
self.tab("G-Code Tools").grid_columnconfigure( | ||
(0, 1), | ||
weight=1, | ||
) | ||
|
||
self.select_all_gcode = ctk.CTkSwitch( | ||
self.tab("G-Code Tools"), | ||
text="Select All", | ||
command=self.toggle_all_switches, | ||
) | ||
self.select_all_gcode.place(anchor="nw") | ||
|
||
self.gcode_switch_data = [ | ||
{ | ||
"text": "Remove Comments", | ||
"variable": "remove_comments_switch", | ||
"row": 0, | ||
"column": 1, | ||
}, | ||
{ | ||
"text": "Remove M-Codes", | ||
"variable": "remove_mcodes_switch", | ||
"row": 1, | ||
"column": 1, | ||
}, | ||
{ | ||
"text": "Remove F/E-Codes", | ||
"variable": "remove_fecodes_switch", | ||
"row": 2, | ||
"column": 1, | ||
}, | ||
{ | ||
"text": "Keep only G0 & G1 moves", | ||
"variable": "remove_nontravel_switch", | ||
"row": 0, | ||
"column": 2, | ||
}, | ||
{ | ||
"text": "Remove lines with lonely G0/G1s", | ||
"variable": "remove_lone_gs_switch", | ||
"row": 1, | ||
"column": 2, | ||
}, | ||
{ | ||
"text": "Remove coordinate names", | ||
"variable": "remove_coordname_switch", | ||
"row": 2, | ||
"column": 2, | ||
}, | ||
] | ||
|
||
for data in self.gcode_switch_data: | ||
switch_variable = data["variable"] | ||
switch = ctk.CTkCheckBox( | ||
self.tab("G-Code Tools"), | ||
text=data["text"], | ||
font=self.normal_font, | ||
onvalue=True, | ||
offvalue=False, | ||
) | ||
setattr(self, switch_variable, switch) | ||
switch.grid( | ||
row=data["row"], | ||
column=data["column"], | ||
padx=PADDING["small"], | ||
pady=PADDING["small"], | ||
sticky="W", | ||
) | ||
|
||
def toggle_all_switches(self): | ||
"""iterates over every switch and toggles it""" | ||
for data in self.gcode_switch_data: | ||
switch_variable = data["variable"] | ||
if isinstance(switch_variable, str): | ||
# Get the actual variable object based on its name | ||
switch_variable = getattr(self, switch_variable) | ||
if self.select_all_gcode.get() == False: | ||
switch_variable.deselect() | ||
self.select_all_gcode.configure(text="Select All") | ||
else: | ||
switch_variable.select() | ||
self.select_all_gcode.configure(text="Deselect All") | ||
|
||
def selected_tab(self): | ||
"""Returns the currently selected tab | ||
Returns: | ||
string: current tab name | ||
""" | ||
return self.get() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import re | ||
import time | ||
|
||
from interface.tabview import gcode_switch_data | ||
from modules.settings import RE_PATTERNS | ||
|
||
|
||
def process_file_contents( | ||
file_contents, | ||
remove_comments=False, | ||
remove_mcodes=False, | ||
remove_fecodes=False, | ||
remove_nontravel=False, | ||
remove_lone_gs=False, | ||
remove_coordname=False, | ||
): | ||
timer = time.process_time() | ||
|
||
if remove_comments: | ||
file_contents = re.sub( | ||
RE_PATTERNS["remove_comments"], | ||
"", | ||
file_contents, | ||
flags=re.MULTILINE, | ||
) | ||
|
||
if remove_mcodes: | ||
file_contents = re.sub( | ||
RE_PATTERNS["remove_mcodes"], | ||
"", | ||
file_contents, | ||
flags=re.MULTILINE, | ||
) | ||
|
||
if remove_fecodes: | ||
file_contents = re.sub( | ||
RE_PATTERNS["remove_fecodes"], | ||
"", | ||
file_contents, | ||
) | ||
|
||
if remove_nontravel: | ||
file_contents = re.sub( | ||
RE_PATTERNS["remove_nontravel"], | ||
"", | ||
file_contents, | ||
flags=re.MULTILINE, | ||
) | ||
|
||
if remove_lone_gs: | ||
file_contents = re.sub( | ||
RE_PATTERNS["remove_lone_gs"], | ||
"", | ||
file_contents, | ||
flags=re.MULTILINE, | ||
) | ||
|
||
if remove_coordname: | ||
file_contents = re.sub( | ||
RE_PATTERNS["remove_coordname"], | ||
r"\2 \3 \4 \1\5", | ||
file_contents, | ||
) | ||
file_contents = re.sub(r"G", "", file_contents) | ||
|
||
elapsed_time = time.process_time() - timer | ||
|
||
return file_contents, elapsed_time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
; test comment | ||
|
||
; | ||
|
||
; | ||
M104 S180 T1 ; non G-Code | ||
|
||
G28 ; non 01 G-Code | ||
G92 E0 ; Reset Extruder | ||
|
||
G1 Z2 F3000 ; no WY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class GCodeProcessor(file_contents): | ||
|
||
def remove_comments(self, file_contents): | ||
file_contents = re.sub( | ||
RE_PATTERNS["remove_comments"], "", file_contents, flags=re.MULTILINE | ||
) | ||
|
||
|
Oops, something went wrong.