Пример #1
0
        def recup_add_data(
        ):  # function that will use tkinter input to feed SQL database trougth SQLManager after check
            name = name_frame_value.get()
            side = side_frame_value.get()
            color = color_frame_value.get()
            length = length_frame_value.get()
            filename = filename_frame_value.get()

            if (name != "" and side != "" and color != "" and length != ""
                    and filename != ""):  # if all fields are fullfield
                test_passed = True
            else:
                test_passed = False

            if test_passed:  # if all fields are fullfield
                # then no_previous record check :
                if (SQLManager.retrive_video_path(name, side, color) == []):
                    print("Pas de résultats équivalent, enregistrement ok ")
                    SQLManager.ajout_dyn(name, side, color, length, filename)
                    messagebox.showinfo("Validation", "Enregistrement ok")
                    ref_video()
                    add_video.destroy()

                else:
                    print(
                        "Un enregistrement existe déjà avec les mêmes références coleur, côté et action"
                    )
                    print(SQLManager.retrive_video_path(name, side, color))
            else:
                print("Remplir tous les champs SVP")
Пример #2
0
    def TotalToSql(self, name, side, color):

        localactionList = self.generate_actionlist_from_list()

        print('le nom:', name, ' le cote ', side, 'la couleur ', color)
        print('et la liste', localactionList)

        print('et la longueur est', self.length)
        SQLManager.ajout_dyn_sequence(name, color, side, str(self.length),
                                      localactionList)
Пример #3
0
 def del_video():
     global index_selected
     SQLManager.delete_vid(index_selected)
     my_list = SQLManager.readAll()
     print("Ma liste dans VM " + str(my_list))
     listeVideos.delete(0, END)
     for item in my_list:
         label_in_list = str(
             item[0]) + " : >" + item[1] + "< Coté : >" + item[
                 2] + "< Couleur : >" + item[3] + "< Longueur : >" + str(
                     item[4]
                 ) + "< Fichier : >" + item[5] + "< Date : >" + str(item[6])
         listeVideos.insert(item[0], label_in_list)
Пример #4
0
def ValidateRightFrame(
):  # function called when Button in right frame is clicked
    #print("Right FrameVal")
    Sequence_Chosen = SQLManager.retrive_sequence(RightSelectedAction,
                                                  handSideClic,
                                                  colorChoosen)  #item select
    #print("La séquence choisie :", Sequence_Chosen)
    list_of_actions_to_play = SQLManager.sequence_to_list(
        Sequence_Chosen)  #then retrive list of names
    list_of_filepath = SQLManager.find_by_id_to_filename_list(
        list_of_actions_to_play, handSideClic,
        colorChoosen)  #retrive the filename lsit
    #print("La liste des adresses : ",list_of_filepath)
    MovieManager.multiple_different_videos(list_of_filepath)
Пример #5
0
 def post(self):
     post_content = request.get_json()
     print(post_content)
     username = post_content['username']
     try:
         conn = SQLManager.MSSQLDatabase()
         cursor = conn.query(
             """SELECT username FROM dbo.users WHERE username = ?""",
             [username])
         data = cursor.fetchall()
         if data:
             print('user exist', data)
             return {
                 'User Exist': [
                     dict(
                         zip([column[0]
                              for column in cursor.description], row))
                     for row in cursor.fetchall()
                 ]
             }
         else:
             print('user not exist', data)
             return {
                 'User not Exist': [
                     dict(
                         zip([column[0]
                              for column in cursor.description], row))
                     for row in cursor.fetchall()
                 ]
             }
     except Exception as e:
         return {'error': str(e)}
Пример #6
0
 def post(self):
     try:
         from bcrypt import hashpw, gensalt
         import uuid
         # request into json variable
         post_content = request.get_json()
         # start extracting properties
         username = post_content['username']
         password = post_content['password']
         # hash the password
         passhash = hashpw(password.encode('utf-8'), gensalt(14))
         firstname = post_content['firstname']
         lastname = post_content['lastname']
         emailaddress = post_content['email']
         uuid = uuid.uuid4()
         # get datetime for created column
         i = datetime.datetime.now()
         datecreated = i.isoformat()
         #check if null values, this doesn't really work with json input tbh
         if username is None or password is None or firstname is None or lastname is None or emailaddress is None:
             abort(400)  # invalid parameters
             return
         conn = SQLManager.MSSQLDatabase()
         conn.query(
             """INSERT INTO dbo.users (username, firstname, lastname, emailaddress, password, created, uuid) VALUES (?, ?, ?, ?, ?, ?, ?)""",
             [
                 username, firstname, lastname, emailaddress, passhash,
                 datecreated, uuid
             ])
         conn.commit()  # don't forget to commit your change
     except Exception as e:
         print('error :' + str(e))
         return {'error': str(e)}
     return ('User ' + username + ' Added')
Пример #7
0
        def feed_fields_from_db():
            info_chain = recup_spec_seq_Id(
            )  # call the function that will grab informations of sequences from database
            print("La liste récupérée contient : ", info_chain)
            # feed of different fields:
            right_frame_value_title.insert(0, info_chain[0][1])
            left_frame_value_side.insert(0, info_chain[0][3])
            left_frame_value_color.insert(0, info_chain[0][2])

            # recalculate what to show in left list of videos
            listeVideos.delete(0, END)
            list_to_show = SQLManager.tri_and_title(info_chain[0][3],
                                                    info_chain[0][2])
            print(list_to_show)
            for item in list_to_show:
                label_in_list = str(item[0]) + " : " + str(
                    item[1]) + " : Longueur : " + str(item[4])
                listeVideos.insert(item[0], label_in_list)

            liste_dynamique_mod.generate_list_from_actionlist(
                actionlist=info_chain[0][5],
                side=info_chain[0][3],
                color=info_chain[0][2])
            newduree = "          Durée : " + str(
                liste_dynamique_mod.calcul_total_len())
            texte_duree.config(text=newduree)
            RefreshChosenList(liste_dynamique_mod.return_list())
Пример #8
0
 def generate_list_from_actionlist(self, actionlist, side, color):
     print("Process de génération de la liste : ", actionlist)
     listofactions = actionlist.split(';')
     for act in listofactions:  #for the different actions , will retrive the total spec of vid and add it to list
         tempIt = SQLManager.retrive_video_path(act, side, color)
         self.addToList(tempIt)
         print("item temporaire : ", tempIt)
Пример #9
0
    def test_videos_links():

        list_of_errors_in_videofiles = []
        all_test_passed = True
        list_of_files_in_directory = os.listdir('Videos/')
        print(list_of_files_in_directory)
        list_of_video_entry_to_check = SQLManager.readAll()

        for entry in list_of_video_entry_to_check:
            if entry[5] in list_of_files_in_directory:
                video_found_in_directory = True
            else:
                video_found_in_directory = False
                messageErrorLog = "Video [", entry[
                    5], "] correspondant à l'item n°", entry, " non trouvée dans le répertoire."
                print(messageErrorLog)
                list_of_errors_in_videofiles.append(messageErrorLog)
                all_test_passed = False

            print(video_found_in_directory)

        if all_test_passed == False:
            video_link_text.config(
                text="Fichiers video défaillants, voir le fichier ErrorLogs",
                foreground="#FF0000")
        else:
            video_link_text.config(text="Fichiers video OK")

        return list_of_errors_in_videofiles
Пример #10
0
        def Call_for_SQL_Mod():
            global index_selected_int
            SQLManager.delete_seq(index_selected_int)

            side = left_frame_value_side.get()
            color = left_frame_value_color.get()
            title = right_frame_value_title.get()

            if side != "" and color != "" and title != "":
                liste_dynamique_mod.TotalToSql(title, side, color)
                messagebox.showinfo("Info", "Sequence modifiée")
                ref_sequence()
                mod_sequence.destroy()
            else:
                messagebox.showerror(
                    "Erreur de remplissage",
                    "Remplissez bien tous les champs, dont le titre")
