Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/api/configuration_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ def get_available_printers(self):
def add_printer(self, name):
self._current_config = self._configuration_manager.new(name)
self.save()

def remove_printer(self, name):
self._current_config = self._configuration_manager.remove(name)

'''Loads a previous configured printer by name'''
def load_printer(self, name):
Expand Down
3 changes: 3 additions & 0 deletions src/domain/configuration_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ def save(self, configuration):

def new(self, printer_name):
raise NotImplementedException("Abstract Class")

def remove(self, printer_name):
raise NotImplementedException("Abstract Class")

def get_current_config(self):
raise NotImplementedException("Abstract Class")
Expand Down
6 changes: 5 additions & 1 deletion src/infrastructure/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,11 @@ def new(self, printer_name):
new_printer_config = ConfigurationGenerator().default_configuration()
new_printer_config.name = printer_name
return new_printer_config


def remove(self, printer_name):
filename = self._get_file_name(printer_name)
os.remove(filename)

def _path(self):
if not os.path.exists(config.PEACHY_PATH):
os.makedirs(config.PEACHY_PATH)
Expand Down
33 changes: 32 additions & 1 deletion src/ui/configuration_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def initialize(self):
Button(self,text=u"Setup Drip Calibration", command=self._drip_calibration).grid(column=1,row=40,sticky=NSEW)
Button(self,text=u"Setup Calibration", command=self._calibration).grid(column=1,row=50,sticky=NSEW)
Button(self,text=u"Run Cure Test", command=self._cure_test).grid(column=1,row=60,sticky=NSEW)
Button(self,text=u"Delete Selected Printer", command=self._Delete_Config).grid(column=1,row=90,sticky=NSEW)
Label(self).grid(column=0,row=70)
Button(self,text=u"Back", command=self._back).grid(column=0,row=100)

Expand All @@ -46,6 +47,9 @@ def _printer_selected(self, selection):

def _add_printer(self):
self.navigate(AddPrinterUI)

def _Delete_Config(self):
self.navigate(DeleteSelectedConfig, printer = self._current_printer)

def _setup_options(self):
self.navigate(SetupOptionsUI, printer = self._current_printer)
Expand Down Expand Up @@ -81,13 +85,17 @@ def initialize(self):
Label(self).grid(column=1,row=20)

Button(self, text ="Save", command = self._save).grid(column=1,row=30, sticky=N+S+E)
Button(self,text=u"Cancel", command=self._back).grid(column=0,row=100)

self.update()

def _save(self):
printer_name = self._printer_name.get()
self._configuration_api.add_printer(printer_name)
self.navigate(SetupUI)

def _back(self):
self.navigate(SetupUI)

def close(self):
pass
Expand Down Expand Up @@ -471,4 +479,27 @@ def _start(self):
tkMessageBox.showwarning("Error", ex.message)

def close(self):
pass
pass

class DeleteSelectedConfig(PeachyFrame):
def initialize(self):
self.grid()

self._current_printer = self.kwargs['printer']
self._configuration_api = ConfigurationAPI(self._configuration_manager)


Label(self, text = self._current_printer).grid(column=1,row=10)
Button(self, text ="Do not delete", command = self._back).grid(column=1,row=110)
Button(self, text ="Yes, delete" , command = self._remove_printer).grid(column=1,row=120)

def _back(self):
self.navigate(SetupUI)

def _remove_printer(self):
printer_name = self._current_printer
self._configuration_api.remove_printer(printer_name)
self.navigate(SetupUI)

def close(self):
pass