From dc8afb3a38ce75429a41fc126224e40f25c672c1 Mon Sep 17 00:00:00 2001 From: MickSlash Date: Mon, 13 Apr 2020 14:44:02 +0000 Subject: [PATCH] Aggiunta Libreria Grafica Tkinter --- google_drive_direct_link_tkinter.py | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 google_drive_direct_link_tkinter.py diff --git a/google_drive_direct_link_tkinter.py b/google_drive_direct_link_tkinter.py new file mode 100644 index 0000000..2685d5c --- /dev/null +++ b/google_drive_direct_link_tkinter.py @@ -0,0 +1,36 @@ +import tkinter as tk +import re + +window = tk.Tk() +window.geometry("900x600") +window.title("Genera Direct Link Google Drive") +window.grid_columnconfigure(0,weight=1) + +def gdrive(): + GDRIVE_DOMAIN = "drive.google.com" + if GDRIVE_DOMAIN in text_input.get(): + domain = "GD" + text_response = text_input.get() + file_id = re.search('/d/(.+?)/view',text_response) + if file_id: + file_gdrive = file_id.group(1) + else: + direct_url = "Errore" + DLINK = "https://drive.google.com/uc?export=view&id=" + direct_url = DLINK + file_gdrive + else: + direct_url = "Il link inserito non sembra essere un link Google Drive!" + textwidget = tk.Text() + textwidget.insert(tk.END,direct_url) + textwidget.grid(row=3,column=0,sticky="WE",padx=20) + + +welcome_label = tk.Label(window,text="Aggiungi un Link Google Drive") +welcome_label.grid(row=0,column=0,sticky="N",pady=20) +text_input = tk.Entry() +text_input.grid(row=1,column=0,sticky="WE",padx=10) +generate_gdrive_link = tk.Button(text="Genera Direct Link Google Drive",command=gdrive) +generate_gdrive_link.grid(row=2,column=0,sticky="WE",pady=20,padx=10) + +if __name__ == "__main__": + window.mainloop() \ No newline at end of file