Пример #11
0
def Chose_Integrator(
):  # will use the side and the color to manage the Combobox content
    print("main ", handSideClic, " ", colorChoosen)
    selectedList = SQLManager.tri_and_title(
        handSideClic,
        colorChoosen)  # select solo items with good color and side
    print("liste totale : ", selectedList)  # and print this list
    # if (handSideClic!="0" and colorChoosen !="0"):
    #    print(selectedList[0][1])
    list_for_solo_combobox = []
    for i in selectedList:  # create a new list for combobox
        list_for_solo_combobox.append(i[1])  #i[1] is the Title of action
    left_frame_combobox.configure(values=list_for_solo_combobox)

    list_for_sequence_combobox = SQLManager.sort_sequences_by_color_side_to_names(
        colorChoosen, handSideClic)
    right_frame_combobox.configure(values=list_for_sequence_combobox)
Пример #12
0
        def add_video():
            video = SQLManager.find_vid_by_id(index_selected)
            liste_dynamique_mod.addToList(video)

            newduree = "          Durée : " + str(
                liste_dynamique_mod.calcul_total_len())
            texte_duree.config(text=newduree)
            RefreshChosenList(liste_dynamique_mod.return_list())
Пример #13
0
        def recup_spec_seq_Id(
        ):  #will thanks to ID catch all the other caract of sequence entry
            # print("Récupération des infos")
            global index_selected_int
            print("appel final Id dans le SQL Manager : ", index_selected_int)
            data_of_seq = SQLManager.spec_from_id(index_selected_int)

            # print("Et importé dans mod_sequence",data_of_seq)
            return data_of_seq
Пример #14
0
 def ref_video():
     listeVideos.delete(0, END)
     my_list = SQLManager.readAll()
     for item in my_list:
         label_in_list = str(
             item[0]) + " : >" + item[1] + "< Coté : >" + item[
                 2] + "< Couleur : >" + item[3] + "< Longueur : >" + str(
                     item[4]
                 ) + "< Fichier : >" + item[5] + "< Date : >" + str(item[6])
         listeVideos.insert(item[0], label_in_list)
Пример #15
0
 def ref_sequence():
     listeSequences.delete(0, END)
     my_list = SQLManager.list_of_sequence()
     print("Ma liste dans SM " + str(my_list))
     for item in my_list:
         label_in_list = str(
             item[0]) + " : >" + item[1] + "< Couleur : >" + item[
                 2] + "< Coté : >" + item[3] + "< Longueur : >" + str(
                     item[4]) + "< Schema : >" + item[5]
         listeSequences.insert(item[0], label_in_list)
Пример #16
0
 def get(self, client_id):
     conn = SQLManager.MSSQLDatabase()
     cursor = conn.query(
         """SELECT name, cpu, memory FROM dbo.servers WHERE clientid = ?""",
         [client_id])
     return {
         'servers': [
             dict(zip([column[0] for column in cursor.description], row))
             for row in cursor.fetchall()
         ]
     }
Пример #17
0
 def get(self, username):
     conn = SQLManager.MSSQLDatabase()
     cursor = conn.query(
         """SELECT username, firstname, lastname, emailaddress FROM dbo.users WHERE username = ?""",
         [username])
     return {
         'userdetails': [
             dict(zip([column[0] for column in cursor.description], row))
             for row in cursor.fetchall()
         ]
     }
Пример #18
0
    def test_sequences_coherence():

        list_of_errors_in_seq_coherence = []
        all_test_passed = True
        list_of_seq_entry_to_check = SQLManager.list_of_sequence()

        for entry in list_of_seq_entry_to_check:

            list_of_actions = entry[5].split(";")
            for action in list_of_actions:
                videoFound = SQLManager.retrive_video_path(action=action,
                                                           side=entry[3],
                                                           color=entry[2])
                print(videoFound)

                if videoFound == []:
                    messageErrorLog = "Sequence : ", entry, " incomplète : Vidéo correspondant à l'action [", action, "] introuvable."
                    list_of_errors_in_seq_coherence.append(messageErrorLog)
                    all_test_passed = False
                    print(messageErrorLog)
            """
            if 1==True:
                all_test_passed = True
            else:
                messageErrorLog = "Video [", entry[
                    5], "] correspondant à l'item n°", entry, " non trouvée dans le répertoire."
                print(messageErrorLog)
                list_of_errors_in_seq_coherence.append(messageErrorLog)
                all_test_passed = False
            """

        if all_test_passed == False:
            seq_coherence_text.config(
                text="Sequences incohérentes, voir le fichier ErrorLogs",
                foreground="#FF0000")
        else:
            seq_coherence_text.config(text="Séquences OK")

        return list_of_errors_in_seq_coherence
Пример #19
0
        def recup_mod_data(
        ):  # function that will use tkinter input to feed SQL database trougth SQLManager after check
            name = name_frame_value.get()
            side = side_frame_value.get()
            color = color_frame_value.get()
            length = length_frame_value.get()
            filename = filename_frame_value.get()

            if (name != "" and side != "" and color != "" and length != ""
                    and filename != ""):  # if all fields are fullfield
                test_passed = True
            else:
                test_passed = False

            if test_passed:  # if all fields are fullfield
                print("Pas de résultats équivalent, enregistrement ok ")
                SQLManager.delete_vid(indexSel)
                SQLManager.ajout_dyn(name, side, color, length, filename)
                messagebox.showinfo("Validation", "Enregistrement ok")
                mod_video.destroy()

            else:
                print("Remplir tous les champs SVP")
Пример #20
0
        def SideAndColorChoseEvent(
            event
        ):  # when changes in color and side entry box, will recalculate what to show in video selection listbox
            side = left_frame_value_side.get()
            color = left_frame_value_color.get()

            print("Le côté est :", side, " et la couleur ", color)
            listeVideos.delete(0, END)
            list_to_show = SQLManager.tri_and_title(side, color)
            print(list_to_show)
            for item in list_to_show:
                label_in_list = str(item[0]) + " : " + str(
                    item[1]) + " : Longueur : " + str(item[4])
                listeVideos.insert(item[0], label_in_list)
Пример #21
0
def right_combo_action(event):
    global RightSelectedAction
    RightSelectedAction = right_frame_combobox.get()
    Sequence_Chosen = SQLManager.retrive_sequence(
        RightSelectedAction, handSideClic,
        colorChoosen)  # retrive spec of chosen seq

    sec_to_min = Sequence_Chosen[0][4] / 60  #convert to min
    sec_to_min = format(sec_to_min, '.1f')  #takes only one digit after comma

    duration = "Durée : " + str(sec_to_min) + " min"  #convert in a string
    scheme = Sequence_Chosen[0][
        5]  #will retrive the scheme / An other function to factorise the sheme would be interesting to develop
    #insert here the changes in text fields.
    right_frame_text_length.configure(
        text=duration)  #write duration in text field
    right_frame_text_scheme.configure(text=scheme)  #write schema in text field

    print(RightSelectedAction)
