Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../usr/lib64/tcl8.6/Tix8.4.3/pref
File: WmDefault.py
# -*- mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
[0] Fix | Delete
#
[1] Fix | Delete
# $Id: WmDefault.py,v 1.2 2001/12/09 05:03:09 idiscovery Exp $
[2] Fix | Delete
#
[3] Fix | Delete
[4] Fix | Delete
[5] Fix | Delete
"""One of the bad things about Tk/Tkinter is that it does not pick up
[6] Fix | Delete
the current color and font scheme from the prevailing CDE/KDE/GNOME/Windows
[7] Fix | Delete
window manager scheme.
[8] Fix | Delete
[9] Fix | Delete
One of the good things about Tk/Tkinter is that it is not tied to one
[10] Fix | Delete
particular widget set so it could pick up the current color and font scheme
[11] Fix | Delete
from the prevailing CDE/KDE/GNOME/Windows window manager scheme.
[12] Fix | Delete
[13] Fix | Delete
The WmDefault package is for making Tk/Tkinter applications use the
[14] Fix | Delete
prevailing CDE/KDE/GNOME/Windows scheme. It tries to find the files
[15] Fix | Delete
and/or settings that the current window manager is using, and then
[16] Fix | Delete
sets the Tk options database accordingly.
[17] Fix | Delete
[18] Fix | Delete
Download the latest version of wm_default from http://tix.sourceforge.net
[19] Fix | Delete
either as a part of the standard Tix distribution, or as a part of the
[20] Fix | Delete
Tix Applications: http://tix.sourceforge.net/Tide. wm_default does not
[21] Fix | Delete
require Tix, but is Tix enabled.
[22] Fix | Delete
"""
[23] Fix | Delete
[24] Fix | Delete
import os, sys, traceback, string
[25] Fix | Delete
import tkMessageBox
[26] Fix | Delete
[27] Fix | Delete
def setup(root, wm=''):
[28] Fix | Delete
"""1) find the files and/or settings (::wm_default::setup).
[29] Fix | Delete
Takes one optional argument: wm, the name of the window manager
[30] Fix | Delete
as a string, if known. One of: windows gnome kde1 kde2 cde kde.
[31] Fix | Delete
"""
[32] Fix | Delete
try:
[33] Fix | Delete
try:
[34] Fix | Delete
# Make sure Tcl/Tk knows wm_default is installed
[35] Fix | Delete
root.tk.eval("package require wm_default")
[36] Fix | Delete
except:
[37] Fix | Delete
# Try again with this directory on the Tcl/Tk path
[38] Fix | Delete
dir = os.path.dirname (self.__file__)
[39] Fix | Delete
root.tk.eval('global auto_path; lappend auto_path {%s}' % dir)
[40] Fix | Delete
root.tk.eval("package require wm_default")
[41] Fix | Delete
except:
[42] Fix | Delete
t, v, tb = sys.exc_info()
[43] Fix | Delete
text = "Error loading WmDefault\n"
[44] Fix | Delete
for line in traceback.format_exception(t,v,tb): text = text + line + '\n'
[45] Fix | Delete
try:
[46] Fix | Delete
tkMessageBox.showerror ('WmDefault Error', text)
[47] Fix | Delete
except:
[48] Fix | Delete
sys.stderr.write( text )
[49] Fix | Delete
[50] Fix | Delete
return root.tk.call('::wm_default::setup', wm)
[51] Fix | Delete
[52] Fix | Delete
def addoptions(root, cnf=None, **kw):
[53] Fix | Delete
"""2) Setting the Tk options database (::wm_default::addoptions).
[54] Fix | Delete
You can override the settings in 1) by adding your values to the
[55] Fix | Delete
call to addoptions().
[56] Fix | Delete
"""
[57] Fix | Delete
if cnf is None:
[58] Fix | Delete
return root.tk.splitlist(root.tk.call('::wm_default::addoptions'))
[59] Fix | Delete
return root.tk.splitlist(
[60] Fix | Delete
apply(root.tk.call,
[61] Fix | Delete
('::wm_default::addoptions',) + root._options(cnf,kw)))
[62] Fix | Delete
[63] Fix | Delete
def getoptions(root):
[64] Fix | Delete
"""Returns the current settings, as a dictionary.
[65] Fix | Delete
"""
[66] Fix | Delete
words = root.tk.splitlist(root.tk.call('::wm_default::getoptions'))
[67] Fix | Delete
dict = {}
[68] Fix | Delete
for i in range(0, len(words), 2):
[69] Fix | Delete
key = words[i]
[70] Fix | Delete
value = words[i+1]
[71] Fix | Delete
dict[key] = value
[72] Fix | Delete
return dict
[73] Fix | Delete
[74] Fix | Delete
def parray(root):
[75] Fix | Delete
"""Returns a string of the current settings, one value-pair per line.
[76] Fix | Delete
"""
[77] Fix | Delete
return root.tk.call('::wm_default::parray')
[78] Fix | Delete
[79] Fix | Delete
if __name__ == "__main__":
[80] Fix | Delete
dir = ""
[81] Fix | Delete
if len(sys.argv) > 0:
[82] Fix | Delete
# Assume the name of the file containing the tixinspect Tcl source
[83] Fix | Delete
# is the same as argument on the command line with .tcl
[84] Fix | Delete
dir = os.path.dirname(sys.argv[0])
[85] Fix | Delete
if not dir or not os.path.isdir(dir) or not os.path.isabs(dir):
[86] Fix | Delete
# Or, assume it's in the same directory as this one:
[87] Fix | Delete
dir = os.getcwd()
[88] Fix | Delete
import Tkinter
[89] Fix | Delete
root = Tkinter.Tk()
[90] Fix | Delete
setup(root)
[91] Fix | Delete
addoptions(root, {'foreground': 'red'})
[92] Fix | Delete
retval = getoptions(root)
[93] Fix | Delete
print retval
[94] Fix | Delete
[95] Fix | Delete
[96] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function