mirror of
https://github.com/Kilian/Trimage.git
synced 2026-01-26 01:58:41 -05:00
write skeleton app, begin development
This commit is contained in:
parent
7402201365
commit
61a0dffe59
5 changed files with 188 additions and 3 deletions
57
trimage.py
Normal file
57
trimage.py
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
import sys
|
||||||
|
from PyQt4 import QtCore, QtGui
|
||||||
|
from ui import Ui_trimage
|
||||||
|
from os.path import isfile
|
||||||
|
|
||||||
|
class StartQT4(QtGui.QMainWindow):
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
QtGui.QWidget.__init__(self, parent)
|
||||||
|
self.ui = Ui_trimage()
|
||||||
|
self.ui.setupUi(self)
|
||||||
|
|
||||||
|
# connect signals with slots
|
||||||
|
QtCore.QObject.connect(self.ui.addfiles,QtCore.SIGNAL("clicked()"), self.file_dialog)
|
||||||
|
QtCore.QObject.connect(self.ui.recompress,QtCore.SIGNAL("clicked()"), self.recompress_files)
|
||||||
|
|
||||||
|
# set recompress to false
|
||||||
|
self.ui.recompress.setEnabled(False)
|
||||||
|
|
||||||
|
def file_dialog(self):
|
||||||
|
fd = QtGui.QFileDialog(self)
|
||||||
|
images = fd.getOpenFileNames(self,
|
||||||
|
"Select one or more image files to compress",
|
||||||
|
"", # directory
|
||||||
|
"Image files (*.png *.gif *.jpg)")
|
||||||
|
|
||||||
|
for image in images:
|
||||||
|
filename = image
|
||||||
|
oldfilesize = QtCore.QFileInfo(image).size()
|
||||||
|
# send image to processing
|
||||||
|
|
||||||
|
def enable_recompress(self):
|
||||||
|
self.ui.recompress.setEnabled(True)
|
||||||
|
|
||||||
|
def recompress_files(self):
|
||||||
|
# get list of currently processed files
|
||||||
|
# reprocess them
|
||||||
|
# update columnview
|
||||||
|
self.setWindowTitle("check too!")
|
||||||
|
|
||||||
|
def compress_file(self, file):
|
||||||
|
# check file extention
|
||||||
|
# get file size
|
||||||
|
# run correct command line tool and get reply
|
||||||
|
# get new file size
|
||||||
|
# add to columnview
|
||||||
|
self.setWindowTitle("check too!")
|
||||||
|
|
||||||
|
def add_to_columnview(self):
|
||||||
|
# update column view with file info
|
||||||
|
self.setWindowTitle("check too!")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app = QtGui.QApplication(sys.argv)
|
||||||
|
myapp = StartQT4()
|
||||||
|
myapp.show()
|
||||||
|
sys.exit(app.exec_())
|
||||||
|
|
||||||
BIN
trimage.pyc
Normal file
BIN
trimage.pyc
Normal file
Binary file not shown.
110
ui.py
Normal file
110
ui.py
Normal file
|
|
@ -0,0 +1,110 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Form implementation generated from reading ui file 'window.ui'
|
||||||
|
#
|
||||||
|
# Created: Mon Feb 1 16:48:11 2010
|
||||||
|
# by: PyQt4 UI code generator 4.4.4
|
||||||
|
#
|
||||||
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
|
||||||
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
class Ui_trimage(object):
|
||||||
|
def setupUi(self, trimage):
|
||||||
|
trimage.setObjectName("trimage")
|
||||||
|
trimage.resize(600, 170)
|
||||||
|
self.centralwidget = QtGui.QWidget(trimage)
|
||||||
|
self.centralwidget.setObjectName("centralwidget")
|
||||||
|
self.gridLayout_2 = QtGui.QGridLayout(self.centralwidget)
|
||||||
|
self.gridLayout_2.setMargin(0)
|
||||||
|
self.gridLayout_2.setSpacing(0)
|
||||||
|
self.gridLayout_2.setObjectName("gridLayout_2")
|
||||||
|
self.widget = QtGui.QWidget(self.centralwidget)
|
||||||
|
self.widget.setEnabled(True)
|
||||||
|
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
|
||||||
|
sizePolicy.setHorizontalStretch(1)
|
||||||
|
sizePolicy.setVerticalStretch(1)
|
||||||
|
sizePolicy.setHeightForWidth(self.widget.sizePolicy().hasHeightForWidth())
|
||||||
|
self.widget.setSizePolicy(sizePolicy)
|
||||||
|
self.widget.setObjectName("widget")
|
||||||
|
self.verticalLayout = QtGui.QVBoxLayout(self.widget)
|
||||||
|
self.verticalLayout.setSpacing(0)
|
||||||
|
self.verticalLayout.setMargin(0)
|
||||||
|
self.verticalLayout.setObjectName("verticalLayout")
|
||||||
|
self.frame = QtGui.QFrame(self.widget)
|
||||||
|
self.frame.setObjectName("frame")
|
||||||
|
self.verticalLayout_2 = QtGui.QVBoxLayout(self.frame)
|
||||||
|
self.verticalLayout_2.setSpacing(0)
|
||||||
|
self.verticalLayout_2.setMargin(0)
|
||||||
|
self.verticalLayout_2.setObjectName("verticalLayout_2")
|
||||||
|
self.horizontalLayout = QtGui.QHBoxLayout()
|
||||||
|
self.horizontalLayout.setSpacing(0)
|
||||||
|
self.horizontalLayout.setMargin(10)
|
||||||
|
self.horizontalLayout.setObjectName("horizontalLayout")
|
||||||
|
self.addfiles = QtGui.QPushButton(self.frame)
|
||||||
|
font = QtGui.QFont()
|
||||||
|
font.setPointSize(9)
|
||||||
|
self.addfiles.setFont(font)
|
||||||
|
self.addfiles.setCursor(QtCore.Qt.PointingHandCursor)
|
||||||
|
icon = QtGui.QIcon()
|
||||||
|
icon.addPixmap(QtGui.QPixmap("list-add.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
|
self.addfiles.setIcon(icon)
|
||||||
|
self.addfiles.setObjectName("addfiles")
|
||||||
|
self.horizontalLayout.addWidget(self.addfiles)
|
||||||
|
self.label = QtGui.QLabel(self.frame)
|
||||||
|
font = QtGui.QFont()
|
||||||
|
font.setPointSize(8)
|
||||||
|
self.label.setFont(font)
|
||||||
|
self.label.setFrameShadow(QtGui.QFrame.Plain)
|
||||||
|
self.label.setMargin(1)
|
||||||
|
self.label.setIndent(10)
|
||||||
|
self.label.setObjectName("label")
|
||||||
|
self.horizontalLayout.addWidget(self.label)
|
||||||
|
spacerItem = QtGui.QSpacerItem(498, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||||
|
self.horizontalLayout.addItem(spacerItem)
|
||||||
|
self.recompress = QtGui.QPushButton(self.frame)
|
||||||
|
font = QtGui.QFont()
|
||||||
|
font.setPointSize(9)
|
||||||
|
self.recompress.setFont(font)
|
||||||
|
self.recompress.setCursor(QtCore.Qt.PointingHandCursor)
|
||||||
|
icon1 = QtGui.QIcon()
|
||||||
|
icon1.addPixmap(QtGui.QPixmap("view-refresh.png"), QtGui.QIcon.Normal, QtGui.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 = QtGui.QColumnView(self.frame)
|
||||||
|
self.processedfiles.setEnabled(True)
|
||||||
|
self.processedfiles.setAcceptDrops(True)
|
||||||
|
self.processedfiles.setFrameShape(QtGui.QFrame.NoFrame)
|
||||||
|
self.processedfiles.setFrameShadow(QtGui.QFrame.Plain)
|
||||||
|
self.processedfiles.setLineWidth(0)
|
||||||
|
self.processedfiles.setMidLineWidth(0)
|
||||||
|
self.processedfiles.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||||
|
self.processedfiles.setTabKeyNavigation(True)
|
||||||
|
self.processedfiles.setDragEnabled(True)
|
||||||
|
self.processedfiles.setDragDropMode(QtGui.QAbstractItemView.DropOnly)
|
||||||
|
self.processedfiles.setAlternatingRowColors(True)
|
||||||
|
self.processedfiles.setTextElideMode(QtCore.Qt.ElideRight)
|
||||||
|
self.processedfiles.setObjectName("processedfiles")
|
||||||
|
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)
|
||||||
|
QtCore.QMetaObject.connectSlotsByName(trimage)
|
||||||
|
|
||||||
|
def retranslateUi(self, trimage):
|
||||||
|
trimage.setWindowTitle(QtGui.QApplication.translate("trimage", "Trimage image compressor", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
|
self.addfiles.setToolTip(QtGui.QApplication.translate("trimage", "Add file to the compression list", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
|
self.addfiles.setText(QtGui.QApplication.translate("trimage", "&Add and compress", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
|
self.addfiles.setShortcut(QtGui.QApplication.translate("trimage", "Alt+A", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
|
self.label.setText(QtGui.QApplication.translate("trimage", "Drag and drop images onto the table", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
|
self.recompress.setToolTip(QtGui.QApplication.translate("trimage", "Recompress selected images", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
|
self.recompress.setText(QtGui.QApplication.translate("trimage", "&Recompress", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
|
self.recompress.setShortcut(QtGui.QApplication.translate("trimage", "Alt+R", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
|
self.processedfiles.setToolTip(QtGui.QApplication.translate("trimage", "Drag files in here", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
|
self.processedfiles.setWhatsThis(QtGui.QApplication.translate("trimage", "Drag files in here", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
|
|
||||||
BIN
ui.pyc
Normal file
BIN
ui.pyc
Normal file
Binary file not shown.
24
window.ui
24
window.ui
|
|
@ -1,12 +1,13 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>MainWindow</class>
|
<author>Kilian Valkhof</author>
|
||||||
<widget class="QMainWindow" name="MainWindow">
|
<class>trimage</class>
|
||||||
|
<widget class="QMainWindow" name="trimage">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>602</width>
|
<width>600</width>
|
||||||
<height>170</height>
|
<height>170</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -202,4 +203,21 @@
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
<designerdata>
|
||||||
|
<property name="gridDeltaX">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="gridDeltaY">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="gridSnapX">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="gridSnapY">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="gridVisible">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</designerdata>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue