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