diff orpg/gametree/gametree.py @ 76:37a11fea3304 ornery-dev

More clean up. Images now posts a Chat Info post if image doesn't load.
author sirebral
date Sat, 22 Aug 2009 04:02:14 -0500
parents 449a8900f9ac
children 217fb049bd00 dcf4fbe09b70
line wrap: on
line diff
--- a/orpg/gametree/gametree.py	Fri Aug 21 21:49:42 2009 -0500
+++ b/orpg/gametree/gametree.py	Sat Aug 22 04:02:14 2009 -0500
@@ -38,6 +38,8 @@
 import time
 import os
 
+from orpg.orpg_xml import xml
+from orpg.tools.validate import validate
 from orpg.tools.orpg_log import logger
 from orpg.tools.decorators import debugging
 from orpg.gametree.nodehandlers import containers, forms, dnd3e, dnd35, chatmacro
@@ -79,9 +81,7 @@
     def __init__(self, parent, id):
         wx.TreeCtrl.__init__(self,parent,id,  wx.DefaultPosition, 
                 wx.DefaultSize,style=wx.TR_EDIT_LABELS | wx.TR_HAS_BUTTONS)
-        self.orpgLog = component.get('log')
-        self.validate = component.get('validate')
-        self.xml = component.get('xml')
+        #self.xml = component.get('xml') #
         self.settings = component.get('settings')
         self.session = component.get('session')
         self.chat = component.get('chat')
@@ -105,28 +105,25 @@
         self.last_save_dir = dir_struct["user"]
 
         #Create tree from default if it does not exist
-        self.validate.config_file("tree.xml","default_tree.xml")
+        validate.config_file("tree.xml","default_tree.xml")
         component.add("tree", self)
         #build tree
         self.root = self.AddRoot("Game Tree",self.icons['gear'])
         self.was_labeling = 0
         self.rename_flag = 0
         self.image_cache = {}
-        self.orpgLog.log("Exit game_tree", ORPG_DEBUG)
+        logger.debug("Exit game_tree")
 
     @debugging
     def add_nodehandler(self, nodehandler, nodeclass):
-        if not self.nodehandlers.has_key(nodehandler):
-            self.nodehandlers[nodehandler] = nodeclass
-        else:
-            self.orpgLog.log("Nodehandler for " + nodehandler + " already exists!", ORPG_DEBUG, True)
+        if not self.nodehandlers.has_key(nodehandler): self.nodehandlers[nodehandler] = nodeclass
+        else: logger.debug("Nodehandler for " + nodehandler + " already exists!")
 
     @debugging
     def remove_nodehandler(self, nodehandler):
         if self.nodehandlers.has_key(nodehandler):
             del self.nodehandlers[nodehandler]
-        else:
-            self.orpgLog.log("No nodehandler for " + nodehandler + " exists!", ORPG_DEBUG, True)
+        else: logger.debug("No nodehandler for " + nodehandler + " exists!")
 
     @debugging
     def init_nodehandlers(self):
@@ -183,17 +180,14 @@
                 cur = wx.StockCursor(wx.CURSOR_HAND)
                 self.SetCursor(cur)
                 self.drag_obj = obj
-        elif key_code == wx.WXK_LEFT:
-            self.Collapse(curSelection)
+        elif key_code == wx.WXK_LEFT: self.Collapse(curSelection)
         elif key_code == wx.WXK_DELETE:                          #  Handle the delete key
             if curSelection:
                 nextSelect = self.GetItemParent(curSelection)
                 self.on_del(evt)
                 try:
-                    if self.GetItemText(nextSelect) != "":
-                        self.SelectItem(nextSelect)
-                except:
-                    pass
+                    if self.GetItemText(nextSelect) != "": self.SelectItem(nextSelect)
+                except: pass
         elif key_code == wx.WXK_F2:
             self.rename_flag = 1
             self.EditLabel(curSelection)
@@ -213,7 +207,7 @@
             else: self.load_tree(file)
             return
         else:
-            self.validate.config_file("tree.xml","default_tree.xml")
+            validate.config_file("tree.xml","default_tree.xml")
             self.load_tree(error=1)
             return
 
@@ -224,15 +218,13 @@
         xml_dom = None
         xml_doc = None
         try:
