Results 1 to 8 of 8

Thread: html/javascript page call python function

  1. #1

    html/javascript page call python function

    hi,

    I have a webview section into which is loaded a HTML page. I have a page where I have written some python functions. How do I call the python function that is in a particular page from the html/javascript page that is loaded into the webview? I have done this and it works:

    Code:
    Lianja.showDocument("python:resetidleflag()");


    But it crashes Lianja if I repeat it a few times. Lianja.execute works without crashing but I can use that to only call VFP functions and not python functions. And do I need to prefix the function name with the page name or something? But strange it does execute, except that after I call it a few times it crashes Lianja.

    In short is there another way of executing a python function which is in one of the pages from javascript, by using something other than showDocument?

    The best way to replicate this would be to call(from Lianja/VFP or javascript) a python function repeatedly from the console, using Lianja.showDocument("python:mypyfunc"). The first time it will execute, subsequently it will freeze/hang.


    Cheers,
    M&M
    Last edited by murali_mepath; 2014-05-19 at 00:24.

  2. #2
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,359
    Blog Entries
    22
    Hi Murali,

    Python (as well as PHP and JavaScript) functions are global in the App. They are not page specific.

    You can also call execPython(), execPHP() and execJavaScript() to load and execute external script files.

    if you want to report a bug then please submit a ticket on Lianja.com rather than notify us on the forums so that we can schedule to look into it. It also depends on what your Python function is doing. If it's messing about with threads or similar you may be interfering with the main GUI thread.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  3. #3
    Hi Barry,

    Thanks for the information. I figured out what causes the crash. Later I will post on what actually was the culprit. I need to get some sleep first :-D

    Cheers,
    Murali

  4. #4
    Hi Barry,

    I have a file in my application called convert.py.

    I would like to call it from a Custom VFP section.

    I have tried execPython("convert.py"), but that is not calling it.

    Is there something else I need to do call the py file?

    Thanks.

    Herb

  5. #5
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,359
    Blog Entries
    22
    Hi Herb,

    Lianja.evaluate("execPython('file.py')")
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  6. #6
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,188
    Hi Barry,

    So if Herb was in a prg, execPython() by itself would work, but not from a Custom Section? Trying to get my head around this (although I have no urge to build a custom section <s>).

    Hank

  7. #7
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,359
    Blog Entries
    22
    Oh sorry herb, I misread the question. From a custom VFP section execPython() should just work. Does it work from the console?
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  8. #8
    Hi Barry,

    Yes - once I loaded the file using loadlibrary(), all of my python functions are working using execPython("functionName()").

    Thanks.

    Herb

Tags for this Thread

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us