Skip to content

Commit 247b6b7

Browse files
committed
Reverted back to original naming of widget class.
1 parent f9ff2cf commit 247b6b7

File tree

2 files changed

+61
-28
lines changed

2 files changed

+61
-28
lines changed

example/example.ipynb

Lines changed: 56 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": null,
5+
"execution_count": 1,
66
"id": "5df2c405",
77
"metadata": {},
88
"outputs": [],
99
"source": [
10-
"from widget_code_input import CodeInputWidget\n",
10+
"from widget_code_input import WidgetCodeInput\n",
1111
"# import importlib\n",
1212
"# importlib.reload(code_input_widget)\n",
1313
"\n",
14-
"w = CodeInputWidget(\n",
14+
"w = WidgetCodeInput(\n",
1515
" function_name = \"my_function\",\n",
1616
" function_parameters = \"a, b\",\n",
1717
" docstring=\"\"\"\n",
@@ -25,17 +25,33 @@
2525
},
2626
{
2727
"cell_type": "code",
28-
"execution_count": null,
28+
"execution_count": 2,
2929
"id": "e74c9c9e",
3030
"metadata": {},
31-
"outputs": [],
31+
"outputs": [
32+
{
33+
"data": {
34+
"application/vnd.jupyter.widget-view+json": {
35+
"model_id": "80b8268cbfe0416494f266f6f8a19aa1",
36+
"version_major": 2,
37+
"version_minor": 1
38+
},
39+
"text/plain": [
40+
"WidgetCodeInput(code_theme='basicLight', docstring='\\n Input docstring here.\\n', function_body='# Give infor…"
41+
]
42+
},
43+
"execution_count": 2,
44+
"metadata": {},
45+
"output_type": "execute_result"
46+
}
47+
],
3248
"source": [
3349
"w"
3450
]
3551
},
3652
{
3753
"cell_type": "code",
38-
"execution_count": null,
54+
"execution_count": 3,
3955
"id": "4d389a14",
4056
"metadata": {},
4157
"outputs": [],
@@ -45,27 +61,28 @@
4561
},
4662
{
4763
"cell_type": "code",
48-
"execution_count": null,
64+
"execution_count": 4,
4965
"id": "2fc2b3ed",
5066
"metadata": {},
51-
"outputs": [],
67+
"outputs": [
68+
{
69+
"data": {
70+
"text/plain": [
71+
"3"
72+
]
73+
},
74+
"execution_count": 4,
75+
"metadata": {},
76+
"output_type": "execute_result"
77+
}
78+
],
5279
"source": [
5380
"my_function(1, 2)"
5481
]
5582
},
5683
{
5784
"cell_type": "code",
58-
"execution_count": null,
59-
"id": "601edb7d",
60-
"metadata": {},
61-
"outputs": [],
62-
"source": [
63-
"w.code_theme=\"nord\""
64-
]
65-
},
66-
{
67-
"cell_type": "code",
68-
"execution_count": null,
85+
"execution_count": 5,
6986
"id": "e90010bd",
7087
"metadata": {},
7188
"outputs": [],
@@ -75,12 +92,28 @@
7592
},
7693
{
7794
"cell_type": "code",
78-
"execution_count": null,
95+
"execution_count": 6,
7996
"id": "75900629",
8097
"metadata": {},
81-
"outputs": [],
98+
"outputs": [
99+
{
100+
"data": {
101+
"application/vnd.jupyter.widget-view+json": {
102+
"model_id": "9238263cacc04a728e878c13d8fac749",
103+
"version_major": 2,
104+
"version_minor": 1
105+
},
106+
"text/plain": [
107+
"WidgetCodeInput(code_theme='basicLight', docstring='\\n Input docstring here.\\n', function_body='# Give infor…"
108+
]
109+
},
110+
"execution_count": 6,
111+
"metadata": {},
112+
"output_type": "execute_result"
113+
}
114+
],
82115
"source": [
83-
"w2 = CodeInputWidget(\n",
116+
"w2 = WidgetCodeInput(\n",
84117
" function_name = \"my_function\",\n",
85118
" function_parameters = \"a, b, c\",\n",
86119
" docstring=\"\"\"\n",
@@ -109,7 +142,7 @@
109142
"name": "python",
110143
"nbconvert_exporter": "python",
111144
"pygments_lexer": "ipython3",
112-
"version": "3.11.7"
145+
"version": "3.10.12"
113146
}
114147
},
115148
"nbformat": 4,

src/widget_code_input/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
)
1919

2020

21+
bundler_output_dir = pathlib.Path(os.path.dirname(os.path.abspath(__file__))) / "./static"
2122

2223

23-
24-
class CodeInputWidget(anywidget.AnyWidget):
24+
class WidgetCodeInput(anywidget.AnyWidget):
2525
_esm = pathlib.Path(__file__).parent / "static" / "widget.js"
2626
_css = pathlib.Path(__file__).parent / "static" / "widget.css"
2727
widget_instance_count=0 # counter to keep track of number of widget instances in use
@@ -90,15 +90,15 @@ def __init__( # pylint: disable=too-many-arguments
9090
:param code_theme: the code theme of the code input box.
9191
"""
9292

93-
super(CodeInputWidget, self).__init__()
93+
super(WidgetCodeInput, self).__init__()
9494

9595
self.function_name = function_name
9696
self.function_parameters = function_parameters
9797
self.docstring = docstring
9898
self.function_body = function_body
9999
self.code_theme = code_theme
100-
self.widget_instance_count_trait=f"{CodeInputWidget.widget_instance_count}"
101-
CodeInputWidget.widget_instance_count+=1
100+
self.widget_instance_count_trait=f"{WidgetCodeInput.widget_instance_count}"
101+
WidgetCodeInput.widget_instance_count+=1
102102

103103

104104

0 commit comments

Comments
 (0)