Cleaned up comments and spacing.
This commit is contained in:
14
main.py
14
main.py
@@ -50,7 +50,7 @@ class MangaReader:
|
|||||||
self.panel.pack()
|
self.panel.pack()
|
||||||
|
|
||||||
def open_menu(self):
|
def open_menu(self):
|
||||||
# file dialog. reset page counts, call display Maanga passing in starting values
|
# file dialog. reset page counts, call display Manga passing in starting values
|
||||||
mangaFile = filedialog.askopenfilename()
|
mangaFile = filedialog.askopenfilename()
|
||||||
self.file = mangaFile
|
self.file = mangaFile
|
||||||
self.page = 0
|
self.page = 0
|
||||||
@@ -70,14 +70,15 @@ class MangaReader:
|
|||||||
data = zip.read(fl[pg])
|
data = zip.read(fl[pg])
|
||||||
im = Image.open(io.BytesIO(data))
|
im = Image.open(io.BytesIO(data))
|
||||||
|
|
||||||
|
# I found the below code to maintain image ratios at https://stackoverflow.com/questions/273946/how-do-i-resize-an-image-using-pil-and-maintain-its-aspect-ratio
|
||||||
wpercent = (basewidth / float(im.size[0]))
|
wpercent = (basewidth / float(im.size[0]))
|
||||||
hsize = int((float(im.size[1]) * float(wpercent)))
|
hsize = int((float(im.size[1]) * float(wpercent)))
|
||||||
|
|
||||||
im = im.resize((basewidth, hsize), Image.ANTIALIAS)
|
im = im.resize((basewidth, hsize), Image.ANTIALIAS)
|
||||||
#convert to tkImage and update the on screen image.
|
# convert to tkImage and update the on screen image.
|
||||||
self.img = ImageTk.PhotoImage(im)
|
self.img = ImageTk.PhotoImage(im)
|
||||||
self.panel.config(image=self.img)
|
self.panel.config(image=self.img)
|
||||||
#finally update the current page count
|
# finally update the current page count
|
||||||
self.pgcount.configure(text=str(pg+1) + " of " + str(self.total))
|
self.pgcount.configure(text=str(pg+1) + " of " + str(self.total))
|
||||||
|
|
||||||
def nextPage(self, event):
|
def nextPage(self, event):
|
||||||
@@ -85,7 +86,7 @@ class MangaReader:
|
|||||||
if self.page < self.total:
|
if self.page < self.total:
|
||||||
self.displayManga(self.file, self.page)
|
self.displayManga(self.file, self.page)
|
||||||
else:
|
else:
|
||||||
#reset self.page and doNothing
|
# reset self.page and doNothing
|
||||||
self.page = self.page - 1
|
self.page = self.page - 1
|
||||||
# self.doNothing()
|
# self.doNothing()
|
||||||
|
|
||||||
@@ -94,7 +95,7 @@ class MangaReader:
|
|||||||
if self.page >= 0:
|
if self.page >= 0:
|
||||||
self.displayManga(self.file, self.page)
|
self.displayManga(self.file, self.page)
|
||||||
else:
|
else:
|
||||||
#reset self.page and doNothing
|
# reset self.page and doNothing
|
||||||
self.page = self.page + 1
|
self.page = self.page + 1
|
||||||
# self.doNothing()
|
# self.doNothing()
|
||||||
|
|
||||||
@@ -102,8 +103,7 @@ class MangaReader:
|
|||||||
print(self.page)
|
print(self.page)
|
||||||
print("FUCCK YOU")
|
print("FUCCK YOU")
|
||||||
|
|
||||||
|
# initalize tk
|
||||||
#initalize tk
|
|
||||||
root=Tk()
|
root=Tk()
|
||||||
app = MangaReader(root)
|
app = MangaReader(root)
|
||||||
root.mainloop()
|
root.mainloop()
|
||||||
|
|||||||
Reference in New Issue
Block a user