mirror of
https://github.com/Kilian/Trimage.git
synced 2026-01-26 10:08:40 -05:00
get rid of verbose and showapp globals
This commit is contained in:
parent
217f622540
commit
a831a5b85c
2 changed files with 13 additions and 17 deletions
29
trimage.py
29
trimage.py
|
|
@ -15,18 +15,14 @@ VERSION = "1.0.0"
|
||||||
#init imagelist
|
#init imagelist
|
||||||
imagelist = []
|
imagelist = []
|
||||||
|
|
||||||
# defaults
|
|
||||||
showapp = True
|
|
||||||
verbose = 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.showapp = True
|
||||||
|
self.verbose = True
|
||||||
# check if apps are installed
|
# check if apps are installed
|
||||||
if self.checkapps():
|
if self.checkapps():
|
||||||
quit()
|
quit()
|
||||||
|
|
@ -85,8 +81,7 @@ class StartQT4(QMainWindow):
|
||||||
if options.directory:
|
if options.directory:
|
||||||
self.dir_from_cmd(options.directory)
|
self.dir_from_cmd(options.directory)
|
||||||
|
|
||||||
global verbose
|
self.verbose = options.verbose
|
||||||
verbose = options.verbose
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Input functions
|
Input functions
|
||||||
|
|
@ -96,8 +91,7 @@ class StartQT4(QMainWindow):
|
||||||
"""
|
"""
|
||||||
Read the files in the directory and send all files to compress_file.
|
Read the files in the directory and send all files to compress_file.
|
||||||
"""
|
"""
|
||||||
global showapp
|
self.showapp = False
|
||||||
showapp = False
|
|
||||||
dirpath = path.abspath(path.dirname(directory))
|
dirpath = path.abspath(path.dirname(directory))
|
||||||
imagedir = listdir(directory)
|
imagedir = listdir(directory)
|
||||||
filelist = QStringList()
|
filelist = QStringList()
|
||||||
|
|
@ -108,8 +102,7 @@ class StartQT4(QMainWindow):
|
||||||
|
|
||||||
def file_from_cmd(self, image):
|
def file_from_cmd(self, image):
|
||||||
"""Get the file and send it to compress_file"""
|
"""Get the file and send it to compress_file"""
|
||||||
global showapp
|
self.showapp = False
|
||||||
showapp = False
|
|
||||||
image = path.abspath(image)
|
image = path.abspath(image)
|
||||||
filecmdlist = QStringList()
|
filecmdlist = QStringList()
|
||||||
filecmdlist.append(image)
|
filecmdlist.append(image)
|
||||||
|
|
@ -156,7 +149,7 @@ class StartQT4(QMainWindow):
|
||||||
QIcon(QPixmap("compressing.gif"))))
|
QIcon(QPixmap("compressing.gif"))))
|
||||||
else:
|
else:
|
||||||
sys.stderr.write("[error] %s not an image file" % image)
|
sys.stderr.write("[error] %s not an image file" % image)
|
||||||
self.thread.compress_file(delegatorlist)
|
self.thread.compress_file(delegatorlist, self.showapp, self.verbose)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
UI Functions
|
UI Functions
|
||||||
|
|
@ -273,9 +266,11 @@ class Worker(QThread):
|
||||||
self.exiting = True
|
self.exiting = True
|
||||||
self.wait()
|
self.wait()
|
||||||
|
|
||||||
def compress_file(self, images):
|
def compress_file(self, images, showapp, verbose):
|
||||||
"""Start the worker thread."""
|
"""Start the worker thread."""
|
||||||
self.images = images
|
self.images = images
|
||||||
|
self.showapp = showapp
|
||||||
|
self.verbose = verbose
|
||||||
self.start()
|
self.start()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
@ -327,7 +322,7 @@ class Worker(QThread):
|
||||||
|
|
||||||
self.emit(SIGNAL("updateUi"))
|
self.emit(SIGNAL("updateUi"))
|
||||||
|
|
||||||
if not showapp and verbose:
|
if not self.showapp and self.verbose:
|
||||||
# we work via the commandline
|
# we work via the commandline
|
||||||
print("File: " + filename + ", Old Size: "
|
print("File: " + filename + ", Old Size: "
|
||||||
+ oldfilesizestr + ", New Size: " + newfilesizestr
|
+ oldfilesizestr + ", New Size: " + newfilesizestr
|
||||||
|
|
@ -335,7 +330,7 @@ class Worker(QThread):
|
||||||
else:
|
else:
|
||||||
sys.stderr.write("[error] %s" % runfile)
|
sys.stderr.write("[error] %s" % runfile)
|
||||||
|
|
||||||
if not showapp:
|
if not self.showapp:
|
||||||
#make sure the app quits after all images are done
|
#make sure the app quits after all images are done
|
||||||
quit()
|
quit()
|
||||||
|
|
||||||
|
|
@ -343,6 +338,6 @@ if __name__ == "__main__":
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
myapp = StartQT4()
|
myapp = StartQT4()
|
||||||
|
|
||||||
if showapp:
|
if myapp.showapp:
|
||||||
myapp.show()
|
myapp.show()
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@
|
||||||
.tri {
|
.tri {
|
||||||
-moz-column-count:3;
|
-moz-column-count:3;
|
||||||
-webkit-column-count:3;
|
-webkit-column-count:3;
|
||||||
|
text-align:justify;
|
||||||
}
|
}
|
||||||
img {
|
img {
|
||||||
margin-bottom:1.5em;
|
margin-bottom:1.5em;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue