import eel eel.init('web') # Give folder containing web files @eel.expose # Expose this function to Javascript def say_hello_py(x): print('Hello from %s' % x) say_hello_py('Python World!') eel.say_hello_js('Python World!') # Call a Javascript function eel.start('hello.html', size=(300, 200)) # Start
import eel import random from datetime import datetime from os import getcwd dir = getcwd() eel.init('application/web') @eel.expose def get_random_name(): eel.prompt_alerts('Random name') @eel.expose def get_random_number(): eel.prompt_alerts(random.randint(1, 100)) @eel.expose def get_date(): eel.prompt_alerts(datetime.now().strftime("%d/%m/%Y %H:%M:%S")) print("ADASD") @eel.expose def get_ip(): eel.prompt_alerts('127.0.0.1') eel.start('index.html')
def key_pressed(before_pos, next_char, ins_cnt): """called from gui app Args - before_pos (list of integer): before - next_char (char): after - ins_cnt (int): #(instances) Returns - dictionary - solution: plan of agents - char: final config """ logger.info(f'solve unlabeled-MAPF to char-{next_char}') ins_name = f'./instance/tmp/{ins_cnt}.txt' map_name = './map/5x7.map' create_transition_file(ins_name, before_pos, next_char) solver = Unlabled_MAPF_Solver(map_name, ins_name) solver.solve() return { "solution": solver.solution, "char": get_trimed_str(next_char) } if __name__ == '__main__': eel.init("gui", allowed_extensions=[".js", ".html"]) eel.start("index.html", host="localhost", port=8000, mode="chrome")
import eel import os import sys movie_file_types = ['mp4', 'mkv'] @eel.expose def launchMovie(movie): # get movie file from folder movie_folder = 'H:\Movies\\' + movie + '\\' files = os.listdir(movie_folder) movie_path = '' for file in files: file_str = str(file)[-3:] if (file_str in movie_file_types): movie_path = 'H:\Movies\\' + movie + '\\' + file print(movie_path) print(movie_path) os.system('vlc -f ' + '"' + movie_path + '"') eel.init('site') eel.start('index.html', size=(1000, 1200))
import json import ast from datetime import datetime import random ##for testing purposes only## import pytz import queue_process from constants import NORMAL_MODE, REVERSE_MODE import time import ADB from watchdog.observers import Observer from watchdog.events import PatternMatchingEventHandler # Set web files folder and optionally specify which file types to check for eel.expose() # *Default allowed_extensions are: ['.js', '.html', '.txt', '.htm', '.xhtml'] eel.init('web', allowed_extensions=['.js', '.html']) queue_place_path = './tempfiles/queue/queue_place' # Declaration of watchdog event handler patterns = "*" ignore_patterns = "" ignore_directories = False case_sensitive = True queue_place_event_handler = PatternMatchingEventHandler( patterns, ignore_patterns, ignore_directories, case_sensitive) path = "./tempfiles/queue" go_recursively = False
import eel from tkinter.filedialog import askopenfilename, askdirectory, askopenfilenames from tkinter import Tk import os import subprocess import shutil import sys web_location = 'web' web_path = os.path.dirname(os.path.realpath(__file__)) + '\\' + web_location eel.init(web_path) @eel.expose def getFileFromArgs(): if len(sys.argv) > 1: return os.path.abspath(sys.argv[1]) return '' @eel.expose def openOutputFolder(folder): folder = folder.replace('/', '\\') if os.name == 'nt': # Opens the new window to the top on Windows os.system('explorer "' + folder + '"') else: os.startfile(folder) @eel.expose
import eel from colorama import * print("app") @eel.expose def refresh(): print(f"{Fore.GREEN}Python is ready...{Fore.RESET}") eel.init("www") eel.start("index.html", size=(746, 683))
import eel import os import sys import pandas as pd #select folder eel.init('startbootstrap') @eel.expose def get_data(filename): file = str(os.path.dirname(os.path.realpath(sys.argv[0]))+"/data/"+filename) df = pd.read_csv(file) time = df['time'].tolist() x = df['x'].tolist() y = df['y'].tolist() z = df['z'].tolist() return time,x,y,z eel.sel()(get_data) eel.start('charts.html',size=(1200,800))
@eel.expose def getResult(query): #print(query) query = query.strip().lower() if query == "": return {"resultNews": [], "correctedQuery":'', "resultLen": 0, "searchTime": 0.000} correctQuery = SearchAndRank.correctKeywords([query])[0] print(correctQuery) iniQueryWords = wordsCut.sentence_seg(correctQuery) queryWords = [] for word in iniQueryWords: if word != ' ': queryWords.append(word) SearchResult = SearchAndRank.Search(query,correctQuery,queryWords) #print(SearchResult) return SearchResult web_app_options = { 'mode': '', 'host': 'localhost', 'port': 8000, 'chromeFlags': [] } if __name__ == '__main__': eel.init('front') eel.start('index.html', options=web_app_options)
def startGUI(): global GUI_STATE GUI_STATE = True eel.init('app') eel.start('index.html', size=(300, 200), mode='edge') # Start return
import eel from pyjson import whconfig, write_data import json from testing import attendance from datetime import datetime from datetime import time from datetime import date import openpyxl as xl from threading import Timer import os eel.init("gui") timer = [] @eel.expose def get_directory(): print("here") from tkinter import filedialog from tkinter import Tk root = Tk() root.withdraw() root.call("wm", "attributes", ".", "-topmost", True) folder_selected = filedialog.askdirectory() if whconfig["output"] == "": if not os.path.exists(os.path.join(folder_selected, "screenshots")): os.mkdir(os.path.join(folder_selected, "screenshots")) if not os.path.exists(os.path.join(folder_selected, "excel")): os.mkdir(os.path.join(folder_selected, "excel")) whconfig["image_location"] = os.path.join(folder_selected, "screenshots")
#-*-coding : utf8 -*- import eel, mysql.connector, hashlib, webbrowser, re from datetime import datetime eel.init('view') usr= '' moisFr = ['Janvier', 'Fevrier', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet' ,'Aout', 'Septembre', 'Octobre', 'Novembre', 'Decembre'] def model(): try: global liaison liaison = mysql.connector.connect(host="localhost",user="******",password="******", database="optica") except: return "Erreur de connexion avec la base de donnee, Peut etre qu'il est eteint, \n Essayer de l'allume d'abord " else: return liaison def authentification(user, password): try: liaison = model() except: pass else: cursor = liaison.cursor(buffered=True) cursor.execute(""" SELECT User FROM personnel WHERE User = %s; """, (user, )) if cursor.fetchone() is not None:
html_code=html_code), get_category(html_code=html_code) add_to_db(articles) return convert_into_table(articles=articles, category=category) @eel.expose # вказуємо доступ з html def parse(url: str): # url = 'https://overclockers.ru/lab?offset=-180&max=200' return parse_one_page(url) @eel.expose # вказуємо доступ з html def write_to_xlsx(): global category, category if write_to_excel(articles=articles, category=category): return "Дані успішно записані" else: return "Помилка запису, закрийте excel" @eel.expose def open_xlsx(): startfile(RESULT_FILENAME) if __name__ == '__main__': eel.init('web_folder') # вказуємо з якої папки брати веб файли eel.start('index.html', cmdline_args=['--start-fullscreen' ]) # вказуємо запуск програми в повний екран
import cv2 import argparse import time import os import Update_Model import glob import random import eel frequency=2500 duration=1000 eel.init('WD_INNOVATIVE') emotions=["angry", "happy", "sad", "neutral"] fishface = cv2.face.FisherFaceRecognizer_create() font = cv2.FONT_HERSHEY_SIMPLEX parser=argparse.ArgumentParser(description="Options for emotions based music player(Updating the model)") parser.add_argument("--update", help="Call for taking new images and retraining the model.", action="store_true") args=parser.parse_args() facedict={} video_capture=cv2.VideoCapture(0) facecascade=cv2.CascadeClassifier("haarcascade_frontalface_default.xml") def crop(clahe_image, face): for (x, y, w, h) in face: faceslice=clahe_image[y:y+h, x:x+w] faceslice=cv2.resize(faceslice, (350, 350)) facedict["face%s" %(len(facedict)+1)]=faceslice
# -*- coding: utf-8 -*- import eel import pandas as pd import matplotlib.pyplot as plt import sys import os pd.options.mode.chained_assignment = None # Inicia eel app eel.init('app') #################### INPUTS #################### @eel.expose def retorna_Regiao(region): return str(region) @eel.expose def retorna_TCV(tcv): return float(tcv) @eel.expose def retorna_TERM(term): return int(term) @eel.expose
# notify function for windows elif current_os.lower() == "windows": import win10toast as wtt toaster = wtt.ToastNotifier() @eel.expose def notify(msg, head, icon_file=jarvis_icon, ul=1, duration=5): toaster.show_toast(head, msg, icon_path=icon_file, threaded=True, duration=duration) # publish a mqtt message @eel.expose def msg_pub(topic, msg, broker=BROKER, port=PORT): mqtt.publish.single(topic, hostname=broker, port=port) if __name__ == "__main__": # initialise app on start eel.init(static_dir) eel.start("index.html", size=SIZE) conn.close() conn_temp.close()
import os import eel import search import openFile app_web = "html" end_point = "index.html" size = (600, 500) @eel.expose def open(): path = openFile.openDialog() base = os.path.basename(path) return [path, base] @eel.expose def kimetsuSearch(name, path): return search.kimetsuSearch(name, path) eel.init(app_web) eel.start(end_point, size = size)
import task_manager as tM import eel eel.init('front', allowed_extensions=['.js', '.html']) @eel.expose def createTask(name, **params): tM.addTask(name, **params) print(f"Tache '{name}' créée avec success.") @eel.expose def showTasks(): tasks = tM.getTasks() tasks = tasks[1:] for task in tasks: eel.addTaskElement(task) eel.start('index.html', geometry={ 'size': (200, 100), 'position': (300, 50) }) # Start (this blocks and enters loop)
import eel from CryptoModule import keysFile from base64 import b64encode, b64decode from Crypto.PublicKey import RSA from Crypto.Cipher import PKCS1_OAEP KEYSFILE = keysFile() eel.init('UI') @eel.expose def create_file(name, password): KEYSFILE.new(password, name) @eel.expose def login(path, password): return KEYSFILE._import(path, password) # Friends Page # @eel.expose def get_friends_keys(): return KEYSFILE.get_friends_pubKeys() @eel.expose def add_friend_key(name, key):
import eel eel.init('src') @eel.expose def exx(x): print(x) eel.start("cook.html", size = (634, 951))
# pass @eel.expose def save_data(): return ctx.save_data() @eel.expose def null_process(method, label=None): return ctx.null_process(method, label) @eel.expose def noise_process(method, label=None): return ctx.noise_process(method, label) @eel.expose def normalize(method, label=None): return ctx.normalize(method, label) @eel.expose def visualization(method, label): return ctx.visualization(method, label) eel.init("ui") eel.start("index.html", options={ 'port': 47932, })
from corpus import * from hmm import * from viterbi import * import os import re import eel import random from os import listdir from os.path import isfile, join train_set = [] lexicon = [] model = {} mounted = 0 print(mounted) eel.init('GUI') def tokenize(sentence): os.chdir('api') source = open('source.txt', 'w', encoding='windows_1256') source.write(sentence) source.close() os.system('perl splitaffixfirstSol.pl < source.txt > output.txt') output = open('output.txt', encoding='windows_1256').read() output = re.sub(r'\s+', ' ', output).split(' ') for w in output: if w == '': output.remove(w)
#detect if the "User" folder exists yet if os.path.isdir("web/User/Trialtypes") == False: os.mkdir("web/User/Trialtypes") trialtype_file = open("web/User/Trialtypes/" + trialtype_name, "w", newline='') trialtype_file.write(trialtype_content) #################### # Start Collector ## #################### if os.path.isdir("web") == False: # more code here # check if github is installed pull_open_collector_only() eel.init('web') #allowed_extensions=[".js",".html"] ''' for proc in process_iter(): for conns in proc.get_connections(kind='inet'): if conns.laddr[1] == 8000: proc.send_signal(SIGKILL) continue ''' eel.start('kitten/index.html', port=8000)
def gui(): eel.init('web') eel.start('main.html', size=(350, 350), position=(1540, 30))
try: import eel except ImportError: from subprocess import run run("pip install eel".split(" ")) import eel pass eel.init(".") from sys import argv @eel.expose def index(string): print(string) return argv[0] eel.index(argv[0])(callback=print) eel.start("index.html",size=(640,480))
import eel import torch import matplotlib.pyplot as plt import torch.nn as nn import torch.nn.functional as F eel.init('frontend_template') class MNISTModel(nn.Module): def __init__(self, input_neurons, hidden_neurons, output): super().__init__() self.lyr_1 = nn.Linear(input_neurons, hidden_neurons) self.lyr_2 = nn.Linear(hidden_neurons, output) def forward(self, xbtch): xbtch = xbtch.view(xbtch.size(0), -1) out = self.lyr_1(xbtch) out = F.relu(out) #apply relu on the output out = self.lyr_2(out) return out def training_step(self, btch): imgs, labels = btch out = self(imgs) #run the forward method on the images loss = F.cross_entropy(out, labels) return loss def validation_step(self, btch): imgs, labels = btch
import io import eel eel.init('web') eel.start('index.html', size=(1000, 600))
import eel import random import json import os import fs from availabilipy.classes import * os.makedirs('saves', exist_ok=True) save_folder = os.path.join(os.getcwd(), 'saves') persistent_data = {'chains': {}, 'rbd': {}} eel.init('dist') #################################### General ######################################################################## @eel.expose def save(name): print("Saving to json") if os.path.exists(name + '.json'): return 'That file already exists' try: file = open(os.path.join(save_folder, name + '.json'), 'w') data = { 'rbd': persistent_data['rbd'].to_json(), 'chains': { persistent_data['chains'][chain].chainid: persistent_data['chains'][chain].to_json() for chain in persistent_data['chains'] } } json.dump(data, file)
def update_data(data): global pdf_splitter columns = pdf_splitter.df.columns.tolist() data = [d for d in data if d != [] and d != [""] * len(columns)] pdf_splitter.df = pd.DataFrame(data[1:], columns=columns) pdf_splitter.df["from"][pdf_splitter.df["from"] == ""] = 1 pdf_splitter.df["to"][pdf_splitter.df["to"] == ""] = int( pdf_splitter.num_pages) pdf_splitter.df["from"] = pdf_splitter.df["from"].astype(int) pdf_splitter.df["to"] = pdf_splitter.df["to"].astype(int) pdf_splitter.df.sort_values(["from", "to"], inplace=True) pdf_splitter.df.reset_index(drop=True) print(pdf_splitter.df) @eel.expose def get_data(): data = [pdf_splitter.df.columns.tolist()] + pdf_splitter.df.values.tolist() return data @eel.expose def split_pdf(): global split_progress for v in pdf_splitter.split_pdf(output_path, pdf_splitter.prefix): eel.update_progressbar(v, str(v) + "%") if __name__ == "__main__": eel.init("web") eel.start("main.html", close_callback=onCloseWindow, size=(1200, 800))
# Import the eel and random libraries import eel import random from random import choice # Starts the GUI frontend server eel.init('web-gui') eel.start('index.html', size=(1440, 900)) # This function randomly chooses an answer of yes or no @eel.expose # Exposes this function (makes it callable) from Javascript def mainFunction(): output = (random.choice(['Yes', 'No'])) if output == 'Yes': eel.yesFunction() # Calls yesFunction() in JavaScript else: eel.noFunction() # Calls noFunction() in JavaScript # For dev purposes only: while True: eel.sleep(10)
import signal import psutil import player_plain target_dir = os.path.abspath(os.path.dirname(__file__)) print('Moving into', target_dir) os.chdir(target_dir) options = {'host':'0.0.0.0', 'port':6147, 'mode':'default'} if sys.platform == 'win32': options['host'] = 'localhost' print('Starting eel') eel.init('web') game = None def start_game(return_args): global WINNER WINNER = 0 return_args['map'] = cli.get_map(os.path.abspath(os.path.join('..', 'battlecode-maps', return_args['map']))) if 'NODOCKER' in os.environ: return_args['docker'] = False return_args['dir_p1'] = os.path.abspath(os.path.join('..', return_args['dir_p1'])) return_args['dir_p2'] = os.path.abspath(os.path.join('..', return_args['dir_p2'])) else: return_args['docker'] = True return_args['dir_p1'] = os.path.abspath(os.path.join('/player', return_args['dir_p1']))
@eel.expose def is_done(): return _app_is_done ge = {"port": 8700, "get_port": False} while ge["get_port"] is False: try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(.1) s.connect(("localhost", ge["port"])) ge['port'] += 1 except socket.error: ge["get_port"] = True eel.init(os.path.dirname(os.path.abspath(__file__)) + '\gui') eel.start('load.html', port=ge["port"], suppress_error=True, block=False, size=(300, 600), mode='edge') finally: if s: s.close() done_time = time.process_time() #================================================ info("loading") import threading, queue