-            self.orpgLog.log("Reading Gametree file: " + filename + "...", ORPG_INFO, True)
+            logger.info("Reading Gametree file: " + filename + "...", True)
             tmp = open(filename,"r")
-            xml_doc = self.xml.parseXml(tmp.read())
+            xml_doc = xml.parseXml(tmp.read())
             tmp.close()
-            if xml_doc == None:
-                pass
-            else:
-                xml_dom = xml_doc._get_documentElement()
-            self.orpgLog.log("done.", ORPG_INFO, True)
+            if xml_doc == None: pass
+            else: xml_dom = xml_doc._get_documentElement()
+            logger.info("done.", True)
 
         except IOError:
             emsg = "Gametree Missing!\n"+filename+" cannot be found.\n\n"\
@@ -240,7 +232,7 @@
                    "(Selecting 'No' will cause a new default gametree to be generated)"
             fn = filename[ ((filename.rfind(os.sep))+len(os.sep)):]
             self.locate_valid_tree("Gametree Error", emsg, dir_struct["user"], fn)
-            self.orpgLog.log(emsg, ORPG_GENERAL)
+            logger.general(emsg)
             return
 
         if not xml_dom:
@@ -255,7 +247,7 @@
                    "Would you like to select a different gametree file to use?\n"\
                    "(Selecting 'No' will cause a new default gametree to be generated)"
             self.locate_valid_tree("Corrupt Gametree!", emsg, dir_struct["user"], fn)
-            self.orpgLog.log(emsg, ORPG_GENERAL)
+            logger.general(emsg)
             return
 
         if xml_dom._get_tagName() != "gametree":
@@ -264,47 +256,45 @@
                    "Would you like to select a different gametree file to use?\n"\
                    "(Selecting 'No' will cause a new default gametree to be generated)"
             self.locate_valid_tree("Invalid Gametree!", emsg, dir_struct["user"], fn)
-            self.orpgLog.log(emsg, ORPG_DEBUG)
-            self.orpgLog.log("Exit game_tree->load_tree(self, filename, error)", ORPG_DEBUG)
+            logger.debug(emsg)
             return
 
         # get gametree version - we could write conversion code here!
         self.master_dom = xml_dom
-        self.orpgLog.log("Master Dom Set", ORPG_DEBUG)
+        logger.debug("Master Dom Set")
 
         try:
             version = self.master_dom.getAttribute("version")
             # see if we should load the gametree
             loadfeatures = int(self.settings.get_setting("LoadGameTreeFeatures"))
             if loadfeatures:
-                xml_dom = self.xml.parseXml(open(dir_struct["template"]+"feature.xml","r").read())
+                xml_dom = xml.parseXml(open(dir_struct["template"]+"feature.xml","r").read())
                 xml_dom = xml_dom._get_documentElement()
                 xml_dom = self.master_dom.appendChild(xml_dom)
                 self.settings.set_setting("LoadGameTreeFeatures","0")
 
             ## load tree
-            self.orpgLog.log("Features loaded (if required)", ORPG_DEBUG)
+            logger.debug("Features loaded (if required)")
             self.CollapseAndReset(self.root)
             children = self.master_dom._get_childNodes()
-            self.orpgLog.log("Parsing Gametree Nodes ", ORPG_INFO, True)
+            logger.info("Parsing Gametree Nodes ", True)
             for c in children:
                 print '.',
                 self.load_xml(c,self.root)
-            self.orpgLog.log("done", ORPG_INFO, True)
+            logger.info("done", True)
             self.Expand(self.root)
             self.SetPyData(self.root,self.master_dom)
             if error != 1:
                 infile = open(filename, "rb")
                 outfile = open(dir_struct["user"]+"lastgood.xml", "wb")
                 outfile.write(infile.read())
-            else:
-                self.orpgLog.log("Not overwriting lastgood.xml file.", ORPG_INFO, True)
+            else: logger.info("Not overwriting lastgood.xml file.", True)
 
         except Exception, e:
-            self.orpgLog.log(traceback.format_exc(), ORPG_GENERAL)
+            logger.general(traceback.format_exc())
             wx.MessageBox("Corrupt Tree!\nYour game tree is being regenerated. To\nsalvage a recent version of your gametree\nexit OpenRPG and copy the lastgood.xml\nfile in your myfiles directory\nto "+filename+ "\nin your myfiles directory.\nlastgood.xml WILL BE OVERWRITTEN NEXT TIME YOU RUN OPENRPG.")
             os.rename(filename,filename+".corrupt")
