-
Notifications
You must be signed in to change notification settings - Fork 0
/
\
48 lines (45 loc) · 1.4 KB
/
\
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use futures_util::{SinkExt, StreamExt, stream::SplitStream};
use eframe::egui;
use tokio_tungstenite::*;
use rdev::{simulate,EventType,Key};
mod websocket;
mod gui;
#[tokio::main]
async fn main() -> Result<(),Box<dyn std::error::Error>> {
let r = simulate(&EventType::KeyPress(Key::KeyS))?;
let url = "ws://127.0.0.1:8080/ws/";
let conn = connect_async(url).await?.0;
let (mut sink,mut stream) = conn.split();
websocket::read::send_image(&mut sink).await?;
websocket::read::read_input(&mut stream).await?;
Ok(())
}
struct MyApp {
name: String,
age: u32,
}
impl Default for MyApp {
fn default() -> Self {
Self {
name: "Arthur".to_owned(),
age: 42,
}
}
}
impl eframe::App for MyApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("My egui Application");
ui.horizontal(|ui| {
let name_label = ui.label("Your name: ");
ui.text_edit_singleline(&mut self.name)
.labelled_by(name_label.id);
});
ui.add(egui::Slider::new(&mut self.age, 0..=120).text("age"));
if ui.button("Click each year").clicked() {
self.age += 1;
}
ui.label(format!("Hello '{}', age {}", self.name, self.age));
});
}
}