본문으로 바로가기

label 0.0.1

category Tcl & Tk/확장 패키지 (Extension Package) 2025. 3. 5. 16:02

랩 기능을 제공하는 레이블 위젯 입니다.

Example

  wm withdraw .
  update idletasks

  set W .label_example2
  toplevel $W
  wm withdraw $W
  update idletasks

  wm title $W "Label Wrapping Example"
  wm protocol $W WM_DELETE_WINDOW exit

  tk_focusNext $W

  pack propagate $W 0
  wm geometry $W 500x300

  set image [image create photo]
  $image put red -to 0 0 16 16

  label $W.label \
    -bg white \
    -anchor nw \
    -highlightthickness 1 \
    -justify l \
    -padx 10 \
    -pady 10 \
    -takefocus 1

  set text "A label with a long text string to example auto-wrapping"

  set text "Label Wrapping

This is a demonstration of the label wrapping feature. To use, you\
should put the following code in your application:

	package require label
	# Create a new label
	label .label -text \"My Label Text\"
	bind .label <Configure> \[list label::wrap %W %w\]

You are using Tcl version $::tcl_patchLevel and Tk version\
$::tk_patchLevel."

  if { [catch {$W.label configure -compound left} err] } {
    append text " This version does not support compound images\
(labels with images and text), so there is no image to the left."
  } else {
    $W.label configure -image $image
    append text " This version supports compound images (labels with\
images and text), so you should see a red square image to the left."
  }

  append text "

If you resize this toplevel window, you should see the text in this\
label wrap to fit the width of the window."

  $W.label configure -text $text

  bind  $W.label <Configure> [list label::wrap %W %w]

# ----------------------------------------------------------------------

  button $W.button \
    -text Close \
    -default active \
    -command exit

  focus $W.button

# ----------------------------------------------------------------------

  pack $W.button -side bottom -anchor se
  pack $W.label  -side top -fill x -padx 20 -pady 20

# ----------------------------------------------------------------------

  wm deiconify $W
  raise $W

# ----------------------------------------------------------------------

Download

label-0.0.1.tgz
0.01MB

'Tcl & Tk > 확장 패키지 (Extension Package)' 카테고리의 다른 글

mentry 2.8  (0) 2025.03.05
imagine 1.0  (0) 2025.03.05
winsend 0.6  (0) 2025.03.05
TclXML 3.2  (0) 2025.03.05
baseconv 1.0  (0) 2025.03.05