paint, translate, unzip: Updates, additions to apps.
This commit is contained in:
13
README.md
13
README.md
@@ -28,23 +28,24 @@ include the MIT license file when distributing.
|
||||
1. Webcam/Snapshot - "NSAViewer"
|
||||
1. Media Player - "Failamp"
|
||||
1. Post-it Notes - "Brown Note" (QtDesigner)
|
||||
1. Paint - "Piecasso" (QtDesigner)
|
||||
1. Translator - "Babelvis" (QtDesigner)
|
||||
1. Unzip - "7Pez" (QtDesigner)
|
||||
|
||||
## In progress
|
||||
|
||||
1. Paint - "Piecasso" (QtDesigner)
|
||||
1. Translator - "Babelvis" (QtDesigner)
|
||||
1. Currency converter (QtDesigner, PyQtGraph)
|
||||
1. RSS Reader (QtDesigner)
|
||||
|
||||
## Up next
|
||||
|
||||
1. Solitaire - "Ronery"
|
||||
1. Unzip - "7Pez" (QtDesigner)
|
||||
1. Address Book - "PeepKeep" (QtDesigner)
|
||||
1. RSS Reader
|
||||
|
||||
## Maybe oneday
|
||||
|
||||
1. Address Book - "PeepKeep" (QtDesigner)
|
||||
1. Photo Gallery - "PeepPeek"
|
||||
1. Vector Graphics - "Madcap Artisan"
|
||||
1. Vector Graphics - "Madcap Artist"
|
||||
1. Email - "GeeMail"
|
||||
1. IRC - "kIRC"
|
||||
1. Sound Editor
|
||||
|
||||
@@ -628,15 +628,31 @@ class Ui_MainWindow(object):
|
||||
self.statusBar = QtWidgets.QStatusBar(MainWindow)
|
||||
self.statusBar.setObjectName("statusBar")
|
||||
MainWindow.setStatusBar(self.statusBar)
|
||||
self.fileToolbar = QtWidgets.QToolBar(MainWindow)
|
||||
self.fileToolbar.setIconSize(QtCore.QSize(16, 16))
|
||||
self.fileToolbar.setObjectName("fileToolbar")
|
||||
MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.fileToolbar)
|
||||
self.drawingToolbar = QtWidgets.QToolBar(MainWindow)
|
||||
self.drawingToolbar.setIconSize(QtCore.QSize(16, 16))
|
||||
self.drawingToolbar.setObjectName("drawingToolbar")
|
||||
MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.drawingToolbar)
|
||||
self.fontToolbar = QtWidgets.QToolBar(MainWindow)
|
||||
self.fontToolbar.setIconSize(QtCore.QSize(16, 16))
|
||||
self.fontToolbar.setObjectName("fontToolbar")
|
||||
MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.fontToolbar)
|
||||
self.actionCopy = QtWidgets.QAction(MainWindow)
|
||||
self.actionCopy.setObjectName("actionCopy")
|
||||
self.actionClearImage = QtWidgets.QAction(MainWindow)
|
||||
self.actionClearImage.setObjectName("actionClearImage")
|
||||
self.actionClearselection = QtWidgets.QAction(MainWindow)
|
||||
self.actionClearselection.setObjectName("actionClearselection")
|
||||
self.actionOpenImage = QtWidgets.QAction(MainWindow)
|
||||
icon16 = QtGui.QIcon()
|
||||
icon16.addPixmap(QtGui.QPixmap("images/blue-folder-open-image.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.actionOpenImage.setIcon(icon16)
|
||||
self.actionOpenImage.setObjectName("actionOpenImage")
|
||||
self.actionSaveImage = QtWidgets.QAction(MainWindow)
|
||||
icon17 = QtGui.QIcon()
|
||||
icon17.addPixmap(QtGui.QPixmap("images/disk.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.actionSaveImage.setIcon(icon17)
|
||||
self.actionSaveImage.setObjectName("actionSaveImage")
|
||||
self.actionInvertColors = QtWidgets.QAction(MainWindow)
|
||||
self.actionInvertColors.setObjectName("actionInvertColors")
|
||||
@@ -645,7 +661,34 @@ class Ui_MainWindow(object):
|
||||
self.actionFlipVertical = QtWidgets.QAction(MainWindow)
|
||||
self.actionFlipVertical.setObjectName("actionFlipVertical")
|
||||
self.actionNewImage = QtWidgets.QAction(MainWindow)
|
||||
icon18 = QtGui.QIcon()
|
||||
icon18.addPixmap(QtGui.QPixmap("images/document-image.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.actionNewImage.setIcon(icon18)
|
||||
self.actionNewImage.setObjectName("actionNewImage")
|
||||
self.actionBold = QtWidgets.QAction(MainWindow)
|
||||
self.actionBold.setCheckable(True)
|
||||
icon19 = QtGui.QIcon()
|
||||
icon19.addPixmap(QtGui.QPixmap("images/edit-bold.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.actionBold.setIcon(icon19)
|
||||
self.actionBold.setObjectName("actionBold")
|
||||
self.actionItalic = QtWidgets.QAction(MainWindow)
|
||||
self.actionItalic.setCheckable(True)
|
||||
icon20 = QtGui.QIcon()
|
||||
icon20.addPixmap(QtGui.QPixmap("images/edit-italic.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.actionItalic.setIcon(icon20)
|
||||
self.actionItalic.setObjectName("actionItalic")
|
||||
self.actionUnderline = QtWidgets.QAction(MainWindow)
|
||||
self.actionUnderline.setCheckable(True)
|
||||
icon21 = QtGui.QIcon()
|
||||
icon21.addPixmap(QtGui.QPixmap("images/edit-underline.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.actionUnderline.setIcon(icon21)
|
||||
self.actionUnderline.setObjectName("actionUnderline")
|
||||
self.actionFillShapes = QtWidgets.QAction(MainWindow)
|
||||
self.actionFillShapes.setCheckable(True)
|
||||
icon22 = QtGui.QIcon()
|
||||
icon22.addPixmap(QtGui.QPixmap("images/paint-can-color.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.actionFillShapes.setIcon(icon22)
|
||||
self.actionFillShapes.setObjectName("actionFillShapes")
|
||||
self.menuFIle.addAction(self.actionNewImage)
|
||||
self.menuFIle.addAction(self.actionOpenImage)
|
||||
self.menuFIle.addAction(self.actionSaveImage)
|
||||
@@ -660,6 +703,9 @@ class Ui_MainWindow(object):
|
||||
self.menuBar.addAction(self.menuEdit.menuAction())
|
||||
self.menuBar.addAction(self.menuImage.menuAction())
|
||||
self.menuBar.addAction(self.menuHelp.menuAction())
|
||||
self.fileToolbar.addAction(self.actionNewImage)
|
||||
self.fileToolbar.addAction(self.actionOpenImage)
|
||||
self.fileToolbar.addAction(self.actionSaveImage)
|
||||
|
||||
self.retranslateUi(MainWindow)
|
||||
QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
||||
@@ -671,14 +717,22 @@ class Ui_MainWindow(object):
|
||||
self.menuEdit.setTitle(_translate("MainWindow", "Edit"))
|
||||
self.menuImage.setTitle(_translate("MainWindow", "Image"))
|
||||
self.menuHelp.setTitle(_translate("MainWindow", "Help"))
|
||||
self.fileToolbar.setWindowTitle(_translate("MainWindow", "toolBar"))
|
||||
self.drawingToolbar.setWindowTitle(_translate("MainWindow", "toolBar"))
|
||||
self.fontToolbar.setWindowTitle(_translate("MainWindow", "toolBar"))
|
||||
self.actionCopy.setText(_translate("MainWindow", "Copy"))
|
||||
self.actionCopy.setShortcut(_translate("MainWindow", "Ctrl+C"))
|
||||
self.actionClearImage.setText(_translate("MainWindow", "Clear Image"))
|
||||
self.actionClearselection.setText(_translate("MainWindow", "Clear Selection"))
|
||||
self.actionOpenImage.setText(_translate("MainWindow", "Open Image..."))
|
||||
self.actionSaveImage.setText(_translate("MainWindow", "Save Image As..."))
|
||||
self.actionInvertColors.setText(_translate("MainWindow", "Invert Colors"))
|
||||
self.actionFlipHorizontal.setText(_translate("MainWindow", "Flip Horizontal"))
|
||||
self.actionFlipVertical.setText(_translate("MainWindow", "Flip Vertical"))
|
||||
self.actionNewImage.setText(_translate("MainWindow", "New Image"))
|
||||
self.actionBold.setText(_translate("MainWindow", "Bold"))
|
||||
self.actionBold.setShortcut(_translate("MainWindow", "Ctrl+B"))
|
||||
self.actionItalic.setText(_translate("MainWindow", "Italic"))
|
||||
self.actionItalic.setShortcut(_translate("MainWindow", "Ctrl+I"))
|
||||
self.actionUnderline.setText(_translate("MainWindow", "Underline"))
|
||||
self.actionFillShapes.setText(_translate("MainWindow", "Fill Shapes?"))
|
||||
|
||||
|
||||
@@ -1431,6 +1431,60 @@
|
||||
<addaction name="menuHelp"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<widget class="QToolBar" name="fileToolbar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionNewImage"/>
|
||||
<addaction name="actionOpenImage"/>
|
||||
<addaction name="actionSaveImage"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="drawingToolbar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="fontToolbar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<action name="actionCopy">
|
||||
<property name="text">
|
||||
<string>Copy</string>
|
||||
@@ -1444,17 +1498,20 @@
|
||||
<string>Clear Image</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionClearselection">
|
||||
<property name="text">
|
||||
<string>Clear Selection</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOpenImage">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>images/blue-folder-open-image.png</normaloff>images/blue-folder-open-image.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open Image...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSaveImage">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>images/disk.png</normaloff>images/disk.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save Image As...</string>
|
||||
</property>
|
||||
@@ -1475,10 +1532,68 @@
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNewImage">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>images/document-image.png</normaloff>images/document-image.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New Image</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionBold">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>images/edit-bold.png</normaloff>images/edit-bold.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Bold</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+B</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionItalic">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>images/edit-italic.png</normaloff>images/edit-italic.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Italic</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+I</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionUnderline">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>images/edit-underline.png</normaloff>images/edit-underline.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Underline</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFillShapes">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>images/paint-can-color.png</normaloff>images/paint-can-color.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fill Shapes?</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
|
||||
100
paint/paint.py
100
paint/paint.py
@@ -2,9 +2,6 @@ from PyQt5.QtGui import *
|
||||
from PyQt5.QtWidgets import *
|
||||
from PyQt5.QtCore import *
|
||||
|
||||
QPushButton.pressed_right = pyqtSignal()
|
||||
|
||||
|
||||
from MainWindow import Ui_MainWindow
|
||||
|
||||
import os
|
||||
@@ -12,7 +9,8 @@ import random
|
||||
import types
|
||||
|
||||
|
||||
SPRAY_PAINT_SD = 10
|
||||
BRUSH_MULT = 3
|
||||
SPRAY_PAINT_MULT = 5
|
||||
SPRAY_PAINT_N = 100
|
||||
|
||||
COLORS = [
|
||||
@@ -23,6 +21,8 @@ COLORS = [
|
||||
'#b92fc2', '#fffc91', '#00fd83', '#87f9f9', '#8481c4', '#dc137d', '#fb803c',
|
||||
]
|
||||
|
||||
FONT_SIZES = [7, 8, 9, 10, 11, 12, 13, 14, 18, 24, 36, 48, 64, 72, 96, 144, 288]
|
||||
|
||||
MODES = [
|
||||
'selectpoly', 'selectrect',
|
||||
'eraser', 'fill',
|
||||
@@ -42,6 +42,22 @@ STAMPS = [os.path.join(STAMP_DIR, f) for f in os.listdir(STAMP_DIR)]
|
||||
SELECTION_PEN = QPen(QColor(0xff, 0xff, 0xff), 1, Qt.DashLine)
|
||||
PREVIEW_PEN = QPen(QColor(0xff, 0xff, 0xff), 1, Qt.SolidLine)
|
||||
|
||||
|
||||
def build_font(config):
|
||||
"""
|
||||
Construct a complete font from the configuration options
|
||||
:param self:
|
||||
:param config:
|
||||
:return: QFont
|
||||
"""
|
||||
font = config['font']
|
||||
font.setPointSize(config['fontsize'])
|
||||
font.setBold(config['bold'])
|
||||
font.setItalic(config['italic'])
|
||||
font.setUnderline(config['underline'])
|
||||
return font
|
||||
|
||||
|
||||
class Canvas(QLabel):
|
||||
|
||||
mode = 'rectangle'
|
||||
@@ -52,6 +68,19 @@ class Canvas(QLabel):
|
||||
primary_color_updated = pyqtSignal(str)
|
||||
secondary_color_updated = pyqtSignal(str)
|
||||
|
||||
# Store configuration settings, including pen width, fonts etc.
|
||||
config = {
|
||||
# Drawing options.
|
||||
'size': 1,
|
||||
'fill': True,
|
||||
# Font options.
|
||||
'font': QFont('Times'),
|
||||
'fontsize': 12,
|
||||
'bold': False,
|
||||
'italic': False,
|
||||
'underline': False,
|
||||
}
|
||||
|
||||
active_color = None
|
||||
preview_pen = None
|
||||
|
||||
@@ -78,6 +107,9 @@ class Canvas(QLabel):
|
||||
def set_secondary_color(self, hex):
|
||||
self.secondary_color = QColor(hex)
|
||||
|
||||
def set_config(self, key, value):
|
||||
self.config[key] = value
|
||||
|
||||
def set_mode(self, mode):
|
||||
# Clean up active timer animations.
|
||||
self.timer_cleanup()
|
||||
@@ -96,6 +128,8 @@ class Canvas(QLabel):
|
||||
self.current_text = ""
|
||||
self.last_text = ""
|
||||
|
||||
self.last_config = {}
|
||||
|
||||
self.dash_offset = 0
|
||||
self.locked = False
|
||||
# Apply the mode
|
||||
@@ -261,7 +295,7 @@ class Canvas(QLabel):
|
||||
def pen_mouseMoveEvent(self, e):
|
||||
if self.last_pos:
|
||||
p = QPainter(self.pixmap())
|
||||
p.setPen(QPen(self.active_color, 1, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
|
||||
p.setPen(QPen(self.active_color, self.config['size'], Qt.SolidLine, Qt.SquareCap, Qt.RoundJoin))
|
||||
p.drawLine(self.last_pos, e.pos())
|
||||
|
||||
self.last_pos = e.pos()
|
||||
@@ -278,7 +312,7 @@ class Canvas(QLabel):
|
||||
def brush_mouseMoveEvent(self, e):
|
||||
if self.last_pos:
|
||||
p = QPainter(self.pixmap())
|
||||
p.setPen(QPen(self.active_color, 10, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
|
||||
p.setPen(QPen(self.active_color, self.config['size'] * BRUSH_MULT, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
|
||||
p.drawLine(self.last_pos, e.pos())
|
||||
|
||||
self.last_pos = e.pos()
|
||||
@@ -297,8 +331,9 @@ class Canvas(QLabel):
|
||||
p = QPainter(self.pixmap())
|
||||
p.setPen(QPen(self.active_color, 1))
|
||||
|
||||
for n in range(SPRAY_PAINT_N):
|
||||
xo, yo = random.gauss(0, SPRAY_PAINT_SD), random.gauss(0, SPRAY_PAINT_SD)
|
||||
for n in range(self.config['size'] * SPRAY_PAINT_N):
|
||||
xo = random.gauss(0, self.config['size'] * SPRAY_PAINT_MULT)
|
||||
yo = random.gauss(0, self.config['size'] * SPRAY_PAINT_MULT)
|
||||
p.drawPoint(e.x() + xo, e.y() + yo)
|
||||
|
||||
self.update()
|
||||
@@ -316,7 +351,7 @@ class Canvas(QLabel):
|
||||
self.current_text = self.current_text + e.text()
|
||||
|
||||
def text_mousePressEvent(self, e):
|
||||
if e.button() == Qt.LeftButton:
|
||||
if e.button() == Qt.LeftButton and self.current_pos is None:
|
||||
self.current_pos = e.pos()
|
||||
self.current_text = ""
|
||||
self.timer_event = self.text_timerEvent
|
||||
@@ -326,7 +361,8 @@ class Canvas(QLabel):
|
||||
# Draw the text to the image
|
||||
p = QPainter(self.pixmap())
|
||||
p.setRenderHints(QPainter.Antialiasing)
|
||||
p.setFont(QFont("Times", 30))
|
||||
font = build_font(self.config)
|
||||
p.setFont(font)
|
||||
pen = QPen(self.primary_color, 1, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
|
||||
p.setPen(pen)
|
||||
p.drawText(self.current_pos, self.current_text)
|
||||
@@ -336,17 +372,21 @@ class Canvas(QLabel):
|
||||
|
||||
def text_timerEvent(self, final=False):
|
||||
p = QPainter(self.pixmap())
|
||||
p.setFont(QFont("Times", 30))
|
||||
p.setCompositionMode(QPainter.RasterOp_SourceXorDestination)
|
||||
pen = PREVIEW_PEN
|
||||
p.setPen(pen)
|
||||
if self.last_text:
|
||||
font = build_font(self.last_config)
|
||||
p.setFont(font)
|
||||
p.drawText(self.current_pos, self.last_text)
|
||||
|
||||
if not final:
|
||||
font = build_font(self.config)
|
||||
p.setFont(font)
|
||||
p.drawText(self.current_pos, self.current_text)
|
||||
|
||||
self.last_text = self.current_text
|
||||
self.last_config = self.config.copy()
|
||||
self.update()
|
||||
|
||||
# Fill events
|
||||
@@ -456,9 +496,9 @@ class Canvas(QLabel):
|
||||
self.timer_cleanup()
|
||||
|
||||
p = QPainter(self.pixmap())
|
||||
p.setPen(QPen(self.primary_color, 5, Qt.SolidLine, Qt.SquareCap, Qt.MiterJoin))
|
||||
p.setPen(QPen(self.primary_color, self.config['size'], Qt.SolidLine, Qt.SquareCap, Qt.MiterJoin))
|
||||
|
||||
if self.secondary_color:
|
||||
if self.config['fill']:
|
||||
p.setBrush(QBrush(self.secondary_color))
|
||||
getattr(p, self.active_shape_fn)(QRect(self.origin_pos, e.pos()), *self.active_shape_args)
|
||||
self.update()
|
||||
@@ -712,6 +752,40 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
self.actionFlipHorizontal.triggered.connect(self.flip_horizontal)
|
||||
self.actionFlipVertical.triggered.connect(self.flip_vertical)
|
||||
|
||||
# Setup the drawing toolbar.
|
||||
self.fontselect = QFontComboBox()
|
||||
self.fontToolbar.addWidget(self.fontselect)
|
||||
self.fontselect.currentFontChanged.connect(lambda f: self.canvas.set_config('font', f))
|
||||
self.fontselect.setCurrentFont(QFont('Times'))
|
||||
|
||||
self.fontsize = QComboBox()
|
||||
self.fontsize.addItems([str(s) for s in FONT_SIZES])
|
||||
self.fontsize.currentTextChanged.connect(lambda f: self.canvas.set_config('fontsize', int(f)))
|
||||
|
||||
# Connect to the signal producing the text of the current selection. Convert the string to float
|
||||
# and set as the pointsize. We could also use the index + retrieve from FONT_SIZES.
|
||||
self.fontToolbar.addWidget(self.fontsize)
|
||||
|
||||
self.fontToolbar.addAction(self.actionBold)
|
||||
self.actionBold.triggered.connect(lambda s: self.canvas.set_config('bold', s))
|
||||
self.fontToolbar.addAction(self.actionItalic)
|
||||
self.actionItalic.triggered.connect(lambda s: self.canvas.set_config('italic', s))
|
||||
self.fontToolbar.addAction(self.actionUnderline)
|
||||
self.actionUnderline.triggered.connect(lambda s: self.canvas.set_config('underline', s))
|
||||
|
||||
sizeicon = QLabel()
|
||||
sizeicon.setPixmap(QPixmap(os.path.join('images', 'border-weight.png')))
|
||||
self.drawingToolbar.addWidget(sizeicon)
|
||||
self.sizeselect = QSlider()
|
||||
self.sizeselect.setRange(1,20)
|
||||
self.sizeselect.setOrientation(Qt.Horizontal)
|
||||
self.sizeselect.valueChanged.connect(lambda s: self.canvas.set_config('size', s))
|
||||
self.drawingToolbar.addWidget(self.sizeselect)
|
||||
|
||||
self.actionFillShapes.triggered.connect(lambda s: self.canvas.set_config('fill', s))
|
||||
self.drawingToolbar.addAction(self.actionFillShapes)
|
||||
self.actionFillShapes.setChecked(True)
|
||||
|
||||
self.show()
|
||||
|
||||
def choose_color(self, callback):
|
||||
|
||||
109
translate/mainwindow.ui
Normal file
109
translate/mainwindow.ui
Normal file
@@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>721</width>
|
||||
<height>333</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Babelvis</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="srcLanguage"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="srcTextEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="translateButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Translate</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>images/locale.png</normaloff>images/locale.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="reverseButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Reverse translate</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>images/arrow-return-180.png</normaloff>images/arrow-return-180.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QComboBox" name="destLanguage"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="destTextEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>721</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
182
unzip/MainWindow.py
Normal file
182
unzip/MainWindow.py
Normal file
@@ -0,0 +1,182 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Form implementation generated from reading ui file 'mainwindow.ui'
|
||||
#
|
||||
# Created by: PyQt5 UI code generator 5.10
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||
|
||||
class Ui_MainWindow(object):
|
||||
def setupUi(self, MainWindow):
|
||||
MainWindow.setObjectName("MainWindow")
|
||||
MainWindow.resize(207, 503)
|
||||
self.centralwidget = QtWidgets.QWidget(MainWindow)
|
||||
self.centralwidget.setObjectName("centralwidget")
|
||||
self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
|
||||
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
|
||||
self.verticalLayout.setObjectName("verticalLayout")
|
||||
self.widget = QtWidgets.QWidget(self.centralwidget)
|
||||
self.widget.setObjectName("widget")
|
||||
self.head = QtWidgets.QLabel(self.widget)
|
||||
self.head.setGeometry(QtCore.QRect(0, -40, 201, 261))
|
||||
self.head.setText("")
|
||||
self.head.setPixmap(QtGui.QPixmap("images/cat-head-glasses.png"))
|
||||
self.head.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.head.setObjectName("head")
|
||||
self.verticalLayoutWidget = QtWidgets.QWidget(self.widget)
|
||||
self.verticalLayoutWidget.setGeometry(QtCore.QRect(90, 232, 81, 131))
|
||||
self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
|
||||
self.fileBar = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
|
||||
self.fileBar.setContentsMargins(0, 0, 0, 0)
|
||||
self.fileBar.setSpacing(0)
|
||||
self.fileBar.setObjectName("fileBar")
|
||||
self.progress_1 = QtWidgets.QLabel(self.verticalLayoutWidget)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(8)
|
||||
self.progress_1.setFont(font)
|
||||
self.progress_1.setStyleSheet("QLabel {\n"
|
||||
" background-color: rgb(233,30,99);\n"
|
||||
"border: 2px solid rgb(194,24,91);\n"
|
||||
"color: rgb(136,14,79);\n"
|
||||
"}")
|
||||
self.progress_1.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.progress_1.setObjectName("progress_1")
|
||||
self.fileBar.addWidget(self.progress_1)
|
||||
self.progress_2 = QtWidgets.QLabel(self.verticalLayoutWidget)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(8)
|
||||
self.progress_2.setFont(font)
|
||||
self.progress_2.setStyleSheet("QLabel {\n"
|
||||
" background-color: rgb(233,30,99);\n"
|
||||
"border: 2px solid rgb(194,24,91);\n"
|
||||
"color: rgb(136,14,79);\n"
|
||||
"}")
|
||||
self.progress_2.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.progress_2.setObjectName("progress_2")
|
||||
self.fileBar.addWidget(self.progress_2)
|
||||
self.progress_3 = QtWidgets.QLabel(self.verticalLayoutWidget)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(8)
|
||||
self.progress_3.setFont(font)
|
||||
self.progress_3.setStyleSheet("QLabel {\n"
|
||||
" background-color: rgb(233,30,99);\n"
|
||||
"border: 2px solid rgb(194,24,91);\n"
|
||||
"color: rgb(136,14,79);\n"
|
||||
"}")
|
||||
self.progress_3.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.progress_3.setObjectName("progress_3")
|
||||
self.fileBar.addWidget(self.progress_3)
|
||||
self.progress_4 = QtWidgets.QLabel(self.verticalLayoutWidget)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(8)
|
||||
self.progress_4.setFont(font)
|
||||
self.progress_4.setStyleSheet("QLabel {\n"
|
||||
" background-color: rgb(233,30,99);\n"
|
||||
"border: 2px solid rgb(194,24,91);\n"
|
||||
"color: rgb(136,14,79);\n"
|
||||
"}")
|
||||
self.progress_4.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.progress_4.setObjectName("progress_4")
|
||||
self.fileBar.addWidget(self.progress_4)
|
||||
self.progress_5 = QtWidgets.QLabel(self.verticalLayoutWidget)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(8)
|
||||
self.progress_5.setFont(font)
|
||||
self.progress_5.setStyleSheet("QLabel {\n"
|
||||
" background-color: rgb(233,30,99);\n"
|
||||
"border: 2px solid rgb(194,24,91);\n"
|
||||
"color: rgb(136,14,79);\n"
|
||||
"}")
|
||||
self.progress_5.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.progress_5.setObjectName("progress_5")
|
||||
self.fileBar.addWidget(self.progress_5)
|
||||
self.progress_6 = QtWidgets.QLabel(self.verticalLayoutWidget)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(8)
|
||||
self.progress_6.setFont(font)
|
||||
self.progress_6.setStyleSheet("QLabel {\n"
|
||||
" background-color: rgb(233,30,99);\n"
|
||||
"border: 2px solid rgb(194,24,91);\n"
|
||||
"color: rgb(136,14,79);\n"
|
||||
"}")
|
||||
self.progress_6.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.progress_6.setObjectName("progress_6")
|
||||
self.fileBar.addWidget(self.progress_6)
|
||||
self.progress_7 = QtWidgets.QLabel(self.verticalLayoutWidget)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(8)
|
||||
self.progress_7.setFont(font)
|
||||
self.progress_7.setStyleSheet("QLabel {\n"
|
||||
" background-color: rgb(233,30,99);\n"
|
||||
"border: 2px solid rgb(194,24,91);\n"
|
||||
"color: rgb(136,14,79);\n"
|
||||
"}")
|
||||
self.progress_7.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.progress_7.setObjectName("progress_7")
|
||||
self.fileBar.addWidget(self.progress_7)
|
||||
self.progress_8 = QtWidgets.QLabel(self.verticalLayoutWidget)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(8)
|
||||
self.progress_8.setFont(font)
|
||||
self.progress_8.setStyleSheet("QLabel {\n"
|
||||
" background-color: rgb(233,30,99);\n"
|
||||
"border: 2px solid rgb(194,24,91);\n"
|
||||
"color: rgb(136,14,79);\n"
|
||||
"}")
|
||||
self.progress_8.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.progress_8.setObjectName("progress_8")
|
||||
self.fileBar.addWidget(self.progress_8)
|
||||
self.progress_9 = QtWidgets.QLabel(self.verticalLayoutWidget)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(8)
|
||||
self.progress_9.setFont(font)
|
||||
self.progress_9.setStyleSheet("QLabel {\n"
|
||||
" background-color: rgb(233,30,99);\n"
|
||||
"border: 2px solid rgb(194,24,91);\n"
|
||||
"color: rgb(136,14,79);\n"
|
||||
"}")
|
||||
self.progress_9.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.progress_9.setObjectName("progress_9")
|
||||
self.fileBar.addWidget(self.progress_9)
|
||||
self.progress_10 = QtWidgets.QLabel(self.verticalLayoutWidget)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(8)
|
||||
self.progress_10.setFont(font)
|
||||
self.progress_10.setStyleSheet("QLabel {\n"
|
||||
" background-color: rgb(233,30,99);\n"
|
||||
"border: 2px solid rgb(194,24,91);\n"
|
||||
"color: rgb(136,14,79);\n"
|
||||
"}")
|
||||
self.progress_10.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.progress_10.setObjectName("progress_10")
|
||||
self.fileBar.addWidget(self.progress_10)
|
||||
self.body = QtWidgets.QLabel(self.widget)
|
||||
self.body.setGeometry(QtCore.QRect(20, 120, 191, 381))
|
||||
self.body.setText("")
|
||||
self.body.setPixmap(QtGui.QPixmap("images/cat-body-space.png"))
|
||||
self.body.setObjectName("body")
|
||||
self.verticalLayoutWidget.raise_()
|
||||
self.body.raise_()
|
||||
self.head.raise_()
|
||||
self.verticalLayout.addWidget(self.widget)
|
||||
MainWindow.setCentralWidget(self.centralwidget)
|
||||
|
||||
self.retranslateUi(MainWindow)
|
||||
QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
||||
|
||||
def retranslateUi(self, MainWindow):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
MainWindow.setWindowTitle(_translate("MainWindow", "7Pez"))
|
||||
self.progress_1.setText(_translate("MainWindow", "7PEZ"))
|
||||
self.progress_2.setText(_translate("MainWindow", "7PEZ"))
|
||||
self.progress_3.setText(_translate("MainWindow", "7PEZ"))
|
||||
self.progress_4.setText(_translate("MainWindow", "7PEZ"))
|
||||
self.progress_5.setText(_translate("MainWindow", "7PEZ"))
|
||||
self.progress_6.setText(_translate("MainWindow", "7PEZ"))
|
||||
self.progress_7.setText(_translate("MainWindow", "7PEZ"))
|
||||
self.progress_8.setText(_translate("MainWindow", "7PEZ"))
|
||||
self.progress_9.setText(_translate("MainWindow", "7PEZ"))
|
||||
self.progress_10.setText(_translate("MainWindow", "7PEZ"))
|
||||
|
||||
BIN
unzip/images/cat-body-space.png
Normal file
BIN
unzip/images/cat-body-space.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 129 KiB |
BIN
unzip/images/cat-head-glasses.png
Normal file
BIN
unzip/images/cat-head-glasses.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 52 KiB |
312
unzip/mainwindow.ui
Normal file
312
unzip/mainwindow.ui
Normal file
@@ -0,0 +1,312 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>207</width>
|
||||
<height>503</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>7Pez</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<widget class="QLabel" name="head">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>-40</y>
|
||||
<width>201</width>
|
||||
<height>261</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>images/cat-head-glasses.png</pixmap>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>232</y>
|
||||
<width>81</width>
|
||||
<height>131</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="fileBar">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="progress_1">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel {
|
||||
background-color: rgb(233,30,99);
|
||||
border: 2px solid rgb(194,24,91);
|
||||
color: rgb(136,14,79);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>7PEZ</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="progress_2">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel {
|
||||
background-color: rgb(233,30,99);
|
||||
border: 2px solid rgb(194,24,91);
|
||||
color: rgb(136,14,79);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>7PEZ</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="progress_3">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel {
|
||||
background-color: rgb(233,30,99);
|
||||
border: 2px solid rgb(194,24,91);
|
||||
color: rgb(136,14,79);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>7PEZ</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="progress_4">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel {
|
||||
background-color: rgb(233,30,99);
|
||||
border: 2px solid rgb(194,24,91);
|
||||
color: rgb(136,14,79);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>7PEZ</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="progress_5">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel {
|
||||
background-color: rgb(233,30,99);
|
||||
border: 2px solid rgb(194,24,91);
|
||||
color: rgb(136,14,79);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>7PEZ</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="progress_6">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel {
|
||||
background-color: rgb(233,30,99);
|
||||
border: 2px solid rgb(194,24,91);
|
||||
color: rgb(136,14,79);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>7PEZ</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="progress_7">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel {
|
||||
background-color: rgb(233,30,99);
|
||||
border: 2px solid rgb(194,24,91);
|
||||
color: rgb(136,14,79);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>7PEZ</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="progress_8">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel {
|
||||
background-color: rgb(233,30,99);
|
||||
border: 2px solid rgb(194,24,91);
|
||||
color: rgb(136,14,79);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>7PEZ</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="progress_9">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel {
|
||||
background-color: rgb(233,30,99);
|
||||
border: 2px solid rgb(194,24,91);
|
||||
color: rgb(136,14,79);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>7PEZ</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="progress_10">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel {
|
||||
background-color: rgb(233,30,99);
|
||||
border: 2px solid rgb(194,24,91);
|
||||
color: rgb(136,14,79);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>7PEZ</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QLabel" name="body">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>120</y>
|
||||
<width>191</width>
|
||||
<height>381</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>images/cat-body-space.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
<zorder>verticalLayoutWidget</zorder>
|
||||
<zorder>body</zorder>
|
||||
<zorder>head</zorder>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
213
unzip/unzip.py
Normal file
213
unzip/unzip.py
Normal file
@@ -0,0 +1,213 @@
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtWidgets import *
|
||||
from PyQt5.QtCore import *
|
||||
|
||||
from MainWindow import Ui_MainWindow
|
||||
|
||||
import os
|
||||
import types
|
||||
import random
|
||||
import sys
|
||||
import traceback
|
||||
import zipfile
|
||||
|
||||
|
||||
PROGRESS_ON = """
|
||||
QLabel {
|
||||
background-color: rgb(233,30,99);
|
||||
border: 2px solid rgb(194,24,91);
|
||||
color: rgb(136,14,79);
|
||||
}
|
||||
"""
|
||||
|
||||
PROGRESS_OFF = """
|
||||
QLabel {
|
||||
color: rgba(0,0,0,0);
|
||||
}
|
||||
"""
|
||||
|
||||
class WorkerSignals(QObject):
|
||||
'''
|
||||
Defines the signals available from a running worker thread.
|
||||
'''
|
||||
finished = pyqtSignal()
|
||||
error = pyqtSignal(tuple)
|
||||
progress = pyqtSignal(float)
|
||||
|
||||
|
||||
class UnzipWorker(QRunnable):
|
||||
'''
|
||||
Worker thread for unzipping.
|
||||
'''
|
||||
signals = WorkerSignals()
|
||||
|
||||
def __init__(self, path):
|
||||
super(UnzipWorker, self).__init__()
|
||||
os.chdir(os.path.dirname(path))
|
||||
self.zipfile = zipfile.ZipFile(path)
|
||||
|
||||
@pyqtSlot()
|
||||
def run(self):
|
||||
try:
|
||||
items = self.zipfile.infolist()
|
||||
total_n = len(items)
|
||||
|
||||
for n, item in enumerate(items):
|
||||
self.zipfile.extract(item)
|
||||
self.signals.progress.emit(n/total_n)
|
||||
|
||||
except Exception as e:
|
||||
exctype, value = sys.exc_info()[:2]
|
||||
self.signals.error.emit((exctype, value, traceback.format_exc()))
|
||||
return
|
||||
|
||||
self.signals.finished.emit()
|
||||
|
||||
|
||||
|
||||
class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MainWindow, self).__init__(*args, **kwargs)
|
||||
self.setupUi(self)
|
||||
|
||||
self.setAttribute(Qt.WA_TranslucentBackground )
|
||||
self.setWindowFlags(Qt.FramelessWindowHint)
|
||||
self.setAcceptDrops(True)
|
||||
|
||||
self.prev_pos = None
|
||||
|
||||
# Create a threadpool to run our unzip worker in.
|
||||
self.threadpool = QThreadPool()
|
||||
|
||||
self.head.raise_()
|
||||
|
||||
def patch_mousePressEvent(self_, e):
|
||||
if e.button() == Qt.LeftButton and self.worker is not None:
|
||||
# Extract the archive.
|
||||
self_.current_rotation = random.randint(-15, +15)
|
||||
self_.current_y = 30
|
||||
|
||||
# Redraw the mainwindow
|
||||
self.update()
|
||||
|
||||
# Perform the unzip
|
||||
self.threadpool.start(self.worker)
|
||||
self.worker = None # Remove the worker so it is not double-triggere.
|
||||
|
||||
elif e.button() == Qt.RightButton:
|
||||
pass # Open a new zip.
|
||||
|
||||
def patch_paintEvent(self, event):
|
||||
|
||||
p = QPainter(self)
|
||||
rect = event.rect()
|
||||
|
||||
# Translate
|
||||
transform = QTransform()
|
||||
transform.translate(rect.width()/2, rect.height()/2)
|
||||
transform.rotate(self.current_rotation)
|
||||
transform.translate(-rect.width()/2, -rect.height()/2)
|
||||
p.setTransform(transform)
|
||||
|
||||
|
||||
# Calculate rect to center the pixmap on the QLabel.
|
||||
prect = self.pixmap().rect()
|
||||
rect.adjust(
|
||||
(rect.width() - prect.width()) / 2,
|
||||
self.current_y + (rect.height() - prect.height()) / 2,
|
||||
-(rect.width() - prect.width()) / 2,
|
||||
self.current_y + -(rect.height() - prect.height()) / 2,
|
||||
)
|
||||
p.drawPixmap(rect, self.pixmap())
|
||||
|
||||
self.head.mousePressEvent = types.MethodType(patch_mousePressEvent, self.head)
|
||||
self.head.paintEvent = types.MethodType(patch_paintEvent, self.head)
|
||||
|
||||
self.timer = QTimer()
|
||||
self.timer.timeout.connect(self.timer_triggered)
|
||||
self.timer.start(5)
|
||||
|
||||
# Initialize
|
||||
self.head.current_rotation = 0
|
||||
self.head.current_y = 0
|
||||
self.head.locked = True
|
||||
self.worker = None
|
||||
|
||||
# Reset bar to complete (empty)
|
||||
self.update_progress(1)
|
||||
|
||||
self.show()
|
||||
|
||||
def timer_triggered(self):
|
||||
if self.head.current_y > 0:
|
||||
self.head.current_y -= 1
|
||||
|
||||
if self.head.current_rotation > 0:
|
||||
self.head.current_rotation -= 1
|
||||
|
||||
elif self.head.current_rotation < 0:
|
||||
self.head.current_rotation += 1
|
||||
|
||||
self.head.update()
|
||||
|
||||
if self.head.current_y == 0 and self.head.current_rotation == 0:
|
||||
self.head.locked = False
|
||||
|
||||
def dragEnterEvent(self, e):
|
||||
data = e.mimeData()
|
||||
if data.hasUrls():
|
||||
# We are passed urls as a list, but only accept one.
|
||||
url = data.urls()[0].toLocalFile()
|
||||
if os.path.splitext(url)[1].lower() == '.zip':
|
||||
e.accept()
|
||||
|
||||
def dropEvent(self, e):
|
||||
data = e.mimeData()
|
||||
path = data.urls()[0].toLocalFile()
|
||||
|
||||
# Load the zipfile and pass to the worker which will extract.
|
||||
self.worker = UnzipWorker(path)
|
||||
self.worker.signals.progress.connect(self.update_progress)
|
||||
self.worker.signals.finished.connect(self.unzip_finished)
|
||||
self.worker.signals.error.connect(self.unzip_error)
|
||||
self.update_progress(0)
|
||||
|
||||
def mousePressEvent(self, e):
|
||||
self.prev_pos = e.globalPos()
|
||||
|
||||
def mouseMoveEvent(self, e):
|
||||
if self.prev_pos:
|
||||
delta = e.globalPos() - self.prev_pos
|
||||
self.move(self.x() + delta.x(), self.y() + delta.y())
|
||||
self.prev_pos = e.globalPos()
|
||||
|
||||
def update_progress(self, pc):
|
||||
"""
|
||||
Accepts progress as float in
|
||||
:param pc: float 0-1 of completion.
|
||||
:return:
|
||||
"""
|
||||
current_n = int(pc * 10)
|
||||
for n in range(1, 11):
|
||||
getattr(self, 'progress_%d' % n).setStyleSheet(
|
||||
PROGRESS_ON if n > current_n else PROGRESS_OFF
|
||||
)
|
||||
|
||||
def unzip_finished(self):
|
||||
self.update_progress(1)
|
||||
|
||||
def unzip_error(self, err):
|
||||
exctype, value, traceback = err
|
||||
|
||||
dlg = QMessageBox(self)
|
||||
dlg.setText(traceback)
|
||||
dlg.setIcon(QMessageBox.Critical)
|
||||
dlg.show()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
app = QApplication([])
|
||||
window = MainWindow()
|
||||
app.exec_()
|
||||
@@ -7,7 +7,7 @@ import os
|
||||
import sys
|
||||
import uuid
|
||||
|
||||
FONT_SIZES = [9, 10, 11, 12, 13, 14, 18, 24, 36, 48, 64, 72, 96, 144, 288]
|
||||
FONT_SIZES = [7, 8, 9, 10, 11, 12, 13, 14, 18, 24, 36, 48, 64, 72, 96, 144, 288]
|
||||
IMAGE_EXTENSIONS = ['.jpg','.png','.bmp']
|
||||
HTML_EXTENSIONS = ['.htm', '.html']
|
||||
|
||||
@@ -187,7 +187,6 @@ class MainWindow(QMainWindow):
|
||||
format_toolbar.addWidget(self.fonts)
|
||||
|
||||
self.fontsize = QComboBox()
|
||||
self.fontsize.setEditable(True)
|
||||
self.fontsize.addItems([str(s) for s in FONT_SIZES])
|
||||
|
||||
# Connect to the signal producing the text of the current selection. Convert the string to float
|
||||
|
||||
Reference in New Issue
Block a user