Пример #22
0
def Main_SequenceManagement_Window():
    index_selected_int = 9999  # is the index of selected video (sql index, not listbox index that are differents ...

    def OnSelectList(event):
        print("changement de liste" + str(event))
        w = event.widget
        index = int(w.curselection()[0])
        value = w.get(index)
        print('You selected "%s"' % (value))
        expr_reg = r"^[0-9]{1,5}"

        global index_selected_int
        index_selected_int = re.findall(
            expr_reg, value
        )[0]  #will find the corresponding index with regular expression (THERE IS A MOST SIMPLE WAY TO DO IT but I didn't succeded)
        print(index_selected_int)

    def add_sequence():

        liste_dynamique = SeqMClass.MySequence()  # name of local object

        def add_video():
            video = SQLManager.find_vid_by_id(index_selected)
            liste_dynamique.addToList(video)

            newduree = "          Durée : " + str(
                liste_dynamique.calcul_total_len())
            texte_duree.config(text=newduree)
            RefreshChosenList(liste_dynamique.return_list())

        def del_video():
            liste_dynamique.deleteFromList(chosen_index_selected)

            newduree = "          Durée : " + str(
                liste_dynamique.calcul_total_len())
            texte_duree.config(text=newduree)
            RefreshChosenList(liste_dynamique.return_list())

        def up_video():
            liste_dynamique.up(chosen_index_selected)
            RefreshChosenList(liste_dynamique.return_list())

        def down_video():
            liste_dynamique.down(chosen_index_selected)
            RefreshChosenList(liste_dynamique.return_list())

        def OnSelectList(event):
            print("changement de liste" + str(event))
            w = event.widget
            index = int(w.curselection()[0])
            value = w.get(index)
            print('You selected "%s"' % (value))
            expr_reg = r"^[0-9]{1,5}"

            global index_selected
            index_selected = re.findall(
                expr_reg, value
            )[0]  # will find the corresponding index with regular expression (THERE IS A MOST SIMPLE WAY TO DO IT but I didn't succeded)
            print(index_selected)

        def SideAndColorChoseEvent(
            event
        ):  # when changes in color and side entry box, will recalculate what to show in video selection listbox
            side = left_frame_value_side.get()
            color = left_frame_value_color.get()

            print("Le côté est :", side, " et la couleur ", color)
            listeVideos.delete(0, END)
            list_to_show = SQLManager.tri_and_title(side, color)
            print(list_to_show)
            for item in list_to_show:
                label_in_list = str(item[0]) + " : " + str(
                    item[1]) + " : Longueur : " + str(item[4])
                listeVideos.insert(item[0], label_in_list)

        def OnSelectChosenList(event):
            w = event.widget
            index = int(w.curselection()[0])
            value = w.get(index)
            print('You selected ', value, ' a l index ', index)
            global chosen_index_selected
            chosen_index_selected = index

        def RefreshChosenList(my_list):
            # print(my_list)
            index = 0
            listeChosenVideos.delete(0, END)
            for item in my_list:
                index += 1
                listeChosenVideos.insert(index, item)

        def Call_for_SQL_Insertion():
            side = left_frame_value_side.get()
            color = left_frame_value_color.get()
            title = right_frame_value_title.get()

            if side != "" and color != "" and title != "":
                liste_dynamique.TotalToSql(title, side, color)
                messagebox.showinfo("Info", "Sequence ajoutée")
                ref_sequence()
                add_sequence.destroy()
            else:
                messagebox.showerror(
                    "Erreur de remplissage",
                    "Remplissez bien tous les champs, dont le titre")

        def Test_List_To_Video():
            list_videos_to_test = liste_dynamique.return_list()
            tests_passed = True
            # here, write the tests and modify message box ... (to check ie that every color is the same ... )
            if messagebox.askokcancel(
                    "Rapport",
                    message=
                    "Sequence Valide (ou non pour l'instant). Voulez vous la jouer ? "
            ):
                list_adresses = []
                for item in list_videos_to_test:
                    list_adresses.append('/Videos/' + item[0][5])
                print(list_adresses)
                MovieManager.multiple_different_videos(list_adresses)

        add_sequence = Tk()
        add_sequence.title("Module de création de séquences")
        # window.geometry("1080x720")
        add_sequence.minsize(1080, 720)
        add_sequence.maxsize(1080, 720)
        add_sequence.iconbitmap("pictures/likeBlack.ico")
        add_sequence.config(background='#FFFFFF')

        Titre_ajouter = Label(add_sequence,
                              text="Ajout d'une nouvelle séquence",
                              font=("Helvetica", 14),
                              bg="white",
                              fg="black")
        Titre_ajouter.pack()

        items_frame = Frame(add_sequence, bg="#FFFFFF", border=1)
        items_frame.pack()

        left_frame_t = Frame(items_frame, border=1)

        left_frame_text_side_grid = Frame(left_frame_t)
        left_frame_text_side = Label(left_frame_text_side_grid,
                                     text="Côté (g ou d) :",
                                     font=("Helvetica", 14),
                                     fg="black")
        left_frame_text_side.pack()
        left_frame_text_side_grid.grid(row=0, column=0)

        left_frame_value_side_grid = Frame(left_frame_t)
        left_frame_value_side = Entry(left_frame_value_side_grid, width=3)
        left_frame_value_side.pack()
        left_frame_value_side.bind('<FocusOut>', SideAndColorChoseEvent)
        left_frame_value_side.bind('<Return>', SideAndColorChoseEvent)
        left_frame_value_side_grid.grid(row=0, column=1)

        left_frame_text_color_grid = Frame(left_frame_t)
        left_frame_text_color = Label(left_frame_text_color_grid,
                                      text="Couleur (j,b,m ou n) :",
                                      font=("Helvetica", 14),
                                      fg="black")
        left_frame_text_color.pack()
        left_frame_text_color_grid.grid(row=0, column=2)

        left_frame_value_color_grid = Frame(left_frame_t)
        left_frame_value_color = Entry(left_frame_value_color_grid, width=3)
        left_frame_value_color.pack()
        left_frame_value_color.bind('<FocusOut>', SideAndColorChoseEvent)
        left_frame_value_color.bind('<Return>', SideAndColorChoseEvent)
        left_frame_value_color_grid.grid(row=0, column=3)

        list_of_vid_frame = Frame(left_frame_t, bg="#FFF0F0", border=2)

        scrollbar = Scrollbar(list_of_vid_frame)
        scrollbar.pack(side=RIGHT, fill=Y)

        listeVideos = Listbox(list_of_vid_frame)
        listeVideos.configure(width=90, height=35)
        listeVideos.bind('<<ListboxSelect>>', OnSelectList)

        my_list = SQLManager.readAll()
        print("Ma liste dans VM " + str(my_list))
        for item in my_list:
            label_in_list = str(
                item[0]) + " : >" + item[1] + "< Coté : >" + item[
                    2] + "< Couleur : >" + item[3] + "< Longueur : >" + str(
                        item[4]
                    ) + "< Fichier : >" + item[5] + "< Date : >" + str(item[6])
            listeVideos.insert(item[0], label_in_list)

        # attach listbox to scrollbar
        listeVideos.config(yscrollcommand=scrollbar.set)
        scrollbar.config(command=listeVideos.yview)
        list_of_vid_frame.grid(row=1, column=0, columnspan=4)
        listeVideos.pack()

        left_frame_t.grid(row=0, column=0)

        center_frame = Frame(items_frame, border=1)

        button_add = Button(center_frame, text="+", command=add_video)
        button_add.pack()
        button_del = Button(center_frame, text="- ", command=del_video)
        button_del.pack()
        button_up = Button(center_frame, text="^", command=up_video)
        button_up.pack()
        button_down = Button(center_frame, text="v", command=down_video)
        button_down.pack()
        center_frame.grid(row=0, column=1)

        right_frame_t = Frame(items_frame, border=1)

        right_frame_text_title_grid = Frame(right_frame_t)
        right_frame_text_title = Label(right_frame_text_title_grid,
                                       text="Titre : ",
                                       font=("Helvetica", 14),
                                       fg="black")
        right_frame_text_title.pack()
        right_frame_text_title_grid.grid(row=0, column=0)

        right_frame_value_title_grid = Frame(right_frame_t)
        right_frame_value_title = Entry(right_frame_value_title_grid, width=30)
        right_frame_value_title.pack()
        right_frame_value_title_grid.grid(row=0, column=1)

        list_of_selected_vids_grid = Frame(right_frame_t)

        list_of_chosen_vid_frame = Frame(list_of_selected_vids_grid,
                                         bg="#FFF0F0",
                                         border=2)

        scrollbar_chosen_list = Scrollbar(list_of_chosen_vid_frame)
        scrollbar_chosen_list.pack(side=RIGHT, fill=Y)

        listeChosenVideos = Listbox(list_of_chosen_vid_frame)
        listeChosenVideos.configure(width=60, height=35)
        listeChosenVideos.bind('<<ListboxSelect>>', OnSelectChosenList)

        my_list = [[1, "Vide"]]
        for item in my_list:
            label_in_list = str(item[0]) + " : >" + item[1]
            listeChosenVideos.insert(item[0], label_in_list)

        # attach listbox to scrollbar
        listeChosenVideos.config(yscrollcommand=scrollbar_chosen_list.set)
        scrollbar_chosen_list.config(command=listeChosenVideos.yview)
        list_of_chosen_vid_frame.grid(row=1, column=0, columnspan=4)
        listeChosenVideos.pack()

        list_of_selected_vids_grid.grid(row=1, column=0, columnspan=2)

        right_frame_t.grid(row=0, column=2)

        spacer = Label(add_sequence,
                       text="",
                       font=("Helvetica", 10),
                       fg="black")
        spacer.pack()

        buttons_frame = Frame(add_sequence, border=1)
        button_val_t = Frame(buttons_frame, padx=20)
        button_val = Button(button_val_t,
                            text="Valider",
                            command=Call_for_SQL_Insertion)
        button_val.pack()
        button_val_t.grid(row=0, column=0)

        button_test_t = Frame(buttons_frame, padx=20)
        button_test = Button(button_test_t,
                             text="Test",
                             command=Test_List_To_Video)
        button_test.pack()
        button_test_t.grid(row=0, column=1)

        button_dismiss_t = Frame(buttons_frame, padx=20)
        button_dismiss = Button(button_dismiss_t,
                                text="Annuler",
                                command=add_sequence.destroy)
        button_dismiss.pack()
        button_dismiss_t.grid(row=0, column=2)

        texte_duree = Label(buttons_frame,
                            text="                  Durée = ",
                            font=("Helvetica", 12),
                            fg="black")
        texte_duree.grid(row=0, column=3)

        buttons_frame.pack()

        add_sequence.mainloop()
        ref_sequence()

    def mod_sequence():
        liste_dynamique_mod = SeqMClass.MySequence()  # name of local object

        def recup_spec_seq_Id(
        ):  #will thanks to ID catch all the other caract of sequence entry
            # print("Récupération des infos")
            global index_selected_int
            print("appel final Id dans le SQL Manager : ", index_selected_int)
            data_of_seq = SQLManager.spec_from_id(index_selected_int)

            # print("Et importé dans mod_sequence",data_of_seq)
            return data_of_seq

        def feed_fields_from_db():
            info_chain = recup_spec_seq_Id(
            )  # call the function that will grab informations of sequences from database
            print("La liste récupérée contient : ", info_chain)
            # feed of different fields:
            right_frame_value_title.insert(0, info_chain[0][1])
            left_frame_value_side.insert(0, info_chain[0][3])
            left_frame_value_color.insert(0, info_chain[0][2])

            # recalculate what to show in left list of videos
            listeVideos.delete(0, END)
            list_to_show = SQLManager.tri_and_title(info_chain[0][3],
                                                    info_chain[0][2])
            print(list_to_show)
            for item in list_to_show:
                label_in_list = str(item[0]) + " : " + str(
                    item[1]) + " : Longueur : " + str(item[4])
                listeVideos.insert(item[0], label_in_list)

            liste_dynamique_mod.generate_list_from_actionlist(
                actionlist=info_chain[0][5],
                side=info_chain[0][3],
                color=info_chain[0][2])
            newduree = "          Durée : " + str(
                liste_dynamique_mod.calcul_total_len())
            texte_duree.config(text=newduree)
            RefreshChosenList(liste_dynamique_mod.return_list())

        def add_video():
            video = SQLManager.find_vid_by_id(index_selected)
            liste_dynamique_mod.addToList(video)

            newduree = "          Durée : " + str(
                liste_dynamique_mod.calcul_total_len())
            texte_duree.config(text=newduree)
            RefreshChosenList(liste_dynamique_mod.return_list())

        def del_video():
            liste_dynamique_mod.deleteFromList(chosen_index_selected)

            newduree = "          Durée : " + str(
                liste_dynamique_mod.calcul_total_len())
            texte_duree.config(text=newduree)
            RefreshChosenList(liste_dynamique_mod.return_list())

        def up_video():
            liste_dynamique_mod.up(chosen_index_selected)
            RefreshChosenList(liste_dynamique_mod.return_list())

        def down_video():
            liste_dynamique_mod.down(chosen_index_selected)
            RefreshChosenList(liste_dynamique_mod.return_list())

        def OnSelectList(event):
            print("changement de liste" + str(event))
            w = event.widget
            index = int(w.curselection()[0])
            value = w.get(index)
            print('You selected "%s"' % (value))
            expr_reg = r"^[0-9]{1,5}"

            global index_selected
            index_selected = re.findall(
                expr_reg, value
            )[0]  # will find the corresponding index with regular expression (THERE IS A MOST SIMPLE WAY TO DO IT but I didn't succeded)
            print(index_selected)

        def SideAndColorChoseEvent(
            event
        ):  # when changes in color and side entry box, will recalculate what to show in video selection listbox
            side = left_frame_value_side.get()
            color = left_frame_value_color.get()

            print("Le côté est :", side, " et la couleur ", color)
            listeVideos.delete(0, END)
            list_to_show = SQLManager.tri_and_title(side, color)
            print(list_to_show)
            for item in list_to_show:
                label_in_list = str(item[0]) + " : " + str(
                    item[1]) + " : Longueur : " + str(item[4])
                listeVideos.insert(item[0], label_in_list)

        def OnSelectChosenList(event):
            w = event.widget
            index = int(w.curselection()[0])
            value = w.get(index)
            print('You selected ', value, ' a l index ', index)
            global chosen_index_selected
            chosen_index_selected = index

        def RefreshChosenList(my_list):
            # print(my_list)
            index = 0
            listeChosenVideos.delete(0, END)
            for item in my_list:
                index += 1
                listeChosenVideos.insert(index, item)

        def Call_for_SQL_Mod():
            global index_selected_int
            SQLManager.delete_seq(index_selected_int)

            side = left_frame_value_side.get()
            color = left_frame_value_color.get()
            title = right_frame_value_title.get()

            if side != "" and color != "" and title != "":
                liste_dynamique_mod.TotalToSql(title, side, color)
                messagebox.showinfo("Info", "Sequence modifiée")
                ref_sequence()
                mod_sequence.destroy()
            else:
                messagebox.showerror(
                    "Erreur de remplissage",
                    "Remplissez bien tous les champs, dont le titre")

        def Test_List_To_Video():
            list_videos_to_test = liste_dynamique_mod.return_list()
            tests_passed = True
            # here, write the tests and modify message box ... (to check ie that every color is the same ... )
            if messagebox.askokcancel(
                    "Rapport",
                    message=
                    "Sequence Valide (ou non pour l'instant). Voulez vous la jouer ? "
            ):
                list_adresses = []
                for item in list_videos_to_test:
                    list_adresses.append('/Videos/' + item[0][5])
                print(list_adresses)
                MovieManager.multiple_different_videos(list_adresses)

        mod_sequence = Tk()
        mod_sequence.title("Module de modification de séquences")
        # window.geometry("1080x720")
        mod_sequence.minsize(1080, 720)
        mod_sequence.maxsize(1080, 720)
        mod_sequence.iconbitmap("pictures/likeBlack.ico")
        mod_sequence.config(background='#FFFFFF')

        Titre_ajouter = Label(mod_sequence,
                              text="Modification de la séquence",
                              font=("Helvetica", 14),
                              bg="white",
                              fg="black")
        Titre_ajouter.pack()

        items_frame = Frame(mod_sequence, bg="#FFFFFF", border=1)
        items_frame.pack()

        left_frame_t = Frame(items_frame, border=1)

        left_frame_text_side_grid = Frame(left_frame_t)
        left_frame_text_side = Label(left_frame_text_side_grid,
                                     text="Côté (g ou d) :",
                                     font=("Helvetica", 14),
                                     fg="black")
        left_frame_text_side.pack()
        left_frame_text_side_grid.grid(row=0, column=0)

        left_frame_value_side_grid = Frame(left_frame_t)
        left_frame_value_side = Entry(left_frame_value_side_grid, width=3)
        left_frame_value_side.pack()
        left_frame_value_side.bind('<FocusOut>', SideAndColorChoseEvent)
        left_frame_value_side.bind('<Return>', SideAndColorChoseEvent)
        left_frame_value_side_grid.grid(row=0, column=1)

        left_frame_text_color_grid = Frame(left_frame_t)
        left_frame_text_color = Label(left_frame_text_color_grid,
                                      text="Couleur (j,b,m ou n) :",
                                      font=("Helvetica", 14),
                                      fg="black")
        left_frame_text_color.pack()
        left_frame_text_color_grid.grid(row=0, column=2)

        left_frame_value_color_grid = Frame(left_frame_t)
        left_frame_value_color = Entry(left_frame_value_color_grid, width=3)
        left_frame_value_color.pack()
        left_frame_value_color.bind('<FocusOut>', SideAndColorChoseEvent)
        left_frame_value_color.bind('<Return>', SideAndColorChoseEvent)
        left_frame_value_color_grid.grid(row=0, column=3)

        list_of_vid_frame = Frame(left_frame_t, bg="#FFF0F0", border=2)

        scrollbar = Scrollbar(list_of_vid_frame)
        scrollbar.pack(side=RIGHT, fill=Y)

        listeVideos = Listbox(list_of_vid_frame)
        listeVideos.configure(width=90, height=35)
        listeVideos.bind('<<ListboxSelect>>', OnSelectList)

        my_list = SQLManager.readAll()
        print("Ma liste dans VM " + str(my_list))
        for item in my_list:
            label_in_list = str(
                item[0]) + " : >" + item[1] + "< Coté : >" + item[
                    2] + "< Couleur : >" + item[3] + "< Longueur : >" + str(
                        item[4]
                    ) + "< Fichier : >" + item[5] + "< Date : >" + str(item[6])
            listeVideos.insert(item[0], label_in_list)

        # attach listbox to scrollbar
        listeVideos.config(yscrollcommand=scrollbar.set)
        scrollbar.config(command=listeVideos.yview)
        list_of_vid_frame.grid(row=1, column=0, columnspan=4)
        listeVideos.pack()

        left_frame_t.grid(row=0, column=0)

        center_frame = Frame(items_frame, border=1)

        button_add = Button(center_frame, text="+", command=add_video)
        button_add.pack()
        button_del = Button(center_frame, text="- ", command=del_video)
        button_del.pack()
        button_up = Button(center_frame, text="^", command=up_video)
        button_up.pack()
        button_down = Button(center_frame, text="v", command=down_video)
        button_down.pack()
        center_frame.grid(row=0, column=1)

        right_frame_t = Frame(items_frame, border=1)

        right_frame_text_title_grid = Frame(right_frame_t)
        right_frame_text_title = Label(right_frame_text_title_grid,
                                       text="Titre : ",
                                       font=("Helvetica", 14),
                                       fg="black")
        right_frame_text_title.pack()
        right_frame_text_title_grid.grid(row=0, column=0)

        right_frame_value_title_grid = Frame(right_frame_t)
        right_frame_value_title = Entry(right_frame_value_title_grid, width=30)
        right_frame_value_title.pack()
        right_frame_value_title_grid.grid(row=0, column=1)

        list_of_selected_vids_grid = Frame(right_frame_t)

        list_of_chosen_vid_frame = Frame(list_of_selected_vids_grid,
                                         bg="#FFF0F0",
                                         border=2)

        scrollbar_chosen_list = Scrollbar(list_of_chosen_vid_frame)
        scrollbar_chosen_list.pack(side=RIGHT, fill=Y)

        listeChosenVideos = Listbox(list_of_chosen_vid_frame)
        listeChosenVideos.configure(width=60, height=35)
        listeChosenVideos.bind('<<ListboxSelect>>', OnSelectChosenList)

        my_list = [[1, "Vide"]]
        for item in my_list:
            label_in_list = str(item[0]) + " : >" + item[1]
            listeChosenVideos.insert(item[0], label_in_list)

        # attach listbox to scrollbar
        listeChosenVideos.config(yscrollcommand=scrollbar_chosen_list.set)
        scrollbar_chosen_list.config(command=listeChosenVideos.yview)
        list_of_chosen_vid_frame.grid(row=1, column=0, columnspan=4)
        listeChosenVideos.pack()

        list_of_selected_vids_grid.grid(row=1, column=0, columnspan=2)

        right_frame_t.grid(row=0, column=2)

        spacer = Label(mod_sequence,
                       text="",
                       font=("Helvetica", 10),
                       fg="black")
        spacer.pack()

        buttons_frame = Frame(mod_sequence, border=1)
        button_val_t = Frame(buttons_frame, padx=20)
        button_val = Button(button_val_t,
                            text="Valider",
                            command=Call_for_SQL_Mod)
        button_val.pack()
        button_val_t.grid(row=0, column=0)

        button_test_t = Frame(buttons_frame, padx=20)
        button_test = Button(button_test_t,
                             text="Test",
                             command=Test_List_To_Video)
        button_test.pack()
        button_test_t.grid(row=0, column=1)

        button_dismiss_t = Frame(buttons_frame, padx=20)
        button_dismiss = Button(button_dismiss_t,
                                text="Annuler",
                                command=mod_sequence.destroy)
        button_dismiss.pack()
        button_dismiss_t.grid(row=0, column=2)

        texte_duree = Label(buttons_frame,
                            text="                  Durée = ",
                            font=("Helvetica", 12),
                            fg="black")
        texte_duree.grid(row=0, column=3)

        buttons_frame.pack()

        feed_fields_from_db(
        )  # call the corresponding function that will fullfill fields from SQLDataBase

        mod_sequence.mainloop()
        ref_sequence()

    def del_sequence():
        global index_selected_int
        SQLManager.delete_seq(index_selected_int)
        ref_sequence()

    def ref_sequence():
        listeSequences.delete(0, END)
        my_list = SQLManager.list_of_sequence()
        print("Ma liste dans SM " + str(my_list))
        for item in my_list:
            label_in_list = str(
                item[0]) + " : >" + item[1] + "< Couleur : >" + item[
                    2] + "< Coté : >" + item[3] + "< Longueur : >" + str(
                        item[4]) + "< Schema : >" + item[5]
            listeSequences.insert(item[0], label_in_list)

    windowSM = Tk()

    windowSM.title("Gestion des séquences")
    # window.geometry("1080x720")
    windowSM.minsize(900, 700)
    windowSM.iconbitmap("pictures/likeBlack.ico")
    windowSM.config(background='#FFFFFF')

    top_title = Label(windowSM,
                      text="Gestion des séquences",
                      font=("Helvetica", 14),
                      bg="white",
                      fg="black")
    top_title.pack()

    list_of_vid_frame = Frame(windowSM, bg="#FFFFFF", border=1)

    scrollbar = Scrollbar(list_of_vid_frame)
    scrollbar.pack(side=RIGHT, fill=Y)

    listeSequences = Listbox(list_of_vid_frame)
    listeSequences.configure(width=140, height=35)
    listeSequences.bind('<<ListboxSelect>>', OnSelectList)

    my_list = SQLManager.list_of_sequence()
    print("Ma liste dans SM " + str(my_list))
    for item in my_list:
        label_in_list = str(
            item[0]) + " : >" + item[1] + "< Couleur : >" + item[
                2] + "< Coté : >" + item[3] + "< Longueur : >" + str(
                    item[4]) + "< Schema : >" + item[5]
        listeSequences.insert(item[0], label_in_list)

    # attach listbox to scrollbar
    listeSequences.config(yscrollcommand=scrollbar.set)
    scrollbar.config(command=listeSequences.yview)

    buttons_frame = Frame(windowSM, bg="#FFFFFF", border=1)

    add_button_frame = Frame(buttons_frame, padx=20)
    add_button = Button(add_button_frame,
                        text="Nouvelle séquence",
                        border=1,
                        font=("Helvetica", 12),
                        bg="#2ECC71",
                        command=add_sequence)
    add_button_frame.grid(row=0, column=0)
    add_button.pack()

    modify_button_frame = Frame(buttons_frame, padx=20)
    modify_button = Button(modify_button_frame,
                           text="Modifier",
                           border=1,
                           font=("Helvetica", 12),
                           bg="#F4D03F",
                           command=mod_sequence)
    modify_button_frame.grid(row=0, column=1)
    modify_button.pack()

    delete_button_frame = Frame(buttons_frame, padx=20)
    delete_button = Button(delete_button_frame,
                           text="Supprimer",
                           border=1,
                           font=("Helvetica", 12),
                           bg="#922B21",
                           command=del_sequence)
    delete_button_frame.grid(row=0, column=2)
    delete_button.pack()

    refresh_button_frame = Frame(buttons_frame, padx=20)
    refresh_button = Button(refresh_button_frame,
                            text="Actualiser",
                            border=1,
                            font=("Helvetica", 12),
                            command=ref_sequence)
    refresh_button_frame.grid(row=0, column=3)
    refresh_button.pack()

    list_of_vid_frame.pack()
    buttons_frame.pack()
    listeSequences.pack()

    windowSM.mainloop()
