Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
b6db1b94
Kaydet (Commit)
b6db1b94
authored
Ock 30, 1998
tarafından
Barry Warsaw
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
mered Greg's suggestions, added docstring
üst
7080a7f6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
18 deletions
+26
-18
ChipViewer.py
Tools/pynche/ChipViewer.py
+26
-18
No files found.
Tools/pynche/ChipViewer.py
Dosyayı görüntüle @
b6db1b94
"""Color chip megawidget.
This widget is used for displaying a color. It consists of three components:
label -- a Tkinter.Label, this is the chip's label which is displayed
about the color chip
chip -- A Tkinter.Frame, the frame displaying the color
name -- a Tkinter.Label, the name of the color
In addition, the megawidget understands the following options:
color -- the color displayed in the chip and name widgets
When run as a script, this program displays a sample chip.
"""
from
Tkinter
import
*
import
Pmw
...
...
@@ -6,10 +22,11 @@ class ChipWidget(Pmw.MegaWidget):
_HEIGHT
=
100
def
__init__
(
self
,
parent
=
None
,
**
kw
):
optionsdefs
=
((
'chipcolor'
,
'blue'
,
self
.
__set_color
),
(
'width'
,
self
.
_WIDTH
,
self
.
__set_dims
),
(
'height'
,
self
.
_HEIGHT
,
self
.
__set_dims
),
(
'text'
,
'Color'
,
self
.
__set_label
),
optionsdefs
=
((
'chip_borderwidth'
,
2
,
None
),
(
'chip_width'
,
self
.
_WIDTH
,
None
),
(
'chip_height'
,
self
.
_HEIGHT
,
None
),
(
'label_text'
,
'Color'
,
None
),
(
'color'
,
'blue'
,
self
.
__set_color
),
)
self
.
defineoptions
(
kw
,
optionsdefs
)
...
...
@@ -41,22 +58,12 @@ class ChipWidget(Pmw.MegaWidget):
# Check keywords and initialize options
self
.
initialiseoptions
(
ChipWidget
)
# called whenever `c
hipc
olor' option is set
# called whenever `color' option is set
def
__set_color
(
self
):
color
=
self
[
'c
hipc
olor'
]
color
=
self
[
'color'
]
self
.
__chip
[
'background'
]
=
color
self
.
__name
[
'text'
]
=
color
def
__set_dims
(
self
):
width
=
self
[
'width'
]
height
=
self
[
'height'
]
self
.
__chip
.
configure
(
width
=
width
,
height
=
height
)
def
__set_label
(
self
):
self
.
__label
[
'text'
]
=
self
[
'text'
]
Pmw
.
forwardmethods
(
ChipWidget
,
Frame
,
'__chip'
)
if
__name__
==
'__main__'
:
...
...
@@ -65,7 +72,8 @@ if __name__ == '__main__':
exitbtn
=
Button
(
root
,
text
=
'Exit'
,
command
=
root
.
destroy
)
exitbtn
.
pack
(
side
=
BOTTOM
)
widget
=
ChipWidget
(
root
,
chipcolor
=
'red'
,
width
=
200
,
text
=
'Selected Color'
)
widget
=
ChipWidget
(
root
,
color
=
'red'
,
chip_width
=
200
,
label_text
=
'Selected Color'
)
widget
.
pack
()
root
.
mainloop
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment