Skip to content

Commit 2369d3a

Browse files
committed
12 June "Generatio"
1 parent c814e0c commit 2369d3a

File tree

2 files changed

+41
-12
lines changed

2 files changed

+41
-12
lines changed

POVRayThread.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,16 @@
3535
__copyright__ = '(c) 2024-2025 Ilya Razmanov'
3636
__credits__ = 'Ilya Razmanov'
3737
__license__ = 'unlicense'
38-
__version__ = '1.17.9.11'
38+
__version__ = '1.18.12.8'
3939
__maintainer__ = 'Ilya Razmanov'
4040
__email__ = 'ilyarazmanov@gmail.com'
4141
__status__ = 'Production'
4242

4343
from copy import deepcopy
4444
from pathlib import Path
45+
from random import randbytes # Used for random icon only
4546
from tkinter import Button, Frame, IntVar, Label, Menu, Menubutton, PhotoImage, Spinbox, Tk, filedialog
47+
from tkinter.messagebox import showinfo
4648

4749
from export import linen, stitch
4850
from filter import avgrow
@@ -64,6 +66,15 @@ def ShowMenu(event) -> None:
6466
menu02.post(event.x_root, event.y_root)
6567

6668

69+
def ShowInfo(event=None):
70+
"""Show program and module version"""
71+
showinfo(
72+
title='Image information',
73+
message=f'File: {sourcefilename}',
74+
detail=f'Image: X={X}, Y={Y}, Z={Z}, maxcolors={maxcolors}',
75+
)
76+
77+
6778
def UINormal() -> None:
6879
"""Normal UI state, buttons enabled"""
6980
for widget in frame_top.winfo_children():
@@ -118,7 +129,7 @@ def GetSource(event=None) -> None:
118129
is_filtered = False
119130
is_saved = False
120131

121-
sourcefilename = filedialog.askopenfilename(title='Open image file', filetypes=[('Supported formats', '.png .ppm .pgm .pbm'), ('PNG', '.png'), ('PNM', '.ppm .pgm .pbm')])
132+
sourcefilename = filedialog.askopenfilename(title='Open image file', filetypes=[('Supported formats', '.png .ppm .pgm .pbm'), ('Portable network graphics', '.png'), ('Portable network map', '.ppm .pgm .pbm')])
122133
if sourcefilename == '':
123134
return
124135

@@ -180,6 +191,8 @@ def GetSource(event=None) -> None:
180191
zanyato.bind('<Alt-Button-1>', zoomOut) # Alt + left click
181192
zanyato.bind('<Double-Alt-Button-1>', zoomOut) # Alt + left click too fast
182193
sortir.bind_all('<MouseWheel>', zoomWheel) # Wheel
194+
sortir.bind_all('<Control-i>', ShowInfo)
195+
menu02.entryconfig('Image Info...', state='normal')
183196
# binding global
184197
sortir.bind_all('<Return>', RunFilter)
185198
# enabling save
@@ -346,12 +359,10 @@ def SaveAsStitch():
346359

347360
sortir = Tk()
348361

362+
sortir.iconphoto(True, PhotoImage(data='P6\n2 8\n255\n'.encode(encoding='ascii') + randbytes(2 * 8 * 3)))
349363
sortir.title('POV-Ray Thread')
350364
sortir.geometry('+200+100')
351365

352-
# Main dialog icon is PPM as well!
353-
sortir.iconphoto(True, PhotoImage(data=b'P6\n2 2\n255\n\xff\x00\x00\xff\xff\x00\x00\x00\xff\x00\xff\x00'))
354-
355366
# Info statuses dictionaries
356367
info_normal = {'txt': f'POV-Ray Thread {__version__}', 'fg': 'grey', 'bg': 'grey90'}
357368
info_busy = {'txt': 'BUSY, PLEASE WAIT', 'fg': 'red', 'bg': 'yellow'}
@@ -384,6 +395,8 @@ def SaveAsStitch():
384395
menu02.add_command(label='Export Linen...', state='disabled', command=SaveAsLinen)
385396
menu02.add_command(label='Export Stitch...', state='disabled', command=SaveAsStitch)
386397
menu02.add_separator()
398+
menu02.add_command(label='Image Info...', accelerator='Ctrl+I', state='disabled', command=ShowInfo)
399+
menu02.add_separator()
387400
menu02.add_command(label='Exit', state='normal', command=DisMiss, accelerator='Ctrl+Q')
388401

389402
butt01.config(menu=menu02)

averager.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@
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

4242
from copy import deepcopy
4343
from pathlib import Path
44+
from random import randbytes # Used for random icon only
4445
from tkinter import Button, Frame, IntVar, Label, Menu, Menubutton, PhotoImage, Spinbox, Tk, filedialog
46+
from tkinter.messagebox import showinfo
4547

4648
from filter import avgrow
4749
from 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+
6576
def 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

339355
sortir = Tk()
340356

357+
sortir.iconphoto(True, PhotoImage(data='P6\n2 8\n255\n'.encode(encoding='ascii') + randbytes(2 * 8 * 3)))
341358
sortir.title('Averager')
342359
sortir.geometry('+200+100')
343360

344-
# Main dialog icon is PPM as well!
345-
sortir.iconphoto(True, PhotoImage(data=b'P6\n2 2\n255\n\xff\x00\x00\xff\xff\x00\x00\x00\xff\x00\xff\x00'))
346-
347361
# Info statuses dictionaries
348362
info_normal = {'txt': f'Adaptive Average {__version__}', 'fg': 'grey', 'bg': 'grey90'}
349363
info_busy = {'txt': 'BUSY, PLEASE WAIT', 'fg': 'red', 'bg': 'yellow'}
@@ -376,6 +390,8 @@ def SaveAs(event=None) -> None:
376390
menu02.add_command(label='Save', state='disabled', command=Save, accelerator='Ctrl+S')
377391
menu02.add_command(label='Save as...', state='disabled', command=SaveAs, accelerator='Ctrl+Shift+S')
378392
menu02.add_separator()
393+
menu02.add_command(label='Image Info...', accelerator='Ctrl+I', state='disabled', command=ShowInfo)
394+
menu02.add_separator()
379395
menu02.add_command(label='Exit', state='normal', command=DisMiss, accelerator='Ctrl+Q')
380396

381397
butt01.config(menu=menu02)

0 commit comments

Comments
 (0)