Created
December 15, 2023 19:20
-
-
Save connordavenport/97b11cd05db9504fa9b078d6d9f3701a to your computer and use it in GitHub Desktop.
a little script to switch pair lists super fast!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ezui | |
from mm4.tools.pairListParser import * | |
import metricsMachine | |
from mm4.mmScripting import MetricsMachineScriptingError | |
class PairListSetter(ezui.WindowController): | |
def build(self): | |
content = """ | |
|-files----| @fileTable | |
| | | |
|----------| | |
""" | |
descriptionData = dict( | |
fileTable=dict( | |
itemType="dict", | |
acceptedDropFileTypes=[".txt"], | |
allowsDropBetweenRows=True, | |
allowsInternalDropReordering=True, | |
columnDescriptions=[ | |
dict( | |
identifier="path", | |
title="Path", | |
cellClassArguments=dict( | |
showFullPath=True, | |
) | |
), | |
dict( | |
identifier="pairs", | |
title="#", | |
width=40, | |
), | |
dict( | |
identifier="listtype", | |
title="Type", | |
width=60 | |
) | |
] | |
) | |
) | |
self.w = ezui.EZWindow( | |
title="Pair List Setter", | |
content=content, | |
descriptionData=descriptionData, | |
controller=self, | |
size=(300, 300) | |
) | |
def started(self): | |
self.w.open() | |
def fileTableSelectionCallback(self, sender): | |
txtFile = sender.getSelectedItems() | |
filePath = txtFile[0]["path"] | |
try: | |
metricsMachine.LoadPairList(filePath) | |
except MetricsMachineScriptingError: | |
pass | |
def fileTableCreateItemsForDroppedPathsCallback(self, sender, paths): | |
items = [] | |
for path in paths: | |
with open(path, "r") as f: | |
pairs,mode,_ = parsePairList(f.read(),CurrentFont()) | |
if mode == "pair": | |
m = "" | |
else: | |
m = "" | |
item = dict( | |
path=path, | |
pairs=len(pairs), | |
listtype=m, | |
) | |
items.append(item) | |
return items | |
PairListSetter() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment