test_Floater.py 1.4 KB

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