diff --git a/src/u6.py b/src/u6.py new file mode 100644 index 0000000..ed0aa28 --- /dev/null +++ b/src/u6.py @@ -0,0 +1,28 @@ +import turtle + +t = turtle.Turtle() +t.speed(100) +t.penup() + +def a(): + t.dot(100, "red") + t.dot(85, "white") + t.setheading(-135) + t.forward(50) + t.write("80", font=("Arial", 48)) + +def b(): + t.dot(100, "red") + t.dot(85, "white") + t.setheading(-135) + t.forward(50) + t.write("6 t", font=("Arial", 48)) + +def main(): + func = input("a or b\n") + globals().get(func)() + + input() + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/src/u6.rs b/src/u6.rs index da0f5d9..0730096 100644 --- a/src/u6.rs +++ b/src/u6.rs @@ -1 +1,13 @@ -pub fn main() {} +use std::ffi::CString; +use pyo3::ffi::c_str; +use pyo3::prelude::*; + +static code: &'static str = include_str!("u6.py"); + +pub fn main() { + Python::with_gil(|py| { + let c = CString::new(code.as_bytes()).unwrap(); + let activator = PyModule::from_code(py, c.as_c_str(), c_str!("main.py"), c_str!("main")).unwrap(); + activator.call_method("main", (), None).unwrap(); + }) +}