test_EntryScale.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import pytest
  2. pytest.importorskip('Pmw')
  3. from direct.tkwidgets.EntryScale import EntryScale, EntryScaleGroup
  4. def test_EntryScale(tk_toplevel):
  5. # Initialise Tkinter and Pmw.
  6. root = tk_toplevel
  7. root.title('Pmw EntryScale demonstration')
  8. # Dummy command
  9. def printVal(val):
  10. print(val)
  11. # Create and pack a EntryScale megawidget.
  12. mega1 = EntryScale(root, command = printVal)
  13. mega1.pack(side = 'left', expand = 1, fill = 'x')
  14. # These are things you can set/configure
  15. # Starting value for entryScale
  16. #mega1['value'] = 123.456
  17. #mega1['text'] = 'Drive delta X'
  18. #mega1['min'] = 0.0
  19. #mega1['max'] = 1000.0
  20. #mega1['resolution'] = 1.0
  21. # To change the color of the label:
  22. #mega1.label['foreground'] = 'Red'
  23. # Max change/update, default is 100
  24. # To have really fine control, for example
  25. # mega1['maxVelocity'] = 0.1
  26. # Number of digits to the right of the decimal point, default = 2
  27. # mega1['numDigits'] = 5
  28. # To create a entryScale group to set an RGBA value:
  29. group1 = EntryScaleGroup(root, dim = 4,
  30. title = 'Simple RGBA Panel',
  31. labels = ('R', 'G', 'B', 'A'),
  32. Valuator_min = 0.0,
  33. Valuator_max = 255.0,
  34. Valuator_resolution = 1.0,
  35. command = printVal)
  36. # Uncomment this if you aren't running in IDLE
  37. #root.mainloop()