import tkinter as tk import signal import os import subprocess import time win = tk.Tk() win.title(" AStrophoto Pauses Longues") ### WIDGETS ### canvas1 = tk.Canvas(win, width = 550, height = 320, relief = 'raised') canvas1.pack() slider1 = tk.Scale(win, from_=0, to=180, orient='horizontal', resolution=5, tickinterval=60, length=300, label='pause (s)') canvas1.create_window(170,50, window=slider1) slider2 = tk.Scale(win, from_=0, to=100, orient='horizontal', resolution=1, tickinterval=25, length=300, label='intervale (s)') canvas1.create_window(170,130, window=slider2) slider3 = tk.Scale(win, from_=0, to=100, orient='horizontal', resolution=1, tickinterval=25, length=300, label='nombre') canvas1.create_window(170,210, window=slider3) label1 = tk.Label(win, text='ISO') label1.config(font=('helvetica', 15)) canvas1.create_window(450,24, window=label1) spinbox1 = tk.Spinbox(win, values=["250","320","400","500","640","800","1000","1250","1600","2000","2500","3200","4000","5000","6400" ],width=4) spinbox1.config(font=('helvetica', 30)) canvas1.create_window(450,60, window=spinbox1) ### Event Functions ### def killgphoto2Process(): p = subprocess.Popen(['ps', '-A'], stdout=subprocess.PIPE) out, err = p.communicate() for line in out.splitlines(): if b'gvfsd-gphoto2' in line: pid = int(line.split(None,1)[0]) os.kill(pid, signal.SIGKILL) def takepicture(): tmpPause = int(slider1.get()) isovalue = int(spinbox1.get()) interPause = int(slider2.get()) nbrPhoto = int(slider3.get()) tempphoto = (tmpPause + interPause) print("def BULB et def ISO") subprocess.run(["gphoto2","--set-config","shutterspeed=bulb"]) time.sleep(2) print("Bulb OK") subprocess.run(["gphoto2","--set-config","iso="+str(isovalue)]) time.sleep(2) print("ISO OK") i=1 while i <= nbrPhoto : label2=tk.Label(win,text='photo '+str(i)+'/'+str(nbrPhoto)+' reste '+ str((nbrPhoto - i)*tempphoto)+ ' secondes', fg='blue',font=('helvetica',14, 'bold'),width=25) canvas1.create_window(275,300, window=label2) win.update_idletasks() print("i=",(i)) subprocess.run(["gphoto2","--set-config","eosremoterelease=2"]) time.sleep(tmpPause) subprocess.run(["gphoto2","--set-config","eosremoterelease=4"]) time.sleep(2) print("photo",(i)) time.sleep(interPause) i=i+1 def close(): win.destroy() # ferme le pgme takePic = tk.Button (text='LANCER', command=takepicture, bg='blue', fg='white', font=('helvetica',10, 'bold')) canvas1.create_window(50,300, window=takePic) exitButton = tk.Button(text='QUITTER', command=close, bg='red', fg='white', font=('helvetica',10, 'bold')) canvas1.create_window(500,300, window=exitButton) killgphoto2Process() win.mainloop() # Loops forever