I wish I can edit my old post, but I made a script to automatically number the gui elements. Now, I’ll have to figure out how to do the reverse. To use this, of course, you have to use clipboard.
EDIT: I added reverse mode. You have to type in the mode that you want and press enter.
Number the GUI arguments
import pyperclip as pc
import re
num=0
u_string="u "
def find_num_of_colors(istr):
n=1
for c in istr:
if c==",":
n += 1
return n
def new_string(istr,line):
global num
global u_string
if istr in ["int","float","choice","button","text","bool"]:
num += 1
part_string = str(num) + "."
if istr=="button":
u_string += "\"{0}\"\\" + "\n"
else:
u_string += "\"{$"+str(num)+"}\"\\"+"\n"
new_string = line[:7] + part_string + line[7:]
return new_string
elif istr=="color":
if find_num_of_colors(line)==4:
u_string += "\"{$" + str(int(num+1)) +",$" + str(int(num+2)) + ",$" + str(int(num+3)) + ",$" + str(int(num+4)) + "}\"\\" + "\n"
part_string=str(int(num+1)) + "." + str(int(num+2)) + "." +str(int(num+3)) + "." + str(int(num+4)) + "."
num += 4
new_string=line[:7]+part_string+line[7:]
return new_string
else:
u_string += "\"{$" + str(int(num+1)) +",$" + str(int(num+2)) + ",$" + str(int(num+3)) + "}\"\\" + "\n"
part_string=str(int(num+1))+"."+str(int(num+2))+"."+str(int(num+3)) + "."
num += 3
new_string=line[:7]+part_string+line[7:]
return new_string
elif istr=="point":
u_string += "\"{$" + str(int(num + 1)) + ",$" + str(int(num + 2)) + "}\"\\" + "\n"
part_string = str(int(num + 1)) + "." + str(int(num + 2)) + "."
num += 2
new_string=line[:7]+part_string+line[7:]
return new_string
else:
return line
def remove_number_and_period(line):
pos=8
iter=False
while True:
if line[pos].isdigit() or line[pos]=='.':
iter=True
pos += 1
else:
break
if iter:
return line[:7]+line[pos:]
else:
return line
between_these_char="\=(.*?)\("
gmic_str_paste=pc.paste()
gmic_str=str(gmic_str_paste)
lines=gmic_str.splitlines()
while True:
init_mode=input("""
Type in the one of the two characters in the set of two character at the left to use one of those mode?
0F. Remove Number and Period.
1T. Add Numbers and Period0 """)
if init_mode=="0" or init_mode=="F":
mode=False
break
elif init_mode=="1" or init_mode=="T":
mode=True
break
if mode:
for line in lines:
try:
substring=re.search(between_these_char,line).group(1)
except AttributeError:
substring=re.search(between_these_char,line)
if substring is None:
print(line)
continue
else:
print(new_string(str(substring),line))
print(u_string)
else:
for line in lines:
print(remove_number_and_period(line))
Old
#@gui Mitchell Concatenation: fx_rep_mitchell_concatenation
#@gui :_=note("This filter is a recreation of Kerry's Mitchell Concatenation"),_=separator()
#@gui :_=note("<b>Initial</b>")
#@gui :Mode=choice(0,"Singular","Dual")
#@gui :Pixel Size(%)=float(0,0,100)
#@gui :Output=choice(0,"New Dimension","New Dimension - New Layer","Old Dimension","Old Dimension - New Layer")
#@gui :_=separator(),_=note("<b>Starting Point</b>")
#@gui :Start=int(1,1,2000000)
#@gui :Start A=int(1,1,2000000)
#@gui :Start B=int(1,1,2000000)
#@gui :Link Start Numbers?=bool(0)
#@gui :_=separator(),_=note("<b>Base System</b>")
#@gui :Base=int(10,2,1000)
#@gui :Base A=int(10,2,1000)
#@gui :Base B=int(10,2,1000)
#@gui :Link Start Numbers?=bool(0)
#@gui :_=separator(),_=note("<b>Method</b>")
#@gui :Method=choice(0,"Subtraction","Addition","Multiplication")
#@gui :Method A=choice(0,"Subtraction","Addition","Multiplication")
#@gui :Method B=choice(0,"Subtraction","Addition","Multiplication")
#@gui :Link Start Numbers?=bool(0)
#@gui :_=separator(),_=note("<b>Palette</b>")
#@gui :Mode=choice(1,"Singular","Dual")
#@gui :Set=choice(0,"Foreground","Background")
#@gui :Color 1=color(255,255,255)
#@gui :Color 2=color(255,255,255)
#@gui :Color 3=color(255,255,255)
#@gui :Color 4=color(255,255,255)
#@gui :Color 5=color(255,255,255)
#@gui :Color 6=color(255,255,255)
#@gui :Color 7=color(255,255,255)
#@gui :Color 1=color(255,255,255)
#@gui :Color 2=color(255,255,255)
#@gui :Color 3=color(255,255,255)
#@gui :Color 4=color(255,255,255)
#@gui :Color 5=color(255,255,255)
#@gui :Color 6=color(255,255,255)
#@gui :Color 7=color(255,255,255)
#@gui :Color 1=color(255,255,255)
#@gui :Color 2=color(255,255,255)
#@gui :Color 3=color(255,255,255)
#@gui :Color 4=color(255,255,255)
#@gui :Color 5=color(255,255,255)
#@gui :Color 6=color(255,255,255)
#@gui :Color 7=color(255,255,255)
#@gui :_=separator(),_=note("<b>Shape</b>")
#@gui :Use Shape=bool(1)
#@gui :Tiled Shape=choice(3,"By Layer","Australia","Barbedwire","Circle","Crosshair","Cupid","Diamond","Dragon Curve-[D]","Dragonfly","Fern-[D]","Flip","Gear-[D]","Gumleaf","Heart","Information","Kookaburra","Mail","Mapleleaf","Paint Splat","Paw","Phone","Polygon-[D]","Rooster","Shopping Cart","Snowflake-[D]","Star-[D]")
#@gui :Fit Tile?=bool(1)
#@gui :Dragon Curve Recursion=int(10,0,30)
#@gui :Dragon Curve Rotation=float(0,-180,180)
#@gui :Fern Type=choice("Asplenium Adiantum-Nigrum","Thelypteridaceae")
#@gui :Fern Density (%)=float(100,0,300)
#@gui :Gear Teeth Count=int(8,3,32)
#@gui :Gear Height (%)=float(25,0.1,100)
#@gui :Gear Offset Teeth (%)=float(0,0,100)
#@gui :Gear Inner Ratio (%)=float(50,0.1,100)
#@gui :Polygon Vertices=int(5,3,100)
#@gui :Snowflake Recursion=int(5,1,6)
#@gui :Star Branches=int(3,5,100)
#@gui :Star Thickness (%)=float(38,.1,100)
#@gui :_=separator(),_=note("<b>Misc</b>")
#@gui :Position=choice(0,"10","100","1000","10000","100000")
#@gui :Position A=choice(0,"10","100","1000","10000","100000")
#@gui :Position B=choice(0,"10","100","1000","10000","100000")
#@gui :Push into Start Number=button()
#@gui :Push into Start A=button()
#@gui :Push into Start B=button()
#@gui :Push into Both=button()
New
#@gui Mitchell Concatenation: fx_rep_mitchell_concatenation
#@gui :_=note("This filter is a recreation of Kerry's Mitchell Concatenation"),_=separator()
#@gui :_=note("<b>Initial</b>")
#@gui :1.Mode=choice(0,"Singular","Dual")
#@gui :2.Pixel Size(%)=float(0,0,100)
#@gui :3.Output=choice(0,"New Dimension","New Dimension - New Layer","Old Dimension","Old Dimension - New Layer")
#@gui :_=separator(),_=note("<b>Starting Point</b>")
#@gui :4.Start=int(1,1,2000000)
#@gui :5.Start A=int(1,1,2000000)
#@gui :6.Start B=int(1,1,2000000)
#@gui :7.Link Start Numbers?=bool(0)
#@gui :_=separator(),_=note("<b>Base System</b>")
#@gui :8.Base=int(10,2,1000)
#@gui :9.Base A=int(10,2,1000)
#@gui :10.Base B=int(10,2,1000)
#@gui :11.Link Start Numbers?=bool(0)
#@gui :_=separator(),_=note("<b>Method</b>")
#@gui :12.Method=choice(0,"Subtraction","Addition","Multiplication")
#@gui :13.Method A=choice(0,"Subtraction","Addition","Multiplication")
#@gui :14.Method B=choice(0,"Subtraction","Addition","Multiplication")
#@gui :15.Link Start Numbers?=bool(0)
#@gui :_=separator(),_=note("<b>Palette</b>")
#@gui :16.Mode=choice(1,"Singular","Dual")
#@gui :17.Set=choice(0,"Foreground","Background")
#@gui :18.19.20.Color 1=color(255,255,255)
#@gui :21.22.23.Color 2=color(255,255,255)
#@gui :24.25.26.Color 3=color(255,255,255)
#@gui :27.28.29.Color 4=color(255,255,255)
#@gui :30.31.32.Color 5=color(255,255,255)
#@gui :33.34.35.Color 6=color(255,255,255)
#@gui :36.37.38.Color 7=color(255,255,255)
#@gui :39.40.41.Color 1=color(255,255,255)
#@gui :42.43.44.Color 2=color(255,255,255)
#@gui :45.46.47.Color 3=color(255,255,255)
#@gui :48.49.50.Color 4=color(255,255,255)
#@gui :51.52.53.Color 5=color(255,255,255)
#@gui :54.55.56.Color 6=color(255,255,255)
#@gui :57.58.59.Color 7=color(255,255,255)
#@gui :60.61.62.Color 1=color(255,255,255)
#@gui :63.64.65.Color 2=color(255,255,255)
#@gui :66.67.68.Color 3=color(255,255,255)
#@gui :69.70.71.Color 4=color(255,255,255)
#@gui :72.73.74.Color 5=color(255,255,255)
#@gui :75.76.77.Color 6=color(255,255,255)
#@gui :78.79.80.Color 7=color(255,255,255)
#@gui :_=separator(),_=note("<b>Shape</b>")
#@gui :81.Use Shape=bool(1)
#@gui :82.Tiled Shape=choice(3,"By Layer","Australia","Barbedwire","Circle","Crosshair","Cupid","Diamond","Dragon Curve-[D]","Dragonfly","Fern-[D]","Flip","Gear-[D]","Gumleaf","Heart","Information","Kookaburra","Mail","Mapleleaf","Paint Splat","Paw","Phone","Polygon-[D]","Rooster","Shopping Cart","Snowflake-[D]","Star-[D]")
#@gui :83.Fit Tile?=bool(1)
#@gui :84.Dragon Curve Recursion=int(10,0,30)
#@gui :85.Dragon Curve Rotation=float(0,-180,180)
#@gui :86.Fern Type=choice("Asplenium Adiantum-Nigrum","Thelypteridaceae")
#@gui :87.Fern Density (%)=float(100,0,300)
#@gui :88.Gear Teeth Count=int(8,3,32)
#@gui :89.Gear Height (%)=float(25,0.1,100)
#@gui :90.Gear Offset Teeth (%)=float(0,0,100)
#@gui :91.Gear Inner Ratio (%)=float(50,0.1,100)
#@gui :92.Polygon Vertices=int(5,3,100)
#@gui :93.Snowflake Recursion=int(5,1,6)
#@gui :94.Star Branches=int(3,5,100)
#@gui :95.Star Thickness (%)=float(38,.1,100)
#@gui :_=separator(),_=note("<b>Misc</b>")
#@gui :96.Position=choice(0,"10","100","1000","10000","100000")
#@gui :97.Position A=choice(0,"10","100","1000","10000","100000")
#@gui :98.Position B=choice(0,"10","100","1000","10000","100000")
#@gui :99.Push into Start Number=button()
#@gui :100.Push into Start A=button()
#@gui :101.Push into Start B=button()
#@gui :102.Push into Both=button()
I updated the script for extraction of unique u string. It returns them in order now:
Extract unique u string
import pyperclip as pc
import re
import numpy
gmic_str_paste=pc.paste()
gmic_str=str(gmic_str_paste)
lines=gmic_str.splitlines()
list_of_strings=[]
between_these_char="\_\"{(.*?)\}"
for l in lines:
current_string=l.split('"')
try:
substring = re.search(between_these_char, l).group(1)
except AttributeError:
substring = re.search(between_these_char, l)
if substring is None:
continue
else:
list_of_strings.append("{"+substring+"}")
unique_list=numpy.unique(list_of_strings)
size_of_unique_list=int(len(unique_list))
order_unique_number=[]
for a in unique_list:
n=0
for line in list_of_strings:
if line==a:
order_unique_number.append(n)
break
n += 1
ordered_unique_list=[None] * len(unique_list)
order_unique_number.sort()
for n in range(0,len(unique_list)):
ordered_unique_list[n]=list_of_strings[order_unique_number[n]]
for v in range(0,len(unique_list)):
print("condition_"+str(v)+"="+str(ordered_unique_list[v]))