import ipywidgets as widgets
tab = widgets.Tab()
one = int(input())
two = int(input())
c = f"{one+two}"
tab.children = [widgets.HTML(c)]
tab.titles=[‘tab1’]
display(tab)
how about?
import ipywidgets as widgets
tab = widgets.Tab()
one = int(input())
two = int(input())
c = f'{one+two}'
tab.children = [widgets.HTML(f'{one}+{two} = {c}')]
tab.titles=['tab1']
display(tab)
It’s just the display i want the user inputs to be asked inside the tab.
It’s not exactly the same idea, but I would do it like this:
import ipywidgets as widgets
tab = widgets.Tab()
one = widgets.Text()
two = widgets.Text()
output = widgets.Output()
def display_result(event):
with output:
c = f'{int(one.value) + int(two.value)}'
display(widgets.HTML(f'{one.value}+{two.value} = {c}'))
button = widgets.Button(
tooltip='Click me',
icon='check',
)
button.on_click(display_result)
tab.children = [widgets.VBox([one, two, button, output])]
tab.titles=['tab1']
display(tab)
input not being a widget, I’m not sure if we can use it in a tab
Great work.I was trying to get both Button and VBox together but you figured it out.Is there any widget to store the values in database?
Not to my knowledge…
Why function returns are displayed inside the tab and function prints displayed outside the tab?
import ipywidgets as widgets
tab = widgets.Tab()
def fun():
print(“hello”)
tab.children = [widgets.HTML(fun())]
tab.titles = [‘tab1’]
display(tab)
import ipywidgets as widgets
tab = widgets.Tab()
def fun():
return “hello”
tab.children = [widgets.HTML(fun())]
tab.titles = [‘tab1’]
display(tab)
Above code i want to try with ‘html tabs’ instead of ‘jupyter tabs’ .The output is displayed in the next page not the same page.Can you have a look at it?I am not much familiar with django.
index.html
body {font-family: Arial;}/* Style the tab */
.tab {
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
}
/* Style the buttons inside the tab */
.tab button {
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
font-size: 17px;
}
/* Change background color of buttons on hover */
.tab button:hover {
background-color: #ddd;
}
/* Create an active/current tablink class */
.tab button.active {
background-color: #ccc;
}
/* Style the tab content */
.tabcontent {
display: none;
padding: 6px 12px;
border: 1px solid #ccc;
border-top: none;
}
views.py
from django.http import HttpResponse
from django.shortcuts import render
Create your views here.
def home_screen_view(request):
print(request.headers)
return render(request, “index.html”, {})
import cv2
import ipywidgets as widgets
button = widgets.Button(description=‘My Button’)
out = widgets.Output()
def simple_function(request):
with out:
return HttpResponse(f"{1+2}")
#button = widgets.Button(tooltip=‘Click me’, icon=‘check’)
button.on_click(simple_function)
displaying button and its output together
widgets.VBox([button, out])
I think this question no longer has much to do with the starting point or even with jupyter.
You should use a more general forum (like https://codereview.stackexchange.com)
Anyway, I don’t know Django well either.
Ok.I just saw profile name as djangoliv and asked.