SHARE
TWEET

Untitled

a guest Aug 25th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from tkinter import *
  2. from tkinter import filedialog
  3. import os
  4. import time
  5. from insert_doc import create_doc_w_multiple_sound
  6. from dependencies import create_label, bg_color, text_color
  7.  
  8.  
  9. def create_new_w_multiple_sound():
  10.     global m, name_m, song_number_m, song_name_m, genre_m, timecode_m, path_multiple_m, song_number
  11.     song_number = 0
  12.     path_multiple_m.clear()
  13.     m = Tk()
  14.     m.title("Créer un élément avec plusieurs sons")
  15.     m.resizable(False, False)
  16.     m.config(bg=bg_color)
  17.     create_label(m, "Genre", 0)
  18.     create_label(m, "Nom de l'élément", 1)
  19.     create_label(m, "Nom de la musique", 2)
  20.     create_label(m, "Timecode de la musique (0, 5, 10)", 3)
  21.     options = [
  22.         "Game",
  23.         "Tv Show",
  24.         "Anime",
  25.         "Movie",
  26.         "Animation Movie",
  27.         "Cartoon"
  28.     ]
  29.     genre_m = StringVar(m)
  30.     genre_m.set(options[0])
  31.     name_m = StringVar(m)
  32.     song_name_m = StringVar(m)
  33.     timecode_m = StringVar(m)
  34.     g_menu = OptionMenu(m, genre_m, *options)
  35.     g_menu.grid(row=1, column=0, padx=10, pady=2)
  36.     Entry(m, textvariable=name_m).grid(row=1, column=1, padx=10, pady=8)
  37.     Entry(m, textvariable=song_name_m).grid(row=1, column=2, padx=10, pady=8)
  38.     Entry(m, textvariable=timecode_m).grid(row=1, column=3, padx=10, pady=8)
  39.     Button(m, text="Sélectionnez le fichier", font=("Arial", 10), command=define_multiple_file_m).\
  40.         grid(row=2, column=0, pady=3, padx=10)
  41.     Button(m, text="Confirmer", font=("Arial", 10), command=insert_doc_w_multiple_sound).\
  42.         grid(row=2, column=1)
  43.  
  44.  
  45. def insert_doc_w_multiple_sound():
  46.     global song_number, song_number_bis, path_multiple_m
  47.     genre = genre_m.get()
  48.     name = name_m.get()
  49.     song_name = []
  50.     timecode = []
  51.     song_name.append(song_name_m.get())
  52.     timecode.append(timecode_m.get())
  53.     while song_number > 1:
  54.         song_name.append(lst_song_name_var_m[song_number - 2].get())
  55.         timecode.append(lst_timecode_var_m[song_number - 2].get())
  56.         song_number -= 1
  57.     create_doc_w_multiple_sound(path_multiple_m, genre, name, song_name, timecode)
  58.     song_number = 0
  59.     song_number_bis = 0
  60.     path_multiple_m = []
  61.     text_finished_m = Label(m, text="Transfert terminé.", font=("Arial", 10), bg=bg_color, fg=text_color)
  62.     text_finished_m.grid(row=song_number + 1, column=3, columnspan=2, sticky=E)
  63.     time.sleep(3)
  64.     m.destroy()
  65.  
  66.  
  67. def define_multiple_file_m():
  68.     global path_multiple_m
  69.     temp_path = filedialog.askopenfilename(parent=m, title="Séléctionner un son")
  70.     if temp_path:
  71.         path_multiple_m.append(temp_path)
  72.         print(path_multiple_m)
  73.         song_name_temp = os.path.basename(temp_path)
  74.         song_name_temp = song_name_temp[:-4]
  75.         print(song_name_temp)
  76.         create_new_line(song_name_temp)
  77.  
  78.  
  79. def create_new_line(song_name):
  80.     global song_number
  81.     if song_number is 0:
  82.         song_name_m.set(song_name)
  83.         timecode_m.set("0")
  84.         song_number += 1
  85.     else:
  86.         create_new_entries()
  87.         lst_song_name_var_m[song_number - 1].set(song_name)
  88.         lst_timecode_var_m[song_number - 1].set("0")
  89.         song_number += 1
  90.  
  91.  
  92. def create_new_entries():
  93.     global lst_song_name_var_m, lst_timecode_var_m
  94.     if song_number < 20:
  95.         lst_song_name_var_m[song_number - 1] = StringVar(m)
  96.         lst_timecode_var_m[song_number - 1] = StringVar(m)
  97.         Entry(m, textvariable=lst_song_name_var_m[song_number - 1]).grid(row=song_number + 1, column=2, padx=10, pady=8)
  98.         Entry(m, textvariable=lst_timecode_var_m[song_number - 1]).grid(row=song_number + 1, column=3, padx=10, pady=8)
  99.     else:
  100.         Label(m, text="Trop d'entrées", font=("Arial", 12), bg=bg_color, fg=text_color).\
  101.             grid(column=2, columnspan=2, row=song_number + 1)
  102.  
  103.  
  104. lst_song_name_var_m = ["s_2", "s_3", "s_4", "s_5", "s_6", "s_7", "s_8", "s_9",
  105.                        "s_10", "s_11", "s_12", "s_13", "s_14", "s_15", "s_16", "s_17", "s_18", "s_19", "s_20"]
  106. lst_timecode_var_m = ["t_2", "t_3", "t_4", "t_5", "t_6", "t_7", "t_8", "t_9", "t_10", "t_11", "t_12", "t_13",
  107.                       "t_14", "t_15", "t_16", "t_17", "t_18", "t_19", "t_20"]
  108. path_multiple_m = []
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top