33 lines
863 B
Python
33 lines
863 B
Python
from IPython.display import display
|
|
from IPython import get_ipython
|
|
import ipywidgets as widgets
|
|
|
|
snippets = {
|
|
"📥 Start": '''
|
|
from build123d import *
|
|
from jupyter_cadquery import show, show_all,open_viewer, show_clear
|
|
from IPython.display import display
|
|
import ipywidgets as widgets''',
|
|
|
|
"🧲 Import STEP": '''from build123d import *
|
|
model = import_step("element.step")
|
|
show_object(model)''',
|
|
|
|
"🧪 Cylinder": '''from build123d import *
|
|
Cylinder(30, 80)'''
|
|
}
|
|
|
|
dropdown = widgets.Dropdown(
|
|
options=["-- wybierz snippet --"] + list(snippets.keys()),
|
|
description="Snippet:"
|
|
)
|
|
|
|
def on_select(change):
|
|
key = change["new"]
|
|
if key != "-- wybierz snippet --":
|
|
get_ipython().set_next_input(snippets[key], replace=False)
|
|
dropdown.value = "-- wybierz snippet --"
|
|
|
|
dropdown.observe(on_select, names="value")
|
|
display(dropdown)
|