-            self.validate.config_file("tree.xml","default_tree.xml")
+            validate.config_file("tree.xml","default_tree.xml")
             self.load_tree(error=1)
 
     @debugging
@@ -383,15 +373,11 @@
         in_tag = 0
         for x in xrange(len(player[0])) :
             if player[0][x] == "<" or player[0][x] == ">" or in_tag == 1 :
-                if player[0][x] == "<" :
-                    in_tag = 1
-                elif player[0][x] == ">" :
-                    in_tag = 0
-                else :
-                    pass
-            else :
-                ret_string = ret_string + player[0][x]
-        self.orpgLog.log(ret_string, ORPG_DEBUG)
+                if player[0][x] == "<" : in_tag = 1
+                elif player[0][x] == ">" : in_tag = 0
+                else: pass
+            else: ret_string = ret_string + player[0][x]
+        logger.debug(ret_string)
         return ret_string
 
     @debugging
@@ -414,20 +400,16 @@
         myid = self.session.get_id()
         me = None
         for p in players:
-            if p[2] != myid:
-                opts.append("("+p[2]+") " + self.strip_html(p))
-            else:
-                me = p
-        if len(opts):
-            players.remove(me)
+            if p[2] != myid: opts.append("("+p[2]+") " + self.strip_html(p))
+            else: me = p
+        if len(opts): players.remove(me)
         if len(opts):
             dlg = orpgMultiCheckBoxDlg( self.GetParent(),opts,"Select Players:","Whisper To",[] )
             if dlg.ShowModal() == wx.ID_OK:
                 item = self.GetSelection()
                 obj = self.GetPyData(item)
                 selections = dlg.get_selections()
-                if len(selections) == len(opts):
-                    self.chat.ParsePost(obj.tohtml(),True,True)
+                if len(selections) == len(opts): self.chat.ParsePost(obj.tohtml(),True,True)
                 else:
                     player_ids = []
                     for s in selections:
@@ -481,23 +463,19 @@
         myid = self.session.get_id()
         me = None
         for p in players:
-            if p[2] != myid:
-                opts.append("("+p[2]+") " + self.strip_html(p))
-            else:
-                me = p
+            if p[2] != myid: opts.append("("+p[2]+") " + self.strip_html(p))
+            else: me = p
         if len(opts):
             players.remove(me)
             dlg = orpgMultiCheckBoxDlg( None, opts, "Select Players:", "Send To", [] )
             if dlg.ShowModal() == wx.ID_OK:
                 item = self.GetSelection()
                 obj = self.GetPyData(item)
-                xmldata = "<tree>" + self.xml.toxml(obj) + "</tree>"
+                xmldata = "<tree>" + xml.toxml(obj) + "</tree>"
                 selections = dlg.get_selections()
-                if len(selections) == len(opts):
-                    self.session.send(xmldata)
+                if len(selections) == len(opts): self.session.send(xmldata)
                 else:
-                    for s in selections:
-                        self.session.send(xmldata,players[s][2])
+                    for s in selections: self.session.send(xmldata,players[s][2])
             dlg.Destroy()
 
     @debugging
@@ -519,10 +497,10 @@
         name = "New " + obj.master_dom.getAttribute("name")
         icon = obj.master_dom.getAttribute("icon")
         xml_data = "<nodehandler name=\""+name+"\" icon=\"" + icon + "\" module=\"core\" class=\"node_loader\" >"
-        xml_data += self.xml.toxml(obj)
+        xml_data += xml.toxml(obj)
         xml_data += "</nodehandler>"
         self.insert_xml(xml_data)
-        self.orpgLog.log(xml_data, ORPG_DEBUG)
+        logger.debug(xml_data)
 
     @debugging
     def on_clone(self, evt):
@@ -531,9 +509,8 @@
         if obj.can_clone():
             parent_node = self.GetItemParent(item)
             prev_sib = self.GetPrevSibling(item)
-            if not prev_sib.IsOk():
-                prev_sib = parent_node
-            xml_dom = self.xml.parseXml(self.xml.toxml(obj))
+            if not prev_sib.IsOk(): prev_sib = parent_node
+            xml_dom = xml.parseXml(xml.toxml(obj))
             xml_dom = xml_dom._get_firstChild()
             parent = obj.master_dom._get_parentNode()
             xml_dom = parent.insertBefore(xml_dom, obj.master_dom)
