moved next/back buttons down a row. Displaying just filename instead of entire path. Added keybindings for next/back/quit.

This commit is contained in:
dan
2021-05-07 11:39:01 -04:00
parent 2d64059e6a
commit b5f3fe3b25

14
main.py
View File

@@ -34,17 +34,17 @@ class MangaReader:
# forward/back buttons # forward/back buttons
self.nextPg = Button(self.buttonFrame, text='>') self.nextPg = Button(self.buttonFrame, text='>')
self.nextPg.bind('<Button-1>', self.nextPage) self.nextPg.bind('<Button-1>', self.nextPage)
self.nextPg.grid(row=0, column=2) self.nextPg.grid(row=1, column=2)
self.buttonFrame.pack(side=BOTTOM) self.buttonFrame.pack(side=BOTTOM)
self.backPg = Button(self.buttonFrame, text='<') self.backPg = Button(self.buttonFrame, text='<')
self.backPg.bind('<Button-1>', self.backPage) self.backPg.bind('<Button-1>', self.backPage)
self.backPg.grid(row=0, column=0) self.backPg.grid(row=1, column=0)
# page counter # page counter
self.pgcount = Label(self.buttonFrame, text= str(self.page) + " of " + str(self.total)) self.pgcount = Label(self.buttonFrame, text= str(self.page) + " of " + str(self.total))
self.pgcount.grid(row=1, columns=1, columnspan=2) self.pgcount.grid(row=1, columns=1, columnspan=2)
self.mangaTitle = Label(self.buttonFrame, text=self.file) self.mangaTitle = Label(self.buttonFrame, text=os.path.basename(self.file))
self.mangaTitle.grid(row=0, column=1) self.mangaTitle.grid(row=0, column=1)
# display image # display image
@@ -52,6 +52,11 @@ class MangaReader:
self.panel.pack() self.panel.pack()
self.panel.bind('<Configure>', self.redraw) self.panel.bind('<Configure>', self.redraw)
# key bindings
self.master.bind('<Right>', self.nextPage)
self.master.bind('<Left>', self.backPage)
self.master.bind('q', quit)
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 Maanga passing in starting values
if self.dir == 'None': if self.dir == 'None':
@@ -62,7 +67,7 @@ class MangaReader:
if self.file != '': if self.file != '':
self.page = 0 self.page = 0
self.total = 0 self.total = 0
self.mangaTitle.configure(text=self.file) self.mangaTitle.configure(text=os.path.basename(self.file))
self.dir = os.path.dirname(self.file) self.dir = os.path.dirname(self.file)
self.displayManga(self.file, 0) self.displayManga(self.file, 0)
@@ -96,6 +101,7 @@ class MangaReader:
#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))
self.panel.focus_set()
self.master.config(width=wsize) self.master.config(width=wsize)
def nextPage(self, event): def nextPage(self, event):