ipyvuetify 在用户更改时捕获文本字段的用户输入值

ipyvuetify catch the user input value of text Field when user changes it

我正在使用 vuetify 来捕捉用户的输入,如下所示:

%pip install ipyvuetify
%pip install ipywidgets
import random 
import ipywidgets as widget
from ipywidgets import VBox
import ipyvuetify as v

v_nr = v.TextField(label='Enter a number here:', placeholder='Enter here data', value = '2342354')
v_nr.value='The value was changed sucssefully'
v_btn_load    = v.Btn(class_='mx-2 light-red darken-1', children=['the data'])
w_Output = widget.Output()
infostring    = ' this is the infostring there'
other_info    = v.Html(tag='p', children=[infostring])

Output = VBox([w_Output])
total_widgets = v.Col(children = [v_nr,v_btn_load,w_Output,other_info])

def on_click_v_btn_load(widget, event, data):
    with w_Output:
        w_Output.clear_output()
        n = random.random()
        display(str(n) + '  :' + v_nr.value)
    other_info.children.append(' APPEND ')
        
    
v_btn_load.on_event('click', on_click_v_btn_load)
container = v.Container(children=[total_widgets])
display(container)

我想解决的问题:

  1. 可视化效果不错,但是当更改输入中的值时,它不会被按钮事件处理程序中的 v_application.value 捕获。尽管如此,在第二行中:v_nr.value='The value was changed successfully' 该值已以编程方式更改。您必须如何编写代码才能在用户更改输入文本时更改输入文本的值?
  2. other_info.children.append(' APPEND ') 似乎不起作用,但不报告任何错误。令人期待的是每次点击按钮时都会附加GORILA这个词,但事实并非如此。

有什么想法吗? 谢谢

注意:为方便起见,包含 %pips。

v_nr 的 属性 访问内容是 'v_model',而不是 'value'。

只要简单地改变它就可以了:

import random 
import ipywidgets as widget
from ipywidgets import VBox
import ipyvuetify as v

v_nr = v.TextField(label='Enter a number here:', placeholder='Enter here data', v_model = '2342354')
v_nr.v_model='The value was changed sucssefully'
v_btn_load    = v.Btn(class_='mx-2 light-red darken-1', children=['the data'])
w_Output = widget.Output()
infostring    = ' this is the infostring there'
other_info    = v.Html(tag='p', children=[infostring])

Output = VBox([w_Output])
total_widgets = v.Col(children = [v_nr,v_btn_load,w_Output,other_info])

def on_click_v_btn_load(widget, event, data):
    with w_Output:
        w_Output.clear_output()
        n = random.random()
        display(str(n) + '  :' + v_nr.v_model)
    other_info.children.append(' APPEND ')
        
    
v_btn_load.on_event('click', on_click_v_btn_load)
container = v.Container(children=[total_widgets])
display(container)