*** empty log message ***
This commit is contained in:
parent
5000ac5975
commit
379da28f75
|
|
@ -1,25 +1,4 @@
|
|||
from PandaObject import *
|
||||
from EntryScale import EntryScale
|
||||
|
||||
def adjust(**kw):
|
||||
"""
|
||||
Popup and entry scale to adjust a parameter
|
||||
Accepts any EntryScale keyword argument. Typical arguments include:
|
||||
command: The one argument command to execute
|
||||
min: The min value of the slider
|
||||
max: The max value of the slider
|
||||
resolution: The resolution of the slider
|
||||
text: The label on the slider
|
||||
"""
|
||||
from Tkinter import *
|
||||
import Pmw
|
||||
from EntryScale import *
|
||||
tl = Toplevel()
|
||||
tl.title('Parameter Adjust')
|
||||
es = apply(EntryScale, (tl,), kw)
|
||||
es.pack(expand = 1, fill = X)
|
||||
es.tl = tl
|
||||
return es
|
||||
|
||||
## Background Color ##
|
||||
def setBackgroundColor(r,g,b):
|
||||
|
|
|
|||
|
|
@ -145,7 +145,6 @@ def _pdir(obj, str = None, fOverloaded = 0, width = None,
|
|||
strvalue = strvalue[:max(1,lineWidth - maxWidth)]
|
||||
print (format % key)[:maxWidth] + '\t' + strvalue
|
||||
|
||||
|
||||
# Magic numbers: These are the bit masks in func_code.co_flags that
|
||||
# reveal whether or not the function has a *arg or **kw argument.
|
||||
_POS_LIST = 4
|
||||
|
|
@ -267,6 +266,42 @@ def doc(obj):
|
|||
(isinstance(obj, types.FunctionType)):
|
||||
print obj.__doc__
|
||||
|
||||
def adjust(parent = None, **kw):
|
||||
"""
|
||||
adjust(parent = None, **kw)
|
||||
Popup and entry scale to adjust a parameter
|
||||
|
||||
Accepts any EntryScale keyword argument. Typical arguments include:
|
||||
command: The one argument command to execute
|
||||
min: The min value of the slider
|
||||
max: The max value of the slider
|
||||
resolution: The resolution of the slider
|
||||
text: The label on the slider
|
||||
|
||||
These values can be accessed and/or changed after the fact
|
||||
>>> es = adjust()
|
||||
>>> es['min']
|
||||
0.0
|
||||
>>> es['min'] = 10.0
|
||||
>>> es['min']
|
||||
10.0
|
||||
"""
|
||||
# Make sure we enable Tk
|
||||
base.wantDIRECT = 1
|
||||
base.wantTk = 1
|
||||
import TkGlobal
|
||||
from Tkinter import *
|
||||
import EntryScale
|
||||
import Pmw
|
||||
# Create toplevel if needed
|
||||
if not parent:
|
||||
parent = Toplevel()
|
||||
parent.title('Parameter Adjust')
|
||||
es = apply(EntryScale.EntryScale, (parent,), kw)
|
||||
es.pack(expand = 1, fill = X)
|
||||
es.parent = parent
|
||||
return es
|
||||
|
||||
def intersection(a, b):
|
||||
"""
|
||||
intersection(list, list):
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from Tkinter import *
|
|||
import Pmw
|
||||
import string
|
||||
import tkColorChooser
|
||||
from tkSimpleDialog import askfloat
|
||||
from tkSimpleDialog import *
|
||||
|
||||
"""
|
||||
Change Min/Max buttons to labels, add highlight binding
|
||||
|
|
@ -74,6 +74,7 @@ class EntryScale(Pmw.MegaWidget):
|
|||
anchor = 'center',
|
||||
font = "Arial 12 bold")
|
||||
self.label.pack(side='left', expand = 1, fill = 'x')
|
||||
self.label.bind('<Button-3>', self.askForLabel)
|
||||
|
||||
# Now pack the frame
|
||||
self.labelFrame.pack(expand = 1, fill = 'both')
|
||||
|
|
@ -83,14 +84,14 @@ class EntryScale(Pmw.MegaWidget):
|
|||
Frame, interior)
|
||||
# Create the EntryScale's min max labels
|
||||
self.minLabel = self.createcomponent('minLabel', (), None,
|
||||
Button, self.minMaxFrame,
|
||||
command = self.askForMin,
|
||||
Label, self.minMaxFrame,
|
||||
text = `self['min']`,
|
||||
relief = FLAT,
|
||||
width = 5,
|
||||
anchor = W,
|
||||
font = "Arial 8")
|
||||
self.minLabel.pack(side='left', fill = 'x')
|
||||
self.minLabel.bind('<Button-3>', self.askForMin)
|
||||
|
||||
# Create the scale component.
|
||||
self.scale = self.createcomponent('scale', (), None,
|
||||
|
|
@ -107,15 +108,16 @@ class EntryScale(Pmw.MegaWidget):
|
|||
self.scale.set(self['initialValue'])
|
||||
self.scale.bind('<Button-1>', self.__onPress)
|
||||
self.scale.bind('<ButtonRelease-1>', self.__onRelease)
|
||||
self.scale.bind('<Button-3>', self.askForResolution)
|
||||
|
||||
self.maxLabel = self.createcomponent('maxLabel', (), None,
|
||||
Button, self.minMaxFrame,
|
||||
command = self.askForMax,
|
||||
Label, self.minMaxFrame,
|
||||
text = `self['max']`,
|
||||
relief = FLAT,
|
||||
width = 5,
|
||||
anchor = E,
|
||||
font = "Arial 8")
|
||||
self.maxLabel.bind('<Button-3>', self.askForMax)
|
||||
self.maxLabel.pack(side='left', fill = 'x')
|
||||
self.minMaxFrame.pack(expand = 1, fill = 'both')
|
||||
|
||||
|
|
@ -129,9 +131,18 @@ class EntryScale(Pmw.MegaWidget):
|
|||
def entry(self):
|
||||
return self.entry
|
||||
|
||||
def askForMin(self):
|
||||
def askForLabel(self, event = None):
|
||||
newLabel = askstring(title = self['text'],
|
||||
prompt = 'New label:',
|
||||
initialvalue = `self['text']`,
|
||||
parent = self.interior())
|
||||
if newLabel:
|
||||
self['text'] = newLabel
|
||||
|
||||
def askForMin(self, event = None):
|
||||
newMin = askfloat(title = self['text'],
|
||||
prompt = 'New min val:',
|
||||
initialvalue = `self['min']`,
|
||||
parent = self.interior())
|
||||
if newMin:
|
||||
self.setMin(newMin)
|
||||
|
|
@ -142,9 +153,10 @@ class EntryScale(Pmw.MegaWidget):
|
|||
self.minLabel['text'] = newMin
|
||||
self.entry.checkentry()
|
||||
|
||||
def askForMax(self):
|
||||
def askForMax(self, event = None):
|
||||
newMax = askfloat(title = self['text'],
|
||||
parent = self.interior(),
|
||||
initialvalue = self['max'],
|
||||
prompt = 'New max val:')
|
||||
if newMax:
|
||||
self.setMax(newMax)
|
||||
|
|
@ -155,6 +167,19 @@ class EntryScale(Pmw.MegaWidget):
|
|||
self.maxLabel['text'] = newMax
|
||||
self.entry.checkentry()
|
||||
|
||||
def askForResolution(self, event = None):
|
||||
newResolution = askfloat(title = self['text'],
|
||||
parent = self.interior(),
|
||||
initialvalue = self['resolution'],
|
||||
prompt = 'New resolution:')
|
||||
if newResolution:
|
||||
self.setResolution(newResolution)
|
||||
|
||||
def setResolution(self, newResolution):
|
||||
self['resolution'] = newResolution
|
||||
self.scale['resolution'] = newResolution
|
||||
self.entry.checkentry()
|
||||
|
||||
def _updateLabelText(self):
|
||||
self.label['text'] = self['text']
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue