/apps/autodock_mgl.bak/autodock_mgl_1.125_i686-pc-linux-gnu/test/lib/python2.5/site-packages/Pmw/Pmw_1_3/demos/ComboBox.py

https://github.com/jackygrahamez/DrugDiscovery-Home
Python | 76 lines | 55 code | 13 blank | 8 comment | 1 complexity | d6b5dda9e2488547cc453a27ad4c399c MD5 | raw file
  1. title = 'Pmw.ComboBox demonstration'
  2. # Import Pmw from this directory tree.
  3. import sys
  4. sys.path[:0] = ['../../..']
  5. import Tkinter
  6. import Pmw
  7. class Demo:
  8. def __init__(self, parent):
  9. parent.configure(background = 'white')
  10. # Create and pack the widget to be configured.
  11. self.target = Tkinter.Label(parent,
  12. relief = 'sunken',
  13. padx = 20,
  14. pady = 20,
  15. )
  16. self.target.pack(fill = 'x', padx = 8, pady = 8)
  17. # Create and pack the simple ComboBox.
  18. words = ('Monti', 'Python', 'ik', 'den', 'Holie', 'Grailen', '(Bok)')
  19. simple = Pmw.ComboBox(parent,
  20. label_text = 'Simple ComboBox:',
  21. labelpos = 'nw',
  22. selectioncommand = self.changeText,
  23. scrolledlist_items = words,
  24. dropdown = 0,
  25. )
  26. simple.pack(side = 'left', fill = 'both',
  27. expand = 1, padx = 8, pady = 8)
  28. # Display the first text.
  29. first = words[0]
  30. simple.selectitem(first)
  31. self.changeText(first)
  32. # Create and pack the dropdown ComboBox.
  33. colours = ('cornsilk1', 'snow1', 'seashell1', 'antiquewhite1',
  34. 'bisque1', 'peachpuff1', 'navajowhite1', 'lemonchiffon1',
  35. 'ivory1', 'honeydew1', 'lavenderblush1', 'mistyrose1')
  36. dropdown = Pmw.ComboBox(parent,
  37. label_text = 'Dropdown ComboBox:',
  38. labelpos = 'nw',
  39. selectioncommand = self.changeColour,
  40. scrolledlist_items = colours,
  41. )
  42. dropdown.pack(side = 'left', anchor = 'n',
  43. fill = 'x', expand = 1, padx = 8, pady = 8)
  44. # Display the first colour.
  45. first = colours[0]
  46. dropdown.selectitem(first)
  47. self.changeColour(first)
  48. def changeColour(self, colour):
  49. print 'Colour: ' + colour
  50. self.target.configure(background = colour)
  51. def changeText(self, text):
  52. print 'Text: ' + text
  53. self.target.configure(text = text)
  54. ######################################################################
  55. # Create demo in root window for testing.
  56. if __name__ == '__main__':
  57. root = Tkinter.Tk()
  58. Pmw.initialise(root)
  59. root.title(title)
  60. exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy)
  61. exitButton.pack(side = 'bottom')
  62. widget = Demo(root)
  63. root.mainloop()