Dateien hochladen nach „“
parent
403dcdad13
commit
9d0729824e
|
@ -1 +1 @@
|
|||
{1: {'name': 'variable erstellen', 'code': '#executor\n#block\n#args\nexecutor.makevariable(args[0], args[1])', 'args': 2}, 2: {'name': 'bekomme den variablen value', 'code': '#executor\n#block\n#args\nexecutor.getvariable(args[0])', 'args': 1}, 3: {'name': 'setze variablen value', 'code': '#executor\n#block\n#args\nexecutor.setvariable(args[0], args[1])', 'args': 2}, 4: {'name': 'l<>sche variable', 'code': '#executor\n#block\n#args\nexecutor.deletevariable(args[0])', 'args': 1}, 5: {'name': 'gebe variable value aus', 'code': '#executor\n#block\n#args\nprint(executor.getvariable(args[0]))', 'args': 1}, 7: {'name': 'plus rechnen test bla bla bla nervig BRUH', 'code': '#executor\n#block\n#args\nprint(int(args[0])+int(args[1]))', 'args': 2}}
|
||||
{1: {'name': 'variable erstellen', 'code': '#executor\n#block\n#args\nexecutor.makevariable(args[0], args[1])', 'args': 2}, 2: {'name': 'bekomme den variablen value', 'code': '#executor\n#block\n#args\nexecutor.getvariable(args[0])', 'args': 1}, 3: {'name': 'setze variablen value', 'code': '#executor\n#block\n#args\nexecutor.setvariable(args[0], args[1])', 'args': 2}, 4: {'name': 'l<>sche variable', 'code': '#executor\n#block\n#args\nexecutor.deletevariable(args[0])', 'args': 1}, 5: {'name': 'gebe variable value aus', 'code': '#executor\n#block\n#args\nprint(executor.getvariable(args[0]))', 'args': 1}, 7: {'name': 'plus rechnen', 'code': '#executor\n#block\n#out\n#args\nout = (int(args[0])+int(args[1]))', 'args': 2}, 8: {'name': 'minus rechnen', 'code': '#executor\n#block\n#out\n#args\nout = (int(args[0])-int(args[1]))', 'args': 2}, 9: {'name': 'multiplizieren', 'code': '#executor\n#block\n#out\n#args\nout = (int(args[0])*int(args[1]))', 'args': 2}, 10: {'name': 'geteilt rechnen', 'code': '#executor\n#block\n#out\n#args\nout = (int(args[0])/int(args[1]))', 'args': 2}}
|
34
main.py
34
main.py
|
@ -17,14 +17,36 @@ class block():
|
|||
return "ERROR 1"
|
||||
|
||||
def execute(self):
|
||||
#preparing arguments
|
||||
preparedargs = []
|
||||
for i in self.args:
|
||||
if "<variable>" in i:
|
||||
temp = i.replace("<variable>", "")
|
||||
temp = self.executor.getvariable(temp)
|
||||
preparedargs.append(temp)
|
||||
elif "<function>" in i:
|
||||
temp = i.replace("<function>", "")
|
||||
tempargs = temp.split("<args>")
|
||||
tempargs = tempargs[1]
|
||||
tempargs = ast.literal_eval(tempargs)
|
||||
temp = temp.split("<args>")
|
||||
temp = temp[0]
|
||||
temp = self.executor.texttointtype(temp)
|
||||
if self.type in self.combinations:
|
||||
temp2 = {"executor": self.executor, "block": self, "args": tempargs, "out": ""}
|
||||
try:
|
||||
exec(self.combinations[temp]["code"], temp2)
|
||||
temp = temp2["out"]
|
||||
except Exception as e:
|
||||
messagebox.showerror("fehler", "ERROR 2: block type: {} error information: {}".format(self.type, e))
|
||||
temp = "ERROR 2: block type: {} error information: {}".format(self.type, e)
|
||||
else:
|
||||
messagebox.showerror("fehler", "ERROR 3: block type: {}".format(self.type))
|
||||
temp = "ERROR 3: block type: {}".format(self.type)
|
||||
preparedargs.append(temp)
|
||||
else:
|
||||
preparedargs.append(i)
|
||||
#code execution
|
||||
if self.type in self.combinations:
|
||||
temp2 = {"executor": self.executor, "block": self, "args": preparedargs}
|
||||
try:
|
||||
|
@ -117,11 +139,19 @@ class executor():
|
|||
for i in range(self.combinations[self.texttointtype(selected)]["args"]):
|
||||
reply = easygui.enterbox("argument nummer {}".format(i+1), "argumenten abfrage")
|
||||
if reply:
|
||||
if reply[0] == "*" and reply[-1] == "*":
|
||||
if reply[0] == "*" and reply[-1] == "*" and reply[1] != "*":
|
||||
temp = reply
|
||||
temp = temp[1:]
|
||||
temp = temp[:-1]
|
||||
args.append("<variable>{}".format(temp))
|
||||
elif reply[0] == "*" and reply[1] == "*" and reply[-1] == "*" and reply[-2] == "*":
|
||||
temp = reply
|
||||
temp = temp[1:]
|
||||
temp = temp[:-1]
|
||||
temp = temp[1:]
|
||||
temp = temp[:-1]
|
||||
temp = temp.split("[")
|
||||
args.append("<function>{}<args>{}".format(temp[0], "["+temp[1]))
|
||||
else:
|
||||
args.append(reply)
|
||||
else:
|
||||
|
@ -198,7 +228,7 @@ class executor():
|
|||
if variablename in self.variables:
|
||||
self.variables[variablename] = value
|
||||
else:
|
||||
messagebox.showerror("fehler", "ERROR 5")
|
||||
messagebox.showerror("fehler", "ERROR 5: set var")
|
||||
|
||||
def manuelsave(self, path):
|
||||
temp = []
|
||||
|
|
Loading…
Reference in New Issue