Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

362
Visualizações
how to call a python function from javascript function in brython

I want to call a python function from javascript in brython but it doesn't work. Who can help me ?


<!-- HTML CODE -->

    <input type="text" id="height2" />
    <br />
    <br />
    <input type="text" id="width2" />
    <br />
    <br />
    <input type="text" id="color2" />
    <br />
    <br />
    <button onclick="draw_js_2()">Draw</button>
    <div id="shap2"></div>



// javascript CODE

function draw_js_2() {
    var height2 = parseInt(document.getElementById('height2').value);
    var width2 = parseInt(document.getElementById('width2').value);
    var color2 = document.getElementById('color2').value;

    // call the python function
    draw_br_2(height2, width2, color2);
}


# PYTHON CODE


shap2 = document['shap2']

def draw_br_2(height2, width2, color2):
    shap2.attrs['style'] = f"background-color: {color2}"
    shap2.height = height2
    shap2.width = width2

window.draw_br_2 = draw_br_2


I want to get the data from template by javascript and passing them to a python function to draw a square. but it doesn't work! i don't know why ? please help me ! Thanks

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda