Skip to content

Commit 830a58d

Browse files
author
dn0z
committed
Added about window
1 parent b8d82cb commit 830a58d

File tree

4 files changed

+96
-5
lines changed

4 files changed

+96
-5
lines changed

about_header.png

11.2 KB
Loading

bir.py

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
import imgedit
88

99
import os
10-
import threading, queue
10+
import queue
11+
import threading
1112

1213
from enum import Enum
1314
from tkinter import *
@@ -146,6 +147,69 @@ def display_progress_window(self):
146147
self.progress_bar.pack(expand=True, fill="both", side="bottom")
147148
self.progress_bar["value"] = 0
148149

150+
def display_about(self):
151+
"""
152+
Display the about window (with a scrollbar)
153+
"""
154+
155+
if self.about_window is not None:
156+
self.about_window.destroy()
157+
158+
# Set the window
159+
self.about_window = Toplevel(self)
160+
self.about_window.title("About")
161+
self.about_window.geometry("400x300")
162+
163+
# Header
164+
header_imagetk = imgedit.HelpingMethods.get_imagetk("about_header.png")
165+
166+
header_label = Label(self.about_window, width=400, height=150)
167+
header_label.pack(side="top", fill="both")
168+
header_label.configure(image=header_imagetk)
169+
header_label.image = header_imagetk
170+
171+
# Text with scrollbar
172+
t = Text(self.about_window, width=300, height=200, font=("Courier New", 11))
173+
174+
scrollbar = ttk.Scrollbar(self.about_window)
175+
scrollbar.pack(side="right", fill="y")
176+
t.pack(side="left", fill="y")
177+
scrollbar.config(command=t.yview)
178+
t.config(yscrollcommand=scrollbar.set)
179+
180+
t.insert(END,
181+
"Batch Image Resize (v0.1)"
182+
"\n"
183+
"\nDeveloped by dn0z"
184+
"\nhttps://github.com/dn0z/Batch-Image-Resize"
185+
"\n"
186+
"\nThe icon is designed by Vecteezy "
187+
"(https://iconfinder.com/icons/532771) "
188+
"and it is licensed under Creative Commons "
189+
"(Attribution-Share Alike 3.0 Unported)"
190+
"\n\n"
191+
"The MIT License (MIT)"
192+
"\n\n"
193+
"Copyright (c) 2016 dn0z"
194+
"\n\n"
195+
"Permission is hereby granted, free of charge, to any person obtaining a copy"
196+
"of this software and associated documentation files (the \"Software\"), to deal"
197+
"in the Software without restriction, including without limitation the rights"
198+
"to use, copy, modify, merge, publish, distribute, sublicense, and/or sell"
199+
"copies of the Software, and to permit persons to whom the Software is"
200+
"furnished to do so, subject to the following conditions:"
201+
"\n\n"
202+
"The above copyright notice and this permission notice shall be included in all"
203+
"copies or substantial portions of the Software."
204+
"\n\n"
205+
"THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR"
206+
"IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,"
207+
"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE"
208+
"AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER"
209+
"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,"
210+
"OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE"
211+
"SOFTWARE.")
212+
149213
def get_settings_status(self):
150214
"""
151215
Check if our settings are valid (directory exists, width and height are digits etc)
@@ -198,11 +262,10 @@ def export_button_handler(self):
198262
else:
199263
# Valid settings, confirm settings with the user and export
200264
if self.confirm_settings():
201-
# num_of_images = imgedit.image_files_in_dir(self.selected_directory.get())
202-
203265
self.display_progress_window()
204-
print("Progress window is on screen")
205266

267+
# call `ImgEdit.export_all_in_dir` as the target of a new thread
268+
# and put the final result in a `Queue`
206269
q = queue.Queue()
207270
my_thread = threading.Thread(target=self.img_edit.export_all_in_dir,
208271
args=(self.selected_directory.get(),
@@ -305,9 +368,13 @@ def create_widgets(self):
305368
ttk.Button(main_container, text="Export", command=self.export_button_handler).grid(
306369
row=3, column=2, rowspan=2, sticky="nesw", padx=2)
307370

371+
# About
372+
ttk.Button(main_container, text="About", command=self.display_about).grid(
373+
row=5, column=2, sticky="we")
374+
308375
# Copyright
309376
Label(main_container, text="Copyright (c) 2016 dn0z | v0.1", font=font_small).grid(
310-
row=5, column=0, columnspan=3, sticky="we", pady=20)
377+
row=5, column=0, columnspan=2, sticky="we", pady=20)
311378

312379
def __init__(self, parent=None):
313380
"""
@@ -318,6 +385,7 @@ def __init__(self, parent=None):
318385
Frame.__init__(self, parent)
319386

320387
# properties
388+
self.about_window = None
321389
self.save_as_dropdown = None
322390
self.progress_window = None
323391
self.progress_bar = None

imgedit.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import os
88
import PIL.Image
9+
import PIL.ImageTk
910

1011

1112
class HelpingMethods(object):
@@ -35,6 +36,17 @@ def get_filename_with_type(filename, file_type, suffix=""):
3536
extension = filename.split(".")[-1]
3637
return filename[:-(len(extension) + 1)] + suffix + "." + file_type.lower()
3738

39+
@staticmethod
40+
def get_imagetk(filename):
41+
"""
42+
Open an image and return it as an `ImageTk` object
43+
44+
:param filename: the filename of the image we want to open
45+
:return: the `ImageTk` object
46+
"""
47+
48+
return PIL.ImageTk.PhotoImage(PIL.Image.open(filename))
49+
3850

3951
class ImgEdit(object):
4052
def export_file(self, path, name, width, height, export_type, overwrite):

setup.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from distutils.core import setup
2+
import py2exe
3+
4+
setup(
5+
windows=[
6+
{
7+
"script": "LoL Skype DnD.py",
8+
"icon_resources": [(1, "icon.ico")]
9+
}
10+
]
11+
)

0 commit comments

Comments
 (0)