test_Floater.py 1.3 KB

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