WmDefault.txt 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. One of the bad things about Tk/Tkinter is that it does not pick up
  2. the current color and font scheme from the prevailing CDE/KDE/GNOME/Windows
  3. window manager scheme.
  4. One of the good things about Tk/Tkinter is that it is not tied to one
  5. particular widget set so it could pick up the current color and font scheme
  6. from the prevailing CDE/KDE/GNOME/Windows window manager scheme.
  7. The WmDefault package is for making Tk/Tkinter applications use the
  8. prevailing CDE/KDE/GNOME/Windows scheme. It tries to find the files
  9. and/or settings that the current window manager is using, and then
  10. sets the Tk options database accordingly (plus a few other things as well).
  11. DOWNLOAD
  12. --------
  13. Download the latest version of wm_default from http://tix.sourceforge.net
  14. either as a part of the standard Tix distribution, or as a part of the
  15. Tix Applications: http://tix.sourceforge.net/Tide. wm_default does not
  16. require Tix, but is Tix enabled.
  17. USAGE:
  18. ------
  19. For Tix versions 8.1.2 and above from http://tix.sourceforge.net,
  20. WmDefault is the default Tix scheme, so there is nothing else to do.
  21. For Tk applications, it should be sufficent at the beginning of a wish
  22. app to simply:
  23. package require wm_default
  24. wm_default::setup
  25. wm_default::addoptions
  26. The process is divided into 2 steps:
  27. 1) find the files and/or settings (::wm_default::setup).
  28. This is complete for Windows, pretty good for KDE and CDE, and
  29. still barely supported for GNOME because of the difficulty
  30. of finding and parsing sawfish definition files.
  31. setup takes one optional argument: wm, the name of the window manager
  32. as a string, if known. One of: windows gnome kde1 kde2 cde.
  33. 2) Setting the Tk options database (::wm_default::addoptions).
  34. You can override the settings in 1) by adding your values to the call
  35. to addoptions:
  36. ::wm_default::addoptions -foreground red -background blue
  37. You can examine the settings with
  38. ::wm_default::getoptions
  39. which returns a Tcl array of the current settings, and
  40. ::wm_default::parray
  41. which returns a string of the current settings, one value-pair per line.
  42. There are a number of assumptions built into the heuristics of addoptions,
  43. that may need fine tuning. Post patches to http://tix.sourceforge.net.
  44. PYTHON
  45. ______
  46. If you are using Tix versions 8.1.2 and above from http://tix.sourceforge.net
  47. with Python 2.1 and above, WmDefault is the default Tix scheme,
  48. so there is nothing else you need to do.
  49. The easiest way to install WmDefault for Tkinter is to copy the WmDefault.*
  50. AND THE FILE pkgIndex.tcl from lib/tix8.1/pref to a directory on your
  51. PYTHONPATH. Then the following should work:
  52. import Tkinter
  53. root = Tkinter.Tk()
  54. import WmDefault
  55. WmDefault.setup(root)
  56. WmDefault.addoptions(root, {'foreground': 'red'})
  57. print WmDefault.getoptions(root)
  58. SETTINGS
  59. --------
  60. Here is a list of all the settings controlled by WmDefault:
  61. wm - one of windows gnome kde1 kde2 cde kde
  62. background
  63. foreground
  64. disabledforeground
  65. disabledbackground
  66. textfamily
  67. systemfamily
  68. menufamily
  69. fixedfamily
  70. fontsize - in pixels under Unix, in points under Windows
  71. textbackground
  72. textforeground
  73. disabledtextbackground
  74. selectbackground
  75. selectforeground
  76. selectcolor
  77. highlightcolor
  78. highlightbackground
  79. scrollbars - scrollbar trough color
  80. borderwidth
  81. priority
  82. menubackground
  83. menuforeground
  84. activebackground
  85. activeforeground
  86. system_font - a Tcl font spec, a list of family size weight
  87. menu_font
  88. fixed_font
  89. text_font
  90. linkcolor - not working completely yet
  91. vlinkcolor
  92. alinkcolor
  93. TO MAKE A PREVIOUS TIX USE THIS AS THE DEFAULT SCHEME:
  94. ------------------------------------------------------
  95. 1) Compile Tix with
  96. -DTIX_DEF_SCHEME "WmDefault"
  97. -DTIX_DEF_FONTSET "WmDefault"
  98. or change the defines in generic/tixInit.c
  99. #define TIX_DEF_SCHEME "WmDefault"
  100. #define TIX_DEF_FONTSET "WmDefault"
  101. 2) Edit the installed lib/8.1/Tix.tcl and change the -configspec
  102. in tixClass tixAppContext with the following
  103. {-fontset WmDefault}
  104. {-scheme WmDefault}
  105. 3) Copy the files WmDefault.* AND pkgIndex.tcl to the installed
  106. lib/tix8.1/pref
  107. 4) Make or edit the file lib/tix8.1/pkgIndex.tcl and add the lines
  108. package ifneeded wm_default 1.0 \
  109. [list source [file join $dir pref WmDefault.tcl]]