work in progress of creating an installable version

This commit is contained in:
Kilian Valkhof 2010-03-23 13:09:52 +01:00
parent a283ce8481
commit b86c5aa8cd
15 changed files with 189 additions and 7 deletions

3
.gitignore vendored
View file

@ -1,2 +1,5 @@
*.pyc
MANIFEST
dist/
build/

3
MANIFEST.in Normal file
View file

@ -0,0 +1,3 @@
include trimage
recursive-include pixmaps *

0
__init__.py Normal file
View file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 486 B

View file

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 676 B

After

Width:  |  Height:  |  Size: 676 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 2 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 9.3 KiB

Before After
Before After

5
setup.cfg Normal file
View file

@ -0,0 +1,5 @@
[install]
install_lib=/usr/local/share/trimage
install_data=/usr/local/share/trimage
install_scripts=/usr/local/bin

19
setup.py Normal file
View file

@ -0,0 +1,19 @@
#!/usr/bin/env python
from distutils.core import setup
setup(name = "Trimage",
version = "1.0.0b",
description = "Trimage image compressor - A cross-platform tool for optimizing PNG and JPG files",
author = "Kilian Valkhof, Paul Chaplin",
author_email = "help@trimage.org",
url = "http://trimage.org",
license = "MIT license",
packages = ["hurry", "hurry/filesize",""],
data_files = [("pixmaps", ["pixmaps/list-add.png",
"pixmaps/view-refresh.png",
"pixmaps/compressing.gif",
"pixmaps/trimage-icon.png"])],
scripts = ["trimage"],
long_description = """Trimage is a cross-platform GUI and command-line interface to optimize image files via optipng, advpng and jpegoptim, depending on the filetype (currently, PNG and JPG files are supported). It was inspired by imageoptim. All image files are losslessy compressed on the highest available compression levels. Trimage gives you various input functions to fit your own workflow: A regular file dialog, dragging and dropping and various command line options."""
)

160
trimage.py → trimage Normal file → Executable file
View file

