From af025bc10e7fdef597e433c913fcef088b109703 Mon Sep 17 00:00:00 2001 From: superblobmonster Date: Wed, 11 Jun 2014 09:04:12 -0400 Subject: [PATCH 1/4] Update configuration_ui.py +Delete printer option on main menu +Delete printer ui +Cancel button in Add Printer ui --- src/ui/configuration_ui.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/ui/configuration_ui.py b/src/ui/configuration_ui.py index a07b404..795a3a3 100644 --- a/src/ui/configuration_ui.py +++ b/src/ui/configuration_ui.py @@ -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) @@ -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) @@ -81,6 +85,7 @@ 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() @@ -88,6 +93,9 @@ 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 @@ -471,4 +479,27 @@ def _start(self): tkMessageBox.showwarning("Error", ex.message) def close(self): - pass \ No newline at end of file + 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 From 0928798d6fb30f91ff20a8fe5310419777186dc8 Mon Sep 17 00:00:00 2001 From: superblobmonster Date: Wed, 11 Jun 2014 09:07:44 -0400 Subject: [PATCH 2/4] Update configuration.py --- src/infrastructure/configuration.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/infrastructure/configuration.py b/src/infrastructure/configuration.py index cbed911..29c0f1c 100644 --- a/src/infrastructure/configuration.py +++ b/src/infrastructure/configuration.py @@ -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) From 3c4f5bf336deeb2eae99c1c923aa302997360d9d Mon Sep 17 00:00:00 2001 From: superblobmonster Date: Wed, 11 Jun 2014 09:09:16 -0400 Subject: [PATCH 3/4] Update configuration_api.py --- src/api/configuration_api.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/api/configuration_api.py b/src/api/configuration_api.py index bc94d51..c7dab2c 100644 --- a/src/api/configuration_api.py +++ b/src/api/configuration_api.py @@ -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): From 5b64655a9d6c165b773f6718d1b6e8b6d1f318af Mon Sep 17 00:00:00 2001 From: superblobmonster Date: Wed, 11 Jun 2014 09:10:10 -0400 Subject: [PATCH 4/4] Update configuration_manager.py --- src/domain/configuration_manager.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/domain/configuration_manager.py b/src/domain/configuration_manager.py index 8203e5b..a630a91 100644 --- a/src/domain/configuration_manager.py +++ b/src/domain/configuration_manager.py @@ -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")