annotate orpg/gametree/nodehandlers/rpg_grid.py @ 173:0dde29a41614 alpha

Traipse Alpha 'OpenRPG' {100107-00} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Keeping up with Beta) New Features: Added Bookmarks Added 'boot' command to remote admin Added confirmation window for sent nodes Minor changes to allow for portability to an OpenSUSE linux OS Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Zoom Mouse plugin added Images added to Plugin UI Switching to Element Tree Map efficiency, from FlexiRPG Added Status Bar to Update Manager New TrueDebug Class in orpg_log (See documentation for usage) Portable Mercurial Tip of the Day added, from Core and community New Reference Syntax added for custom PC sheets New Child Reference for gametree New Parent Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added Dieroller structure from Core Added 7th Sea die roller method; ie [7k3] = [7d10.takeHighest(3).open(10)] New 'Mythos' System die roller added Added new vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)]. Includes support for Mythos roller New EZ_Tree Reference system. Push a button, Traipse the tree, get a reference (Alpha!!) Fixes: Fix to Text based Server Fix to Remote Admin Commands Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Fix to Map from gametree not showing to all clients Fix to gametree about menus Fix to Password Manager check on startup Fix to PC Sheets from tool nodes. They now use the tabber_panel Fixed Whiteboard ID to prevent random line or text deleting. Modified ID's to prevent non updated clients from ruining the fix. default_manifest.xml renamed to default_upmana.xml Fix to Update Manager; cleaner clode for saved repositories Fixes made to Settings Panel and no reactive settings when Ok is pressed Fixes to Alternity roller's attack roll. Uses a simple Tuple instead of a Splice Fix to Use panel of Forms and Tabbers. Now longer enters design mode
author sirebral
date Thu, 07 Jan 2010 01:53:12 -0600
parents bf799efe7a8a
children ff6cbd2b7620
rev   line source
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
1 # Copyright (C) 2000-2001 The OpenRPG Project
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
2 #
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
3 # openrpg-dev@lists.sourceforge.net
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
4 #
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
5 # This program is free software; you can redistribute it and/or modify
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
6 # it under the terms of the GNU General Public License as published by
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
7 # the Free Software Foundation; either version 2 of the License, or
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
8 # (at your option) any later version.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
9 #
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
10 # This program is distributed in the hope that it will be useful,
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
13 # GNU General Public License for more details.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
14 #
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
15 # You should have received a copy of the GNU General Public License
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
16 # along with this program; if not, write to the Free Software
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
18 # --
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
19 #
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
20 # File: rpg_grid.py
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
21 # Author: Chris Davis
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
22 # Maintainer:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
23 # Version:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
24 # $Id: rpg_grid.py,v 1.20 2006/11/15 12:11:24 digitalxero Exp $
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
25 #
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
26 # Description: The file contains code for the grid nodehanlers
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
27 #
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
28
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
29 __version__ = "$Id: rpg_grid.py,v 1.20 2006/11/15 12:11:24 digitalxero Exp $"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
30
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
31 from core import *
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
32 from forms import *
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
33
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
34 class rpg_grid_handler(node_handler):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
35 """ Node handler for rpg grid tool
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
36 <nodehandler module='rpg_grid' class='rpg_grid_handler' name='sample'>
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
37 <grid border='' autosize='1' >
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
38 <row>
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
39 <cell size='?'></cell>
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
40 <cell></cell>
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
41 </row>
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
42 <row>
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
43 <cell></cell>
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
44 <cell></cell>
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
45 </row>
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
46 </grid>
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
47 <macros>
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
48 <macro name=''/>
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
49 </macros>
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
50 </nodehandler>
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
51 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
52 def __init__(self,xml,tree_node):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
53 node_handler.__init__(self,xml,tree_node)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
54 self.grid = self.xml.find('grid')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
55 if self.grid.get("border") == "": self.grid.set("border","1")
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
56 if self.grid.get("autosize") == "": self.grid.set("autosize","1")
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
57 self.macros = self.xml.find('macros')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
58 self.myeditor = None
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
59 self.refresh_rows()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
60
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
61 def refresh_die_macros(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
62 pass
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
63
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
64 def refresh_rows(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
65 self.rows = {}
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
66 tree = self.tree
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
67 icons = self.tree.icons
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
68 tree.CollapseAndReset(self.mytree_node)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
69 for row in self.grid.findall('row'):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
70 first_cell = row.find('cell')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
71 name = first_cell.text
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
72 if name == None or name == '': name = "Row"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
73 new_tree_node = tree.AppendItem(self.mytree_node,name,icons['gear'],icons['gear'])
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
74 handler = grid_row_handler(row,new_tree_node,self)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
75 tree.SetPyData(new_tree_node,handler)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
76
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
77 def tohtml(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
78 border = self.grid.get("border")
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
79 name = self.xml.get('name')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
80 rows = self.grid.findall('row')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
81 colspan = str(len(rows[0].findall('cell')))
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
82 html_str = "<table border=\""+border+"\" align=center><tr bgcolor=\""+TH_BG+"\" ><th colspan="+colspan+">"+name+"</th></tr>"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
83 for r in rows:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
84 cells = r.findall('cell')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
85 html_str += "<tr>"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
86 for c in cells:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
87 html_str += "<td >"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
88 text = c.text
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
89 if text == None or text == '': text = '<br />'
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
90 html_str += text + "</td>"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
91 html_str += "</tr>"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
92 html_str += "</table>"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
93 return html_str
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
94
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
95 def get_design_panel(self,parent):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
96 return rpg_grid_edit_panel(parent,self)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
97
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
98 def get_use_panel(self,parent):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
99 return rpg_grid_panel(parent,self)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
100
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
101 def get_size_constraint(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
102 return 1
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
103
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
104 def is_autosized(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
105 return self.grid.get("autosize")
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
106
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
107 def set_autosize(self,autosize=1):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
108 self.grid.set("autosize",str(autosize))
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
109
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
110 class grid_row_handler(node_handler):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
111 """ Node Handler grid row.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
112 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
113 def __init__(self,xml,tree_node,parent):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
114 node_handler.__init__(self,xml,tree_node)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
115 self.drag = False
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
116
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
117 def on_drop(self,evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
118 pass
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
119
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
120 def can_clone(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
121 return 0;
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
122
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
123 def tohtml(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
124 cells = self.xml.findall('cell')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
125 html_str = "<table border=1 align=center><tr >"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
126 for c in cells: # should loop over rows first, then cells
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
127 html_str += "<td >"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
128 text = c.text
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
129 if text == '' or text is None: text = '<br />'
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
130 html_str += text + "</td>"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
131 html_str += "</tr>"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
132 html_str += "</table>"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
133 return html_str
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
134
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
135 def get_value(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
136 cells = self.xml.findall('cell')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
137 if len(cells) == 2: return getText(cells[1])
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
138 else: return None
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
139
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
140 def set_value(self, new_value):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
141 cells = self.xml.findall('cell')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
142 if len(cells) == 2:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
143 cells[1].text = new_value
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
144
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
145 class MyCellEditor(wx.grid.PyGridCellEditor):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
146 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
147 This is a sample GridCellEditor that shows you how to make your own custom
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
148 grid editors. All the methods that can be overridden are show here. The
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
149 ones that must be overridden are marked with "*Must Override*" in the
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
150 docstring.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
151
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
152 Notice that in order to call the base class version of these special
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
153 methods we use the method name preceded by "base_". This is because these
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
154 methods are "virtual" in C++ so if we try to call wxGridCellEditor.Create
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
155 for example, then when the wxPython extension module tries to call
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
156 ptr->Create(...) then it actually calls the derived class version which
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
157 looks up the method in this class and calls it, causing a recursion loop.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
158 If you don't understand any of this, don't worry, just call the "base_"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
159 version instead.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
160
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
161 ----------------------------------------------------------------------------
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
162 This class is copied from the wxPython examples directory and was written by
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
163 Robin Dunn.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
164
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
165 I have pasted it directly in and removed all references to "log"
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
166
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
167 -- Andrew
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
168
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
169 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
170 def __init__(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
171 wx.grid.PyGridCellEditor.__init__(self)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
172
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
173 def Create(self, parent, id, evtHandler):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
174 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
175 Called to create the control, which must derive from wxControl.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
176 *Must Override*
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
177 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
178 self._tc = wx.TextCtrl(parent, id, "", style=wx.TE_PROCESS_ENTER | wx.TE_PROCESS_TAB)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
179 self._tc.SetInsertionPoint(0)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
180 self.SetControl(self._tc)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
181 if evtHandler: self._tc.PushEventHandler(evtHandler)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
182
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
183 def SetSize(self, rect):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
184 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
185 Called to position/size the edit control within the cell rectangle.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
186 If you don't fill the cell (the rect) then be sure to override
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
187 PaintBackground and do something meaningful there.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
188 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
189 self._tc.SetDimensions(rect.x+1, rect.y+1, rect.width+2, rect.height+2)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
190
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
191 def BeginEdit(self, row, col, grid):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
192 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
193 Fetch the value from the table and prepare the edit control
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
194 to begin editing. Set the focus to the edit control.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
195 *Must Override*
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
196 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
197 self.startValue = grid.GetTable().GetValue(row, col)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
198 self._tc.SetValue(self.startValue)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
199 self._tc.SetInsertionPointEnd()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
200 self._tc.SetFocus()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
201
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
202 # For this example, select the text
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
203 self._tc.SetSelection(0, self._tc.GetLastPosition())
151
06f10429eedc Traipse Alpha 'OpenRPG' {091125-00}
sirebral
parents: 138
diff changeset
204
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
205 def EndEdit(self, row, col, grid):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
206 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
207 Complete the editing of the current cell. Returns True if the value
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
208 has changed. If necessary, the control may be destroyed.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
209 *Must Override*
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
210 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
211 changed = False
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
212 val = self._tc.GetValue()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
213 if val != self.startValue:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
214 changed = True
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
215 grid.GetTable().SetValue(row, col, val) # update the table
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
216
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
217 self.startValue = ''
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
218 self._tc.SetValue('')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
219 return changed
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
220
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
221 def Reset(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
222 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
223 Reset the value in the control back to its starting value.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
224 *Must Override*
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
225 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
226 self._tc.SetValue(self.startValue)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
227 self._tc.SetInsertionPointEnd()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
228
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
229 def IsAcceptedKey(self, evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
230 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
231 Return True to allow the given key to start editing: the base class
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
232 version only checks that the event has no modifiers. F2 is special
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
233 and will always start the editor.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
234 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
235 return (not (evt.ControlDown() or evt.AltDown()) and
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
236 evt.GetKeyCode() != wx.WXK_SHIFT)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
237
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
238 def StartingKey(self, evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
239 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
240 If the editor is enabled by pressing keys on the grid, this will be
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
241 called to let the editor do something about that first key if desired.
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
242 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
243 key = evt.GetKeyCode()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
244 ch = None
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
245 if key in [wx.WXK_NUMPAD0, wx.WXK_NUMPAD1, wx.WXK_NUMPAD2, wx.WXK_NUMPAD3, wx.WXK_NUMPAD4,
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
246 wx.WXK_NUMPAD5, wx.WXK_NUMPAD6, wx.WXK_NUMPAD7, wx.WXK_NUMPAD8, wx.WXK_NUMPAD9]:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
247 ch = ch = chr(ord('0') + key - wx.WXK_NUMPAD0)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
248 elif key < 256 and key >= 0 and chr(key) in string.printable:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
249 ch = chr(key)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
250 if not evt.ShiftDown(): ch = string.lower(ch)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
251 if ch is not None: self._tc.AppendText(ch)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
252 else: evt.Skip()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
253
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
254 def Destroy(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
255 """final cleanup"""
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
256 self.base_Destroy()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
257
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
258 def Clone(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
259 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
260 Create a new object which is the copy of this one
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
261 *Must Override*
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
262 """
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
263 return MyCellEditor()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
264
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
265
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
266 class rpg_grid(wx.grid.Grid):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
267 """grid for attacks"""
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
268 def __init__(self, parent, handler):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
269 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
270 self.parent = parent
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
271 self.handler = handler
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
272
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
273 self.RegisterDataType(wx.grid.GRID_VALUE_STRING, wx.grid.GridCellStringRenderer(),MyCellEditor())
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
274
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
275 self.rows = handler.grid.findall('row')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
276 rows = len(self.rows)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
277 cols = len(self.rows[0].findall('cell'))
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
278 self.CreateGrid(rows,cols)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
279 self.SetRowLabelSize(0)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
280 self.SetColLabelSize(0)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
281 self.set_col_widths()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
282
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
283 for i in range(0,len(self.rows)): self.refresh_row(i)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
284
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
285 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
286 self.Bind(wx.grid.EVT_GRID_COL_SIZE, self.on_col_size)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
287 self.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.on_leftdclick)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
288
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
289
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
290 def on_leftdclick(self,evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
291 if self.CanEnableCellControl(): self.EnableCellEditControl()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
292
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
293 def on_col_size(self, evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
294 col = evt.GetRowOrCol()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
295 cells = self.rows[0].findall('cell')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
296 size = self.GetColSize(col)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
297 cells[col].set('size',str(size))
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
298 evt.Skip()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
299
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
300 def on_cell_change(self,evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
301 row = evt.GetRow()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
302 col = evt.GetCol()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
303 value = self.GetCellValue(row,col)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
304 cells = self.rows[row].findall('cell')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
305 cells[col].text = value
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
306 if col == 0: self.handler.refresh_rows()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
307
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
308 def set_col_widths(self):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
309 cells = self.rows[0].findall('cell')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
310 for i in range(0,len(cells)):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
311 try:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
312 size = int(cells[i].get('size'))
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
313 self.SetColSize(i,size)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
314 except: continue
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
315
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
316 def refresh_row(self,rowi):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
317 cells = self.rows[rowi].findall('cell')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
318 for i in range(0,len(cells)):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
319 text = cells[i].text
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
320 if text == None or text == '':
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
321 text = ''
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
322 cells[i].text = text
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
323 self.SetCellValue(rowi,i,text)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
324
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
325 def add_row(self,evt=None):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
326 cols = self.GetNumberCols()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
327 row = Element('row')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
328 for i in range(0,cols):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
329 cell = Element('cell')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
330 cell.text = ''
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
331 row.append(cell)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
332 self.handler.grid.append(row)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
333 self.AppendRows(1)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
334 self.rows = self.handler.grid.findall('row')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
335 self.handler.refresh_rows()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
336
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
337 def add_col(self,evt=None):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
338 for r in self.rows:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
339 cell = Element('cell')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
340 cell.text = ''
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
341 r.append(cell)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
342 self.AppendCols(1)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
343 self.set_col_widths()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
344
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
345 def del_row(self,evt=None):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
346 num = self.GetNumberRows()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
347 if num == 1: return
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
348 self.handler.grid.remove(self.handler.grid[num-1])# always remove last row -- nasty
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
349 self.DeleteRows(num-1,1)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
350 self.rows = self.handler.grid.findall('row')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
351 self.handler.refresh_rows()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
352
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
353 def del_col(self,evt=None):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
354 num = self.GetNumberCols()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
355 if num == 1: return
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
356 for r in self.rows:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
357 cells = r.findall('cell')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
358 r.remove(r[num-1]) # always remove the last column -- nasty
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
359 self.DeleteCols(num-1,1)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
360 self.set_col_widths()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
361
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
362
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
363 G_TITLE = wx.NewId()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
364 GRID_BOR = wx.NewId()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
365 class rpg_grid_panel(wx.Panel):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
366 def __init__(self, parent, handler):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
367 wx.Panel.__init__(self, parent, -1)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
368 self.handler = handler
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
369 self.grid = rpg_grid(self,handler)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
370 label = handler.xml.get('name')
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
371 self.main_sizer = wx.BoxSizer(wx.VERTICAL)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
372 self.main_sizer.Add(wx.StaticText(self, -1, label+": "), 0, wx.EXPAND)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
373 self.main_sizer.Add(self.grid,1,wx.EXPAND)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
374 self.SetSizer(self.main_sizer)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
375 self.SetAutoLayout(True)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
376 self.Fit()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
377 parent.SetSize(self.GetBestSize())
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
378
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
379 G_AUTO_SIZE = wx.NewId()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
380 G_ADD_ROW = wx.NewId()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
381 G_ADD_COL = wx.NewId()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
382 G_DEL_ROW = wx.NewId()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
383 G_DEL_COL = wx.NewId()
173
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
384 G_BUT_REF = wx.NewId()
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
385
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
386 class rpg_grid_edit_panel(wx.Panel):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
387 def __init__(self, parent, handler):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
388 wx.Panel.__init__(self, parent, -1)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
389 self.handler = handler
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
390 self.grid = rpg_grid(self,handler)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
391 self.main_sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Grid"), wx.VERTICAL)
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
392
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
393 self.title = wx.TextCtrl(self, G_TITLE, handler.xml.get('name'))
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
394
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
395 radio_b = wx.RadioBox(self, GRID_BOR, "Border (HTML)", choices=["no","yes"])
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
396 border = handler.grid.get("border")
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
397 radio_b.SetSelection(int(border))
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
398
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
399 self.auto_size = wx.CheckBox(self, G_AUTO_SIZE, "Auto Size")
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
400 if handler.is_autosized() == '1': self.auto_size.SetValue(True)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
401 else: self.auto_size.SetValue(False)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
402
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
403 sizer = wx.BoxSizer(wx.HORIZONTAL)
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
404 sizer.Add(wx.Button(self, G_ADD_ROW, "Add Row"), 1, wx.EXPAND)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
405 sizer.Add(wx.Size(10,10))
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
406 sizer.Add(wx.Button(self, G_DEL_ROW, "Remove Row"), 1, wx.EXPAND)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
407 sizer.Add(wx.Size(10,10))
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
408 sizer.Add(wx.Button(self, G_ADD_COL, "Add Column"), 1, wx.EXPAND)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
409 sizer.Add(wx.Size(10,10))
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
410 sizer.Add(wx.Button(self, G_DEL_COL, "Remove Column"), 1, wx.EXPAND)
173
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
411 sizer.Add(wx.Size(10,10))
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
412 sizer.Add(wx.Button(self, G_BUT_REF, "Reference"), 1)
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
413
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
414 self.main_sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
415 self.main_sizer.Add(self.title, 0, wx.EXPAND)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
416 self.main_sizer.Add(radio_b, 0, 0)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
417 self.main_sizer.Add(self.auto_size, 0, 0)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
418 self.main_sizer.Add(self.grid,1,wx.EXPAND)
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
419 self.main_sizer.Add(sizer,0,wx.EXPAND)
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
420
138
1ed2feab0db9 Traipse Alpha 'OpenRPG' {091021-00}
sirebral
parents: 131
diff changeset
421 self.SetSizer(self.main_sizer)
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
422 self.SetAutoLayout(True)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
423 self.Fit()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
424
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
425 self.Bind(wx.EVT_TEXT, self.on_text, id=G_TITLE)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
426 self.Bind(wx.EVT_BUTTON, self.grid.add_row, id=G_ADD_ROW)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
427 self.Bind(wx.EVT_BUTTON, self.grid.del_row, id=G_DEL_ROW)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
428 self.Bind(wx.EVT_BUTTON, self.grid.add_col, id=G_ADD_COL)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
429 self.Bind(wx.EVT_BUTTON, self.grid.del_col, id=G_DEL_COL)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
430 self.Bind(wx.EVT_RADIOBOX, self.on_radio_box, id=GRID_BOR)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
431 self.Bind(wx.EVT_CHECKBOX, self.on_auto_size, id=G_AUTO_SIZE)
173
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
432 self.Bind(wx.EVT_BUTTON, self.on_reference, id=G_BUT_REF)
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
433
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
434 ## EZ_Tree Core TaS - Prof.Ebral ##
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
435 def on_reference(self, evt, car=None):
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
436 self.do_tree = wx.Frame(self, -1, 'Tree')
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
437 self.ez_tree = orpg.gametree.gametree
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
438 self.temp_wnd = self.ez_tree.game_tree(self.do_tree, self.ez_tree.EZ_REF)
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
439 #self.temp_wnd.Bind(wx.EVT_LEFT_DCLICK, self.on_ldclick) ## Remove for Alpha ##
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
440 self.temp_wnd.load_tree(settings.get("gametree"))
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
441 self.do_tree.Show()
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
442
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
443 def on_ldclick(self, evt):
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
444 self.rename_flag = 0
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
445 pt = evt.GetPosition()
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
446 (item, flag) = self.temp_wnd.HitTest(pt)
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
447 if item.IsOk():
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
448 obj = self.temp_wnd.GetPyData(item)
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
449 self.temp_wnd.SelectItem(item)
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
450 start = self.handler.xml.get('map').split('::')
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
451 end = obj.xml.get('map').split('::')
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
452 x = 0
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
453 if start[x] == end[x]:
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
454 try:
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
455 while start[x] == end[x]:
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
456 del end[x], start[x]
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
457 x += 1
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
458 except:
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
459 complete = "!!"
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
460 for e in end: complete += e +'::'
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
461 complete = complete + obj.xml.get('name') + '!!'
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
462 self.value_entry.SetValue(complete); self.reload_options()
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
463 self.do_tree.Destroy()
0dde29a41614 Traipse Alpha 'OpenRPG' {100107-00}
sirebral
parents: 155
diff changeset
464 ##### #####
155
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
465
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
466 def on_auto_size(self,evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
467 self.handler.set_autosize(bool2int(evt.Checked()))
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
468
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
469 def on_radio_box(self,evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
470 id = evt.GetId()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
471 index = evt.GetInt()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
472 if id == GRID_BOR:
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
473 self.handler.grid.set("border",str(index))
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
474
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
475 def on_text(self,evt):
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
476 txt = self.title.GetValue()
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
477 if txt != "":
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
478 self.handler.xml.set('name',txt)
bf799efe7a8a Traipse Alpha 'OpenRPG' {091125-02}
sirebral
parents: 151
diff changeset
479 self.handler.rename(txt)