comparison orpg/main.py @ 72:8bc955faf819 ornery-dev

Fixing a few mistakes from the last update. When Controls is finished I will be happy because users won't miss an file change due to these small updates.
author sirebral
date Thu, 20 Aug 2009 03:45:45 -0500
parents 449a8900f9ac
children fdcca00696ea
comparison
equal deleted inserted replaced
71:449a8900f9ac 72:8bc955faf819
33 from orpg.orpgCore import * 33 from orpg.orpgCore import *
34 from orpg_version import * 34 from orpg_version import *
35 from orpg.orpg_windows import * 35 from orpg.orpg_windows import *
36 36
37 from orpg.dirpath import dir_struct 37 from orpg.dirpath import dir_struct
38
39 from orpg import minidom
38 40
39 import orpg.player_list 41 import orpg.player_list
40 42
41 import orpg.tools.pluginui as pluginUI 43 import orpg.tools.pluginui as pluginUI
42 import orpg.tools.aliaslib 44 import orpg.tools.aliaslib
611 self.validate.config_file("layout.xml","default_layout.xml") 613 self.validate.config_file("layout.xml","default_layout.xml")
612 614
613 filename = dir_struct["user"] + "layout.xml" 615 filename = dir_struct["user"] + "layout.xml"
614 temp_file = open(filename) 616 temp_file = open(filename)
615 txt = temp_file.read() 617 txt = temp_file.read()
616 xml_dom = self.xml.parseXml(txt)._get_documentElement() 618 xml_dom = xml.parseXml(txt)._get_documentElement()
617 temp_file.close() 619 temp_file.close()
618 620
619 """ Would a component work better? 621 """ Would a component work better?
620 etree = ElementTree() 622 etree = ElementTree()
621 with open(dir_struct['user'] + 'layout.xml') as f: 623 with open(dir_struct['user'] + 'layout.xml') as f:
741 logger.debug("AUI Bindings Done") 743 logger.debug("AUI Bindings Done")
742 744
743 #Load the layout if one exists 745 #Load the layout if one exists
744 layout = xml_dom.getElementsByTagName("DockLayout") 746 layout = xml_dom.getElementsByTagName("DockLayout")
745 try: 747 try:
746 textnode = self.xml.safe_get_text_node(layout[0]) 748 textnode = xml.safe_get_text_node(layout[0])
747 self._mgr.LoadPerspective(textnode._get_nodeValue()) 749 self._mgr.LoadPerspective(textnode._get_nodeValue())
748 except: pass 750 except: pass
749 xml_dom.unlink() 751 xml_dom.unlink()
750 self.orpgLog.log("Perspective Loaded", ORPG_DEBUG) 752 self.orpgLog.log("Perspective Loaded", ORPG_DEBUG)
751 self._mgr.GetPane("Browse Server Window").Hide() 753 self._mgr.GetPane("Browse Server Window").Hide()
870 def saveLayout(self): 872 def saveLayout(self):
871 self.orpgLog.log("Enter orpgFrame->saveLayout()", ORPG_DEBUG) 873 self.orpgLog.log("Enter orpgFrame->saveLayout()", ORPG_DEBUG)
872 filename = dir_struct["user"] + "layout.xml" 874 filename = dir_struct["user"] + "layout.xml"
873 temp_file = open(filename) 875 temp_file = open(filename)
874 txt = temp_file.read() 876 txt = temp_file.read()
875 xml_dom = self.xml.parseXml(txt)._get_documentElement() 877 xml_dom = xml.parseXml(txt)._get_documentElement()
876 temp_file.close() 878 temp_file.close()
877 (x_size,y_size) = self.GetClientSize() 879 (x_size,y_size) = self.GetClientSize()
878 (x_pos,y_pos) = self.GetPositionTuple() 880 (x_pos,y_pos) = self.GetPositionTuple()
879 if self.IsMaximized(): max = 1 881 if self.IsMaximized(): max = 1
880 else: max = 0 882 else: max = 0
883 xml_dom.setAttribute("posx", str(x_pos)) 885 xml_dom.setAttribute("posx", str(x_pos))
884 xml_dom.setAttribute("posy", str(y_pos)) 886 xml_dom.setAttribute("posy", str(y_pos))
885 xml_dom.setAttribute("maximized", str(max)) 887 xml_dom.setAttribute("maximized", str(max))
886 layout = xml_dom.getElementsByTagName("DockLayout") 888 layout = xml_dom.getElementsByTagName("DockLayout")
887 try: 889 try:
888 textnode = self.xml.safe_get_text_node(layout[0]) 890 textnode = xml.safe_get_text_node(layout[0])
889 textnode._set_nodeValue(str(self._mgr.SavePerspective())) 891 textnode._set_nodeValue(str(self._mgr.SavePerspective()))
890 except: 892 except:
891 elem = self.xml.minidom.Element('DockLayout') 893 elem = minidom.Element('DockLayout')
892 elem.setAttribute("DO_NO_EDIT","True") 894 elem.setAttribute("DO_NO_EDIT","True")
893 textnode = self.xml.safe_get_text_node(elem) 895 textnode = xml.safe_get_text_node(elem)
894 textnode._set_nodeValue(str(self._mgr.SavePerspective())) 896 textnode._set_nodeValue(str(self._mgr.SavePerspective()))
895 xml_dom.appendChild(elem) 897 xml_dom.appendChild(elem)
896 temp_file = open(filename, "w") 898 temp_file = open(filename, "w")
897 temp_file.write(xml_dom.toxml(1)) 899 temp_file.write(xml_dom.toxml(1))
898 temp_file.close() 900 temp_file.close()