This commit is contained in:
DavidOnTop 2024-12-06 08:54:05 +01:00
parent 65411da66c
commit b865ea307e
No known key found for this signature in database
GPG key ID: 5D05538A45D5149F
2 changed files with 41 additions and 1 deletions

28
src/u6.py Normal file
View file

@ -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()

View file

@ -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();
})
}