Aggiunta Libreria Grafica Tkinter

master GDRIVEMACOS
MickSlash 2020-04-13 14:44:02 +00:00
parent 9e2f592571
commit dc8afb3a38
1 changed files with 36 additions and 0 deletions

View File

@ -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()