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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
########################################################################
#
# Date: Nov. 2001 Author: Michel Sanner, Daniel Stoffler
#
# sanner@scripps.edu
#
# The Scripps Research Institute (TSRI)
# Molecular Graphics Lab
# La Jolla, CA 92037, USA
#
# Copyright: Michel Sanner and TSRI
#
#########################################################################
#
# $Header: /opt/cvs/python/packages/share1.5/NetworkEditor/ImageNodeEditor.py,v 1.2.2.1 2015/08/26 16:42:27 sanner Exp $
#
# $Id: ImageNodeEditor.py,v 1.2.2.1 2015/08/26 16:42:27 sanner Exp $
#
# OBSOLETE
#
import os, Tkinter, Pmw, ImageTk
from NetworkEditor.Editor import ObjectEditor
from mglutil.gui.BasicWidgets.Tk.colorWidgets import ColorChooser
from mglutil.util.packageFilePath import findFilePath
from mglutil.util.callback import CallbackFunction
ICONPATH = findFilePath('Icons', 'WarpIV')
from mglutil.gui.BasicWidgets.Tk.thumbwheel import ThumbWheel
class ImageNodeEditor(ObjectEditor):
def __init__(self, node, master=None):
self.node = node
ObjectEditor.__init__(self, node, 'ImageNode', master)
def nameEntryChange_cb(self, event=None):
"""apply the new name to the node and remember it has been modified"""
name = self.nameTk.get()
self.node.name = name
self.node.redrawNode()
def Apply(self, event=None):
self.nameEntryChange_cb()
self.Dismiss()
def createForm(self, master):
"""Create standard editor form and add a Pmw Group for input ports,
one for output ports and a check button for viewing the source node's code.
"""
ObjectEditor.createForm(self, master)
frame = Tkinter.Frame(self.top)
Tkinter.Label(frame, text="fill color ").grid(row=0, column=0,
sticky='ne')
photo = ImageTk.PhotoImage(
file=os.path.join(ICONPATH, 'colorChooser24.png'))
cb = CallbackFunction(self.setColor, 'fillColor')
b = Tkinter.Button(frame, command=cb, image=photo)
b.photo = photo
b.grid(row=0, column=1, sticky='ne')
cb = CallbackFunction(self.setOpacity, 'fillColor')
fillOpacityThumbwheel = ThumbWheel(
frame,
labCfg={'text':'Opac.', 'side':'left'},
showLabel=1, width=40, height=14,
min=.001, max=1., type=float,
value = self.node.nodeStyle.fillColor[3],
callback = cb, continuous=True,
oneTurn=1., wheelPad=0)
fillOpacityThumbwheel.grid(row=0, column=2, sticky='ne')
Tkinter.Label(frame, text="outline color ").grid(row=1, column=0,
sticky='ne')
photo = ImageTk.PhotoImage(
file=os.path.join(ICONPATH, 'colorChooser24.png'))
cb = CallbackFunction(self.setColor, 'outlineColor')
b = Tkinter.Button(frame, command=cb, image=photo)
b.photo = photo
b.grid(row=1, column=1, sticky='ne')
cb = CallbackFunction(self.setOpacity, 'outlineColor')
outlineOpacityThumbwheel = ThumbWheel(
frame,
labCfg={'text':'Opac.', 'side':'left'},
showLabel=1, width=40, height=14,
min=.001, max=1., type=float,
value = self.node.nodeStyle.fillColor[3],
callback = cb, continuous=True,
oneTurn=1., wheelPad=0)
outlineOpacityThumbwheel.grid(row=1, column=2, sticky='ne')
frame.pack()
def setColor(self, what):
def cb(color):
self.node.nodeStyle.configure(**{what:color})
self.node.redrawNode()
self.currentNodeStyle = None
cc = ColorChooser(immediate=1, commands=cb,
title='Node %s color'%what)
cc.pack(expand=1, fill='both')
def setOpacity(self, what, value):
if what=='fillColor':
self.node.nodeStyle.fillColor[3] = value
elif what=='outlineColor':
self.node.nodeStyle.outlineColor[3] = value
self.node.redrawNode()
self.currentNodeStyle = None
|