Skip to content

Commit a0c3d67

Browse files
author
Mark Mine
committed
*** empty log message ***
1 parent 82b0ce0 commit a0c3d67

File tree

2 files changed

+76
-2
lines changed

2 files changed

+76
-2
lines changed

direct/src/doc/howto.adjust

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
HOWTO USE ADJUST()
2+
3+
What is adjust?
4+
5+
BASIC:
6+
7+
Its a simple function that allows you to quickly pop up a slider to adjust
8+
a value. Example:
9+
10+
myVal = 0.0
11+
def setMyVal(x):
12+
global myVal
13+
myVal = x
14+
print myVal
15+
16+
adjust(setMyVal)
17+
18+
this will print out the current value of the slider
19+
20+
ADVANCED:
21+
22+
You can use keyword arguments to configure the slider during or after
23+
creation, or you can configure the slider interactively
24+
25+
Useful keywords include:
26+
27+
min # min value of the slider
28+
max # max value of the slider
29+
resolution # slider resolution
30+
text # slider label
31+
32+
To set during creation call:
33+
34+
adjust(setMyVal, min = -10.0, max = 1000.0, resolution = 1.0, text = 'Fancy')
35+
36+
To set after creation:
37+
38+
es = adjust()
39+
es['command'] = setMyVal
40+
es['min'] = -1000.0
41+
es['max'] = 10.0
42+
es['resolution'] = 1.0
43+
es['text'] = 'Fancy2'
44+
45+
To configure interactively, right click (mouse button 3) on various parts
46+
of the slider to change settings. Click on:
47+
48+
from label -> to set min
49+
to label -> to set max
50+
slider -> to set resolution
51+
label -> to set slider label
52+
53+
You can pack multiple sliders into a single panel:
54+
55+
from Tkinter import *
56+
57+
def func1(x):
58+
print '1:', x
59+
60+
def func2(x):
61+
print '2:', x
62+
63+
def func3(x):
64+
print '3:', x
65+
66+
tl = Toplevel()
67+
tl.title('Fancy-multi-adjust')
68+
69+
adjust(func1, parent = tl, text = 'One')
70+
adjust(func2, parent = tl, text = 'Two')
71+
adjust(func3, parent = tl, text = 'Three')

direct/src/showbase/PythonUtil.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,9 @@ def doc(obj):
266266
(isinstance(obj, types.FunctionType)):
267267
print obj.__doc__
268268

269-
def adjust(parent = None, **kw):
269+
def adjust(command = None, parent = None, **kw):
270270
"""
271-
adjust(parent = None, **kw)
271+
adjust(command = None, parent = None, **kw)
272272
Popup and entry scale to adjust a parameter
273273
274274
Accepts any EntryScale keyword argument. Typical arguments include:
@@ -297,6 +297,9 @@ def adjust(parent = None, **kw):
297297
if not parent:
298298
parent = Toplevel()
299299
parent.title('Parameter Adjust')
300+
# Set command if specified
301+
if command:
302+
kw['command'] = command
300303
es = apply(EntryScale.EntryScale, (parent,), kw)
301304
es.pack(expand = 1, fill = X)
302305
es.parent = parent

0 commit comments

Comments
 (0)