mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 08:15:18 -04:00
tkwidgets: Fix EntryScale missing import and menu errors
This commit is contained in:
parent
2d65738a18
commit
8ba1ae924c
@ -5,6 +5,7 @@ EntryScale Class: Scale with a label, and a linked and validated entry
|
|||||||
__all__ = ['EntryScale', 'EntryScaleGroup']
|
__all__ = ['EntryScale', 'EntryScaleGroup']
|
||||||
|
|
||||||
from direct.showbase.TkGlobal import *
|
from direct.showbase.TkGlobal import *
|
||||||
|
from panda3d.core import Vec4
|
||||||
import Pmw, sys
|
import Pmw, sys
|
||||||
|
|
||||||
if sys.version_info >= (3, 0):
|
if sys.version_info >= (3, 0):
|
||||||
@ -482,17 +483,24 @@ def rgbPanel(nodePath, callback = None):
|
|||||||
esg.component('menubar').component('EntryScale Group-button')['text'] = (
|
esg.component('menubar').component('EntryScale Group-button')['text'] = (
|
||||||
'RGBA Panel')
|
'RGBA Panel')
|
||||||
# Update menu
|
# Update menu
|
||||||
menu = esg.component('menubar').component('EntryScale Group-menu')
|
menubar = esg.component('menubar')
|
||||||
|
menubar.deletemenuitems('EntryScale 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 np = nodePath: np.clearColor())
|
'EntryScale Group', 'command',
|
||||||
# Set Clear Transparency
|
label='Clear Color', command=lambda np=nodePath: np.clearColor())
|
||||||
menu.insert_command(index = 2, label = 'Set Transparency',
|
|
||||||
command = lambda np = nodePath: np.setTransparency(1))
|
# Set/Clear Transparency
|
||||||
menu.insert_command(
|
menubar.addmenuitem(
|
||||||
index = 3, label = 'Clear Transparency',
|
'EntryScale Group', 'command',
|
||||||
command = lambda np = nodePath: np.clearTransparency())
|
label='Set Transparency', command=lambda np=nodePath: np.setTransparency(1))
|
||||||
|
menubar.addmenuitem(
|
||||||
|
'EntryScale Group', 'command',
|
||||||
|
label='Clear Transparency',
|
||||||
|
command=lambda np=nodePath: np.clearTransparency())
|
||||||
|
|
||||||
# System color picker
|
# System color picker
|
||||||
def popupColorPicker(esg = esg):
|
def popupColorPicker(esg = esg):
|
||||||
# Can pass in current color with: color = (255, 0, 0)
|
# Can pass in current color with: color = (255, 0, 0)
|
||||||
@ -502,13 +510,27 @@ def rgbPanel(nodePath, callback = None):
|
|||||||
initialcolor = tuple(esg.get()[:3]))[0]
|
initialcolor = tuple(esg.get()[:3]))[0]
|
||||||
if color:
|
if color:
|
||||||
esg.set((color[0], color[1], color[2], esg.getAt(3)))
|
esg.set((color[0], color[1], color[2], esg.getAt(3)))
|
||||||
menu.insert_command(index = 4, label = 'Popup Color Picker',
|
|
||||||
command = popupColorPicker)
|
menubar.addmenuitem(
|
||||||
|
'EntryScale Group', 'command',
|
||||||
|
label='Popup Color Picker', command=popupColorPicker)
|
||||||
|
|
||||||
def printToLog(nodePath=nodePath):
|
def printToLog(nodePath=nodePath):
|
||||||
c=nodePath.getColor()
|
c = nodePath.getColor()
|
||||||
print("Vec4(%.3f, %.3f, %.3f, %.3f)"%(c[0], c[1], c[2], c[3]))
|
print("Vec4(%.3f, %.3f, %.3f, %.3f)" % (c[0], c[1], c[2], c[3]))
|
||||||
menu.insert_command(index = 5, label = 'Print to log',
|
|
||||||
command = printToLog)
|
menubar.addmenuitem(
|
||||||
|
'EntryScale Group', 'command',
|
||||||
|
label='Print to log', command=printToLog)
|
||||||
|
|
||||||
|
# Add back the Dismiss item we removed.
|
||||||
|
if esg['fDestroy']:
|
||||||
|
dismissCommand = esg.destroy
|
||||||
|
else:
|
||||||
|
dismissCommand = esg.withdraw
|
||||||
|
menubar.addmenuitem(
|
||||||
|
'EntryScale Group', 'command', 'Dismiss EntryScale Group panel',
|
||||||
|
label='Dismiss', command=dismissCommand)
|
||||||
|
|
||||||
# Set callback
|
# Set callback
|
||||||
def onRelease(r, g, b, a, nodePath = nodePath):
|
def onRelease(r, g, b, a, nodePath = nodePath):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user