From 8f9d1f011ea9f1fd388542ba3cde94bf008b9b61 Mon Sep 17 00:00:00 2001
From: Jdrezen <jeremie.drezen@gmail.com>
Date: Thu, 20 May 2021 15:01:20 +0200
Subject: [PATCH] =?UTF-8?q?Ajout=20d'une=20barre=20de=20menu=20pour=20sauv?=
 =?UTF-8?q?egarder=20l'=C3=A9tat=20du=20syst=C3=A8me?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 pyAmakIHM/classes/controleur.py     |  6 +++---
 pyAmakIHM/classes/fenetre.py        | 21 ++++++++++++++++++++-
 pyAmakIHM/classes/panelCommandes.py | 10 ----------
 3 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/pyAmakIHM/classes/controleur.py b/pyAmakIHM/classes/controleur.py
index 0e0b374..bf42f6f 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 bd374d0..91662ba 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 601d390..a2ad60e 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
     """
-- 
GitLab