diff --git a/pyAmakIHM/classes/controleur.py b/pyAmakIHM/classes/controleur.py index 0e0b374a40e3cd98b0a32e4cac801cf875bf93ae..bf42f6fd56e4eb21b36adec44f871f7c5ccf2660 100644 --- a/pyAmakIHM/classes/controleur.py +++ b/pyAmakIHM/classes/controleur.py @@ -237,11 +237,11 @@ class Controleur: """ Save the current state """ - def updateSave(self) -> None: - self.__scheduler.save() + def updateSave(self, filename : str) -> None: + if not (filename is None): + self.__scheduler.save() def updateCycle(self) -> None: - self.updateWindow() try: self.updateWindow() except: diff --git a/pyAmakIHM/classes/fenetre.py b/pyAmakIHM/classes/fenetre.py index bd374d06fbc3c2327c151cd4a537cd9be77b40bf..91662baa72023298d5931af5b2662fa8bb3d08d6 100644 --- a/pyAmakIHM/classes/fenetre.py +++ b/pyAmakIHM/classes/fenetre.py @@ -5,7 +5,8 @@ Class Fenetre import os, sys import pathlib from tkinter.ttk import LabelFrame -from tkinter import ttk, Tk, PanedWindow, BOTTOM +from tkinter import ttk, Tk, PanedWindow, BOTTOM, Menu +from tkinter.filedialog import askopenfilename sys.path.insert(0, str(pathlib.Path(__file__).parent)) @@ -39,6 +40,15 @@ class Fenetre : self.__root.geometry("1000x700") + menubar = Menu(self.__root) + + filemenu = Menu(menubar, tearoff=0) + filemenu.add_command(label="Save", command=self.notifyAboutSave) + + menubar.add_cascade(label="File", menu=filemenu) + + self.__root.config(menu=menubar) + self.__panelCommandes = PanelCommandes(self.__root) self.__division = PanedWindow(self.__root, orient='vertical',showhandle = True,handlesize = 10) @@ -293,6 +303,9 @@ class Fenetre : self.__observer.updateClosing() for pan in self.__panelGraphiques: pan.quit() + self.__panelVue.quit() + self.__panelCommandes.quit() + self.__panel_log.quit() self.__root.quit() """ @@ -309,3 +322,9 @@ class Fenetre : """ def errorDisplay(self,typeError : str, message : str) -> None: self.__panel_log.errorDisplay(typeError,message) + + """ + """ + def notifyAboutSave(self): + fileName = askopenfilename(filetypes =[('Pickle Files', '*.pickle')]) + self.__observer.updateSave(fileName) diff --git a/pyAmakIHM/classes/panelCommandes.py b/pyAmakIHM/classes/panelCommandes.py index 601d390133e5f3e42830c1226d5861e06fb5dc17..a2ad60ec973f026ba660d9d4aeabe053de258c39 100644 --- a/pyAmakIHM/classes/panelCommandes.py +++ b/pyAmakIHM/classes/panelCommandes.py @@ -24,19 +24,12 @@ class PanelCommandes(LabelFrame): bouttonStartStop = Button(self, text='start/stop',height=2,command=self.notifyObserverAboutStartStop) bouttonStartStop.pack(side='top',fill='x') - bouttonSaveState = Button(self, text='save state',height=2,command=self.notifyObserverAboutSave) - bouttonSaveState.pack(side='top',fill='x') - frameBoutons = Frame(self) frameBoutons.pack(side='bottom',fill='x') frameBoutonAux = Frame(self) frameBoutonAux.pack(side='top') - for i in range (20): - Button(self, text='Aux', height=2).pack(fill='x') - - self.__slider = Scale(frameBoutons,orient='horizontal',from_=1,to=10,command=self.notifyObserverAboutScale) self.__slider.pack(side='bottom',fill='x') @@ -65,9 +58,6 @@ class PanelCommandes(LabelFrame): def notifyObserverAboutStartStop(self) -> None: self.__observer.updateStartStop() - def notifyObserverAboutSave(self) -> None: - self.__observer.updateSave() - """ Notify the observer that the scale has change its value and give the current value """