test_EntryScale.py 1.5 KB

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