tkwidgets: fix exceptions hovering over rgbPanel menu items

This commit is contained in:
rdb 2019-05-02 16:18:22 +02:00
parent a3b4486ef3
commit 6d9b217c2c

View File

@ -656,25 +656,35 @@ def rgbPanel(nodePath, callback = None, style = 'mini'):
pButton.pack(expand = 1, fill = BOTH)
# Update menu
menu = vgp.component('menubar').component('Valuator Group-menu')
menubar = vgp.component('menubar')
menubar.deletemenuitems('Valuator Group', 1, 1)
# Some helper functions
# Clear color
menu.insert_command(index = 1, label = 'Clear Color',
command = lambda: nodePath.clearColor())
menubar.addmenuitem(
'Valuator Group', 'command',
label='Clear Color', command=lambda: nodePath.clearColor())
# Set Clear Transparency
menu.insert_command(index = 2, label = 'Set Transparency',
command = lambda: nodePath.setTransparency(1))
menu.insert_command(
index = 3, label = 'Clear Transparency',
command = lambda: nodePath.clearTransparency())
menubar.addmenuitem(
'Valuator Group', 'command',
label='Set Transparency', command=lambda: nodePath.setTransparency(1))
menubar.addmenuitem(
'Valuator Group', 'command',
label='Clear Transparency', command=lambda: nodePath.clearTransparency())
# System color picker
menu.insert_command(index = 4, label = 'Popup Color Picker',
command = popupColorPicker)
menubar.addmenuitem(
'Valuator Group', 'command',
label='Popup Color Picker', command=popupColorPicker)
menu.insert_command(index = 5, label = 'Print to log',
command = printToLog)
menubar.addmenuitem(
'Valuator Group', 'command',
label='Print to log', command=printToLog)
menubar.addmenuitem(
'Valuator Group', 'command', 'Dismiss Valuator Group panel',
label='Dismiss', command=vgp.destroy)
def setNodePathColor(color):
nodePath.setColor(color[0]/255.0, color[1]/255.0,
@ -724,18 +734,23 @@ def lightRGBPanel(light, style = 'mini'):
# Update menu button
vgp.component('menubar').component('Valuator Group-button')['text'] = (
'Light Control Panel')
# Add a print button which will also serve as a color tile
pButton = Button(vgp.interior(), text = 'Print to Log',
bg = getTkColorString(initColor),
command = printToLog)
pButton.pack(expand = 1, fill = BOTH)
# Update menu
menu = vgp.component('menubar').component('Valuator Group-menu')
menubar = vgp.component('menubar')
# System color picker
menu.insert_command(index = 4, label = 'Popup Color Picker',
command = popupColorPicker)
menu.insert_command(index = 5, label = 'Print to log',
command = printToLog)
menubar.addmenuitem(
'Valuator Group', 'command',
label='Popup Color Picker', command=popupColorPicker)
menubar.addmenuitem(
'Valuator Group', 'command',
label='Print to log', command=printToLog)
def setLightColor(color):
light.setColor(Vec4(color[0]/255.0, color[1]/255.0,
color[2]/255.0, color[3]/255.0))