commit 41458e32859f974d5f29ae03133cdbceb9da3f7b Author: Dan Date: Sat Aug 22 21:51:43 2020 -0400 Inital commit. Sorta kinda has a menu bar with option to open a cbz file. It then opens the first image in the default image viewer. Working on getting 'next' button added. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..96403d3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__/* diff --git a/main.py b/main.py new file mode 100644 index 0000000..a7ae6e0 --- /dev/null +++ b/main.py @@ -0,0 +1,45 @@ +from tkinter import * +from tkinter import filedialog +from zipfile import ZipFile as zf +from PIL import Image +import time +import io + +page = 0 +file = '' + +def open_menu(): + mangaFile = filedialog.askopenfilename() + file = mangaFile + displayManga(file,1) + +def displayManga(file,pg): + with zf(file, 'r') as zip: + #grab all the manga pages from the cbz file and sort them to put them in the correct order + fl = zip.namelist() + fl.sort() + data = zip.read(fl[pg-1]) + im = Image.open(io.BytesIO(data)) + im.show() + page = pg + + +#initalize tk +root=Tk() +root.title("Manga Reader") + +#tk window size and allow resize +root.geometry("500x300") +root.resizable(width=True, height=True) + +#Menu Bar +menu = Menu(root) +item = Menu(menu) +item.add_command(label="Open", command=open_menu) +item.add_separator() +item.add_command(label="Exit", command=root.quit) +menu.add_cascade(label="File", menu=item) +root.config(menu=menu) + + +root.mainloop() diff --git a/qt/main.py b/qt/main.py new file mode 100644 index 0000000..425c20b --- /dev/null +++ b/qt/main.py @@ -0,0 +1,20 @@ +import sys +import readergui as rg + +from PyQt5.QtWidgets import QMainWindow, QApplication +from PyQt5.QtCore import Qt + +class Window(QMainWindow): + def __init__(self): + super(Window, self).__init__() + self.ui = rg.Ui_MainWindow() + self.ui.setupUi(self) + self.ui.nextButton.clicked.connect(self.but_test) + def but_test(self): + print("button clicked") + +if __name__ == '__main__': + app = QApplication(sys.argv) + window = Window() + window.show() + sys.exit(app.exec()) diff --git a/qt/reader.ui b/qt/reader.ui new file mode 100644 index 0000000..133bfcd --- /dev/null +++ b/qt/reader.ui @@ -0,0 +1,81 @@ + + + MainWindow + + + + 0 + 0 + 480 + 640 + + + + MainWindow + + + + + + 10 + 10 + 461 + 511 + + + + + + + 70 + 140 + 174 + 34 + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + 10 + 550 + 461 + 36 + + + + + + + Back + + + + + + + Next + + + + + + + + + + 0 + 0 + 480 + 30 + + + + + + + + diff --git a/qt/readergui.py b/qt/readergui.py new file mode 100644 index 0000000..ebd383a --- /dev/null +++ b/qt/readergui.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'reader.ui' +# +# Created by: PyQt5 UI code generator 5.15.0 +# +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. + + +from PyQt5 import QtCore, QtGui, QtWidgets + + +class Ui_MainWindow(object): + def setupUi(self, MainWindow): + MainWindow.setObjectName("MainWindow") + MainWindow.resize(480, 640) + self.centralwidget = QtWidgets.QWidget(MainWindow) + self.centralwidget.setObjectName("centralwidget") + self.mainImage = QtWidgets.QGraphicsView(self.centralwidget) + self.mainImage.setGeometry(QtCore.QRect(10, 10, 461, 511)) + self.mainImage.setObjectName("mainImage") + self.testBox = QtWidgets.QDialogButtonBox(self.centralwidget) + self.testBox.setGeometry(QtCore.QRect(70, 140, 174, 34)) + self.testBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) + self.testBox.setObjectName("testBox") + self.widget = QtWidgets.QWidget(self.centralwidget) + self.widget.setGeometry(QtCore.QRect(10, 550, 461, 36)) + self.widget.setObjectName("widget") + self.horizontalLayout = QtWidgets.QHBoxLayout(self.widget) + self.horizontalLayout.setContentsMargins(0, 0, 0, 0) + self.horizontalLayout.setObjectName("horizontalLayout") + self.backButton = QtWidgets.QPushButton(self.widget) + self.backButton.setObjectName("backButton") + self.horizontalLayout.addWidget(self.backButton) + self.nextButton = QtWidgets.QPushButton(self.widget) + self.nextButton.setObjectName("nextButton") + self.horizontalLayout.addWidget(self.nextButton) + MainWindow.setCentralWidget(self.centralwidget) + self.menubar = QtWidgets.QMenuBar(MainWindow) + self.menubar.setGeometry(QtCore.QRect(0, 0, 480, 30)) + self.menubar.setObjectName("menubar") + MainWindow.setMenuBar(self.menubar) + self.statusbar = QtWidgets.QStatusBar(MainWindow) + self.statusbar.setObjectName("statusbar") + MainWindow.setStatusBar(self.statusbar) + + self.retranslateUi(MainWindow) + QtCore.QMetaObject.connectSlotsByName(MainWindow) + + def retranslateUi(self, MainWindow): + _translate = QtCore.QCoreApplication.translate + MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) + self.backButton.setText(_translate("MainWindow", "Back")) + self.nextButton.setText(_translate("MainWindow", "Next")) + + +if __name__ == "__main__": + import sys + app = QtWidgets.QApplication(sys.argv) + MainWindow = QtWidgets.QMainWindow() + ui = Ui_MainWindow() + ui.setupUi(MainWindow) + MainWindow.show() + sys.exit(app.exec_())