Пример #23
0
 def del_sequence():
     global index_selected_int
     SQLManager.delete_seq(index_selected_int)
     ref_sequence()
Пример #24
0
 def get(self):
     conn = SQLManager.MSSQLDatabase()
     params = None
     cursor = conn.query("""SELECT name, cpu, memory FROM dbo.servers""")
     return {'servers': [i[0] for i in cursor.fetchall()]}
Пример #25
0
    def MOD_VM_window(indexSelPasse):

        indexSel = indexSelPasse

        def find_file_to_add():
            file_selected = filedialog.askopenfilename(
                title="Selectionnez le fichier",
                filetypes=(("mpeg files", "*.mp4"), ("all files", "*.*")))
            # dialogue box where user will select the file to add
            print("Find the file : ", file_selected)  # catch the entire line
            liste_of_filepath = file_selected.split(
                "/")  # catch the name of file
            filename = liste_of_filepath[-1]  # take it
            filename_frame_value.delete(0, END)
            filename_frame_value.insert(0, filename)  # and fulfill the field

            length_frame_value.delete(0, END)  # ... the same for duration
            clip = VideoFileClip(
                file_selected
            )  # using VideoFileClip that is to say moviepy (on pygame)
            clip_length = clip.duration
            clip.close()  # close the file reading to avoid exception.
            length_frame_value.insert(0, clip_length)

        def recup_mod_data(
        ):  # function that will use tkinter input to feed SQL database trougth SQLManager after check
            name = name_frame_value.get()
            side = side_frame_value.get()
            color = color_frame_value.get()
            length = length_frame_value.get()
            filename = filename_frame_value.get()

            if (name != "" and side != "" and color != "" and length != ""
                    and filename != ""):  # if all fields are fullfield
                test_passed = True
            else:
                test_passed = False

            if test_passed:  # if all fields are fullfield
                print("Pas de résultats équivalent, enregistrement ok ")
                SQLManager.delete_vid(indexSel)
                SQLManager.ajout_dyn(name, side, color, length, filename)
                messagebox.showinfo("Validation", "Enregistrement ok")
                mod_video.destroy()

            else:
                print("Remplir tous les champs SVP")

        mod_video = Tk()
        mod_video.title("Modification d'une vidéo")
        # window.geometry("1080x720")
        mod_video.minsize(800, 300)
        mod_video.iconbitmap("pictures/likeBlack.ico")
        mod_video.config(background='#FFFFFF')
        mod_video.attributes('-topmost', True)

        Titre_ajouter = Label(mod_video,
                              text="Ajouter",
                              font=("Helvetica", 14),
                              bg="white",
                              fg="black")
        Titre_ajouter.pack()

        items_frame = Frame(mod_video, bg="#FFFFFF", border=1)
        items_frame.pack()

        name_frame_t = Frame(items_frame, border=1)
        name_frame_text = Label(name_frame_t,
                                text="Nom",
                                font=("Helvetica", 14),
                                fg="black")
        name_frame_text.pack()
        name_frame_value = Entry(name_frame_t, width=30)
        name_frame_value.pack()
        name_frame_t.grid(row=0, column=0)

        side_frame_t = Frame(items_frame, border=1)
        side_frame_text = Label(side_frame_t,
                                text="Côté (g ou d)",
                                font=("Helvetica", 14),
                                fg="black")
        side_frame_text.pack()
        side_frame_value = Entry(side_frame_t)
        side_frame_value.pack()
        side_frame_t.grid(row=0, column=1)

        color_frame_t = Frame(items_frame, border=1)
        color_frame_text = Label(color_frame_t,
                                 text="Couleur (j,b,m,n)",
                                 font=("Helvetica", 14),
                                 fg="black")
        color_frame_text.pack()
        color_frame_value = Entry(color_frame_t)
        color_frame_value.pack()
        color_frame_t.grid(row=0, column=2)

        length_frame_t = Frame(items_frame, border=1)
        length_frame_text = Label(length_frame_t,
                                  text="Durée(en s)",
                                  font=("Helvetica", 14),
                                  fg="black")
        length_frame_text.pack()
        length_frame_value = Entry(length_frame_t)
        length_frame_value.pack()
        length_frame_t.grid(row=0, column=3)

        filename_frame_t = Frame(items_frame, border=1)
        filename_frame_text = Label(filename_frame_t,
                                    text="Fichier",
                                    font=("Helvetica", 14),
                                    fg="black")
        filename_frame_text.pack()
        filename_frame_value = Entry(filename_frame_t, width=30)
        filename_frame_value.pack()
        filename_frame_t.grid(row=0, column=4)

        button_val = Button(mod_video, text="Valider", command=recup_mod_data)
        button_val.pack()

        spacer = Label(mod_video, text="", font=("Helvetica", 10), fg="black")
        spacer.pack()
        button_find_video = Button(mod_video,
                                   text="Chercher le fichier",
                                   command=find_file_to_add)
        button_find_video.pack()
        spacer = Label(mod_video, text="", font=("Helvetica", 10), fg="black")
        spacer.pack()
        button_dismiss = Button(mod_video,
                                text="Annuler",
                                command=mod_video.destroy)
        button_dismiss.pack()

        # will fill the different fields with values
        chain_to_use = SQLManager.find_vid_by_id(indexSel)
        name_frame_value.insert(0, chain_to_use[0][1])
        side_frame_value.insert(0, chain_to_use[0][2])
        color_frame_value.insert(0, chain_to_use[0][3])
        length_frame_value.insert(0, chain_to_use[0][4])
        filename_frame_value.insert(0, chain_to_use[0][5])

        mod_video.mainloop()
