mirror of
https://github.com/Kilian/Trimage.git
synced 2026-01-26 10:08:40 -05:00
pep8 it
This commit is contained in:
parent
6685635d85
commit
ed52fde42d
1 changed files with 19 additions and 14 deletions
33
trimage.py
33
trimage.py
|
|
@ -7,26 +7,34 @@ from hurry.filesize import *
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
from ui import Ui_trimage
|
from ui import Ui_trimage
|
||||||
|
|
||||||
|
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
|
||||||
|
|
||||||
class StartQT4(QMainWindow):
|
class StartQT4(QMainWindow):
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
QWidget.__init__(self, parent)
|
QWidget.__init__(self, parent)
|
||||||
self.ui = Ui_trimage()
|
self.ui = Ui_trimage()
|
||||||
self.ui.setupUi(self)
|
self.ui.setupUi(self)
|
||||||
self.quit_shortcut = QShortcut(QKeySequence("Ctrl+Q"), self); # todo use standardKey Quit.
|
# todo use standardKey Quit.
|
||||||
|
self.quit_shortcut = QShortcut(QKeySequence("Ctrl+Q"), self)
|
||||||
# set recompress to false
|
# set recompress to false
|
||||||
self.ui.recompress.setEnabled(False)
|
self.ui.recompress.setEnabled(False)
|
||||||
self.imagelist = []
|
self.imagelist = []
|
||||||
self.showapp = True
|
self.showapp = True
|
||||||
|
|
||||||
# connect signals with slots
|
# connect signals with slots
|
||||||
QObject.connect(self.ui.addfiles, SIGNAL("clicked()"), self.file_dialog)
|
QObject.connect(self.ui.addfiles, SIGNAL("clicked()"),
|
||||||
QObject.connect(self.ui.recompress, SIGNAL("clicked()"), self.recompress_files)
|
self.file_dialog)
|
||||||
QObject.connect(self.quit_shortcut, SIGNAL("activated()"), qApp, SLOT('quit()'))
|
QObject.connect(self.ui.recompress, SIGNAL("clicked()"),
|
||||||
|
self.recompress_files)
|
||||||
|
QObject.connect(self.quit_shortcut, SIGNAL("activated()"),
|
||||||
|
qApp, SLOT('quit()'))
|
||||||
|
|
||||||
parser = OptionParser(version="%prog 1.0",
|
parser = OptionParser(version="%prog 1.0",
|
||||||
description="GUI front-end to compress png and jpg images via optipng and jpegoptim")
|
description="GUI front-end to compress png and jpg images via "
|
||||||
|
"optipng and jpegoptim")
|
||||||
|
|
||||||
parser.add_option("-f", "--file",
|
parser.add_option("-f", "--file",
|
||||||
action="store", type="string", dest="filename",
|
action="store", type="string", dest="filename",
|
||||||
|
|
@ -39,7 +47,7 @@ class StartQT4(QMainWindow):
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
if options.filename:
|
if options.filename:
|
||||||
self.file_from_cmd(options.filename)
|
self.file_from_cmd(options.filename)
|
||||||
|
|
||||||
if options.directory:
|
if options.directory:
|
||||||
self.dir_from_cmd(options.directory)
|
self.dir_from_cmd(options.directory)
|
||||||
|
|
@ -68,18 +76,16 @@ class StartQT4(QMainWindow):
|
||||||
def file_dialog(self):
|
def file_dialog(self):
|
||||||
fd = QFileDialog(self)
|
fd = QFileDialog(self)
|
||||||
images = fd.getOpenFileNames(self,
|
images = fd.getOpenFileNames(self,
|
||||||
"Select one or more image files to compress",
|
"Select one or more image files to compress",
|
||||||
"", # directory
|
"", # directory
|
||||||
"Image files (*.png *.jpg)")
|
"Image files (*.png *.jpg)")
|
||||||
for image in images:
|
for image in images:
|
||||||
if self.checkname(name):
|
if self.checkname(name):
|
||||||
self.compress_file(image)
|
self.compress_file(image)
|
||||||
|
|
||||||
|
|
||||||
def enable_recompress(self):
|
def enable_recompress(self):
|
||||||
self.ui.recompress.setEnabled(True)
|
self.ui.recompress.setEnabled(True)
|
||||||
|
|
||||||
|
|
||||||
def recompress_files(self):
|
def recompress_files(self):
|
||||||
imagelistcopy = self.imagelist
|
imagelistcopy = self.imagelist
|
||||||
self.imagelist = []
|
self.imagelist = []
|
||||||
|
|
@ -180,8 +186,7 @@ if __name__ == "__main__":
|
||||||
myapp = StartQT4()
|
myapp = StartQT4()
|
||||||
|
|
||||||
if myapp.showapp:
|
if myapp.showapp:
|
||||||
myapp.show()
|
myapp.show()
|
||||||
else:
|
else:
|
||||||
quit()
|
quit()
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue