volev 0 Posted August 9, 2022 (edited) Hi for all. Please help - how to run a function inside a Tkinter GUI application and get its result (or tuples of results). I successfully launch my application, but cannot understand, how do this simple step. for example: we have such function in __main__.py: def run_settings(): global vid vid.set(cv2.CAP_PROP_SETTINGS, 1) #launch webcam settings How I can run it from Delphi via Python4Delphi?! Sincerely Edited August 9, 2022 by volev Share this post Link to post
pyscripter 689 Posted August 9, 2022 Something like: var SL := TStringList.Create; try SL.LoadFromFile('__main__.py'); GetPythonEngine.ExecStrings(SL); Mainmodule.run_settings(); finally SL.Free; end; 1 Share this post Link to post
volev 0 Posted August 10, 2022 (edited) 14 hours ago, pyscripter said: Something like: var SL := TStringList.Create; try SL.LoadFromFile('__main__.py'); GetPythonEngine.ExecStrings(SL); Mainmodule.run_settings(); finally SL.Free; end; Thanks for answer Unfortunately it didn't work for me. I use classes in the program - one for the main window, the second additional for working with the camera. I tried to call a class instance method - an error, I wrote a function in python code that calls - the result is the same P4D_opencv_pillow.ZIP Edited August 10, 2022 by volev Share this post Link to post
volev 0 Posted August 11, 2022 Maximum simplifying of program: Only one Tkinter window with one arithmetic function. Program not working as it should (access violation error) P4D - 02.ZIP Share this post Link to post
volev 0 Posted August 12, 2022 Hi 4 all. I see that the problem is in the use of tkinter mainloop. If there are only analytical functions in the Python script, then the call works. I can't find a solution to this problem Share this post Link to post