mirror of
https://github.com/ciromattia/kcc
synced 2025-12-15 10:46:40 +00:00
Fixed an issue in OPF generation for device resolution (fixes #4)
Reworked options system (call with -h option to get the inline help) (fixes #3)
This commit is contained in:
@@ -57,9 +57,9 @@
|
|||||||
<key>positionOfDivider</key>
|
<key>positionOfDivider</key>
|
||||||
<real>568</real>
|
<real>568</real>
|
||||||
<key>savedFrame</key>
|
<key>savedFrame</key>
|
||||||
<string>666 338 889 690 0 0 1680 1028 </string>
|
<string>144 338 889 690 0 0 1680 1028 </string>
|
||||||
<key>selectedTabView</key>
|
<key>selectedTabView</key>
|
||||||
<string>event log</string>
|
<string>result</string>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
Binary file not shown.
@@ -24,6 +24,8 @@
|
|||||||
# with portrait target or portrait with landscape target), add palette
|
# with portrait target or portrait with landscape target), add palette
|
||||||
# and other image optimizations from Mangle.
|
# and other image optimizations from Mangle.
|
||||||
# WARNING: PIL is required for all image mangling!
|
# WARNING: PIL is required for all image mangling!
|
||||||
|
# 1.30 - Fixed an issue in OPF generation for device resolution
|
||||||
|
# Reworked options system (call with -h option to get the inline help)
|
||||||
#
|
#
|
||||||
# Todo:
|
# Todo:
|
||||||
# - Add gracefully exit for CBR if no rarfile.py and no unrar
|
# - Add gracefully exit for CBR if no rarfile.py and no unrar
|
||||||
@@ -31,10 +33,11 @@
|
|||||||
# - Improve error reporting
|
# - Improve error reporting
|
||||||
# - recurse into dirtree for multiple comics
|
# - recurse into dirtree for multiple comics
|
||||||
|
|
||||||
__version__ = '1.20'
|
__version__ = '1.30'
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from optparse import OptionParser
|
||||||
import image, cbxarchive
|
import image, cbxarchive
|
||||||
|
|
||||||
class HTMLbuilder:
|
class HTMLbuilder:
|
||||||
@@ -77,17 +80,11 @@ class NCXbuilder:
|
|||||||
return
|
return
|
||||||
|
|
||||||
class OPFBuilder:
|
class OPFBuilder:
|
||||||
def __init__(self, dstdir, title, filelist):
|
def __init__(self, profile, dstdir, title, filelist):
|
||||||
opffile = dstdir + '/content.opf'
|
opffile = dstdir + '/content.opf'
|
||||||
# read the first file resolution
|
# read the first file resolution
|
||||||
try:
|
deviceres, palette = image.ProfileData.Profiles[profile]
|
||||||
from PIL import Image
|
imgres = str(deviceres[0]) + "x" + str(deviceres[1])
|
||||||
im = Image.open(dstdir + "/" + filelist[0][0] + filelist[0][1])
|
|
||||||
width, height = im.size
|
|
||||||
imgres = str(width) + "x" + str(height)
|
|
||||||
except ImportError:
|
|
||||||
print "Could not load PIL, falling back on default HD"
|
|
||||||
imgres = "758x1024"
|
|
||||||
f = open(opffile, "w");
|
f = open(opffile, "w");
|
||||||
f.writelines(["<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",
|
f.writelines(["<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",
|
||||||
"<package version=\"2.0\" unique-identifier=\"PrimaryID\" xmlns=\"http://www.idpf.org/2007/opf\">\n",
|
"<package version=\"2.0\" unique-identifier=\"PrimaryID\" xmlns=\"http://www.idpf.org/2007/opf\">\n",
|
||||||
@@ -137,34 +134,41 @@ def Copyright():
|
|||||||
def Usage():
|
def Usage():
|
||||||
print "Generates HTML, NCX and OPF for a Comic ebook from a bunch of images"
|
print "Generates HTML, NCX and OPF for a Comic ebook from a bunch of images"
|
||||||
print "Optimized for creating Mobipockets to be read into Kindle Paperwhite"
|
print "Optimized for creating Mobipockets to be read into Kindle Paperwhite"
|
||||||
print "Usage:"
|
#print "Usage:"
|
||||||
print " %s <profile> <dir> <title>" % sys.argv[0]
|
#print " %s <profile> <dir> <title>" % sys.argv[0]
|
||||||
print " <title> is optional"
|
#print " <title> is optional"
|
||||||
|
parser.print_help()
|
||||||
|
|
||||||
def main(argv=None):
|
def main(argv=None):
|
||||||
if argv is None:
|
global parser
|
||||||
argv = sys.argv
|
usage = "Usage: %prog [options] comic_file|comic_folder"
|
||||||
profile = argv[1]
|
parser = OptionParser(usage=usage, version=__version__)
|
||||||
dir = argv[2]
|
parser.add_option("-p", "--profile", action="store", dest="profile", default="KHD",
|
||||||
|
help="Device profile (choose one among K1, K2, K3, K4, KHD [default])")
|
||||||
|
parser.add_option("-t", "--title", action="store", dest="title", default="comic",
|
||||||
|
help="Comic title")
|
||||||
|
parser.add_option("-m", "--manga-style", action="store_true", dest="righttoleft", default=False,
|
||||||
|
help="Split pages 'manga style' (right-to-left reading)")
|
||||||
|
options, args = parser.parse_args()
|
||||||
|
if len(args) != 1:
|
||||||
|
parser.print_help()
|
||||||
|
sys.exit(1)
|
||||||
|
dir = args[0]
|
||||||
cbx = cbxarchive.CBxArchive(dir)
|
cbx = cbxarchive.CBxArchive(dir)
|
||||||
if cbx.isCbxFile():
|
if cbx.isCbxFile():
|
||||||
cbx.extract()
|
cbx.extract()
|
||||||
dir = cbx.getPath()
|
dir = cbx.getPath()
|
||||||
if len(argv)==4:
|
|
||||||
title = argv[3]
|
|
||||||
else:
|
|
||||||
title = "comic"
|
|
||||||
filelist = []
|
filelist = []
|
||||||
try:
|
try:
|
||||||
print "Splitting double pages..."
|
print "Splitting double pages..."
|
||||||
for file in os.listdir(dir):
|
for file in os.listdir(dir):
|
||||||
if (getImageFileName(file) != None):
|
if (getImageFileName(file) != None):
|
||||||
img = image.ComicPage(dir+'/'+file, profile)
|
img = image.ComicPage(dir+'/'+file, options.profile)
|
||||||
img.splitPage(dir)
|
img.splitPage(dir, options.righttoleft)
|
||||||
for file in os.listdir(dir):
|
for file in os.listdir(dir):
|
||||||
if (getImageFileName(file) != None):
|
if (getImageFileName(file) != None):
|
||||||
print "Optimizing " + file + " for " + profile
|
print "Optimizing " + file + " for " + options.profile
|
||||||
img = image.ComicPage(dir+'/'+file, profile)
|
img = image.ComicPage(dir+'/'+file, options.profile)
|
||||||
img.resizeImage()
|
img.resizeImage()
|
||||||
#img.frameImage()
|
#img.frameImage()
|
||||||
img.quantizeImage()
|
img.quantizeImage()
|
||||||
@@ -181,16 +185,12 @@ def main(argv=None):
|
|||||||
filename = HTMLbuilder(dir,file).getResult()
|
filename = HTMLbuilder(dir,file).getResult()
|
||||||
if (filename != None):
|
if (filename != None):
|
||||||
filelist.append(filename)
|
filelist.append(filename)
|
||||||
NCXbuilder(dir,title)
|
NCXbuilder(dir,options.title)
|
||||||
# ensure we're sorting files alphabetically
|
# ensure we're sorting files alphabetically
|
||||||
filelist = sorted(filelist, key=lambda name: name[0])
|
filelist = sorted(filelist, key=lambda name: name[0])
|
||||||
OPFBuilder(dir,title,filelist)
|
OPFBuilder(options.profile,dir,options.title,filelist)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
Copyright()
|
Copyright()
|
||||||
if len(sys.argv)<3 or len(sys.argv)>4:
|
main()
|
||||||
Usage()
|
|
||||||
sys.exit(1)
|
|
||||||
else:
|
|
||||||
main()
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class ImageFlags:
|
|||||||
Stretch = 1 << 4
|
Stretch = 1 << 4
|
||||||
|
|
||||||
|
|
||||||
class KindleData:
|
class ProfileData:
|
||||||
Palette4 = [
|
Palette4 = [
|
||||||
0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00,
|
||||||
0x55, 0x55, 0x55,
|
0x55, 0x55, 0x55,
|
||||||
@@ -80,7 +80,7 @@ class KindleData:
|
|||||||
class ComicPage:
|
class ComicPage:
|
||||||
def __init__(self,source,device):
|
def __init__(self,source,device):
|
||||||
try:
|
try:
|
||||||
self.size, self.palette = KindleData.Profiles[device]
|
self.size, self.palette = ProfileData.Profiles[device]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise RuntimeError('Unexpected output device %s' % device)
|
raise RuntimeError('Unexpected output device %s' % device)
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -1699,10 +1699,6 @@ def custom_popen(cmd):
|
|||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
creationflags = 0x08000000 # CREATE_NO_WINDOW
|
creationflags = 0x08000000 # CREATE_NO_WINDOW
|
||||||
|
|
||||||
out_file = open("/tmp/test.txt","w")
|
|
||||||
out_file.write('[%s]' % ', '.join(map(str, cmd)))
|
|
||||||
out_file.close()
|
|
||||||
|
|
||||||
# run command
|
# run command
|
||||||
p = Popen(cmd, bufsize = 0, stdout = PIPE, stdin = PIPE, stderr = STDOUT,
|
p = Popen(cmd, bufsize = 0, stdout = PIPE, stdin = PIPE, stderr = STDOUT,
|
||||||
creationflags = creationflags)
|
creationflags = creationflags)
|
||||||
|
|||||||
25
README.md
25
README.md
@@ -19,14 +19,23 @@ The script takes care of calling `comic2ebook.py`, `kindlegen` and `kindlestrip.
|
|||||||
> If you want to specify other profiles, please use the script from command line.
|
> If you want to specify other profiles, please use the script from command line.
|
||||||
|
|
||||||
### standalone `comic2ebook.py` usage:
|
### standalone `comic2ebook.py` usage:
|
||||||
1. Launch
|
|
||||||
|
|
||||||
```python comic2ebook.py <profile> <directory|file> <title>```
|
```comic2ebook.py [options] comic_file|comic_folder
|
||||||
|
|
||||||
The script takes care of unzipping/unrarring the file if it's an archive, creating a directory of images which should be then filled with a `.opf`, `.ncx`, and many `.html` files.
|
Options:
|
||||||
4. Run `Kindlegen` on `content.opf`. Depending on how many images you have, this may take awhile. Once completed, the `.mobi` file should be in the directory.
|
--version show program's version number and exit
|
||||||
5. Remove the SRCS record to reduce the `.mobi` filesize in half. You can use [Kindlestrip](http://www.mobileread.com/forums/showthread.php?t=96903).
|
-h, --help show this help message and exit
|
||||||
6. Copy the `.mobi` file to your Kindle!
|
-p PROFILE, --profile=PROFILE
|
||||||
|
Device profile (choose one among K1, K2, K3, K4, KHD
|
||||||
|
[default])
|
||||||
|
-t TITLE, --title=TITLE
|
||||||
|
Comic title
|
||||||
|
-m, --manga-style Split pages 'manga style' (right-to-left reading)```
|
||||||
|
|
||||||
|
The script takes care of unzipping/unrarring the file if it's an archive, creating a directory of images which should be then filled with a `.opf`, `.ncx`, and many `.html` files.
|
||||||
|
Run `Kindlegen` on `content.opf`. Depending on how many images you have, this may take awhile. Once completed, the `.mobi` file should be in the directory.
|
||||||
|
Remove the SRCS record to reduce the `.mobi` filesize in half. You can use [Kindlestrip](http://www.mobileread.com/forums/showthread.php?t=96903).
|
||||||
|
Copy the `.mobi` file to your Kindle!
|
||||||
|
|
||||||
## CREDITS
|
## CREDITS
|
||||||
This script born as a cross-platform alternative to `KindleComicParser` by **Dc5e** (published in [this mobileread forum thread](http://www.mobileread.com/forums/showthread.php?t=192783))
|
This script born as a cross-platform alternative to `KindleComicParser` by **Dc5e** (published in [this mobileread forum thread](http://www.mobileread.com/forums/showthread.php?t=192783))
|
||||||
@@ -51,6 +60,8 @@ and installed in `/usr/local/bin/`
|
|||||||
- 1.20 - Comic optimizations! Split pages not target-oriented (landscape with portrait target or portrait
|
- 1.20 - Comic optimizations! Split pages not target-oriented (landscape with portrait target or portrait
|
||||||
with landscape target), add palette and other image optimizations from Mangle.
|
with landscape target), add palette and other image optimizations from Mangle.
|
||||||
WARNING: PIL is required for all image mangling!
|
WARNING: PIL is required for all image mangling!
|
||||||
|
- 1.30 - Fixed an issue in OPF generation for device resolution
|
||||||
|
Reworked options system (call with -h option to get the inline help)
|
||||||
- 2.00 - GUI! AppleScript is gone and Tk is used to provide cross-platform GUI support.
|
- 2.00 - GUI! AppleScript is gone and Tk is used to provide cross-platform GUI support.
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
@@ -61,4 +72,4 @@ and installed in `/usr/local/bin/`
|
|||||||
|
|
||||||
## COPYRIGHT
|
## COPYRIGHT
|
||||||
|
|
||||||
Copyright (c) 2012 Ciro Mattia Gonano. See LICENSE.txt for further details.
|
Copyright (c) 2012-2013 Ciro Mattia Gonano. See LICENSE.txt for further details.
|
||||||
16
kcc.py
16
kcc.py
@@ -33,12 +33,12 @@
|
|||||||
|
|
||||||
__version__ = '1.30'
|
__version__ = '1.30'
|
||||||
|
|
||||||
import sys
|
from Tkinter import *
|
||||||
from kcc import comic2ebook
|
from kcc import gui
|
||||||
|
|
||||||
if __name__ == "__main__":
|
root = Tk()
|
||||||
print ('kcc v%(__version__)s. '
|
app = gui.MainWindow(master=root)
|
||||||
'Written 2012 by Ciro Mattia Gonano.' % globals())
|
app.master.title("Kindle Comic Converter v" + __version__)
|
||||||
for arg in sys.argv[1:]:
|
app.master.maxsize(1000, 400)
|
||||||
comic2ebook.main(['','KHD',arg])
|
app.mainloop()
|
||||||
sys.exit(0)
|
root.destroy()
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
# with portrait target or portrait with landscape target), add palette
|
# with portrait target or portrait with landscape target), add palette
|
||||||
# and other image optimizations from Mangle.
|
# and other image optimizations from Mangle.
|
||||||
# WARNING: PIL is required for all image mangling!
|
# WARNING: PIL is required for all image mangling!
|
||||||
|
# 1.30 - Fixed an issue in OPF generation for device resolution
|
||||||
|
# Reworked options system (call with -h option to get the inline help)
|
||||||
#
|
#
|
||||||
# Todo:
|
# Todo:
|
||||||
# - Add gracefully exit for CBR if no rarfile.py and no unrar
|
# - Add gracefully exit for CBR if no rarfile.py and no unrar
|
||||||
@@ -31,10 +33,11 @@
|
|||||||
# - Improve error reporting
|
# - Improve error reporting
|
||||||
# - recurse into dirtree for multiple comics
|
# - recurse into dirtree for multiple comics
|
||||||
|
|
||||||
__version__ = '1.20'
|
__version__ = '1.30'
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from optparse import OptionParser
|
||||||
import image, cbxarchive
|
import image, cbxarchive
|
||||||
|
|
||||||
class HTMLbuilder:
|
class HTMLbuilder:
|
||||||
@@ -77,17 +80,11 @@ class NCXbuilder:
|
|||||||
return
|
return
|
||||||
|
|
||||||
class OPFBuilder:
|
class OPFBuilder:
|
||||||
def __init__(self, dstdir, title, filelist):
|
def __init__(self, profile, dstdir, title, filelist):
|
||||||
opffile = dstdir + '/content.opf'
|
opffile = dstdir + '/content.opf'
|
||||||
# read the first file resolution
|
# read the first file resolution
|
||||||
try:
|
deviceres, palette = image.ProfileData.Profiles[profile]
|
||||||
from PIL import Image
|
imgres = str(deviceres[0]) + "x" + str(deviceres[1])
|
||||||
im = Image.open(dstdir + "/" + filelist[0][0] + filelist[0][1])
|
|
||||||
width, height = im.size
|
|
||||||
imgres = str(width) + "x" + str(height)
|
|
||||||
except ImportError:
|
|
||||||
print "Could not load PIL, falling back on default HD"
|
|
||||||
imgres = "758x1024"
|
|
||||||
f = open(opffile, "w");
|
f = open(opffile, "w");
|
||||||
f.writelines(["<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",
|
f.writelines(["<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",
|
||||||
"<package version=\"2.0\" unique-identifier=\"PrimaryID\" xmlns=\"http://www.idpf.org/2007/opf\">\n",
|
"<package version=\"2.0\" unique-identifier=\"PrimaryID\" xmlns=\"http://www.idpf.org/2007/opf\">\n",
|
||||||
@@ -137,34 +134,41 @@ def Copyright():
|
|||||||
def Usage():
|
def Usage():
|
||||||
print "Generates HTML, NCX and OPF for a Comic ebook from a bunch of images"
|
print "Generates HTML, NCX and OPF for a Comic ebook from a bunch of images"
|
||||||
print "Optimized for creating Mobipockets to be read into Kindle Paperwhite"
|
print "Optimized for creating Mobipockets to be read into Kindle Paperwhite"
|
||||||
print "Usage:"
|
#print "Usage:"
|
||||||
print " %s <profile> <dir> <title>" % sys.argv[0]
|
#print " %s <profile> <dir> <title>" % sys.argv[0]
|
||||||
print " <title> is optional"
|
#print " <title> is optional"
|
||||||
|
parser.print_help()
|
||||||
|
|
||||||
def main(argv=None):
|
def main(argv=None):
|
||||||
if argv is None:
|
global parser
|
||||||
argv = sys.argv
|
usage = "Usage: %prog [options] comic_file|comic_folder"
|
||||||
profile = argv[1]
|
parser = OptionParser(usage=usage, version=__version__)
|
||||||
dir = argv[2]
|
parser.add_option("-p", "--profile", action="store", dest="profile", default="KHD",
|
||||||
|
help="Device profile (choose one among K1, K2, K3, K4, KHD [default])")
|
||||||
|
parser.add_option("-t", "--title", action="store", dest="title", default="comic",
|
||||||
|
help="Comic title")
|
||||||
|
parser.add_option("-m", "--manga-style", action="store_true", dest="righttoleft", default=False,
|
||||||
|
help="Split pages 'manga style' (right-to-left reading)")
|
||||||
|
options, args = parser.parse_args()
|
||||||
|
if len(args) != 1:
|
||||||
|
parser.print_help()
|
||||||
|
sys.exit(1)
|
||||||
|
dir = args[0]
|
||||||
cbx = cbxarchive.CBxArchive(dir)
|
cbx = cbxarchive.CBxArchive(dir)
|
||||||
if cbx.isCbxFile():
|
if cbx.isCbxFile():
|
||||||
cbx.extract()
|
cbx.extract()
|
||||||
dir = cbx.getPath()
|
dir = cbx.getPath()
|
||||||
if len(argv)==4:
|
|
||||||
title = argv[3]
|
|
||||||
else:
|
|
||||||
title = "comic"
|
|
||||||
filelist = []
|
filelist = []
|
||||||
try:
|
try:
|
||||||
print "Splitting double pages..."
|
print "Splitting double pages..."
|
||||||
for file in os.listdir(dir):
|
for file in os.listdir(dir):
|
||||||
if (getImageFileName(file) != None):
|
if (getImageFileName(file) != None):
|
||||||
img = image.ComicPage(dir+'/'+file, profile)
|
img = image.ComicPage(dir+'/'+file, options.profile)
|
||||||
img.splitPage(dir)
|
img.splitPage(dir, options.righttoleft)
|
||||||
for file in os.listdir(dir):
|
for file in os.listdir(dir):
|
||||||
if (getImageFileName(file) != None):
|
if (getImageFileName(file) != None):
|
||||||
print "Optimizing " + file + " for " + profile
|
print "Optimizing " + file + " for " + options.profile
|
||||||
img = image.ComicPage(dir+'/'+file, profile)
|
img = image.ComicPage(dir+'/'+file, options.profile)
|
||||||
img.resizeImage()
|
img.resizeImage()
|
||||||
#img.frameImage()
|
#img.frameImage()
|
||||||
img.quantizeImage()
|
img.quantizeImage()
|
||||||
@@ -181,16 +185,12 @@ def main(argv=None):
|
|||||||
filename = HTMLbuilder(dir,file).getResult()
|
filename = HTMLbuilder(dir,file).getResult()
|
||||||
if (filename != None):
|
if (filename != None):
|
||||||
filelist.append(filename)
|
filelist.append(filename)
|
||||||
NCXbuilder(dir,title)
|
NCXbuilder(dir,options.title)
|
||||||
# ensure we're sorting files alphabetically
|
# ensure we're sorting files alphabetically
|
||||||
filelist = sorted(filelist, key=lambda name: name[0])
|
filelist = sorted(filelist, key=lambda name: name[0])
|
||||||
OPFBuilder(dir,title,filelist)
|
OPFBuilder(options.profile,dir,options.title,filelist)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
Copyright()
|
Copyright()
|
||||||
if len(sys.argv)<3 or len(sys.argv)>4:
|
main()
|
||||||
Usage()
|
|
||||||
sys.exit(1)
|
|
||||||
else:
|
|
||||||
main()
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|||||||
43
kcc/gui.py
Normal file
43
kcc/gui.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
#
|
||||||
|
# Copyright (c) 2013 Ciro Mattia Gonano <ciromattia@gmail.com>
|
||||||
|
#
|
||||||
|
# Permission to use, copy, modify, and/or distribute this software for
|
||||||
|
# any purpose with or without fee is hereby granted, provided that the
|
||||||
|
# above copyright notice and this permission notice appear in all
|
||||||
|
# copies.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||||
|
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||||
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||||
|
# AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
|
||||||
|
# OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||||
|
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
# PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
from Tkinter import *
|
||||||
|
import tkFileDialog
|
||||||
|
|
||||||
|
class MainWindow(Frame):
|
||||||
|
def open_files(self):
|
||||||
|
self.files = tkFileDialog.askopenfilename()
|
||||||
|
|
||||||
|
def createWidgets(self):
|
||||||
|
self.QUIT = Button(self)
|
||||||
|
self.QUIT["text"] = "Quit"
|
||||||
|
self.QUIT["fg"] = "red"
|
||||||
|
self.QUIT["command"] = self.quit
|
||||||
|
self.QUIT.pack({"side": "right"})
|
||||||
|
|
||||||
|
self.OPENFILES = Button(self)
|
||||||
|
self.OPENFILES["text"] = "Open files",
|
||||||
|
self.OPENFILES["command"] = self.open_files
|
||||||
|
self.OPENFILES.pack({"side": "left"})
|
||||||
|
|
||||||
|
def __init__(self, master=None):
|
||||||
|
Frame.__init__(self, master)
|
||||||
|
self.pack()
|
||||||
|
self.createWidgets()
|
||||||
|
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ class ImageFlags:
|
|||||||
Stretch = 1 << 4
|
Stretch = 1 << 4
|
||||||
|
|
||||||
|
|
||||||
class KindleData:
|
class ProfileData:
|
||||||
Palette4 = [
|
Palette4 = [
|
||||||
0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00,
|
||||||
0x55, 0x55, 0x55,
|
0x55, 0x55, 0x55,
|
||||||
@@ -80,7 +80,7 @@ class KindleData:
|
|||||||
class ComicPage:
|
class ComicPage:
|
||||||
def __init__(self,source,device):
|
def __init__(self,source,device):
|
||||||
try:
|
try:
|
||||||
self.size, self.palette = KindleData.Profiles[device]
|
self.size, self.palette = ProfileData.Profiles[device]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise RuntimeError('Unexpected output device %s' % device)
|
raise RuntimeError('Unexpected output device %s' % device)
|
||||||
try:
|
try:
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user