3838__copyright__ = '(c) 2024-2025 Ilya Razmanov'
3939__credits__ = 'Ilya Razmanov'
4040__license__ = 'unlicense'
41- __version__ = '3.20.20.3 '
41+ __version__ = '3.21.2.11 '
4242__maintainer__ = 'Ilya Razmanov'
4343__email__ = 'ilyarazmanov@gmail.com'
4444__status__ = 'Production'
@@ -96,6 +96,7 @@ def UINormal() -> None:
9696 info_string .config (text = info_normal ['txt' ], foreground = info_normal ['fg' ], background = info_normal ['bg' ])
9797 if Z == 1 or Z == 3 :
9898 check02 ['state' ] = 'disabled'
99+ sortir .update ()
99100
100101
101102def UIBusy () -> None :
@@ -118,14 +119,10 @@ def ShowPreview(preview_name: PhotoImage, caption: str) -> None:
118119 preview = preview_name
119120
120121 if zoom_factor > 0 :
121- preview = preview .zoom (
122- zoom_factor + 1 ,
123- )
122+ preview = preview .zoom (zoom_factor + 1 )
124123 label_zoom ['text' ] = f'Zoom { zoom_factor + 1 } :1'
125124 elif zoom_factor < 0 :
126- preview = preview .subsample (
127- 1 - zoom_factor ,
128- )
125+ preview = preview .subsample (1 - zoom_factor )
129126 label_zoom ['text' ] = f'Zoom 1:{ 1 - zoom_factor } '
130127 else :
131128 preview = preview_name
@@ -216,19 +213,20 @@ def GetSource(event=None) -> None:
216213 butt_minus .config (state = 'normal' , cursor = 'hand2' )
217214 # ↓ Adding filename, mode and status to window title a-la Photoshop
218215 if Z == 1 :
219- color_mode_str = ' (L)'
216+ color_mode_str = f ' (L: { "8" if maxcolors < 256 else "16" } )'
220217 elif Z == 2 :
221- color_mode_str = ' (LA)'
218+ color_mode_str = f ' (LA: { "8" if maxcolors < 256 else "16" } )'
222219 elif Z == 3 :
223- color_mode_str = ' (RGB)'
220+ color_mode_str = f ' (RGB: { "8" if maxcolors < 256 else "16" } )'
224221 elif Z == 4 :
225- color_mode_str = ' (RGBA)'
222+ color_mode_str = f ' (RGBA: { "8" if maxcolors < 256 else "16" } )'
226223 else :
227224 color_mode_str = '' # Just in case
228225 sortir .title (f'Averager: { Path (sourcefilename ).name } { color_mode_str } { "*" if is_filtered else "" } ' )
229226 info_normal = {'txt' : f'{ Path (sourcefilename ).name } { "*" if is_filtered else "" } X={ X } Y={ Y } Z={ Z } maxcolors={ maxcolors } ' , 'fg' : 'grey' , 'bg' : 'grey90' }
230227 # ↓ enabling "Filter"
231228 UINormal ()
229+ sortir .geometry (f'+{ (sortir .winfo_screenwidth () - sortir .winfo_width ()) // 2 } +{ (sortir .winfo_screenheight () - sortir .winfo_height ()) // 2 - 32 } ' )
232230 butt02 .focus_set () # moving focus to "Filter"
233231
234232
@@ -383,7 +381,7 @@ def SaveAs(event=None) -> None:
383381 format_list = [('Portable network graphics' , '.png' ), ('Portable grey map' , '.pgm' )]
384382 proposed_name = Path (sourcefilename ).stem + '.png'
385383 elif Z == 2 :
386- format_list = [('Portable network graphics' , '.png' ), ( 'Portable grey map' , '.pgm' ) ]
384+ format_list = [('Portable network graphics' , '.png' )]
387385 proposed_name = Path (sourcefilename ).stem + '.png'
388386 elif Z == 3 :
389387 if src_extension == '.ppm' :
@@ -393,7 +391,7 @@ def SaveAs(event=None) -> None:
393391 format_list = [('Portable network graphics' , '.png' ), ('Portable pixel map' , '.ppm' )]
394392 proposed_name = Path (sourcefilename ).stem + '.png'
395393 else :
396- format_list = [('Portable network graphics' , '.png' ), ( 'Portable pixel map' , '.ppm' ) ]
394+ format_list = [('Portable network graphics' , '.png' )]
397395 proposed_name = Path (sourcefilename ).stem + '.png'
398396
399397 # ↓ Open export file
@@ -438,7 +436,8 @@ def SaveAs(event=None) -> None:
438436
439437sortir .iconphoto (True , PhotoImage (data = 'P6\n 2 8\n 255\n ' .encode (encoding = 'ascii' ) + randbytes (2 * 8 * 3 )))
440438sortir .title ('Averager' )
441- sortir .minsize (360 , 100 )
439+ sortir .minsize (320 , 240 )
440+ sortir .maxsize (9 * sortir .winfo_screenwidth () // 10 , 9 * sortir .winfo_screenheight () // 10 )
442441
443442# ↓ Info statuses dictionaries
444443info_normal = {'txt' : f'Adaptive Average { __version__ } ' , 'fg' : 'grey' , 'bg' : 'grey90' }
@@ -455,16 +454,16 @@ def SaveAs(event=None) -> None:
455454sortir .bind_all ('<Control-q>' , DisMiss )
456455
457456frame_top = Frame (sortir , borderwidth = 2 , relief = 'groove' )
458- frame_top .pack (side = 'top' , anchor = 'nw ' , pady = (0 , 2 ))
457+ frame_top .pack (side = 'top' , anchor = 'n ' , pady = (0 , 2 ))
459458frame_preview = Frame (sortir , borderwidth = 2 , relief = 'groove' )
460- frame_preview .pack (side = 'top' )
459+ frame_preview .pack (side = 'top' , anchor = 'center' , expand = True )
461460
462461""" ┌──────────────────────┐
463462 │ Top frame (controls) │
464463 └─────────────────────-┘ """
465464
466465# ↓ File menu
467- butt01 = Menubutton (frame_top , text = 'File...' .ljust (10 , ' ' ), font = ('helvetica' , 12 ), cursor = 'hand2' , justify = 'left' , state = 'normal' , indicatoron = False , relief = 'raised' , borderwidth = 2 , background = 'grey90' , activebackground = 'grey98' )
466+ butt01 = Menubutton (frame_top , text = 'File...' .ljust (10 , ' ' ), font = ('helvetica' , 12 ), cursor = 'hand2' , state = 'normal' , indicatoron = False , relief = 'raised' , borderwidth = 2 , background = 'grey90' , activebackground = 'grey98' )
468467butt01 .grid (row = 0 , column = 0 , rowspan = 2 , sticky = 'ns' , padx = (0 , 10 ), pady = 0 )
469468
470469menu02 = Menu (butt01 , tearoff = False ) # "File" menu
@@ -485,15 +484,15 @@ def SaveAs(event=None) -> None:
485484info00 .grid (row = 0 , column = 1 )
486485
487486# ↓ X-pass threshold control
488- info01 = Label (frame_top , text = 'X:' , font = ('helvetica' , 11 ), justify = 'left' , state = 'disabled' )
487+ info01 = Label (frame_top , text = 'X:' , font = ('helvetica' , 11 ), state = 'disabled' )
489488info01 .grid (row = 0 , column = 2 )
490489
491490ini_threshold_x = IntVar (value = 16 )
492491spin01 = Spinbox (frame_top , from_ = 0 , to = 256 , increment = 1 , textvariable = ini_threshold_x , state = 'disabled' , width = 3 , font = ('helvetica' , 11 ))
493492spin01 .grid (row = 0 , column = 3 )
494493
495494# ↓ Y-pass threshold control
496- info02 = Label (frame_top , text = 'Y:' , font = ('helvetica' , 11 ), justify = 'left' , state = 'disabled' )
495+ info02 = Label (frame_top , text = 'Y:' , font = ('helvetica' , 11 ), state = 'disabled' )
497496info02 .grid (row = 0 , column = 4 )
498497
499498ini_threshold_y = IntVar (value = 8 )
@@ -502,16 +501,16 @@ def SaveAs(event=None) -> None:
502501
503502# ↓ Wrap around control
504503ini_wraparound = BooleanVar (value = False )
505- check01 = Checkbutton (frame_top , text = 'Wrap around' , font = ('helvetica' , 9 ), justify = 'left' , variable = ini_wraparound , onvalue = True , offvalue = False , state = 'disabled' )
504+ check01 = Checkbutton (frame_top , text = 'Wrap around' , font = ('helvetica' , 9 ), variable = ini_wraparound , onvalue = True , offvalue = False , state = 'disabled' )
506505check01 .grid (row = 1 , column = 1 , sticky = 'ws' )
507506
508507# ↓ Keep alpha control
509508ini_keep_alpha = BooleanVar (value = False )
510- check02 = Checkbutton (frame_top , text = 'Keep alpha' , font = ('helvetica' , 9 ), justify = 'left' , variable = ini_keep_alpha , onvalue = True , offvalue = False , state = 'disabled' )
509+ check02 = Checkbutton (frame_top , text = 'Keep alpha' , font = ('helvetica' , 9 ), variable = ini_keep_alpha , onvalue = True , offvalue = False , state = 'disabled' )
511510check02 .grid (row = 1 , column = 3 , columnspan = 3 , sticky = 'ws' )
512511
513512# ↓ Filter start
514- butt02 = Button (frame_top , text = 'Filter' .center (10 , ' ' ), font = ('helvetica' , 12 ), cursor = 'arrow' , justify = 'center' , state = 'disabled' , relief = 'raised' , borderwidth = 2 , background = 'grey90' , activebackground = 'grey98' , command = RunFilter )
513+ butt02 = Button (frame_top , text = 'Filter' .center (10 , ' ' ), font = ('helvetica' , 12 ), cursor = 'arrow' , state = 'disabled' , relief = 'raised' , borderwidth = 2 , background = 'grey90' , activebackground = 'grey98' , command = RunFilter )
515514butt02 .grid (row = 0 , column = 6 , rowspan = 2 , sticky = 'nsew' , padx = (10 , 0 ), pady = 0 )
516515
517516""" ┌──────────────────────────────┐
@@ -532,13 +531,13 @@ def SaveAs(event=None) -> None:
532531frame_preview .bind ('<Double-Button-1>' , GetSource )
533532zanyato .pack (side = 'top' )
534533
535- frame_zoom = Frame (frame_preview , width = 300 , borderwidth = 2 , relief = 'groove' )
534+ frame_zoom = Frame (frame_preview , borderwidth = 2 , relief = 'groove' )
536535frame_zoom .pack (side = 'bottom' )
537536
538- butt_plus = Button (frame_zoom , text = '+' , font = ('courier' , 8 ), width = 2 , cursor = 'arrow' , justify = 'center' , state = 'disabled' , borderwidth = 1 , command = zoomIn )
537+ butt_plus = Button (frame_zoom , text = '+' , font = ('courier' , 8 ), width = 2 , cursor = 'arrow' , state = 'disabled' , borderwidth = 1 , command = zoomIn )
539538butt_plus .pack (side = 'left' , padx = 0 , pady = 0 , fill = 'both' )
540539
541- butt_minus = Button (frame_zoom , text = '-' , font = ('courier' , 8 ), width = 2 , cursor = 'arrow' , justify = 'center' , state = 'disabled' , borderwidth = 1 , command = zoomOut )
540+ butt_minus = Button (frame_zoom , text = '-' , font = ('courier' , 8 ), width = 2 , cursor = 'arrow' , state = 'disabled' , borderwidth = 1 , command = zoomOut )
542541butt_minus .pack (side = 'right' , padx = 0 , pady = 0 , fill = 'both' )
543542
544543label_zoom = Label (frame_zoom , text = 'Zoom 1:1' , font = ('courier' , 8 ), state = 'disabled' )
0 commit comments