srplab / starcore_for_flutter

middleware for flutter calling other script languages
140 stars 29 forks source link

How can I write python-code? #6

Open ghost opened 5 years ago

ghost commented 5 years ago

Hi I just want to run a python-file which has a few variables as the return. I want to print them out with flutter. How can I use the variables? And whre do I have to write the python-code? import requests from bs4 import BeautifulSoup import csv URL = "http://vertretungsplan.jkg-reutlingen.de/Vertretungen-Sa.html" r = requests.get(URL) with open("sourcecode.txt", encoding='ISO-8859-1') as source: htmlcode = source.read() print("Wähle deine Stufe.") stufe = input() print("Wähle deine Klasse.") klassenbuchstabe = input() klasse = stufe+klassenbuchstabe print("Deine Klasse ist: "+klasse) ent = "entfällt"

soup = BeautifulSoup(htmlcode, 'html.parser')

absaetze = soup.find_all('tr')

stundenplan = [] for absatz in absaetze: eintrag = absatz.text.split() stundenplan.append(eintrag)

with open('csvfile.csv', 'a', newline='') as csvfile: writer = csv.writer(csvfile, delimiter='|') writer.writerows(stundenplan) for eintrag in stundenplan: if eintrag[0] == klasse: tag = eintrag[1] stunde = eintrag[2] fach = eintrag[5] print("Für dich entfällt am ", tag, "die ", stunde, " ", fach)

srplab commented 5 years ago

Hi,

Register callback function as follow,

    StarCoreFactory starcore = await Starflut.getFactory();
    int Result = 0;
    Result =
        await starcore.initCore(true, false, false, true, "", 0, "", 0);
    await starcore.regMsgCallBackP(
        (int serviceGroupID, int uMsg, Object wParam, Object lParam) async{
      print("$serviceGroupID  $uMsg   $wParam   $lParam");
      return null;
    });

This function will intercept the content printed by python

If return value is expected, you can define the python code as a python function and return it through the function.

发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用


发件人: unddasauchnicht notifications@github.com 发送时间: Thursday, August 29, 2019 6:55:36 PM 收件人: srplab/starcore_for_flutter starcore_for_flutter@noreply.github.com 抄送: Subscribed subscribed@noreply.github.com 主题: [srplab/starcore_for_flutter] How can I write python-code? (#6)

Hi I just want to run a python-file which has a few variables as the return. I want to print them out with flutter. How can I use the variables? And whre do I have to write the python-code? import requests from bs4 import BeautifulSoup import csv URL = "http://vertretungsplan.jkg-reutlingen.de/Vertretungen-Sa.html" r = requests.get(URL) with open("sourcecode.txt", encoding='ISO-8859-1') as source: htmlcode = source.read() print("Wähle deine Stufe.") stufe = input() print("Wähle deine Klasse.") klassenbuchstabe = input() klasse = stufe+klassenbuchstabe print("Deine Klasse ist: "+klasse) ent = "entfällt"

soup = BeautifulSoup(htmlcode, 'html.parser')

absaetze = soup.find_all('tr')

stundenplan = [] for absatz in absaetze: eintrag = absatz.text.split() stundenplan.append(eintrag)

with open('csvfile.csv', 'a', newline='') as csvfile: writer = csv.writer(csvfile, delimiter='|') writer.writerows(stundenplan) for eintrag in stundenplan: if eintrag[0] == klasse: tag = eintrag[1] stunde = eintrag[2] fach = eintrag[5] print("Für dich entfällt am ", tag, "die ", stunde, " ", fach)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/srplab/starcore_for_flutter/issues/6?email_source=notifications&email_token=ACXTPWMS7RM2AJWBKBMM63TQG6TKRA5CNFSM4ISA2O7KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HIFJ4MQ, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACXTPWJC4ITFG2FIBFOLNLTQG6TKRANCNFSM4ISA2O7A.