diff options
| author | tassaron | 2017-06-11 17:03:40 -0400 |
|---|---|---|
| committer | tassaron | 2017-06-11 17:03:40 -0400 |
| commit | 28f07272cc174efe8e219abed683d22f72f18d94 (patch) | |
| tree | fd5285787d87d5086b9d8addfa5a728d7d2b8faf | |
| parent | be5d47f8634d29d58b9811657ede815814ffde18 (diff) | |
using tab in component list updates widget
and more understandable function names for writing/reading presets
| -rw-r--r-- | components/video.py | 11 | ||||
| -rw-r--r-- | core.py | 14 | ||||
| -rw-r--r-- | main.py | 1 | ||||
| -rw-r--r-- | mainwindow.py | 7 | ||||
| -rw-r--r-- | presetmanager.py | 3 |
5 files changed, 22 insertions, 14 deletions
diff --git a/components/video.py b/components/video.py index c529658..bd1bf96 100644 --- a/components/video.py +++ b/components/video.py @@ -10,8 +10,15 @@ from . import __base__ class Video: '''Video Component Frame-Fetcher''' def __init__(self, **kwargs): - mandatoryArgs = ['ffmpeg', 'videoPath', 'width', 'height', - 'frameRate', 'chunkSize', 'parent'] + mandatoryArgs = [ + 'ffmpeg', # path to ffmpeg, usually core.FFMPEG_BIN + 'videoPath', + 'width', + 'height', + 'frameRate', # frames per second + 'chunkSize', # number of bytes in one frame + 'parent' + ] for arg in mandatoryArgs: try: exec('self.%s = kwargs[arg]' % arg) @@ -71,7 +71,7 @@ class Core(): return endI def updateComponent(self, i): - print('updating %s' % self.selectedComponents[i]) + # print('updating %s' % self.selectedComponents[i]) self.selectedComponents[i].update() def moduleIndexFor(self, compIndex): @@ -89,7 +89,7 @@ class Core(): with open(internalPath, 'r') as f: internalData = [line for line in f] try: - saveValueStore = dict(eval(internalData[0].strip())) + saveValueStore = Core.presetFromString(internalData[0].strip()) self.createPresetFile( compName, vers, origName, saveValueStore, @@ -120,7 +120,7 @@ class Core(): f.write('[Components]\n') f.write('%s\n' % compName) f.write('%s\n' % str(vers)) - f.write(Core.stringOrderedDict(saveValueStore)) + f.write(Core.presetToString(saveValueStore)) def createProjectFile(self, filepath): '''Create a project file (.avp) using the current program state''' @@ -136,7 +136,7 @@ class Core(): saveValueStore = comp.savePreset() f.write('%s\n' % str(comp)) f.write('%s\n' % str(comp.version())) - f.write('%s\n' % Core.stringOrderedDict(saveValueStore)) + f.write('%s\n' % Core.presetToString(saveValueStore)) return True except: return False @@ -244,6 +244,10 @@ class Core(): return badName @staticmethod - def stringOrderedDict(dictionary): + def presetToString(dictionary): sorted_ = OrderedDict(sorted(dictionary.items(), key=lambda t: t[0])) return repr(sorted_) + + @staticmethod + def presetFromString(string): + return dict(eval(string)) @@ -1,5 +1,4 @@ from importlib import import_module -from collections import OrderedDict from PyQt4 import QtGui, uic from PyQt4.QtCore import Qt import sys diff --git a/mainwindow.py b/mainwindow.py index 2f04559..dbbc631 100644 --- a/mainwindow.py +++ b/mainwindow.py @@ -1,6 +1,5 @@ from os.path import expanduser from queue import Queue -from collections import OrderedDict from PyQt4 import QtCore, QtGui, uic from PyQt4.QtCore import QSettings, Qt from PyQt4.QtGui import QMenu @@ -159,8 +158,8 @@ class MainWindow(QtCore.QObject): self.window.pushButton_addComponent.setMenu(self.compMenu) componentList.dropEvent = self.componentListChanged - componentList.clicked.connect( - lambda _: self.changeComponentWidget()) + componentList.itemSelectionChanged.connect( + self.changeComponentWidget) self.window.pushButton_removeComponent.clicked.connect( lambda _: self.removeComponent()) @@ -567,7 +566,7 @@ class MainWindow(QtCore.QObject): # version, not used yet i += 1 elif i == 2: - saveValueStore = dict(eval(line)) + saveValueStore = core.Core.presetFromString(line) self.core.selectedComponents[-1].loadPreset( saveValueStore) self.updateComponentTitle(-1) diff --git a/presetmanager.py b/presetmanager.py index 3036f7a..6708d11 100644 --- a/presetmanager.py +++ b/presetmanager.py @@ -1,5 +1,4 @@ from PyQt4 import QtGui, QtCore -from collections import OrderedDict import string import os @@ -171,7 +170,7 @@ class PresetManager(QtGui.QDialog): return with open(filepath, 'r') as f: for line in f: - saveValueStore = dict(eval(line.strip())) + saveValueStore = core.Core.presetFromString(line.strip()) break selectedComponents[index].loadPreset( saveValueStore, |
