4040__copyright__ = '(c) 2024-2025 Ilya Razmanov'
4141__credits__ = 'Ilya Razmanov'
4242__license__ = 'unlicense'
43- __version__ = '3.23.1.1 '
43+ __version__ = '3.23.7.9 '
4444__maintainer__ = 'Ilya Razmanov'
4545__email__ = 'ilyarazmanov@gmail.com'
4646__status__ = 'Production'
@@ -159,11 +159,11 @@ def GetSource(event=None) -> None:
159159 │ GLOBALS! They are used during saving! │
160160 └────────────────────────────────────────┘ """
161161
162- if Path (sourcefilename ).suffix == '.png' :
162+ if Path (sourcefilename ).suffix . lower () == '.png' :
163163 # ↓ Reading PNG image as list
164164 X , Y , Z , maxcolors , source_image3D , info = png2list (sourcefilename )
165165
166- elif Path (sourcefilename ).suffix in ('.ppm' , '.pgm' , '.pbm' , '.pnm' ):
166+ elif Path (sourcefilename ).suffix . lower () in ('.ppm' , '.pgm' , '.pbm' , '.pnm' ):
167167 # ↓ Reading PNM image as list
168168 X , Y , Z , maxcolors , source_image3D = pnm2list (sourcefilename )
169169 # ↓ Creating dummy info required to correctly Save As PNG later.
@@ -405,10 +405,10 @@ def Save(event=None) -> None:
405405 resultfilename = sourcefilename
406406 UIBusy ()
407407 # ↓ Save format choice
408- if Path (resultfilename ).suffix == '.png' :
408+ if Path (resultfilename ).suffix . lower () == '.png' :
409409 info ['compression' ] = 9 # Explicitly setting compression
410410 list2png (resultfilename , image3D , info ) # Writing file
411- elif Path (resultfilename ).suffix in ('.ppm' , '.pgm' , '.pnm' ):
411+ elif Path (resultfilename ).suffix . lower () in ('.ppm' , '.pgm' , '.pnm' ):
412412 list2pnm (resultfilename , image3D , maxcolors ) # Writing file
413413 # ↓ Flagging image as saved, not filtered
414414 is_saved = True # to block future repetitive saving
@@ -426,7 +426,7 @@ def SaveAs(event=None) -> None:
426426
427427 # ↓ Adjusting "Save as" formats to be displayed
428428 # according to bitdepth and source extension
429- src_extension = Path (sourcefilename ).suffix
429+ src_extension = Path (sourcefilename ).suffix . lower ()
430430 if Z == 1 :
431431 if src_extension in ('.pgm' , '.pnm' ):
432432 format_list = [('Portable grey map' , '.pgm' ), ('Portable network graphics' , '.png' )]
@@ -460,10 +460,10 @@ def SaveAs(event=None) -> None:
460460 return None
461461 UIBusy ()
462462 # ↓ Save format choice
463- if Path (resultfilename ).suffix == '.png' :
463+ if Path (resultfilename ).suffix . lower () == '.png' :
464464 info ['compression' ] = 9 # Explicitly setting compression
465465 list2png (resultfilename , image3D , info ) # Writing file
466- elif Path (resultfilename ).suffix in ('.ppm' , '.pgm' ):
466+ elif Path (resultfilename ).suffix . lower () in ('.ppm' , '.pgm' ):
467467 list2pnm (resultfilename , image3D , maxcolors ) # Writing file
468468 else :
469469 raise ValueError ('Extension not recognized' )
@@ -476,9 +476,18 @@ def SaveAs(event=None) -> None:
476476
477477
478478def valiDig (new_value ):
479- """Validate Spinbox input and reject non-numerical."""
480-
481- return True if new_value .isdigit () else False
479+ """Validate Spinbox input and reject non-integer."""
480+
481+ if new_value .strip () == '' :
482+ return True
483+ try :
484+ _ = int (new_value )
485+ if _ >= 0 and _ < 256 :
486+ return True
487+ else :
488+ return False
489+ except ValueError :
490+ return False
482491
483492
484493def incWheel (event ) -> None :
0 commit comments