Exemplo n.º 1
0
def kimetsu_search(word):
    # 検索対象取得
    val = eel.js_function('file')()
    df = pd.read_csv("./" + val)
    source = list(df["name"])

    # 検索
    if word in source:
        # print("『{}』はあります".format(word))
        txt = "『{}』はあります".format(word)

    else:
        # print("『{}』はありません".format(word))
        txt = "『{}』はありません".format(word)
        # 追加
        '''
        add_flg=input("追加登録しますか?(0:しない 1:する) >> ")
        if add_flg=="1":
        '''
        source.append(word)
    return txt

    # CSV書き込み
    df = pd.DataFrame(source, columns=["name"])
    df.to_csv("./" + val, encoding="utf_8-sig")
    print(source)
Exemplo n.º 2
0
def cam_source():
    eel.init('GUI/web')
    eel.start('html/Check.html', block=False)
    num = eel.js_function()()
    print(num)
    return int(num)
Exemplo n.º 3
0
def main():
    class usb_ports_gui:
        def window_usb_ports(self):
            global usb_ports
            usb_ports = []
            for port in serial.tools.list_ports.comports():
                port_ = str(port)
                list_ = port_.split(" ")
                concat = ""
                for i in range(2, len(list_) - 1):
                    concat = concat + list_[i] + " "
                usb_ports.append([list_[0], concat])
            usb_list = []
            for i in usb_ports:
                usb_list.append([i[0] + "  " + i[1], i[1].split(" ")[0]])

            usb_port_name = usb_ports_gui.usb_port_count(self, usb_list)
            return [usb_port_name, len(usb_list)]

        def linux_usb_ports(self):
            global usb_ports
            usb_ports = []
            for port in serial.tools.list_ports.comports():
                port_ = str(port)
                list_ = port_.split(" ")
                concat = ""
                for i in range(2, len(list_)):
                    concat = concat + list_[i] + " "
                string = list_[0][slice(5, len(list_[0]))] + "  " + concat
                usb_ports.append([string, string.split(" ")[2]])
            usb_port_name = usb_ports_gui.usb_port_count(self, usb_ports)
            return [usb_port_name, len(usb_ports)]

        def usb_port_count(self, usb_ports):
            ignore = []
            count = 0
            list_ = []
            for i in range(0, len(usb_ports)):
                com1 = usb_ports[i][1]
                for j in range(i, len(usb_ports)):
                    com2 = usb_ports[j][1]
                    if j not in ignore:
                        if com1 == com2:
                            ignore.append(j)
                            count += 1
                if count != 0:
                    list_.append([usb_ports[i][0], count])
                count = 0
            global eel_list
            eel_list = []
            for i in list_:
                temp_list = []
                concat = ""
                i = i[0].split(" ")
                for j in range(1, len(i) - 1):
                    concat += i[j] + " "
                temp_list.append(concat)
                for k in usb_ports:
                    if concat in k[0]:
                        id = k[0].split(" ")[0]
                        temp_list.append(id)
                eel_list.append(temp_list)
            return eel_list

    obj1 = usb_ports_gui()
    if str(platform.system()) == 'Linux':
        f_usb_list = obj1.linux_usb_ports()
    else:
        f_usb_list = obj1.window_usb_ports()
    usb_list = f_usb_list[0]
    port_length = f_usb_list[1]
    eel.js_function(usb_list, port_length)
Exemplo n.º 4
0
import eel

#Init eel
print("Init eel...")
eel.init("web")

#call js function
eel.js_function("hello eel.")


#define python function
@eel.expose
def python_function(val):
    print(val, "from JavaScript")


#Start eel
print("Start eel: main.html")
eel.start("main.html", size=(1000, 800))
Exemplo n.º 5
0
# JavaScriptから呼べるように関数を登録

def search_open(row,csv_file):
  with open('test.csv') as f:
    reader = csv.reader(f)
    source = []


def search():
  # -------------------↑
  for row in reader:
    print(row)
    source.append(row[0])
  for in_name in source:
    in_name = input('名前を入力')
    if in_name in source:
      print(in_name[0:10] +('の名前はあります'))
    elif in_name != source:
      print('登録されていません')
      source.append(in_name)
      with open('test.csv','a') as f:
        writer = csv.writer(f)
        writer.writerow([in_name])
# JavaScriptの関数の戻り値をPythonで取得するには?
search()
eel.js_function()
# 最初の画面のHTMLファイルを指定

eel.init("web")
eel.start("index.html", size=(800,800),port=9999)
Exemplo n.º 6
0
import eel
import numpy as np

eel.init("web")
eel.js_function(np.random.rand(4).tolist()) # JSON serializableでないとダメ
eel.start("main.html")
Exemplo n.º 7
0
start_options = {
    'mode': "chrome",
    'port': port,
    'size': (1000, 900),
    'close_callback': exit,
    'default_path': "main.html",
    'cmdline_args': CHROME_ARGS
}
# _start_args = {
#     'mode':             "chrome",                   # What browser is used
#     'host':             'localhost',                # Hostname use for Bottle server
#     'port':             8000,                       # Port used for Bottle server (use 0 for auto)
#     'block':            True,                       # Whether start() blocks calling thread
#     'jinja_templates':  None,                       # Folder for jinja2 templates
#     'cmdline_args':     ['--disable-http-cache'],   # Extra cmdline flags to pass to browser start
#     'size':             None,                       # (width, height) of main window
#     'position':         None,                       # (left, top) of main window
#     'geometry':         {},                         # Dictionary of size/position for all windows
#     'close_callback':   None,                       # Callback for when all windows have closed
#     'app_mode':  True,                              # (Chrome specific option)
#     'all_interfaces': False,                        # Allow bottle server to listen for connections on all interfaces
#     'disable_cache': True,                          # Sets the no-store response header when serving assets
#    'default_path': 'index.html',                   # The default file to retrieve for the root URL
#    'app': btl.default_app(),                       # Allows passing in a custom Bottle instance, e.g. with middleware
# }

condition = control.select_search_info()
eel.js_function(condition)  # JSON serializableでないとダメ
eel.start("main.html", options=start_options, suppress_error=True)