*** empty log message ***

This commit is contained in:
Mark Mine 2001-10-12 00:23:20 +00:00
parent a1b9c34397
commit fead331673

View File

@ -23,6 +23,9 @@ class DirectDialog(DirectFrame):
buttonHotKeyList List of hotkeys to bind to each button. buttonHotKeyList List of hotkeys to bind to each button.
Typing hotkey is equivalent to pressing Typing hotkey is equivalent to pressing
the corresponding button. the corresponding button.
supressKeys Set to true if you wish to supress keys
(i.e. Dialog eats key event), false if
you wish Dialog to pass along key event
buttonSize 4-tuple used to specify custom size for buttonSize 4-tuple used to specify custom size for
each button (to make bigger then geom/text each button (to make bigger then geom/text
for example) for example)
@ -97,11 +100,10 @@ class DirectDialog(DirectFrame):
value = self['buttonValueList'][i] value = self['buttonValueList'][i]
except IndexError: except IndexError:
value = i value = i
self['buttonValueList'].append(i)
try: try:
print 'HERE'
hotKey = self['buttonHotKeyList'][i] hotKey = self['buttonHotKeyList'][i]
except IndexError: except IndexError:
print 'THERE'
hotKey = None hotKey = None
button = self.createcomponent( button = self.createcomponent(
name, (), "button", name, (), "button",
@ -109,31 +111,34 @@ class DirectDialog(DirectFrame):
text = text, text = text,
geom = geom, geom = geom,
image = image, image = image,
suppressKeys = self['suppressKeys'],
frameSize = self['buttonSize'], frameSize = self['buttonSize'],
command = lambda s = self, v = value: s.buttonCommand(v) command = lambda s = self, v = value: s.buttonCommand(v)
) )
# Add any hot key binding
print "HOTKEY", hotKey
if hotKey:
print 'DOING IT'
if ((type(hotKey) == types.ListType) or
(type(hotKey) == types.TupleType)):
print 'NOW'
for key in hotKey:
print 'REALLY'
button.accept(key, self.buttonCommand,
extraArgs = [value])
else:
print 'NOT'
button.accept(hotKey, self.buttonCommand,
extraArgs = [value])
self.buttonList.append(button) self.buttonList.append(button)
# Update dialog when everything has been initialised # Update dialog when everything has been initialised
self.postInitialiseFuncList.append(self.configureDialog) self.postInitialiseFuncList.append(self.configureDialog)
self.initialiseoptions(DirectDialog) self.initialiseoptions(DirectDialog)
def configureDialog(self): def configureDialog(self):
# Set up hot key bindings
bindList = zip(self.buttonList, self['buttonHotKeyList'],
self['buttonValueList'])
for button, hotKey, value in bindList:
if ((type(hotKey) == types.ListType) or
(type(hotKey) == types.TupleType)):
for key in hotKey:
button.bind('press-' + key + '-', self.buttonCommand,
extraArgs = [value])
self.bind('press-' + key + '-', self.buttonCommand,
extraArgs = [value])
else:
button.bind('press-' + hotKey + '-',self.buttonCommand,
extraArgs = [value])
self.bind('press-' + hotKey + '-', self.buttonCommand,
extraArgs = [value])
# Position buttons and text # Position buttons and text
pad = self['pad'] pad = self['pad']
bpad = self['button_pad'] bpad = self['button_pad']
@ -234,14 +239,13 @@ class DirectDialog(DirectFrame):
self['image_pos'] = ((l+r)/2.0, 0.0,(b+t)/2.0) self['image_pos'] = ((l+r)/2.0, 0.0,(b+t)/2.0)
self.resetFrameSize() self.resetFrameSize()
def buttonCommand(self, value): def buttonCommand(self, value, event = None):
if self['command']: if self['command']:
self['command'](value) self['command'](value)
def destroy(self): def destroy(self):
DirectFrame.destroy(self) DirectFrame.destroy(self)
class OKDialog(DirectDialog): class OKDialog(DirectDialog):
def __init__(self, parent = guiTop, **kw): def __init__(self, parent = guiTop, **kw):
# Inherits from DirectFrame # Inherits from DirectFrame