@@ -566,7 +543,7 @@
         self.master_dom.setAttribute("version",GAMETREE_VERSION)
         self.settings.set_setting("gametree",filename)
         file = open(filename,"w")
-        file.write(self.xml.toxml(self.master_dom,1))
+        file.write(xml.toxml(self.master_dom,1))
         file.close()
 
     @debugging
@@ -607,8 +584,7 @@
     @debugging
     def on_tree_prop(self, evt):
         dlg = gametree_prop_dlg(self, self.settings)
-        if dlg.ShowModal() == wx.ID_OK:
-            pass
+        if dlg.ShowModal() == wx.ID_OK: pass
         dlg.Destroy()
 
     @debugging
@@ -640,34 +616,25 @@
                 try:
                     status_value = parent_obj.master_dom.getAttribute('status')
                     name = parent_obj.master_dom.getAttribute('name')
-                except:
-                    status_value = "none"
+                except: status_value = "none"
                 parent_obj = parent_obj.master_dom._get_parentNode()
                 while status_value!="useful" and status_value!="useless":
                     try:
                         status_value = parent_obj.getAttribute('status')
                         name = parent_obj.getAttribute('name')
-                        if status_value == "useless":
-                            break
-                        elif status_value == "useful":
-                            break
-                    except:
-                        status_value = "none"
-                    try:
-                        parent_obj = parent_obj._get_parentNode()
-                    except:
-                        break
+                        if status_value == "useless": break
+                        elif status_value == "useful": break
+                    except: status_value = "none"
+                    try: parent_obj = parent_obj._get_parentNode()
+                    except: break
                 if status_value == "useful":
                     dlg = wx.MessageDialog(self, `name` + "  And everything beneath it are considered useful.  \n\nAre you sure you want to delete this item?",'Important Item',wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
-                    if dlg.ShowModal() == wx.ID_YES:
-                        obj.delete()
-                else:
-                    obj.delete()
+                    if dlg.ShowModal() == wx.ID_YES: obj.delete()
+                else: obj.delete()
         except:
             if self.GetSelection() == self.GetRootItem():
                 msg = wx.MessageDialog(None,"You can't delete the root item.","Delete Error",wx.OK)
-            else:
-                msg = wx.MessageDialog(None,"Unknown error deleting node.","Delete Error",wx.OK)
+            else: msg = wx.MessageDialog(None,"Unknown error deleting node.","Delete Error",wx.OK)
             msg.ShowModal()
             msg.Destroy()
 
@@ -683,40 +650,37 @@
     def on_send_to_map(self, evt):
         item = self.GetSelection()
         obj = self.GetPyData(item)
-        if hasattr(obj,"on_send_to_map"):
-            obj.on_send_to_map(evt)
+        if hasattr(obj,"on_send_to_map"): obj.on_send_to_map(evt)
 
     @debugging
     def insert_xml(self, txt):
-        self.orpgLog.log("Enter game_tree->insert_xml(self, txt)", ORPG_DEBUG)
         #Updated to allow safe merging of gametree files
         #without leaving an unusable and undeletable node.
         #                               -- Snowdog 8/03
-        xml_dom = self.xml.parseXml(txt)
+        xml_dom = xml.parseXml(txt)
         if xml_dom == None:
             wx.MessageBox("Import Failed: Invalid or missing node data")
-            self.orpgLog.log("Import Failed: Invalid or missing node data", ORPG_DEBUG)
-            self.orpgLog.log("Exit game_tree->insert_xml(self, txt)", ORPG_DEBUG)
+            logger.debug("Import Failed: Invalid or missing node data")
+            logger.debug("Exit game_tree->insert_xml(self, txt)")
             return
         xml_temp = xml_dom._get_documentElement()
 
         if not xml_temp:
             wx.MessageBox("Error Importing Node or Tree")
-            self.orpgLog.log("Error Importing Node or Tree", ORPG_DEBUG)
-            self.orpgLog.log("Exit game_tree->insert_xml(self, txt)", ORPG_DEBUG)
+            logger.debug("Error Importing Node or Tree")
+            logger.debug("Exit game_tree->insert_xml(self, txt)")
             return
 
         if xml_temp._get_tagName() == "gametree":
             children = xml_temp._get_childNodes()
-            for c in children:
-                self.load_xml(c, self.root)
-            self.orpgLog.log("Exit game_tree->insert_xml(self, txt)", ORPG_DEBUG)
+            for c in children: self.load_xml(c, self.root)
+            logger.debug("Exit game_tree->insert_xml(self, txt)")
             return
 
         if not xml_dom:
             wx.MessageBox("XML Error")
-            self.orpgLog.log("XML Error", ORPG_DEBUG)
-            self.orpgLog.log("Exit game_tree->insert_xml(self, txt)", ORPG_DEBUG)
+            logger.debug("XML Error")
+            logger.debug("Exit game_tree->insert_xml(self, txt)")
             return
 
         xml_dom = xml_dom._get_firstChild()
@@ -731,7 +695,7 @@
         self.icons = { }
         self._imageList= wx.ImageList(16,16,False)
         man = open(dir_struct["icon"]+"icons.xml","r")
-        xml_dom = self.xml.parseXml(man.read())
+        xml_dom = xml.parseXml(man.read())
         man.close()
         xml_dom = xml_dom._get_documentElement()
         node_list = xml_dom._get_childNodes()
@@ -748,39 +712,34 @@
         i = 0
         text = xml_dom.getAttribute("name")
         icon = xml_dom.getAttribute("icon")
-        if self.icons.has_key(icon):
-            i = self.icons[icon]
+        if self.icons.has_key(icon): i = self.icons[icon]
         name = xml_dom._get_nodeName()
-        self.orpgLog.log("Text, icon and name set\n" + text + "\n" + icon + "\n" + name, ORPG_DEBUG)
+        logger.debug("Text, icon and name set\n" + text + "\n" + icon + "\n" + name)
         if prev_node:
-            if prev_node == parent_node:
-                new_tree_node = self.PrependItem(parent_node, text, i, i)
-            else:
-                new_tree_node = self.InsertItem(parent_node,prev_node, text, i, i)
-        else:
-            new_tree_node = self.AppendItem(parent_node, text, i, i)
+            if prev_node == parent_node: new_tree_node = self.PrependItem(parent_node, text, i, i)
+            else: new_tree_node = self.InsertItem(parent_node,prev_node, text, i, i)
+        else: new_tree_node = self.AppendItem(parent_node, text, i, i)
 
-        self.orpgLog.log("Node Added to tree", ORPG_DEBUG)
+        logger.debug("Node Added to tree")
         #create a nodehandler or continue loading xml into tree
         if name == "nodehandler":
             #wx.BeginBusyCursor()
-            self.orpgLog.log("We have a Nodehandler", ORPG_DEBUG)
+            logger.debug("We have a Nodehandler")
             try:
                 py_class = xml_dom.getAttribute("class")
-                self.orpgLog.log("nodehandler class: " + py_class, ORPG_DEBUG)
+                logger.debug("nodehandler class: " + py_class)
                 if not self.nodehandlers.has_key(py_class):
                     raise Exception, "Unknown Nodehandler for " + py_class
                 self.nodes[self.id] = self.nodehandlers[py_class](xml_dom, new_tree_node)
                 self.SetPyData(new_tree_node, self.nodes[self.id])
-                self.orpgLog.log("Node Data set", ORPG_DEBUG)
+                logger.debug("Node Data set")
                 bmp = self.nodes[self.id].get_scaled_bitmap(16,16)
-                if bmp:
-                    self.cached_load_of_image(bmp,new_tree_node,)
-                self.orpgLog.log("Node Icon loaded", ORPG_DEBUG)
+                if bmp: self.cached_load_of_image(bmp,new_tree_node,)
+                logger.debug("Node Icon loaded")
                 self.id = self.id + 1
             except Exception, er:
-                self.orpgLog.log(traceback.format_exc(), ORPG_GENERAL)
- 		        #self.orpgLog.log("Error Info: " + xml_dom.getAttribute("class") + "\n" + str(er), ORPG_GENERAL, True)?indent?
+                logger.general(traceback.format_exc())
+ 		        #logger.debug("Error Info: " + xml_dom.getAttribute("class") + "\n" + str(er), True)?indent?
                 self.Delete(new_tree_node)
                 parent = xml_dom._get_parentNode()
                 parent.removeChild(xml_dom)
@@ -811,12 +770,9 @@
         if item.IsOk():
             obj = self.GetPyData(item)
             self.SelectItem(item)
-            if(isinstance(obj,core.node_handler)):
-                obj.on_rclick(evt)
-            else:
-                self.PopupMenu(self.top_menu)
-        else:
-            self.PopupMenu(self.top_menu,pt)
+            if(isinstance(obj,core.node_handler)): obj.on_rclick(evt)
+            else: self.PopupMenu(self.top_menu)
+        else: self.PopupMenu(self.top_menu,pt)
 
     @debugging
     def on_ldclick(self, evt):
@@ -829,14 +785,10 @@
             if(isinstance(obj,core.node_handler)):
                 if not obj.on_ldclick(evt):
                     action = self.settings.get_setting("treedclick")
-                    if action == "use":
-                        obj.on_use(evt)
-                    elif action == "design":
-                        obj.on_design(evt)
-                    elif action == "print":
-                        obj.on_html_view(evt)
-                    elif action == "chat":
-                        self.on_send_to_chat(evt)
+                    if action == "use": obj.on_use(evt)
+                    elif action == "design": obj.on_design(evt)
+                    elif action == "print": obj.on_html_view(evt)
+                    elif action == "chat": self.on_send_to_chat(evt)
 
     @debugging
     def on_left_down(self, evt):
@@ -849,8 +801,7 @@
         elif (flag & wx.TREE_HITTEST_ONITEMLABEL) == wx.TREE_HITTEST_ONITEMLABEL and self.IsSelected(item):
             #  this next if tests to ensure that the mouse up occurred over a label, and not the icon
             self.rename_flag = 1
-        else:
-            self.SelectItem(item)
+        else: self.SelectItem(item)
         evt.Skip()
 
     @debugging
@@ -877,13 +828,11 @@
         if txt != "":
             obj = self.GetPyData(item)
             obj.master_dom.setAttribute('name',txt)
-        else:
-            evt.Veto()
+        else: evt.Veto()
 
     @debugging
     def on_label_begin(self, evt):
-        if not self.rename_flag:
-            evt.Veto()
+        if not self.rename_flag: evt.Veto()
         else:
             self.was_labeling = 1
             item = evt.GetItem()
@@ -906,13 +855,12 @@
     def is_parent_node(self, node, compare_node):
         parent_node = self.GetItemParent(node)
         if compare_node == parent_node:
-            self.orpgLog.log("parent node", ORPG_DEBUG)
+            logger.debug("parent node")
             return 1
         elif parent_node == self.root:
-            self.orpgLog.log("not parent", ORPG_DEBUG)
+            logger.debug("not parent")
             return 0
-        else:
-            return self.is_parent_node(parent_node, compare_node)
+        else: return self.is_parent_node(parent_node, compare_node)
 
 CTRL_TREE_FILE = wx.NewId()
 CTRL_YES = wx.NewId()
@@ -986,12 +934,8 @@
     def on_ok(self,evt):
         self.settings.set_setting("gametree",self.ctrls[CTRL_TREE_FILE].GetValue())
         self.settings.set_setting("SaveGameTreeOnExit",str(self.ctrls[CTRL_YES].GetValue()))
-        if self.ctrls[CTRL_USE].GetValue():
-            self.settings.set_setting("treedclick","use")
-        elif self.ctrls[CTRL_DESIGN].GetValue():
-            self.settings.set_setting("treedclick","design")
-        elif self.ctrls[CTRL_PRINT].GetValue():
-            self.settings.set_setting("treedclick","print")
-        elif self.ctrls[CTRL_CHAT].GetValue():
-            self.settings.set_setting("treedclick","chat")
+        if self.ctrls[CTRL_USE].GetValue(): self.settings.set_setting("treedclick","use")
+        elif self.ctrls[CTRL_DESIGN].GetValue(): self.settings.set_setting("treedclick","design")
+        elif self.ctrls[CTRL_PRINT].GetValue(): self.settings.set_setting("treedclick","print")
+        elif self.ctrls[CTRL_CHAT].GetValue(): self.settings.set_setting("treedclick","chat")
         self.EndModal(wx.ID_OK)