/usr/share/pyshared/wxglade/widgets/ChoicesProperty.py is in python-wxglade 0.6.8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | # ChoicesProperty.py: defines a Property and two handlers used by choice,
# combo_box, radio_box, list_box
# $Id: ChoicesProperty.py,v 1.8 2007/03/27 07:02:05 agriggio Exp $
#
# Copyright (c) 2002-2007 Alberto Griggio <agriggio@users.sourceforge.net>
# License: MIT (see license.txt)
# THIS PROGRAM COMES WITH NO WARRANTY
import widget_properties
class ChoicesProperty(widget_properties.GridProperty):
def write(self, outfile, tabs):
from xml.sax.saxutils import escape
write = outfile.write
write(' ' * tabs + '<choices>\n')
tab_s = ' ' * (tabs+1)
for val in self.get_value():
v = widget_properties._encode(val[0])
try:
checked = int(val[1])
except (IndexError, ValueError):
checked = None
if checked is None:
write('%s<choice>%s</choice>\n' % (tab_s, escape(v)))
else:
write('%s<choice checked="%d">%s</choice>\n' % \
(tab_s, checked, escape(v)))
write(' ' * tabs + '</choices>\n')
# end of class ChoicesProperty
class ChoicesHandler:
def __init__(self, owner):
self.choices = []
self.curr_choice = []
self.cur_checked = None
self.owner = owner
def start_elem(self, name, attrs):
if name == 'choice':
try:
self.cur_checked = int(attrs['checked'])
except (KeyError, ValueError):
self.cur_checked = None
def end_elem(self, name):
if name == 'choice':
if self.cur_checked is None:
self.choices.append(["".join(self.curr_choice)])
else:
self.choices.append(["".join(self.curr_choice),
self.cur_checked])
self.curr_choice = []
self.cur_checked = None
elif name == 'choices':
self.owner.set_choices(self.choices)
self.owner.properties['choices'].set_value(
self.owner.get_choices())
self.choices = []
return True # remove the handler
def char_data(self, data):
self.curr_choice.append(data)
# end of class ChoicesHandler
|