using tab in component list updates widget
and more understandable function names for writing/reading presets
This commit is contained in:
parent
be5d47f863
commit
28f07272cc
|
@ -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)
|
||||
|
|
14
core.py
14
core.py
|
@ -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
main.py
1
main.py
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
Reference in New Issue