Пример #26
0
def All_Choosen_So_URL_Video():  # will return the corresponding Path to video
    listOfItemSelected = SQLManager.retrive_video_path(LeftSelectedAction,
                                                       handSideClic,
                                                       colorChoosen)
    pathSelected = listOfItemSelected[0][5]
    return pathSelected
Пример #27
0
 def play_video():
     global index_selected
     item = SQLManager.find_vid_by_id(index_selected)
     MovieManager.video_launch(item[0][5])
Пример #28
0
def Main_VideoManagement_Window():
    index_selected = 9999  # is the index of selected video (sql index, not listbox index that are differents ...

    def OnSelectList(event):
        print("changement de liste" + str(event))
        w = event.widget
        index = int(w.curselection()[0])
        value = w.get(index)
        print('You selected "%s"' % (value))
        expr_reg = r"^[0-9]{1,5}"

        global index_selected
        index_selected = re.findall(
            expr_reg, value
        )[0]  # will find the corresponding index with regular expression (THERE IS A MOST SIMPLE WAY TO DO IT but I didn't succeded)
        print(index_selected)

    def mod_video():
        global index_selected
        MOD_VM_window(index_selected)

    def del_video():
        global index_selected
        SQLManager.delete_vid(index_selected)
        my_list = SQLManager.readAll()
        print("Ma liste dans VM " + str(my_list))
        listeVideos.delete(0, END)
        for item in my_list:
            label_in_list = str(
                item[0]) + " : >" + item[1] + "< Coté : >" + item[
                    2] + "< Couleur : >" + item[3] + "< Longueur : >" + str(
                        item[4]
                    ) + "< Fichier : >" + item[5] + "< Date : >" + str(item[6])
            listeVideos.insert(item[0], label_in_list)

    def ref_video():
        listeVideos.delete(0, END)
        my_list = SQLManager.readAll()
        for item in my_list:
            label_in_list = str(
                item[0]) + " : >" + item[1] + "< Coté : >" + item[
                    2] + "< Couleur : >" + item[3] + "< Longueur : >" + str(
                        item[4]
                    ) + "< Fichier : >" + item[5] + "< Date : >" + str(item[6])
            listeVideos.insert(item[0], label_in_list)

    def play_video():
        global index_selected
        item = SQLManager.find_vid_by_id(index_selected)
        MovieManager.video_launch(item[0][5])

    def ADD_VM_Window():  #all the container of add video frame
        def find_file_to_add():
            file_selected = filedialog.askopenfilename(
                title="Selectionnez le fichier",
                filetypes=(("mpeg files", "*.mp4"), ("all files", "*.*")))
            # dialogue box where user will select the file to add
            print("Find the file : ", file_selected)  # catch the entire line
            liste_of_filepath = file_selected.split(
                "/")  # catch the name of file
            filename = liste_of_filepath[-1]  # take it
            filename_frame_value.delete(0, END)
            filename_frame_value.insert(0, filename)  # and fulfill the field

            length_frame_value.delete(0, END)  # ... the same for duration
            clip = VideoFileClip(
                file_selected
            )  # using VideoFileClip that is to say moviepy (on pygame)
            clip_length = clip.duration
            clip.close()  # close the file reading to avoid exception.
            length_frame_value.insert(0, clip_length)

        def recup_add_data(
        ):  # function that will use tkinter input to feed SQL database trougth SQLManager after check
            name = name_frame_value.get()
            side = side_frame_value.get()
            color = color_frame_value.get()
            length = length_frame_value.get()
            filename = filename_frame_value.get()

            if (name != "" and side != "" and color != "" and length != ""
                    and filename != ""):  # if all fields are fullfield
                test_passed = True
            else:
                test_passed = False

            if test_passed:  # if all fields are fullfield
                # then no_previous record check :
                if (SQLManager.retrive_video_path(name, side, color) == []):
                    print("Pas de résultats équivalent, enregistrement ok ")
                    SQLManager.ajout_dyn(name, side, color, length, filename)
                    messagebox.showinfo("Validation", "Enregistrement ok")
                    ref_video()
                    add_video.destroy()

                else:
                    print(
                        "Un enregistrement existe déjà avec les mêmes références coleur, côté et action"
                    )
                    print(SQLManager.retrive_video_path(name, side, color))
            else:
                print("Remplir tous les champs SVP")

        add_video = Toplevel()
        add_video.title("Ajout d'une vidéo")
        # window.geometry("1080x720")
        add_video.minsize(800, 300)
        add_video.maxsize(800, 300)
        add_video.iconbitmap("pictures/likeBlack.ico")
        add_video.config(background='#FFFFFF')

        Titre_ajouter = Label(add_video,
                              text="Ajouter",
                              font=("Helvetica", 14),
                              bg="white",
                              fg="black")
        Titre_ajouter.pack()

        items_frame = Frame(add_video, bg="#FFFFFF", border=1)
        items_frame.pack()

        name_frame_t = Frame(items_frame, border=1)
        name_frame_text = Label(name_frame_t,
                                text="Nom",
                                font=("Helvetica", 14),
                                fg="black")
        name_frame_text.pack()
        name_frame_value = Entry(name_frame_t, width=30)
        name_frame_value.pack()
        name_frame_t.grid(row=0, column=0)

        side_frame_t = Frame(items_frame, border=1)
        side_frame_text = Label(side_frame_t,
                                text="Côté (g ou d)",
                                font=("Helvetica", 14),
                                fg="black")
        side_frame_text.pack()
        side_frame_value = Entry(side_frame_t)
        side_frame_value.pack()
        side_frame_t.grid(row=0, column=1)

        color_frame_t = Frame(items_frame, border=1)
        color_frame_text = Label(color_frame_t,
                                 text="Couleur (j,b,m,n)",
                                 font=("Helvetica", 14),
                                 fg="black")
        color_frame_text.pack()
        color_frame_value = Entry(color_frame_t)
        color_frame_value.pack()
        color_frame_t.grid(row=0, column=2)

        length_frame_t = Frame(items_frame, border=1)
        length_frame_text = Label(length_frame_t,
                                  text="Durée(en s)",
                                  font=("Helvetica", 14),
                                  fg="black")
        length_frame_text.pack()
        length_frame_value = Entry(length_frame_t)
        length_frame_value.pack()
        length_frame_t.grid(row=0, column=3)

        filename_frame_t = Frame(items_frame, border=1)
        filename_frame_text = Label(filename_frame_t,
                                    text="Fichier",
                                    font=("Helvetica", 14),
                                    fg="black")
        filename_frame_text.pack()
        filename_frame_value = Entry(filename_frame_t, width=30)
        filename_frame_value.pack()
        filename_frame_t.grid(row=0, column=4)

        spacer = Label(add_video, text="", font=("Helvetica", 10), fg="black")
        spacer.pack()

        button_find_video = Button(add_video,
                                   text="Chercher le fichier",
                                   command=find_file_to_add)
        button_find_video.pack()

        spacer = Label(add_video, text="", font=("Helvetica", 10), fg="black")
        spacer.pack()

        button_val = Button(add_video, text="Valider", command=recup_add_data)
        button_val.pack()

        spacer = Label(add_video, text="", font=("Helvetica", 10), fg="black")
        spacer.pack()

        button_dismiss = Button(add_video,
                                text="Annuler",
                                command=add_video.destroy)
        button_dismiss.pack()

    def MOD_VM_window(indexSelPasse):

        indexSel = indexSelPasse

        def find_file_to_add():
            file_selected = filedialog.askopenfilename(
                title="Selectionnez le fichier",
                filetypes=(("mpeg files", "*.mp4"), ("all files", "*.*")))
            # dialogue box where user will select the file to add
            print("Find the file : ", file_selected)  # catch the entire line
            liste_of_filepath = file_selected.split(
                "/")  # catch the name of file
            filename = liste_of_filepath[-1]  # take it
            filename_frame_value.delete(0, END)
            filename_frame_value.insert(0, filename)  # and fulfill the field

            length_frame_value.delete(0, END)  # ... the same for duration
            clip = VideoFileClip(
                file_selected
            )  # using VideoFileClip that is to say moviepy (on pygame)
            clip_length = clip.duration
            clip.close()  # close the file reading to avoid exception.
            length_frame_value.insert(0, clip_length)

        def recup_mod_data(
        ):  # function that will use tkinter input to feed SQL database trougth SQLManager after check
            name = name_frame_value.get()
            side = side_frame_value.get()
            color = color_frame_value.get()
            length = length_frame_value.get()
            filename = filename_frame_value.get()

            if (name != "" and side != "" and color != "" and length != ""
                    and filename != ""):  # if all fields are fullfield
                test_passed = True
            else:
                test_passed = False

            if test_passed:  # if all fields are fullfield
                print("Pas de résultats équivalent, enregistrement ok ")
                SQLManager.delete_vid(indexSel)
                SQLManager.ajout_dyn(name, side, color, length, filename)
                messagebox.showinfo("Validation", "Enregistrement ok")
                mod_video.destroy()

            else:
                print("Remplir tous les champs SVP")

        mod_video = Tk()
        mod_video.title("Modification d'une vidéo")
        # window.geometry("1080x720")
        mod_video.minsize(800, 300)
        mod_video.iconbitmap("pictures/likeBlack.ico")
        mod_video.config(background='#FFFFFF')
        mod_video.attributes('-topmost', True)

        Titre_ajouter = Label(mod_video,
                              text="Ajouter",
                              font=("Helvetica", 14),
                              bg="white",
                              fg="black")
        Titre_ajouter.pack()

        items_frame = Frame(mod_video, bg="#FFFFFF", border=1)
        items_frame.pack()

        name_frame_t = Frame(items_frame, border=1)
        name_frame_text = Label(name_frame_t,
                                text="Nom",
                                font=("Helvetica", 14),
                                fg="black")
        name_frame_text.pack()
        name_frame_value = Entry(name_frame_t, width=30)
        name_frame_value.pack()
        name_frame_t.grid(row=0, column=0)

        side_frame_t = Frame(items_frame, border=1)
        side_frame_text = Label(side_frame_t,
                                text="Côté (g ou d)",
                                font=("Helvetica", 14),
                                fg="black")
        side_frame_text.pack()
        side_frame_value = Entry(side_frame_t)
        side_frame_value.pack()
        side_frame_t.grid(row=0, column=1)

        color_frame_t = Frame(items_frame, border=1)
        color_frame_text = Label(color_frame_t,
                                 text="Couleur (j,b,m,n)",
                                 font=("Helvetica", 14),
                                 fg="black")
        color_frame_text.pack()
        color_frame_value = Entry(color_frame_t)
        color_frame_value.pack()
        color_frame_t.grid(row=0, column=2)

        length_frame_t = Frame(items_frame, border=1)
        length_frame_text = Label(length_frame_t,
                                  text="Durée(en s)",
                                  font=("Helvetica", 14),
                                  fg="black")
        length_frame_text.pack()
        length_frame_value = Entry(length_frame_t)
        length_frame_value.pack()
        length_frame_t.grid(row=0, column=3)

        filename_frame_t = Frame(items_frame, border=1)
        filename_frame_text = Label(filename_frame_t,
                                    text="Fichier",
                                    font=("Helvetica", 14),
                                    fg="black")
        filename_frame_text.pack()
        filename_frame_value = Entry(filename_frame_t, width=30)
        filename_frame_value.pack()
        filename_frame_t.grid(row=0, column=4)

        button_val = Button(mod_video, text="Valider", command=recup_mod_data)
        button_val.pack()

        spacer = Label(mod_video, text="", font=("Helvetica", 10), fg="black")
        spacer.pack()
        button_find_video = Button(mod_video,
                                   text="Chercher le fichier",
                                   command=find_file_to_add)
        button_find_video.pack()
        spacer = Label(mod_video, text="", font=("Helvetica", 10), fg="black")
        spacer.pack()
        button_dismiss = Button(mod_video,
                                text="Annuler",
                                command=mod_video.destroy)
        button_dismiss.pack()

        # will fill the different fields with values
        chain_to_use = SQLManager.find_vid_by_id(indexSel)
        name_frame_value.insert(0, chain_to_use[0][1])
        side_frame_value.insert(0, chain_to_use[0][2])
        color_frame_value.insert(0, chain_to_use[0][3])
        length_frame_value.insert(0, chain_to_use[0][4])
        filename_frame_value.insert(0, chain_to_use[0][5])

        mod_video.mainloop()

    windowVM = Tk()

    windowVM.title("Gestion des videos")
    # window.geometry("1080x720")
    windowVM.minsize(900, 700)
    windowVM.maxsize(900, 700)
    windowVM.iconbitmap("pictures/likeBlack.ico")
    windowVM.config(background='#FFFFFF')

    top_title = Label(windowVM,
                      text="Gestion des videos",
                      font=("Helvetica", 14),
                      bg="white",
                      fg="black")
    top_title.pack()

    list_of_vid_frame = Frame(windowVM, bg="#FFFFFF", border=1)

    scrollbar = Scrollbar(list_of_vid_frame)
    scrollbar.pack(side=RIGHT, fill=Y)

    listeVideos = Listbox(list_of_vid_frame)
    listeVideos.configure(width=140, height=35)
    listeVideos.bind('<<ListboxSelect>>', OnSelectList)

    my_list = SQLManager.readAll()
    print("Ma liste dans VM " + str(my_list))
    for item in my_list:
        label_in_list = str(item[0]) + " : >" + item[1] + "< Coté : >" + item[
            2] + "< Couleur : >" + item[3] + "< Longueur : >" + str(
                item[4]) + "< Fichier : >" + item[5] + "< Date : >" + str(
                    item[6])
        listeVideos.insert(item[0], label_in_list)

    # attach listbox to scrollbar
    listeVideos.config(yscrollcommand=scrollbar.set)
    scrollbar.config(command=listeVideos.yview)

    buttons_frame = Frame(windowVM, bg="#FFFFFF", border=1)

    add_button_frame = Frame(buttons_frame, padx=20)
    add_button = Button(add_button_frame,
                        text="Ajouter",
                        border=1,
                        font=("Helvetica", 12),
                        bg="#2ECC71",
                        command=ADD_VM_Window)
    add_button_frame.grid(row=0, column=0)
    add_button.pack()

    modify_button_frame = Frame(buttons_frame, padx=20)
    modify_button = Button(modify_button_frame,
                           text="Modifier",
                           border=1,
                           font=("Helvetica", 12),
                           bg="#F4D03F",
                           command=mod_video)
    modify_button_frame.grid(row=0, column=1)
    modify_button.pack()

    delete_button_frame = Frame(buttons_frame, padx=20)
    delete_button = Button(delete_button_frame,
                           text="Supprimer",
                           border=1,
                           font=("Helvetica", 12),
                           bg="#922B21",
                           command=del_video)
    delete_button_frame.grid(row=0, column=2)
    delete_button.pack()

    refresh_button_frame = Frame(buttons_frame, padx=20)
    refresh_button = Button(refresh_button_frame,
                            text="Actualiser",
                            border=1,
                            font=("Helvetica", 12),
                            command=ref_video)
    refresh_button_frame.grid(row=0, column=3)
    refresh_button.pack()

    play_button_frame = Frame(buttons_frame, padx=20)
    play_button = Button(play_button_frame,
                         text="Jouer",
                         border=1,
                         font=("Helvetica", 12),
                         bg="#6CADFF",
                         command=play_video)
    play_button_frame.grid(row=0, column=4)
    play_button.pack()

    list_of_vid_frame.pack()
    buttons_frame.pack()
    listeVideos.pack()

    windowVM.mainloop()