11#Version:
2- #0.5 .0
2+ #0.6 .0
33###
44from ast import Num
55import os ### Librairie
@@ -239,50 +239,71 @@ def ImageRelated():
239239 global ListScrennshot
240240 global ImageNum
241241 global Activated
242+ global Final
242243 ListScrennshot = []
243244 ImageNum = 0
244245 Activated = True #Was the function called?
245246 path = "Screenshots/"
246247 dir_list = os .listdir (path )
247248 ##
248- for loop in range (len (dir_list )):
249- howmuch = dir_list [loop ][3 :4 ] # Get the number of the screenshot for the same word (0-9)
250- if howmuch == "-" :
251- howmuch = dir_list [loop ][4 :5 ]
252- print (howmuch )
253-
254- if dir_list [loop ]== ("#" + str (NumberOfWord )+ "-" + howmuch + screenshot_type ): # If the screenshot is the for the sale word
255- print ("OK" ,("#" + str (NumberOfWord )+ "-" + howmuch + screenshot_type ))
256- ListScrennshot .append (("#" + str (NumberOfWord )+ "-" + howmuch + screenshot_type ))
257- print ("How much" ,howmuch )
258- print ("ListScrennshot" ,ListScrennshot )
259- print ("num" ,NumberOfWord )
260- ##
261- if ListScrennshot == []:
249+ for i in range (0 ,99 ):
250+ try :
251+ if NumberOfWord <= 9 :
252+ if dir_list [i ][2 :3 ]== "-" : #9
253+ ListScrennshot .append (dir_list [i ])
254+ elif NumberOfWord >= 10 and NumberOfWord <= 99 :
255+ if dir_list [i ][3 :4 ]== "-" : #10
256+ ListScrennshot .append (dir_list [i ])
257+ elif NumberOfWord >= 100 and NumberOfWord <= 999 :
258+ if dir_list [i ][4 :5 ]== "-" : #100
259+ ListScrennshot .append (dir_list [i ])
260+ elif NumberOfWord >= 1000 :
261+ if dir_list [i ][5 :6 ]== "-" : #1000
262+ ListScrennshot .append (dir_list [i ])
263+ except :
264+ pass
265+
266+ print (ListScrennshot ,"Liste des Screenshots" )
267+ Final = []
268+ Sample = []
269+ if ListScrennshot != []:
270+ for u in range (0 ,99 ):
271+ Sample .append (str ("#" + str (NumberOfWord )+ "-" + str (u )+ screenshot_type ))
272+ print (Sample ,"Sample" )
273+ for i in range (0 ,99 ):
274+ for u in range (0 ,99 ):
275+ try :
276+ if Sample [i ]== ListScrennshot [u ]:
277+ Final .append (Sample [i ])
278+ except :
279+ pass
280+ if Final == []: #No screenshot was found
262281 print ("No screenshot for this word" )
263282 Activated = False
264- else :
265- print (path + ListScrennshot [0 ])
266- img = PhotoImage (file = path + ListScrennshot [0 ])
283+ print (Final ,"Final" )
284+ else : #If there is a screenshot
267285 print ('Found a screenshot for this word' )
286+ print (Final ,"Final" )
287+ img = PhotoImage (file = path + Final [0 ])
268288 if adjust_screenshot_size == True :
269289 img = img .zoom (2 )
270290 img = img .subsample (3 )
271291 canvas2 = canvas .create_image (s_screen_width / 3 ,s_screen_height / 3 , image = img )
272292 canvas .create_image ()
273293 Activated = True
274294 return Activated
295+ ### End of ImageRelated()
275296
276297def ImageNext ():
277298 global ImageNum
278299 global Activated
279300 if Activated == True :
280301 path = "Screenshots/"
281302 dir_list = os .listdir (path )
282- if len (ListScrennshot )> ImageNum + 1 :
303+ if len (Final )> ImageNum + 1 :
283304 print ('ok Next' )
284305 ImageNum += 1
285- img = PhotoImage (file = path + ListScrennshot [ImageNum ])
306+ img = PhotoImage (file = path + Final [ImageNum ])
286307 if adjust_screenshot_size == True :
287308 img = img .zoom (2 )
288309 img = img .subsample (3 )
@@ -300,7 +321,7 @@ def ImageBack():
300321 if ImageNum > 0 :
301322 print ('ok Back' )
302323 ImageNum -= 1
303- img = PhotoImage (file = path + ListScrennshot [ImageNum ])
324+ img = PhotoImage (file = path + Final [ImageNum ])
304325 if adjust_screenshot_size == True :
305326 img = img .zoom (2 )
306327 img = img .subsample (3 )
0 commit comments