3434__copyright__ = '(c) 2024-2025 Ilya Razmanov'
3535__credits__ = 'Ilya Razmanov'
3636__license__ = 'unlicense'
37- __version__ = '2.16.20.20 '
37+ __version__ = '2.18.12.8 '
3838__maintainer__ = 'Ilya Razmanov'
3939__email__ = 'ilyarazmanov@gmail.com'
4040__status__ = 'Production'
4141
4242from copy import deepcopy
4343from pathlib import Path
44+ from random import randbytes # Used for random icon only
4445from tkinter import Button , Frame , IntVar , Label , Menu , Menubutton , PhotoImage , Spinbox , Tk , filedialog
46+ from tkinter .messagebox import showinfo
4547
4648from filter import avgrow
4749from pypng .pnglpng import list2png , png2list
@@ -62,6 +64,15 @@ def ShowMenu(event) -> None:
6264 menu02 .post (event .x_root , event .y_root )
6365
6466
67+ def ShowInfo (event = None ):
68+ """Show program and module version"""
69+ showinfo (
70+ title = 'Image information' ,
71+ message = f'File: { sourcefilename } ' ,
72+ detail = f'Image: X={ X } , Y={ Y } , Z={ Z } , maxcolors={ maxcolors } ' ,
73+ )
74+
75+
6576def UINormal () -> None :
6677 """Normal UI state, buttons enabled"""
6778 for widget in frame_top .winfo_children ():
@@ -109,16 +120,19 @@ def GetSource(event=None) -> None:
109120 global preview
110121 global X , Y , Z , maxcolors , image3D , info , sourcefilename
111122 global source_image3D , preview_src , preview_filtered # deep copy of source data and copies of preview
123+ global info_normal
112124
113125 zoom_factor = 0
114126 view_src = True
115127 is_filtered = False
116128 is_saved = False
117129
118- sourcefilename = filedialog .askopenfilename (title = 'Open image file' , filetypes = [('Supported formats' , '.png .ppm .pgm .pbm' ), ('PNG ' , '.png' ), ('PNM ' , '.ppm .pgm .pbm' )])
130+ sourcefilename = filedialog .askopenfilename (title = 'Open image file' , filetypes = [('Supported formats' , '.png .ppm .pgm .pbm' ), ('Portable network graphics ' , '.png' ), ('Portable network map ' , '.ppm .pgm .pbm' )])
119131 if sourcefilename == '' :
120132 return
121133
134+ info_normal = {'txt' : f'{ Path (sourcefilename ).name } ' , 'fg' : 'grey' , 'bg' : 'grey90' }
135+
122136 UIBusy ()
123137
124138 """ ┌────────────────────────────────────────┐
@@ -175,6 +189,8 @@ def GetSource(event=None) -> None:
175189 zanyato .bind ('<Alt-Button-1>' , zoomOut ) # Alt + left click
176190 zanyato .bind ('<Double-Alt-Button-1>' , zoomOut ) # Alt + left click too fast
177191 sortir .bind_all ('<MouseWheel>' , zoomWheel ) # Wheel
192+ sortir .bind_all ('<Control-i>' , ShowInfo )
193+ menu02 .entryconfig ('Image Info...' , state = 'normal' )
178194 # binding global
179195 sortir .bind_all ('<Return>' , RunFilter )
180196 # enabling save
@@ -307,9 +323,9 @@ def SaveAs(event=None) -> None:
307323
308324 # Adjusting "Save to" formats to be displayed according to bitdepth
309325 if Z < 3 :
310- format = [('PNG ' , '.png' ), ('Portable grey map' , '.pgm' )]
326+ format = [('Portable network graphics ' , '.png' ), ('Portable grey map' , '.pgm' )]
311327 else :
312- format = [('PNG ' , '.png' ), ('Portable pixel map' , '.ppm' )]
328+ format = [('Portable network graphics ' , '.png' ), ('Portable pixel map' , '.ppm' )]
313329
314330 # Open export file
315331 resultfilename = filedialog .asksaveasfilename (
@@ -338,12 +354,10 @@ def SaveAs(event=None) -> None:
338354
339355sortir = Tk ()
340356
357+ sortir .iconphoto (True , PhotoImage (data = 'P6\n 2 8\n 255\n ' .encode (encoding = 'ascii' ) + randbytes (2 * 8 * 3 )))
341358sortir .title ('Averager' )
342359sortir .geometry ('+200+100' )
343360
344- # Main dialog icon is PPM as well!
345- sortir .iconphoto (True , PhotoImage (data = b'P6\n 2 2\n 255\n \xff \x00 \x00 \xff \xff \x00 \x00 \x00 \xff \x00 \xff \x00 ' ))
346-
347361# Info statuses dictionaries
348362info_normal = {'txt' : f'Adaptive Average { __version__ } ' , 'fg' : 'grey' , 'bg' : 'grey90' }
349363info_busy = {'txt' : 'BUSY, PLEASE WAIT' , 'fg' : 'red' , 'bg' : 'yellow' }
@@ -376,6 +390,8 @@ def SaveAs(event=None) -> None:
376390menu02 .add_command (label = 'Save' , state = 'disabled' , command = Save , accelerator = 'Ctrl+S' )
377391menu02 .add_command (label = 'Save as...' , state = 'disabled' , command = SaveAs , accelerator = 'Ctrl+Shift+S' )
378392menu02 .add_separator ()
393+ menu02 .add_command (label = 'Image Info...' , accelerator = 'Ctrl+I' , state = 'disabled' , command = ShowInfo )
394+ menu02 .add_separator ()
379395menu02 .add_command (label = 'Exit' , state = 'normal' , command = DisMiss , accelerator = 'Ctrl+Q' )
380396
381397butt01 .config (menu = menu02 )
0 commit comments