Skip to content

Commit

Permalink
chat: run GUI in a separate process
Browse files Browse the repository at this point in the history
  • Loading branch information
rmackay9 committed Dec 12, 2023
1 parent feccdb7 commit fc28a63
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions MAVProxy/modules/mavproxy_chat/chat_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Chat window for input and output of AI chat
'''

from MAVProxy.modules.lib import multiproc
from MAVProxy.modules.lib.wx_loader import wx
from MAVProxy.modules.mavproxy_chat import chat_openai, chat_voice_to_text
from threading import Thread, Lock
Expand All @@ -17,6 +18,11 @@ def __init__(self, mpstate):
# lock to prevent multiple threads sending text to the assistant at the same time
self.send_lock = Lock()

self.child = multiproc.Process(target=self.child_task)
self.child.start()

def child_task(self):
'''child process - this holds all the GUI elements'''
self.app = wx.App()
self.frame = wx.Frame(None, title="Chat", size=(650, 200))

Expand Down Expand Up @@ -72,13 +78,7 @@ def __init__(self, mpstate):
# create chat_voice_to_text object
self.chat_voice_to_text = chat_voice_to_text.chat_voice_to_text()

# run chat window in a separate thread
self.thread = Thread(target=self.idle_task)
self.thread.start()

# update function rapidly called by mavproxy
def idle_task(self):
# update chat window
# run the GUI event loop
self.app.MainLoop()

# show the chat window
Expand Down

0 comments on commit fc28a63

Please sign in to comment.