@@ -26,7 +26,7 @@ def __init__(self, mpstate):
2626 super (chat , self ).__init__ (mpstate , "chat" , "OpenAI chat support" )
2727
2828 # register module and commands
29- self .add_command ('chat' , self .cmd_chat , "chat module" , ["show" ])
29+ self .add_command ('chat' , self .cmd_chat , "chat module" , ["hide" , " show" ])
3030
3131 # keep reference to mpstate
3232 self .mpstate = mpstate
@@ -42,29 +42,47 @@ def __init__(self, mpstate):
4242
4343 # create chat window (should be called from a new thread)
4444 def create_chat_window (self ):
45+ print ("Trying to create chat window" )
4546 if mp_util .has_wxpython :
46- # create chat window
47+ # create chat window, and return the chat_window object created
4748 self .chat_window = chat_window .chat_window (self .mpstate , self .wait_for_command_ack )
49+ # Call main loop of chat window
50+ self .chat_window .start ()
4851 else :
4952 print ("chat: wx support required" )
5053
5154 # show help on command line options
5255 def usage (self ):
53- return "Usage: chat <show>"
56+ return "Usage: chat <hide| show>"
5457
5558 # control behaviour of the module
5659 def cmd_chat (self , args ):
5760 if len (args ) == 0 :
5861 print (self .usage ())
5962 elif args [0 ] == "show" :
6063 self .show ()
64+ elif args [0 ] == "hide" :
65+ self .hide ()
6166 else :
6267 print (self .usage ())
6368
6469 # show chat input window
6570 def show (self ):
6671 self .chat_window .show ()
6772
73+ def hide (self ):
74+ self .chat_window .hide ()
75+
76+ def close (self ):
77+ self .chat_window .close ()
78+
79+ # unload function override for module interface
80+ def unload (self ):
81+ # Close the chat window
82+ self .close ()
83+ # Call the unload function of super class, to include its functionality
84+ super (chat , self ).unload ()
85+
6886 # handle mavlink packet
6987 def mavlink_packet (self , m ):
7088 if m .get_type () == 'COMMAND_ACK' :
0 commit comments