1 """This demonstrates good part of the syntax accepted by theme_create.
3 This is a translation of plastik.tcl to python.
4 You will need the images used by the plastik theme to test this. The
5 images (and other tile themes) can be retrived by doing:
7 $ cvs -z3 -d:pserver:anonymous@tktable.cvs.sourceforge.net:/cvsroot/tktable \
10 To test this module you should do, for example:
16 plastik_theme.install(plastik_image_dir)
19 Where plastik_image_dir contains the path to the images directory used by
20 the plastik theme, something like: tile-themes/plastik/plastik
25 from Tkinter
import PhotoImage
31 "disabledfg": "#aaaaaa",
32 "selectbg": "#657a9e",
37 def _load_imgs(imgdir
):
38 imgdir
= os
.path
.expanduser(imgdir
)
39 if not os
.path
.isdir(imgdir
):
40 raise Exception("%r is not a directory, can't load images" % imgdir
)
41 for f
in glob
.glob("%s/*.gif" % imgdir
):
42 img
= os
.path
.split(f
)[1]
44 imgs
[name
] = PhotoImage(name
, file=f
, format
="gif89")
49 style
.theme_create("plastik", "default", settings
={
52 {"background": colors
['frame'],
53 "troughcolor": colors
['frame'],
54 "selectbackground": colors
['selectbg'],
55 "selectforeground": colors
['selectfg'],
56 "fieldbackground": colors
['frame'],
57 "font": "TkDefaultFont",
59 "map": {"foreground": [("disabled", colors
['disabledfg'])]}
62 "Vertical.TScrollbar": {"layout": [
63 ("Vertical.Scrollbar.uparrow", {"side": "top", "sticky": ''}),
64 ("Vertical.Scrollbar.downarrow", {"side": "bottom", "sticky": ''}),
65 ("Vertical.Scrollbar.uparrow", {"side": "bottom", "sticky": ''}),
66 ("Vertical.Scrollbar.trough", {"sticky": "ns", "children":
67 [("Vertical.Scrollbar.thumb", {"expand": 1, "unit": 1,
68 "children": [("Vertical.Scrollbar.grip", {"sticky": ''})]
73 "Horizontal.TScrollbar": {"layout": [
74 ("Horizontal.Scrollbar.leftarrow", {"side": "left", "sticky": ''}),
75 ("Horizontal.Scrollbar.rightarrow",
76 {"side": "right", "sticky": ''}),
77 ("Horizontal.Scrollbar.leftarrow",
78 {"side": "right", "sticky": ''}),
79 ("Horizontal.Scrollbar.trough", {"sticky": "ew", "children":
80 [("Horizontal.Scrollbar.thumb", {"expand": 1, "unit": 1,
81 "children": [("Horizontal.Scrollbar.grip", {"sticky": ''})]
87 "configure": {"width": 10, "anchor": "center"},
89 ("Button.button", {"children":
90 [("Button.focus", {"children":
91 [("Button.padding", {"children":
92 [("Button.label", {"side": "left", "expand": 1})]
100 "configure": {"anchor": "center"},
102 ("Toolbutton.border", {"children":
103 [("Toolbutton.button", {"children":
104 [("Toolbutton.padding", {"children":
105 [("Toolbutton.label", {"side":"left", "expand":1})]
112 "TMenubutton": {"layout": [
113 ("Menubutton.button", {"children":
114 [("Menubutton.indicator", {"side": "right"}),
115 ("Menubutton.focus", {"children":
116 [("Menubutton.padding", {"children":
117 [("Menubutton.label", {"side": "left", "expand": 1})]
123 "TNotebook": {"configure": {"tabmargins": [0, 2, 0, 0]}},
125 "configure": {"padding": [6, 2, 6, 2], "expand": [0, 0, 2]},
126 "map": {"expand": [("selected", [1, 2, 4, 2])]}
128 "Treeview": {"configure": {"padding": 0}},
131 "Button.button": {"element create":
132 ("image", 'button-n',
133 ("pressed", 'button-p'), ("active", 'button-h'),
134 {"border": [4, 10], "padding": 4, "sticky":"ewns"}
138 "Toolbutton.button": {"element create":
139 ("image", 'tbutton-n',
140 ("selected", 'tbutton-p'), ("pressed", 'tbutton-p'),
141 ("active", 'tbutton-h'),
142 {"border": [4, 9], "padding": 3, "sticky": "news"}
146 "Checkbutton.indicator": {"element create":
147 ("image", 'check-nu',
148 ('active', 'selected', 'check-hc'),
149 ('pressed', 'selected', 'check-pc'),
150 ('active', 'check-hu'),
151 ("selected", 'check-nc'),
156 "Radiobutton.indicator": {"element create":
157 ("image", 'radio-nu',
158 ('active', 'selected', 'radio-hc'),
159 ('pressed', 'selected', 'radio-pc'),
160 ('active', 'radio-hu'), ('selected', 'radio-nc'),
165 "Horizontal.Scrollbar.thumb": {"element create":
166 ("image", 'hsb-n', {"border": 3, "sticky": "ew"})
169 "Horizontal.Scrollbar.grip": {"element create": ("image", 'hsb-g')},
170 "Horizontal.Scrollbar.trough": {"element create": ("image", 'hsb-t')},
171 "Vertical.Scrollbar.thumb": {"element create":
172 ("image", 'vsb-n', {"border": 3, "sticky": "ns"})
174 "Vertical.Scrollbar.grip": {"element create": ("image", 'vsb-g')},
175 "Vertical.Scrollbar.trough": {"element create": ("image", 'vsb-t')},
176 "Scrollbar.uparrow": {"element create":
177 ("image", 'arrowup-n', ("pressed", 'arrowup-p'), {"sticky": ''})
179 "Scrollbar.downarrow": {"element create":
180 ("image", 'arrowdown-n',
181 ("pressed", 'arrowdown-p'), {'sticky': ''})
183 "Scrollbar.leftarrow": {"element create":
184 ("image", 'arrowleft-n',
185 ("pressed", 'arrowleft-p'), {'sticky': ''})
187 "Scrollbar.rightarrow": {"element create":
188 ("image", 'arrowright-n', ("pressed", 'arrowright-p'),
192 "Horizontal.Scale.slider": {"element create":
193 ("image", 'hslider-n', {'sticky': ''})
195 "Horizontal.Scale.trough": {"element create":
196 ("image", 'hslider-t', {'border': 1, 'padding': 0})
198 "Vertical.Scale.slider": {"element create":
199 ("image", 'vslider-n', {'sticky': ''})
201 "Vertical.Scale.trough": {"element create":
202 ("image", 'vslider-t', {'border': 1, 'padding': 0})
205 "Entry.field": {"element create":
207 ("focus", 'entry-f'),
208 {'border': 2, 'padding': [3, 4], 'sticky': 'news'}
212 "Labelframe.border": {"element create":
213 ("image", 'border', {'border': 4, 'padding': 4, 'sticky': 'news'})
216 "Menubutton.button": {"element create":
218 ('active', 'combo-ra'),
219 {'sticky': 'news', 'border': [4, 6, 24, 15],
220 'padding': [4, 4, 5]}
223 "Menubutton.indicator": {"element create":
224 ("image", 'arrow-d', {"sticky": "e", "border": [15, 0, 0, 0]})
227 "Combobox.field": {"element create":
229 ('readonly', 'active', 'combo-ra'),
230 ('focus', 'active', 'combo-fa'),
231 ('active', 'combo-a'), ('!readonly', 'focus', 'combo-f'),
232 ('readonly', 'combo-r'),
233 {'border': [4, 6, 24, 15], 'padding': [4, 4, 5],
237 "Combobox.downarrow": {"element create":
238 ("image", 'arrow-d', {'sticky': 'e', 'border': [15, 0, 0, 0]})
241 "Notebook.client": {"element create":
242 ("image", 'notebook-c', {'border': 4})
244 "Notebook.tab": {"element create":
245 ("image", 'notebook-tn',
246 ("selected", 'notebook-ts'), ("active", 'notebook-ta'),
247 {'padding': [0, 2, 0, 0], 'border': [4, 10, 4, 10]}
251 "Progressbar.trough": {"element create":
252 ("image", 'hprogress-t', {'border': 2})
254 "Horizontal.Progressbar.pbar": {"element create":
255 ("image", 'hprogress-b', {'border': [2, 9]})
257 "Vertical.Progressbar.pbar": {"element create":
258 ("image", 'vprogress-b', {'border': [9, 2]})
261 "Treeheading.cell": {"element create":
263 ("pressed", 'tree-p'),
264 {'border': [4, 10], 'padding': 4, 'sticky': 'news'}
269 style
.theme_use("plastik")