From 9d0729824ea14ca56b4ecad5f12af0b56e2754df Mon Sep 17 00:00:00 2001 From: Justus Jan Nico Wolff Date: Sun, 8 Jan 2023 13:11:07 +0100 Subject: [PATCH] =?UTF-8?q?Dateien=20hochladen=20nach=20=E2=80=9E=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- combinations.txt | 2 +- main.py | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/combinations.txt b/combinations.txt index ae5e39c..70c5d77 100644 --- a/combinations.txt +++ b/combinations.txt @@ -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}} \ No newline at end of file +{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}} \ No newline at end of file diff --git a/main.py b/main.py index 592ee62..240c087 100644 --- a/main.py +++ b/main.py @@ -17,14 +17,36 @@ class block(): return "ERROR 1" def execute(self): + #preparing arguments preparedargs = [] for i in self.args: if "" in i: temp = i.replace("", "") temp = self.executor.getvariable(temp) preparedargs.append(temp) + elif "" in i: + temp = i.replace("", "") + tempargs = temp.split("") + tempargs = tempargs[1] + tempargs = ast.literal_eval(tempargs) + temp = temp.split("") + 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("{}".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("{}{}".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 = []