pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/7080a7f69e52f54a1d0386bf05494e83eeace568

"stylesheet" href="https://github.githubassets.com/assets/global-d18f184ea1a06a2c.css" /> Initial revision · python/cpython@7080a7f · GitHub
Skip to content

Commit 7080a7f

Browse files
committed
Initial revision
1 parent c45c2f3 commit 7080a7f

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

Tools/pynche/ChipViewer.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
from Tkinter import *
2+
import Pmw
3+
4+
class ChipWidget(Pmw.MegaWidget):
5+
_WIDTH = 80
6+
_HEIGHT = 100
7+
8+
def __init__(self, parent=None, **kw):
9+
optionsdefs = (('chipcolor', 'blue', self.__set_color),
10+
('width', self._WIDTH, self.__set_dims),
11+
('height', self._HEIGHT, self.__set_dims),
12+
('text', 'Color', self.__set_label),
13+
)
14+
self.defineoptions(kw, optionsdefs)
15+
16+
# initialize base class -- after defining options
17+
Pmw.MegaWidget.__init__(self, parent)
18+
interiorarg = (self.interior(),)
19+
20+
# create the label
21+
self.__label = self.createcomponent(
22+
# component name, aliases, group
23+
'label', (), None,
24+
# widget class, widget args
25+
Label, interiorarg)
26+
self.__label.grid(row=0, column=0)
27+
28+
# create the color chip
29+
self.__chip = self.createcomponent(
30+
'chip', (), None,
31+
Frame, interiorarg,
32+
relief=RAISED, borderwidth=2)
33+
self.__chip.grid(row=1, column=0)
34+
35+
# create the color name
36+
self.__name = self.createcomponent(
37+
'name', (), None,
38+
Label, interiorarg,)
39+
self.__name.grid(row=2, column=0)
40+
41+
# Check keywords and initialize options
42+
self.initialiseoptions(ChipWidget)
43+
44+
# called whenever `chipcolor' option is set
45+
def __set_color(self):
46+
color = self['chipcolor']
47+
self.__chip['background'] = color
48+
self.__name['text'] = color
49+
50+
def __set_dims(self):
51+
width = self['width']
52+
height = self['height']
53+
self.__chip.configure(width=width, height=height)
54+
55+
def __set_label(self):
56+
self.__label['text'] = self['text']
57+
58+
Pmw.forwardmethods(ChipWidget, Frame, '__chip')
59+
60+
61+
62+
if __name__ == '__main__':
63+
root = Pmw.initialise(fontScheme='pmw1')
64+
root.title('ChipWidget demonstration')
65+
66+
exitbtn = Button(root, text='Exit', command=root.destroy)
67+
exitbtn.pack(side=BOTTOM)
68+
widget = ChipWidget(root, chipcolor='red', width=200,
69+
text='Selected Color')
70+
widget.pack()
71+
root.mainloop()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy