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:
|
class Video:
|
||||||
'''Video Component Frame-Fetcher'''
|
'''Video Component Frame-Fetcher'''
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
mandatoryArgs = ['ffmpeg', 'videoPath', 'width', 'height',
|
mandatoryArgs = [
|
||||||
'frameRate', 'chunkSize', 'parent']
|
'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:
|
for arg in mandatoryArgs:
|
||||||
try:
|
try:
|
||||||
exec('self.%s = kwargs[arg]' % arg)
|
exec('self.%s = kwargs[arg]' % arg)
|
||||||
|
|
14
core.py
14
core.py
|
@ -71,7 +71,7 @@ class Core():
|
||||||
return endI
|
return endI
|
||||||
|
|
||||||
def updateComponent(self, i):
|
def updateComponent(self, i):
|
||||||
print('updating %s' % self.selectedComponents[i])
|
# print('updating %s' % self.selectedComponents[i])
|
||||||
self.selectedComponents[i].update()
|
self.selectedComponents[i].update()
|
||||||
|
|
||||||
def moduleIndexFor(self, compIndex):
|
def moduleIndexFor(self, compIndex):
|
||||||
|
@ -89,7 +89,7 @@ class Core():
|
||||||
with open(internalPath, 'r') as f:
|
with open(internalPath, 'r') as f:
|
||||||
internalData = [line for line in f]
|
internalData = [line for line in f]
|
||||||
try:
|
try:
|
||||||
saveValueStore = dict(eval(internalData[0].strip()))
|
saveValueStore = Core.presetFromString(internalData[0].strip())
|
||||||
self.createPresetFile(
|
self.createPresetFile(
|
||||||
compName, vers,
|
compName, vers,
|
||||||
origName, saveValueStore,
|
origName, saveValueStore,
|
||||||
|
@ -120,7 +120,7 @@ class Core():
|
||||||
f.write('[Components]\n')
|
f.write('[Components]\n')
|
||||||
f.write('%s\n' % compName)
|
f.write('%s\n' % compName)
|
||||||
f.write('%s\n' % str(vers))
|
f.write('%s\n' % str(vers))
|
||||||
f.write(Core.stringOrderedDict(saveValueStore))
|
f.write(Core.presetToString(saveValueStore))
|
||||||
|
|
||||||
def createProjectFile(self, filepath):
|
def createProjectFile(self, filepath):
|
||||||
'''Create a project file (.avp) using the current program state'''
|
'''Create a project file (.avp) using the current program state'''
|
||||||
|
@ -136,7 +136,7 @@ class Core():
|
||||||
saveValueStore = comp.savePreset()
|
saveValueStore = comp.savePreset()
|
||||||
f.write('%s\n' % str(comp))
|
f.write('%s\n' % str(comp))
|
||||||
f.write('%s\n' % str(comp.version()))
|
f.write('%s\n' % str(comp.version()))
|
||||||
f.write('%s\n' % Core.stringOrderedDict(saveValueStore))
|
f.write('%s\n' % Core.presetToString(saveValueStore))
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
@ -244,6 +244,10 @@ class Core():
|
||||||
return badName
|
return badName
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def stringOrderedDict(dictionary):
|
def presetToString(dictionary):
|
||||||
sorted_ = OrderedDict(sorted(dictionary.items(), key=lambda t: t[0]))
|
sorted_ = OrderedDict(sorted(dictionary.items(), key=lambda t: t[0]))
|
||||||
return repr(sorted_)
|
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 importlib import import_module
|
||||||
from collections import OrderedDict
|
|
||||||
from PyQt4 import QtGui, uic
|
from PyQt4 import QtGui, uic
|
||||||
from PyQt4.QtCore import Qt
|
from PyQt4.QtCore import Qt
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
from os.path import expanduser
|
from os.path import expanduser
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
from collections import OrderedDict
|
|
||||||
from PyQt4 import QtCore, QtGui, uic
|
from PyQt4 import QtCore, QtGui, uic
|
||||||
from PyQt4.QtCore import QSettings, Qt
|
from PyQt4.QtCore import QSettings, Qt
|
||||||
from PyQt4.QtGui import QMenu
|
from PyQt4.QtGui import QMenu
|
||||||
|
@ -159,8 +158,8 @@ class MainWindow(QtCore.QObject):
|
||||||
self.window.pushButton_addComponent.setMenu(self.compMenu)
|
self.window.pushButton_addComponent.setMenu(self.compMenu)
|
||||||
|
|
||||||
componentList.dropEvent = self.componentListChanged
|
componentList.dropEvent = self.componentListChanged
|
||||||
componentList.clicked.connect(
|
componentList.itemSelectionChanged.connect(
|
||||||
lambda _: self.changeComponentWidget())
|
self.changeComponentWidget)
|
||||||
|
|
||||||
self.window.pushButton_removeComponent.clicked.connect(
|
self.window.pushButton_removeComponent.clicked.connect(
|
||||||
lambda _: self.removeComponent())
|
lambda _: self.removeComponent())
|
||||||
|
@ -567,7 +566,7 @@ class MainWindow(QtCore.QObject):
|
||||||
# version, not used yet
|
# version, not used yet
|
||||||
i += 1
|
i += 1
|
||||||
elif i == 2:
|
elif i == 2:
|
||||||
saveValueStore = dict(eval(line))
|
saveValueStore = core.Core.presetFromString(line)
|
||||||
self.core.selectedComponents[-1].loadPreset(
|
self.core.selectedComponents[-1].loadPreset(
|
||||||
saveValueStore)
|
saveValueStore)
|
||||||
self.updateComponentTitle(-1)
|
self.updateComponentTitle(-1)
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from PyQt4 import QtGui, QtCore
|
from PyQt4 import QtGui, QtCore
|
||||||
from collections import OrderedDict
|
|
||||||
import string
|
import string
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@ -171,7 +170,7 @@ class PresetManager(QtGui.QDialog):
|
||||||
return
|
return
|
||||||
with open(filepath, 'r') as f:
|
with open(filepath, 'r') as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
saveValueStore = dict(eval(line.strip()))
|
saveValueStore = core.Core.presetFromString(line.strip())
|
||||||
break
|
break
|
||||||
selectedComponents[index].loadPreset(
|
selectedComponents[index].loadPreset(
|
||||||
saveValueStore,
|
saveValueStore,
|
||||||
|
|
Reference in New Issue