python-eel / Eel

A little Python library for making simple Electron-like HTML/JS GUI apps
MIT License
6.44k stars 587 forks source link

Using python unittest stdout values on html page #565

Closed ghost closed 2 years ago

ghost commented 2 years ago

Describe the problem

Hello kindly assist Using Eel I am trying to run simple unitest in python & want to display live output of the unitest running status in text area of the html page similar to status of auto-py-to-exe when compilation is started we can see pyinstaller logs status on the auto-py-to-exe window in the output window . For this I have created a simple html ui with a button which runs the unitest function from the python and a simple text area box currently I am able to run the python function on button click on the html page but I have no clue how can I return the running status on the html page

I want to show the below running status on text area with id as textarea

Ran 1 test in 0.000s
OK

Code snippet(s) Here is some code that can be easily used to reproduce the problem or understand what I need help with

Current js code

Document.addeventlistner('click'', async function something () {Document.getelementbyid('textarea') . inner text = eel.try1()();}

Python code

@eel.expose()
Def try1():

class simpletest(unittest.testcase): 

    # returns true or false.  

    def test(self):         

        self.asserttrue(true) 

if __name__ == '__main__': 

    unittest.main()

Desktop (please complete the following information):

Smartphone (please complete the following information):