Skip to content

Instantly share code, notes, and snippets.

@m3g4p0p
Created August 8, 2020 13:25
Show Gist options
  • Save m3g4p0p/674b9ca6a763a60b030c95581b08edad to your computer and use it in GitHub Desktop.
Save m3g4p0p/674b9ca6a763a60b030c95581b08edad to your computer and use it in GitHub Desktop.
eel window communication
import eel
eel.init('.')
@eel.expose
def send_message(message):
eel.on_message(message)
eel.show('test.html')
eel.start('main.html', size=(300, 100))
<!DOCTYPE html>
<html>
<head>
<title>Main</title>
<script src="/eel.js"></script>
</head>
<body>
<input type="text" id="message">
<script>
const message = document.getElementById('message')
message.addEventListener('input', () => {
eel.send_message(message.value)
})
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<script src="/eel.js"></script>
</head>
<body>
<div id="test"></div>
<script>
const test = document.getElementById('test')
eel.expose(on_message)
function on_message(message) {
test.textContent = message
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment