16 |
# write to the Free Software Foundation, Inc., 59 Temple Place |
# write to the Free Software Foundation, Inc., 59 Temple Place |
17 |
# - Suite 330, Boston, MA 02111-1307, USA. |
# - Suite 330, Boston, MA 02111-1307, USA. |
18 |
# |
# |
19 |
# Copyright 2001-2002 Free Software Foundation |
# Copyright 2001-2003 Free Software Foundation |
20 |
# |
# |
21 |
# FILE: |
# FILE: |
22 |
# forms/wizards/AddButton.py |
# forms/wizards/AddButton.py |
125 |
# |
# |
126 |
def Finalize(self): |
def Finalize(self): |
127 |
|
|
128 |
|
name = self.GetUniqueName(self.variables['name'] or 'Button1') |
|
name = self.variables['name'] or 'Button_1' |
|
129 |
label = self.variables['label'] or name |
label = self.variables['label'] or name |
130 |
triggerName = name + "_Trigger" |
|
131 |
attrs = {'name': name, |
attrs = {'name': name, |
132 |
'label': label, |
'label': label, |
133 |
'trigger': triggerName, |
'Char:x': self.x, |
134 |
'x': self.x, |
'Char:y': self.y, |
135 |
'y': self.y, |
'Char:width': max(self.width, len(label) + 2), |
136 |
'width': max(self.width, len(label) + 2), |
'Char:height': self.height or 1} |
|
'height': self.height or 1} |
|
137 |
|
|
138 |
button = self.AddElement('button', self.current, attrs) |
button = self.AddElement('button', self.current['page'], attrs) |
139 |
|
|
140 |
action, info = string.split(self.variables['action'],':') |
action, info = string.split(self.variables['action'],':') |
141 |
|
|
142 |
if action == 'b': |
if action == 'b': |
143 |
block = self.current.findParentOfType('GFBlock') |
block = self.current['block'] |
144 |
if not block: |
blockName = block.name |
|
block = self.current.findChildOfType('GFBlock') |
|
|
if not block: |
|
|
block = self.form.findChildOfType('GFBlock') |
|
|
if not block: |
|
|
blockName = 'NoBlock' |
|
|
else: |
|
|
blockName = block.name |
|
|
|
|
145 |
|
|
146 |
|
|
147 |
code = triggerTemplates[action] % locals() |
code = triggerTemplates[action] % locals() |
148 |
|
|
|
|
|
149 |
trigger = self.AddElement('trigger', |
trigger = self.AddElement('trigger', |
150 |
self.form, |
button, |
151 |
attributes = { |
attributes = { |
152 |
'type':'NAMED', |
'type':'On-Action' }, |
|
'name': triggerName }, |
|
153 |
content = code) |
content = code) |
154 |
|
|
155 |
return 1 |
return 1 |
168 |
'Version' : VERSION, |
'Version' : VERSION, |
169 |
'Author' : 'The GNUe Designer Team', |
'Author' : 'The GNUe Designer Team', |
170 |
'Behavior': WIZARD, |
'Behavior': WIZARD, |
171 |
'Location' : 'Tools|Insert|Button' |
'Location' : 'Edit|Insert|Button' |
172 |
} |
} |
173 |
|
|
174 |
|
|
176 |
triggerTemplates = { |
triggerTemplates = { |
177 |
't': """\ |
't': """\ |
178 |
## |
## |
179 |
## %(triggerName)s [Button Trigger] |
## [Button On-Action Trigger] |
180 |
## |
## |
181 |
|
|
182 |
# Your code goes here |
# Your code goes here |
185 |
|
|
186 |
'b': """\ |
'b': """\ |
187 |
## |
## |
188 |
## %(triggerName)s [Button Trigger] |
## [Button On-Action Trigger] |
189 |
## |
## |
190 |
|
|
191 |
# Perform a block-level %(info)s |
# Perform a block-level %(info)s |
194 |
|
|
195 |
'f': """\ |
'f': """\ |
196 |
## |
## |
197 |
## %(triggerName)s [Button Trigger] |
## [Button On-Action Trigger] |
198 |
## |
## |
199 |
|
|
200 |
# Perform a form-level %(info)s |
# Perform a form-level %(info)s |