This is just the example as shown in the PyBridge tutorial.
Does anyone have any idea why the Wait For here doesn't work? Is Complete set somehow?
I tested Py.Flush.Completed but it is false.
Does anyone have any idea why the Wait For here doesn't work? Is Complete set somehow?
I tested Py.Flush.Completed but it is false.
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
Py.Initialize(Me, "Py")
Dim opt As PyOptions = Py.CreateOptions("Python/python/python.exe")
Py.Start(opt)
Wait For Py_Connected (Success As Boolean)
If Success = False Then
LogError("Failed to start Python process.")
Return
End If
PrintPythonVersion
Dim Tuple As PyWrapper = Py.WrapObject(Array(1, 2, 3, 4, 5))
Tuple.Print
Tuple.TypeOf.Print2("type is:", "", False)
Dim list As PyWrapper = Tuple.ToList
list.Run("append").Arg(6)
list.Print
Wait For (Py.Flush) Complete (Success As Boolean) 'NOT waiting
Log("after " & Success)
Log(Py.Flush.Completed)
End Sub
'Logs:
'Server Is listening on port: 62118
'Python path: C:\Program Files\Anywhere Software\B4J\libraries\Python\python\python.exe
'Call B4XPages.GetManager.LogEvents = True To enable logging B4XPages events.
'connected
'starting PyBridge v1.00
'watchdog set To 30 seconds
'Connecting To port: 62118
'after true
'false
'Python version: 3.12.8 (tags/v3.12.8:2dc476b, Dec 3 2024, 19:30:04) [MSC v.1942 64 Bit (AMD64)]
'(1, 2, 3, 4, 5)
'type is: <class 'tuple'>
'[1, 2, 3, 4, 5, 6]