@ -1,3 +1,5 @@
#!/usr/bin/python
import sys
from os import listdir
from os import path
@ -8,9 +10,7 @@ from PyQt4.QtCore import *
from PyQt4.QtGui import *
from hurry.filesize import *
from ui import Ui_trimage
VERSION = "1.0.0"
VERSION = "1.0.0b"
class StartQT4(QMainWindow):
@ -146,7 +146,7 @@ class StartQT4(QMainWindow):
if self.checkname(image):
delegatorlist.append((image, QIcon(image)))
self.imagelist.append(("Compressing...", "", "", "", image,
QIcon(QPixmap("compressing.gif"))))
QIcon(QPixmap("pixmaps/compressing.gif"))))
else:
sys.stderr.write("[error] %s not an image file" % image)
@ -338,6 +338,158 @@ class Worker(QThread):
#make sure the app quits after all images are done
quit()
class TrimageTableView(QTableView):
"""Init the table drop event."""
def __init__(self, parent=None):
super(TrimageTableView, self).__init__(parent)
self.setAcceptDrops(True)
def dragEnterEvent(self, event):
if event.mimeData().hasFormat("text/uri-list"):
event.accept()
else:
event.ignore()
def dragMoveEvent(self, event):
event.accept()
def dropEvent(self, event):
files = str(event.mimeData().data("text/uri-list")).strip().split()
for i, file in enumerate(files):
files[i] = QUrl(QString(file)).toLocalFile()
self.emit(SIGNAL("fileDropEvent"), (files))
class Ui_trimage(object):
def setupUi(self, trimage):
trimage.setObjectName("trimage")
trimage.resize(600, 170)
trimage.setWindowIcon(QIcon("pixmaps/trimage-icon.png"))
self.centralwidget = QWidget(trimage)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout_2 = QGridLayout(self.centralwidget)
self.gridLayout_2.setMargin(0)
self.gridLayout_2.setSpacing(0)
self.gridLayout_2.setObjectName("gridLayout_2")
self.widget = QWidget(self.centralwidget)
self.widget.setEnabled(True)
sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(1)
sizePolicy.setVerticalStretch(1)
sizePolicy.setHeightForWidth(
self.widget.sizePolicy().hasHeightForWidth())
self.widget.setSizePolicy(sizePolicy)
self.widget.setObjectName("widget")
self.verticalLayout = QVBoxLayout(self.widget)
self.verticalLayout.setSpacing(0)
self.verticalLayout.setMargin(0)
self.verticalLayout.setObjectName("verticalLayout")
self.frame = QFrame(self.widget)
self.frame.setObjectName("frame")
self.verticalLayout_2 = QVBoxLayout(self.frame)
self.verticalLayout_2.setSpacing(0)
self.verticalLayout_2.setMargin(0)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.horizontalLayout = QHBoxLayout()
self.horizontalLayout.setSpacing(0)
self.horizontalLayout.setMargin(10)
self.horizontalLayout.setObjectName("horizontalLayout")
self.addfiles = QPushButton(self.frame)
font = QFont()
font.setPointSize(9)
self.addfiles.setFont(font)
self.addfiles.setCursor(Qt.PointingHandCursor)
icon = QIcon()
icon.addPixmap(QPixmap("pixmaps/list-add.png"), QIcon.Normal, QIcon.Off)
self.addfiles.setIcon(icon)
self.addfiles.setObjectName("addfiles")
self.addfiles.setAcceptDrops(True)
self.horizontalLayout.addWidget(self.addfiles)
self.label = QLabel(self.frame)
font = QFont()
font.setPointSize(8)
self.label.setFont(font)
self.label.setFrameShadow(QFrame.Plain)
self.label.setMargin(1)
self.label.setIndent(10)
self.label.setObjectName("label")
self.horizontalLayout.addWidget(self.label)
spacerItem = QSpacerItem(498, 20, QSizePolicy.Expanding,
QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.recompress = QPushButton(self.frame)
font = QFont()
font.setPointSize(9)
self.recompress.setFont(font)
self.recompress.setCursor(Qt.PointingHandCursor)
icon1 = QIcon()
icon1.addPixmap(QPixmap("pixmaps/view-refresh.png"), QIcon.Normal, QIcon.Off)
self.recompress.setIcon(icon1)
self.recompress.setCheckable(False)
self.recompress.setObjectName("recompress")
self.horizontalLayout.addWidget(self.recompress)
self.verticalLayout_2.addLayout(self.horizontalLayout)
self.processedfiles = TrimageTableView(self.frame)
self.processedfiles.setEnabled(True)
self.processedfiles.setFrameShape(QFrame.NoFrame)
self.processedfiles.setFrameShadow(QFrame.Plain)
self.processedfiles.setLineWidth(0)
self.processedfiles.setMidLineWidth(0)
self.processedfiles.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.processedfiles.setTabKeyNavigation(True)
self.processedfiles.setAlternatingRowColors(True)
self.processedfiles.setTextElideMode(Qt.ElideRight)
self.processedfiles.setShowGrid(True)
self.processedfiles.setGridStyle(Qt.NoPen)
self.processedfiles.setSortingEnabled(False)
self.processedfiles.setObjectName("processedfiles")
self.processedfiles.resizeColumnsToContents()
self.processedfiles.setSelectionMode(QAbstractItemView.NoSelection)
self.verticalLayout_2.addWidget(self.processedfiles)
self.verticalLayout.addWidget(self.frame)
self.gridLayout_2.addWidget(self.widget, 0, 0, 1, 1)
trimage.setCentralWidget(self.centralwidget)
self.retranslateUi(trimage)
QMetaObject.connectSlotsByName(trimage)
def retranslateUi(self, trimage):
trimage.setWindowTitle(QApplication.translate("trimage",
"Trimage image compressor", None, QApplication.UnicodeUTF8))
self.addfiles.setToolTip(QApplication.translate("trimage",
"Add file to the compression list", None,
QApplication.UnicodeUTF8))
self.addfiles.setText(QApplication.translate("trimage",
"&Add and compress", None, QApplication.UnicodeUTF8))
self.addfiles.setShortcut(QApplication.translate("trimage",
"Alt+A", None, QApplication.UnicodeUTF8))
self.label.setText(QApplication.translate("trimage",
"Drag and drop images onto the table", None,
QApplication.UnicodeUTF8))
self.recompress.setToolTip(QApplication.translate("trimage",
"Recompress selected images", None, QApplication.UnicodeUTF8))
self.recompress.setText(QApplication.translate("trimage",
"&Recompress", None, QApplication.UnicodeUTF8))
self.recompress.setShortcut(QApplication.translate("trimage",
"Alt+R", None, QApplication.UnicodeUTF8))
self.processedfiles.setToolTip(QApplication.translate("trimage",
"Drag files in here", None, QApplication.UnicodeUTF8))
self.processedfiles.setWhatsThis(QApplication.translate("trimage",
"Drag files in here", None, QApplication.UnicodeUTF8))
if __name__ == "__main__":
app = QApplication(sys.argv)
myapp = StartQT4()

6
ui.py
View file

@ -28,7 +28,7 @@ class Ui_trimage(object):
def setupUi(self, trimage):
trimage.setObjectName("trimage")
trimage.resize(600, 170)
trimage.setWindowIcon(QIcon("trimage-icon.png"))
trimage.setWindowIcon(QIcon("pixmaps/trimage-icon.png"))
self.centralwidget = QWidget(trimage)
self.centralwidget.setObjectName("centralwidget")
@ -72,7 +72,7 @@ class Ui_trimage(object):
self.addfiles.setFont(font)
self.addfiles.setCursor(Qt.PointingHandCursor)
icon = QIcon()
icon.addPixmap(QPixmap("list-add.png"), QIcon.Normal, QIcon.Off)
icon.addPixmap(QPixmap("pixmaps/list-add.png"), QIcon.Normal, QIcon.Off)
self.addfiles.setIcon(icon)
self.addfiles.setObjectName("addfiles")
self.addfiles.setAcceptDrops(True)
@ -98,7 +98,7 @@ class Ui_trimage(object):
self.recompress.setCursor(Qt.PointingHandCursor)
icon1 = QIcon()
icon1.addPixmap(QPixmap("view-refresh.png"), QIcon.Normal, QIcon.Off)
icon1.addPixmap(QPixmap("pixmaps/view-refresh.png"), QIcon.Normal, QIcon.Off)
self.recompress.setIcon(icon1)
self.recompress.setCheckable(False)