mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
* updated for Tk-8.5/Tile-0.8.0
git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@175 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
parent
93907151a8
commit
2477ad8845
28 changed files with 3299 additions and 251 deletions
700
data/tcl/clrpick8.5.tcl
Normal file
700
data/tcl/clrpick8.5.tcl
Normal file
|
@ -0,0 +1,700 @@
|
||||||
|
# clrpick.tcl --
|
||||||
|
#
|
||||||
|
# Color selection dialog for platforms that do not support a
|
||||||
|
# standard color selection dialog.
|
||||||
|
#
|
||||||
|
# RCS: @(#) $Id: clrpick.tcl,v 1.20.2.2 2006/03/17 10:50:11 patthoyts Exp $
|
||||||
|
#
|
||||||
|
# Copyright (c) 1996 Sun Microsystems, Inc.
|
||||||
|
#
|
||||||
|
# See the file "license.terms" for information on usage and redistribution
|
||||||
|
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
|
#
|
||||||
|
# ToDo:
|
||||||
|
#
|
||||||
|
# (1): Find out how many free colors are left in the colormap and
|
||||||
|
# don't allocate too many colors.
|
||||||
|
# (2): Implement HSV color selection.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Make sure namespaces exist
|
||||||
|
namespace eval ::tk {}
|
||||||
|
namespace eval ::tk::dialog {}
|
||||||
|
namespace eval ::tk::dialog::color {
|
||||||
|
namespace import ::tk::msgcat::*
|
||||||
|
}
|
||||||
|
|
||||||
|
# ::tk::dialog::color:: --
|
||||||
|
#
|
||||||
|
# Create a color dialog and let the user choose a color. This function
|
||||||
|
# should not be called directly. It is called by the tk_chooseColor
|
||||||
|
# function when a native color selector widget does not exist
|
||||||
|
#
|
||||||
|
proc ::tk::dialog::color:: {args} {
|
||||||
|
variable ::tk::Priv
|
||||||
|
set dataName __tk__color
|
||||||
|
upvar ::tk::dialog::color::$dataName data
|
||||||
|
set w .$dataName
|
||||||
|
|
||||||
|
# The lines variables track the start and end indices of the line
|
||||||
|
# elements in the colorbar canvases.
|
||||||
|
set data(lines,red,start) 0
|
||||||
|
set data(lines,red,last) -1
|
||||||
|
set data(lines,green,start) 0
|
||||||
|
set data(lines,green,last) -1
|
||||||
|
set data(lines,blue,start) 0
|
||||||
|
set data(lines,blue,last) -1
|
||||||
|
|
||||||
|
# This is the actual number of lines that are drawn in each color strip.
|
||||||
|
# Note that the bars may be of any width.
|
||||||
|
# However, NUM_COLORBARS must be a number that evenly divides 256.
|
||||||
|
# Such as 256, 128, 64, etc.
|
||||||
|
set data(NUM_COLORBARS) 16
|
||||||
|
|
||||||
|
# BARS_WIDTH is the number of pixels wide the color bar portion of the
|
||||||
|
# canvas is. This number must be a multiple of NUM_COLORBARS
|
||||||
|
set data(BARS_WIDTH) 160
|
||||||
|
|
||||||
|
# PLGN_WIDTH is the number of pixels wide of the triangular selection
|
||||||
|
# polygon. This also results in the definition of the padding on the
|
||||||
|
# left and right sides which is half of PLGN_WIDTH. Make this number even.
|
||||||
|
set data(PLGN_HEIGHT) 10
|
||||||
|
|
||||||
|
# PLGN_HEIGHT is the height of the selection polygon and the height of the
|
||||||
|
# selection rectangle at the bottom of the color bar. No restrictions.
|
||||||
|
set data(PLGN_WIDTH) 10
|
||||||
|
|
||||||
|
Config $dataName $args
|
||||||
|
InitValues $dataName
|
||||||
|
|
||||||
|
set sc [winfo screen $data(-parent)]
|
||||||
|
set winExists [winfo exists $w]
|
||||||
|
if {!$winExists || $sc ne [winfo screen $w]} {
|
||||||
|
if {$winExists} {
|
||||||
|
destroy $w
|
||||||
|
}
|
||||||
|
toplevel $w -class TkColorDialog -screen $sc
|
||||||
|
BuildDialog $w
|
||||||
|
}
|
||||||
|
|
||||||
|
# Dialog boxes should be transient with respect to their parent,
|
||||||
|
# so that they will always stay on top of their parent window. However,
|
||||||
|
# some window managers will create the window as withdrawn if the parent
|
||||||
|
# window is withdrawn or iconified. Combined with the grab we put on the
|
||||||
|
# window, this can hang the entire application. Therefore we only make
|
||||||
|
# the dialog transient if the parent is viewable.
|
||||||
|
|
||||||
|
if {[winfo viewable [winfo toplevel $data(-parent)]] } {
|
||||||
|
wm transient $w $data(-parent)
|
||||||
|
}
|
||||||
|
|
||||||
|
# 5. Withdraw the window, then update all the geometry information
|
||||||
|
# so we know how big it wants to be, then center the window in the
|
||||||
|
# display and de-iconify it.
|
||||||
|
|
||||||
|
::tk::PlaceWindow $w widget $data(-parent)
|
||||||
|
wm title $w $data(-title)
|
||||||
|
|
||||||
|
# 6. Set a grab and claim the focus too.
|
||||||
|
|
||||||
|
::tk::SetFocusGrab $w $data(okBtn)
|
||||||
|
|
||||||
|
# 7. Wait for the user to respond, then restore the focus and
|
||||||
|
# return the index of the selected button. Restore the focus
|
||||||
|
# before deleting the window, since otherwise the window manager
|
||||||
|
# may take the focus away so we can't redirect it. Finally,
|
||||||
|
# restore any grab that was in effect.
|
||||||
|
|
||||||
|
vwait ::tk::Priv(selectColor)
|
||||||
|
::tk::RestoreFocusGrab $w $data(okBtn)
|
||||||
|
unset data
|
||||||
|
|
||||||
|
return $Priv(selectColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
# ::tk::dialog::color::InitValues --
|
||||||
|
#
|
||||||
|
# Get called during initialization or when user resets NUM_COLORBARS
|
||||||
|
#
|
||||||
|
proc ::tk::dialog::color::InitValues {dataName} {
|
||||||
|
upvar ::tk::dialog::color::$dataName data
|
||||||
|
|
||||||
|
# IntensityIncr is the difference in color intensity between a colorbar
|
||||||
|
# and its neighbors.
|
||||||
|
set data(intensityIncr) [expr {256 / $data(NUM_COLORBARS)}]
|
||||||
|
|
||||||
|
# ColorbarWidth is the width of each colorbar
|
||||||
|
set data(colorbarWidth) \
|
||||||
|
[expr {$data(BARS_WIDTH) / $data(NUM_COLORBARS)}]
|
||||||
|
|
||||||
|
# Indent is the width of the space at the left and right side of the
|
||||||
|
# colorbar. It is always half the selector polygon width, because the
|
||||||
|
# polygon extends into the space.
|
||||||
|
set data(indent) [expr {$data(PLGN_WIDTH) / 2}]
|
||||||
|
|
||||||
|
set data(colorPad) 2
|
||||||
|
set data(selPad) [expr {$data(PLGN_WIDTH) / 2}]
|
||||||
|
|
||||||
|
#
|
||||||
|
# minX is the x coordinate of the first colorbar
|
||||||
|
#
|
||||||
|
set data(minX) $data(indent)
|
||||||
|
|
||||||
|
#
|
||||||
|
# maxX is the x coordinate of the last colorbar
|
||||||
|
#
|
||||||
|
set data(maxX) [expr {$data(BARS_WIDTH) + $data(indent)-1}]
|
||||||
|
|
||||||
|
#
|
||||||
|
# canvasWidth is the width of the entire canvas, including the indents
|
||||||
|
#
|
||||||
|
set data(canvasWidth) [expr {$data(BARS_WIDTH) + $data(PLGN_WIDTH)}]
|
||||||
|
|
||||||
|
# Set the initial color, specified by -initialcolor, or the
|
||||||
|
# color chosen by the user the last time.
|
||||||
|
set data(selection) $data(-initialcolor)
|
||||||
|
set data(finalColor) $data(-initialcolor)
|
||||||
|
set rgb [winfo rgb . $data(selection)]
|
||||||
|
|
||||||
|
set data(red,intensity) [expr {[lindex $rgb 0]/0x100}]
|
||||||
|
set data(green,intensity) [expr {[lindex $rgb 1]/0x100}]
|
||||||
|
set data(blue,intensity) [expr {[lindex $rgb 2]/0x100}]
|
||||||
|
}
|
||||||
|
|
||||||
|
# ::tk::dialog::color::Config --
|
||||||
|
#
|
||||||
|
# Parses the command line arguments to tk_chooseColor
|
||||||
|
#
|
||||||
|
proc ::tk::dialog::color::Config {dataName argList} {
|
||||||
|
variable ::tk::Priv
|
||||||
|
upvar ::tk::dialog::color::$dataName data
|
||||||
|
|
||||||
|
# 1: the configuration specs
|
||||||
|
#
|
||||||
|
if {[info exists Priv(selectColor)] && $Priv(selectColor) ne ""} {
|
||||||
|
set defaultColor $Priv(selectColor)
|
||||||
|
} else {
|
||||||
|
set defaultColor [. cget -background]
|
||||||
|
}
|
||||||
|
|
||||||
|
set specs [list \
|
||||||
|
[list -initialcolor "" "" $defaultColor] \
|
||||||
|
[list -parent "" "" "."] \
|
||||||
|
[list -title "" "" [mc "Color"]] \
|
||||||
|
]
|
||||||
|
|
||||||
|
# 2: parse the arguments
|
||||||
|
#
|
||||||
|
tclParseConfigSpec ::tk::dialog::color::$dataName $specs "" $argList
|
||||||
|
|
||||||
|
if {$data(-title) eq ""} {
|
||||||
|
set data(-title) " "
|
||||||
|
}
|
||||||
|
if {[catch {winfo rgb . $data(-initialcolor)} err]} {
|
||||||
|
error $err
|
||||||
|
}
|
||||||
|
|
||||||
|
if {![winfo exists $data(-parent)]} {
|
||||||
|
error "bad window path name \"$data(-parent)\""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# ::tk::dialog::color::BuildDialog --
|
||||||
|
#
|
||||||
|
# Build the dialog.
|
||||||
|
#
|
||||||
|
proc ::tk::dialog::color::BuildDialog {w} {
|
||||||
|
upvar ::tk::dialog::color::[winfo name $w] data
|
||||||
|
|
||||||
|
# TopFrame contains the color strips and the color selection
|
||||||
|
#
|
||||||
|
set topFrame [ttk::frame $w.top]
|
||||||
|
|
||||||
|
# StripsFrame contains the colorstrips and the individual RGB entries
|
||||||
|
set stripsFrame [ttk::frame $topFrame.colorStrip]
|
||||||
|
|
||||||
|
set maxWidth [::tk::mcmaxamp &Red &Green &Blue]
|
||||||
|
incr maxWidth
|
||||||
|
set maxWidth [expr {$maxWidth<6?6:$maxWidth}]
|
||||||
|
set colorList [list \
|
||||||
|
red [mc "&Red"] \
|
||||||
|
green [mc "&Green"] \
|
||||||
|
blue [mc "&Blue"] \
|
||||||
|
]
|
||||||
|
foreach {color l} $colorList {
|
||||||
|
# each f frame contains an [R|G|B] entry and the equiv. color strip.
|
||||||
|
set f [ttk::frame $stripsFrame.$color]
|
||||||
|
|
||||||
|
# The box frame contains the label and entry widget for an [R|G|B]
|
||||||
|
set box [ttk::frame $f.box]
|
||||||
|
|
||||||
|
bind [::tk::AmpWidget ttk::label $box.label -text $l: -width $maxWidth \
|
||||||
|
-anchor ne] <<AltUnderlined>> [list focus $box.entry]
|
||||||
|
|
||||||
|
ttk::entry $box.entry -textvariable \
|
||||||
|
::tk::dialog::color::[winfo name $w]($color,intensity) \
|
||||||
|
-width 4
|
||||||
|
pack $box.label -side left -fill y -padx 2 -pady 2
|
||||||
|
pack $box.entry -side left -anchor n -padx 2 -pady 1
|
||||||
|
pack $box -side left -fill both
|
||||||
|
|
||||||
|
set height [expr {[winfo reqheight $box.entry] - 4}]
|
||||||
|
|
||||||
|
canvas $f.color -height $height -width $data(BARS_WIDTH) \
|
||||||
|
-relief sunken -bd 2 -highlightthickness 0
|
||||||
|
canvas $f.sel -height $data(PLGN_HEIGHT) \
|
||||||
|
-width $data(canvasWidth) -highlightthickness 0 \
|
||||||
|
-bg [ttk::style lookup . -background]
|
||||||
|
pack $f.color
|
||||||
|
pack $f.sel -expand yes -fill both
|
||||||
|
|
||||||
|
pack $f -side top -fill x -padx 0 -pady 2
|
||||||
|
|
||||||
|
set data($color,entry) $box.entry
|
||||||
|
set data($color,col) $f.color
|
||||||
|
set data($color,sel) $f.sel
|
||||||
|
|
||||||
|
bind $data($color,col) <Configure> \
|
||||||
|
[list tk::dialog::color::DrawColorScale $w $color 1]
|
||||||
|
bind $data($color,col) <Enter> \
|
||||||
|
[list tk::dialog::color::EnterColorBar $w $color]
|
||||||
|
bind $data($color,col) <Leave> \
|
||||||
|
[list tk::dialog::color::LeaveColorBar $w $color]
|
||||||
|
|
||||||
|
bind $data($color,sel) <Enter> \
|
||||||
|
[list tk::dialog::color::EnterColorBar $w $color]
|
||||||
|
bind $data($color,sel) <Leave> \
|
||||||
|
[list tk::dialog::color::LeaveColorBar $w $color]
|
||||||
|
|
||||||
|
bind $box.entry <Return> [list tk::dialog::color::HandleRGBEntry $w]
|
||||||
|
}
|
||||||
|
|
||||||
|
pack $stripsFrame -side left -fill both -padx 4 -pady 10
|
||||||
|
|
||||||
|
# The selFrame contains a frame that demonstrates the currently
|
||||||
|
# selected color
|
||||||
|
#
|
||||||
|
set selFrame [ttk::frame $topFrame.sel]
|
||||||
|
set lab [::tk::AmpWidget ttk::label $selFrame.lab -text [mc "&Selection:"] \
|
||||||
|
-anchor sw]
|
||||||
|
set ent [ttk::entry $selFrame.ent \
|
||||||
|
-textvariable ::tk::dialog::color::[winfo name $w](selection) \
|
||||||
|
-width 16]
|
||||||
|
set f1 [frame $selFrame.f1 -relief sunken -bd 2]
|
||||||
|
set data(finalCanvas) [canvas $f1.demo -relief flat \
|
||||||
|
-width 100 -height 70 -highlightthickness 0]
|
||||||
|
|
||||||
|
pack $lab $ent -side top -fill x -padx 4 -pady 2
|
||||||
|
pack $f1 -expand yes -anchor nw -fill both -padx 6 -pady 10
|
||||||
|
pack $data(finalCanvas) -expand yes -fill both
|
||||||
|
|
||||||
|
bind $ent <Return> [list tk::dialog::color::HandleSelEntry $w]
|
||||||
|
|
||||||
|
pack $selFrame -side left -fill none -anchor nw
|
||||||
|
pack $topFrame -side top -expand yes -fill both -anchor nw
|
||||||
|
|
||||||
|
# the botFrame frame contains the buttons
|
||||||
|
#
|
||||||
|
set sep [ttk::separator $w.sep]
|
||||||
|
set botFrame [ttk::frame $w.bot]
|
||||||
|
|
||||||
|
set maxWidth [::tk::mcmaxamp &OK &Cancel]
|
||||||
|
set maxWidth [expr {$maxWidth<8?8:$maxWidth}]
|
||||||
|
|
||||||
|
::tk::AmpWidget ttk::button $botFrame.ok -text [mc "&OK"] \
|
||||||
|
-command [list tk::dialog::color::OkCmd $w] -width $maxWidth
|
||||||
|
::tk::AmpWidget ttk::button $botFrame.cancel -text [mc "&Cancel"] \
|
||||||
|
-command [list tk::dialog::color::CancelCmd $w] -width $maxWidth
|
||||||
|
|
||||||
|
set data(okBtn) $botFrame.ok
|
||||||
|
set data(cancelBtn) $botFrame.cancel
|
||||||
|
|
||||||
|
grid x $botFrame.ok x $botFrame.cancel x -sticky e
|
||||||
|
grid configure $botFrame.ok -pady 8
|
||||||
|
grid configure $botFrame.cancel -padx 10 -pady 8
|
||||||
|
grid columnconfigure $botFrame 0 -weight 1
|
||||||
|
pack $botFrame $sep -side bottom -fill x
|
||||||
|
|
||||||
|
|
||||||
|
# Accelerator bindings
|
||||||
|
bind $lab <<AltUnderlined>> [list focus $ent]
|
||||||
|
bind $w <KeyPress-Escape> [list tk::ButtonInvoke $data(cancelBtn)]
|
||||||
|
bind $w <Alt-Key> [list tk::AltKeyInDialog $w %A]
|
||||||
|
|
||||||
|
wm protocol $w WM_DELETE_WINDOW [list tk::dialog::color::CancelCmd $w]
|
||||||
|
}
|
||||||
|
|
||||||
|
# ::tk::dialog::color::SetRGBValue --
|
||||||
|
#
|
||||||
|
# Sets the current selection of the dialog box
|
||||||
|
#
|
||||||
|
proc ::tk::dialog::color::SetRGBValue {w color} {
|
||||||
|
upvar ::tk::dialog::color::[winfo name $w] data
|
||||||
|
|
||||||
|
set data(red,intensity) [lindex $color 0]
|
||||||
|
set data(green,intensity) [lindex $color 1]
|
||||||
|
set data(blue,intensity) [lindex $color 2]
|
||||||
|
|
||||||
|
RedrawColorBars $w all
|
||||||
|
|
||||||
|
# Now compute the new x value of each colorbars pointer polygon
|
||||||
|
foreach color [list red green blue ] {
|
||||||
|
set x [RgbToX $w $data($color,intensity)]
|
||||||
|
MoveSelector $w $data($color,sel) $color $x 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# ::tk::dialog::color::XToRgb --
|
||||||
|
#
|
||||||
|
# Converts a screen coordinate to intensity
|
||||||
|
#
|
||||||
|
proc ::tk::dialog::color::XToRgb {w x} {
|
||||||
|
upvar ::tk::dialog::color::[winfo name $w] data
|
||||||
|
|
||||||
|
set x [expr {($x * $data(intensityIncr))/ $data(colorbarWidth)}]
|
||||||
|
if {$x > 255} { set x 255 }
|
||||||
|
return $x
|
||||||
|
}
|
||||||
|
|
||||||
|
# ::tk::dialog::color::RgbToX
|
||||||
|
#
|
||||||
|
# Converts an intensity to screen coordinate.
|
||||||
|
#
|
||||||
|
proc ::tk::dialog::color::RgbToX {w color} {
|
||||||
|
upvar ::tk::dialog::color::[winfo name $w] data
|
||||||
|
|
||||||
|
return [expr {($color * $data(colorbarWidth)/ $data(intensityIncr))}]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# ::tk::dialog::color::DrawColorScale --
|
||||||
|
#
|
||||||
|
# Draw color scale is called whenever the size of one of the color
|
||||||
|
# scale canvases is changed.
|
||||||
|
#
|
||||||
|
proc ::tk::dialog::color::DrawColorScale {w c {create 0}} {
|
||||||
|
upvar ::tk::dialog::color::[winfo name $w] data
|
||||||
|
|
||||||
|
# col: color bar canvas
|
||||||
|
# sel: selector canvas
|
||||||
|
set col $data($c,col)
|
||||||
|
set sel $data($c,sel)
|
||||||
|
|
||||||
|
# First handle the case that we are creating everything for the first time.
|
||||||
|
if {$create} {
|
||||||
|
# First remove all the lines that already exist.
|
||||||
|
if { $data(lines,$c,last) > $data(lines,$c,start)} {
|
||||||
|
for {set i $data(lines,$c,start)} \
|
||||||
|
{$i <= $data(lines,$c,last)} { incr i} {
|
||||||
|
$sel delete $i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# Delete the selector if it exists
|
||||||
|
if {[info exists data($c,index)]} {
|
||||||
|
$sel delete $data($c,index)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Draw the selection polygons
|
||||||
|
CreateSelector $w $sel $c
|
||||||
|
$sel bind $data($c,index) <ButtonPress-1> \
|
||||||
|
[list tk::dialog::color::StartMove $w $sel $c %x $data(selPad) 1]
|
||||||
|
$sel bind $data($c,index) <B1-Motion> \
|
||||||
|
[list tk::dialog::color::MoveSelector $w $sel $c %x $data(selPad)]
|
||||||
|
$sel bind $data($c,index) <ButtonRelease-1> \
|
||||||
|
[list tk::dialog::color::ReleaseMouse $w $sel $c %x $data(selPad)]
|
||||||
|
|
||||||
|
set height [winfo height $col]
|
||||||
|
# Create an invisible region under the colorstrip to catch mouse clicks
|
||||||
|
# that aren't on the selector.
|
||||||
|
set data($c,clickRegion) [$sel create rectangle 0 0 \
|
||||||
|
$data(canvasWidth) $height -fill {} -outline {}]
|
||||||
|
|
||||||
|
bind $col <ButtonPress-1> \
|
||||||
|
[list tk::dialog::color::StartMove $w $sel $c %x $data(colorPad)]
|
||||||
|
bind $col <B1-Motion> \
|
||||||
|
[list tk::dialog::color::MoveSelector $w $sel $c %x $data(colorPad)]
|
||||||
|
bind $col <ButtonRelease-1> \
|
||||||
|
[list tk::dialog::color::ReleaseMouse $w $sel $c %x $data(colorPad)]
|
||||||
|
|
||||||
|
$sel bind $data($c,clickRegion) <ButtonPress-1> \
|
||||||
|
[list tk::dialog::color::StartMove $w $sel $c %x $data(selPad)]
|
||||||
|
$sel bind $data($c,clickRegion) <B1-Motion> \
|
||||||
|
[list tk::dialog::color::MoveSelector $w $sel $c %x $data(selPad)]
|
||||||
|
$sel bind $data($c,clickRegion) <ButtonRelease-1> \
|
||||||
|
[list tk::dialog::color::ReleaseMouse $w $sel $c %x $data(selPad)]
|
||||||
|
} else {
|
||||||
|
# l is the canvas index of the first colorbar.
|
||||||
|
set l $data(lines,$c,start)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Draw the color bars.
|
||||||
|
set highlightW [expr {[$col cget -highlightthickness] + [$col cget -bd]}]
|
||||||
|
for {set i 0} { $i < $data(NUM_COLORBARS)} { incr i} {
|
||||||
|
set intensity [expr {$i * $data(intensityIncr)}]
|
||||||
|
set startx [expr {$i * $data(colorbarWidth) + $highlightW}]
|
||||||
|
if {$c eq "red"} {
|
||||||
|
set color [format "#%02x%02x%02x" \
|
||||||
|
$intensity \
|
||||||
|
$data(green,intensity) \
|
||||||
|
$data(blue,intensity)]
|
||||||
|
} elseif {$c eq "green"} {
|
||||||
|
set color [format "#%02x%02x%02x" \
|
||||||
|
$data(red,intensity) \
|
||||||
|
$intensity \
|
||||||
|
$data(blue,intensity)]
|
||||||
|
} else {
|
||||||
|
set color [format "#%02x%02x%02x" \
|
||||||
|
$data(red,intensity) \
|
||||||
|
$data(green,intensity) \
|
||||||
|
$intensity]
|
||||||
|
}
|
||||||
|
|
||||||
|
if {$create} {
|
||||||
|
set index [$col create rect $startx $highlightW \
|
||||||
|
[expr {$startx +$data(colorbarWidth)}] \
|
||||||
|
[expr {[winfo height $col] + $highlightW}]\
|
||||||
|
-fill $color -outline $color]
|
||||||
|
} else {
|
||||||
|
$col itemconfigure $l -fill $color -outline $color
|
||||||
|
incr l
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$sel raise $data($c,index)
|
||||||
|
|
||||||
|
if {$create} {
|
||||||
|
set data(lines,$c,last) $index
|
||||||
|
set data(lines,$c,start) [expr {$index - $data(NUM_COLORBARS) + 1}]
|
||||||
|
}
|
||||||
|
|
||||||
|
RedrawFinalColor $w
|
||||||
|
}
|
||||||
|
|
||||||
|
# ::tk::dialog::color::CreateSelector --
|
||||||
|
#
|
||||||
|
# Creates and draws the selector polygon at the position
|
||||||
|
# $data($c,intensity).
|
||||||
|
#
|
||||||
|
proc ::tk::dialog::color::CreateSelector {w sel c } {
|
||||||
|
upvar ::tk::dialog::color::[winfo name $w] data
|
||||||
|
set data($c,index) [$sel create polygon \
|
||||||
|
0 $data(PLGN_HEIGHT) \
|
||||||
|
$data(PLGN_WIDTH) $data(PLGN_HEIGHT) \
|
||||||
|
$data(indent) 0]
|
||||||
|
set data($c,x) [RgbToX $w $data($c,intensity)]
|
||||||
|
$sel move $data($c,index) $data($c,x) 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# ::tk::dialog::color::RedrawFinalColor
|
||||||
|
#
|
||||||
|
# Combines the intensities of the three colors into the final color
|
||||||
|
#
|
||||||
|
proc ::tk::dialog::color::RedrawFinalColor {w} {
|
||||||
|
upvar ::tk::dialog::color::[winfo name $w] data
|
||||||
|
|
||||||
|
set color [format "#%02x%02x%02x" $data(red,intensity) \
|
||||||
|
$data(green,intensity) $data(blue,intensity)]
|
||||||
|
|
||||||
|
$data(finalCanvas) configure -background $color
|
||||||
|
set data(finalColor) $color
|
||||||
|
set data(selection) $color
|
||||||
|
set data(finalRGB) [list \
|
||||||
|
$data(red,intensity) \
|
||||||
|
$data(green,intensity) \
|
||||||
|
$data(blue,intensity)]
|
||||||
|
}
|
||||||
|
|
||||||
|
# ::tk::dialog::color::RedrawColorBars --
|
||||||
|
#
|
||||||
|
# Only redraws the colors on the color strips that were not manipulated.
|
||||||
|
# Params: color of colorstrip that changed. If color is not [red|green|blue]
|
||||||
|
# Then all colorstrips will be updated
|
||||||
|
#
|
||||||
|
proc ::tk::dialog::color::RedrawColorBars {w colorChanged} {
|
||||||
|
upvar ::tk::dialog::color::[winfo name $w] data
|
||||||
|
|
||||||
|
switch $colorChanged {
|
||||||
|
red {
|
||||||
|
DrawColorScale $w green
|
||||||
|
DrawColorScale $w blue
|
||||||
|
}
|
||||||
|
green {
|
||||||
|
DrawColorScale $w red
|
||||||
|
DrawColorScale $w blue
|
||||||
|
}
|
||||||
|
blue {
|
||||||
|
DrawColorScale $w red
|
||||||
|
DrawColorScale $w green
|
||||||
|
}
|
||||||
|
default {
|
||||||
|
DrawColorScale $w red
|
||||||
|
DrawColorScale $w green
|
||||||
|
DrawColorScale $w blue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RedrawFinalColor $w
|
||||||
|
}
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
# Event handlers
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
# ::tk::dialog::color::StartMove --
|
||||||
|
#
|
||||||
|
# Handles a mousedown button event over the selector polygon.
|
||||||
|
# Adds the bindings for moving the mouse while the button is
|
||||||
|
# pressed. Sets the binding for the button-release event.
|
||||||
|
#
|
||||||
|
# Params: sel is the selector canvas window, color is the color of the strip.
|
||||||
|
#
|
||||||
|
proc ::tk::dialog::color::StartMove {w sel color x delta {dontMove 0}} {
|
||||||
|
upvar ::tk::dialog::color::[winfo name $w] data
|
||||||
|
|
||||||
|
if {!$dontMove} {
|
||||||
|
MoveSelector $w $sel $color $x $delta
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# ::tk::dialog::color::MoveSelector --
|
||||||
|
#
|
||||||
|
# Moves the polygon selector so that its middle point has the same
|
||||||
|
# x value as the specified x. If x is outside the bounds [0,255],
|
||||||
|
# the selector is set to the closest endpoint.
|
||||||
|
#
|
||||||
|
# Params: sel is the selector canvas, c is [red|green|blue]
|
||||||
|
# x is a x-coordinate.
|
||||||
|
#
|
||||||
|
proc ::tk::dialog::color::MoveSelector {w sel color x delta} {
|
||||||
|
upvar ::tk::dialog::color::[winfo name $w] data
|
||||||
|
|
||||||
|
incr x -$delta
|
||||||
|
|
||||||
|
if { $x < 0 } {
|
||||||
|
set x 0
|
||||||
|
} elseif { $x > $data(BARS_WIDTH)} {
|
||||||
|
set x $data(BARS_WIDTH)
|
||||||
|
}
|
||||||
|
set diff [expr {$x - $data($color,x)}]
|
||||||
|
$sel move $data($color,index) $diff 0
|
||||||
|
set data($color,x) [expr {$data($color,x) + $diff}]
|
||||||
|
|
||||||
|
# Return the x value that it was actually set at
|
||||||
|
return $x
|
||||||
|
}
|
||||||
|
|
||||||
|
# ::tk::dialog::color::ReleaseMouse
|
||||||
|
#
|
||||||
|
# Removes mouse tracking bindings, updates the colorbars.
|
||||||
|
#
|
||||||
|
# Params: sel is the selector canvas, color is the color of the strip,
|
||||||
|
# x is the x-coord of the mouse.
|
||||||
|
#
|
||||||
|
proc ::tk::dialog::color::ReleaseMouse {w sel color x delta} {
|
||||||
|
upvar ::tk::dialog::color::[winfo name $w] data
|
||||||
|
|
||||||
|
set x [MoveSelector $w $sel $color $x $delta]
|
||||||
|
|
||||||
|
# Determine exactly what color we are looking at.
|
||||||
|
set data($color,intensity) [XToRgb $w $x]
|
||||||
|
|
||||||
|
RedrawColorBars $w $color
|
||||||
|
}
|
||||||
|
|
||||||
|
# ::tk::dialog::color::ResizeColorbars --
|
||||||
|
#
|
||||||
|
# Completely redraws the colorbars, including resizing the
|
||||||
|
# colorstrips
|
||||||
|
#
|
||||||
|
proc ::tk::dialog::color::ResizeColorBars {w} {
|
||||||
|
upvar ::tk::dialog::color::[winfo name $w] data
|
||||||
|
|
||||||
|
if { ($data(BARS_WIDTH) < $data(NUM_COLORBARS)) ||
|
||||||
|
(($data(BARS_WIDTH) % $data(NUM_COLORBARS)) != 0)} {
|
||||||
|
set data(BARS_WIDTH) $data(NUM_COLORBARS)
|
||||||
|
}
|
||||||
|
InitValues [winfo name $w]
|
||||||
|
foreach color [list red green blue ] {
|
||||||
|
$data($color,col) configure -width $data(canvasWidth)
|
||||||
|
DrawColorScale $w $color 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# ::tk::dialog::color::HandleSelEntry --
|
||||||
|
#
|
||||||
|
# Handles the return keypress event in the "Selection:" entry
|
||||||
|
#
|
||||||
|
proc ::tk::dialog::color::HandleSelEntry {w} {
|
||||||
|
upvar ::tk::dialog::color::[winfo name $w] data
|
||||||
|
|
||||||
|
set text [string trim $data(selection)]
|
||||||
|
# Check to make sure that the color is valid
|
||||||
|
if {[catch {set color [winfo rgb . $text]} ]} {
|
||||||
|
set data(selection) $data(finalColor)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
set R [expr {[lindex $color 0]/0x100}]
|
||||||
|
set G [expr {[lindex $color 1]/0x100}]
|
||||||
|
set B [expr {[lindex $color 2]/0x100}]
|
||||||
|
|
||||||
|
SetRGBValue $w "$R $G $B"
|
||||||
|
set data(selection) $text
|
||||||
|
}
|
||||||
|
|
||||||
|
# ::tk::dialog::color::HandleRGBEntry --
|
||||||
|
#
|
||||||
|
# Handles the return keypress event in the R, G or B entry
|
||||||
|
#
|
||||||
|
proc ::tk::dialog::color::HandleRGBEntry {w} {
|
||||||
|
upvar ::tk::dialog::color::[winfo name $w] data
|
||||||
|
|
||||||
|
foreach c [list red green blue] {
|
||||||
|
if {[catch {
|
||||||
|
set data($c,intensity) [expr {int($data($c,intensity))}]
|
||||||
|
}]} {
|
||||||
|
set data($c,intensity) 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if {$data($c,intensity) < 0} {
|
||||||
|
set data($c,intensity) 0
|
||||||
|
}
|
||||||
|
if {$data($c,intensity) > 255} {
|
||||||
|
set data($c,intensity) 255
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SetRGBValue $w "$data(red,intensity) \
|
||||||
|
$data(green,intensity) $data(blue,intensity)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# mouse cursor enters a color bar
|
||||||
|
#
|
||||||
|
proc ::tk::dialog::color::EnterColorBar {w color} {
|
||||||
|
upvar ::tk::dialog::color::[winfo name $w] data
|
||||||
|
|
||||||
|
$data($color,sel) itemconfigure $data($color,index) -fill red
|
||||||
|
}
|
||||||
|
|
||||||
|
# mouse leaves enters a color bar
|
||||||
|
#
|
||||||
|
proc ::tk::dialog::color::LeaveColorBar {w color} {
|
||||||
|
upvar ::tk::dialog::color::[winfo name $w] data
|
||||||
|
|
||||||
|
$data($color,sel) itemconfigure $data($color,index) -fill black
|
||||||
|
}
|
||||||
|
|
||||||
|
# user hits OK button
|
||||||
|
#
|
||||||
|
proc ::tk::dialog::color::OkCmd {w} {
|
||||||
|
variable ::tk::Priv
|
||||||
|
upvar ::tk::dialog::color::[winfo name $w] data
|
||||||
|
|
||||||
|
set Priv(selectColor) $data(finalColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
# user hits Cancel button
|
||||||
|
#
|
||||||
|
proc ::tk::dialog::color::CancelCmd {w} {
|
||||||
|
variable ::tk::Priv
|
||||||
|
set Priv(selectColor) ""
|
||||||
|
}
|
||||||
|
|
|
@ -599,7 +599,7 @@ proc ::ttk::dialog::file::ChangeDir {w dir} {
|
||||||
lappend data(history) $data(selectPath)
|
lappend data(history) $data(selectPath)
|
||||||
if {[incr data(histpos)]} {
|
if {[incr data(histpos)]} {
|
||||||
$data(prevBtn) state !disabled
|
$data(prevBtn) state !disabled
|
||||||
set data(selectFile) ""
|
#set data(selectFile) ""
|
||||||
}
|
}
|
||||||
$data(nextBtn) state disabled
|
$data(nextBtn) state disabled
|
||||||
|
|
1765
data/tcl/fsdialog8.5.tcl
Normal file
1765
data/tcl/fsdialog8.5.tcl
Normal file
File diff suppressed because it is too large
Load diff
170
data/themes/blue/blue8.5.tcl
Normal file
170
data/themes/blue/blue8.5.tcl
Normal file
|
@ -0,0 +1,170 @@
|
||||||
|
# blue.tcl - Copyright (C) 2004 Pat Thoyts <patthoyts@users.sourceforge.net>
|
||||||
|
#
|
||||||
|
# blue.tcl,v 1.30 2005/12/13 23:04:25 patthoyts Exp
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
namespace eval ttk::theme::blue {
|
||||||
|
|
||||||
|
package provide ttk::theme::blue 0.7
|
||||||
|
|
||||||
|
proc LoadImages {imgdir {patterns {*.gif}}} {
|
||||||
|
foreach pattern $patterns {
|
||||||
|
foreach file [glob -directory $imgdir $pattern] {
|
||||||
|
set img [file tail [file rootname $file]]
|
||||||
|
if {![info exists images($img)]} {
|
||||||
|
set images($img) [image create photo -file $file]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [array get images]
|
||||||
|
}
|
||||||
|
|
||||||
|
variable I
|
||||||
|
array set I [LoadImages \
|
||||||
|
[file join [file dirname [info script]] blue] *.gif]
|
||||||
|
|
||||||
|
variable colors
|
||||||
|
array set colors {
|
||||||
|
-frame "#6699cc"
|
||||||
|
-lighter "#bcd2e8"
|
||||||
|
-window "#e6f3ff"
|
||||||
|
-selectbg "#ffff33"
|
||||||
|
-selectfg "#000000"
|
||||||
|
-disabledfg "#666666"
|
||||||
|
}
|
||||||
|
|
||||||
|
ttk::style theme create blue -settings {
|
||||||
|
|
||||||
|
ttk::style configure . \
|
||||||
|
-borderwidth 1 \
|
||||||
|
-background $colors(-frame) \
|
||||||
|
-fieldbackground $colors(-window) \
|
||||||
|
-troughcolor $colors(-lighter) \
|
||||||
|
-selectbackground $colors(-selectbg) \
|
||||||
|
-selectforeground $colors(-selectfg) \
|
||||||
|
;
|
||||||
|
ttk::style map . -foreground [list disabled $colors(-disabledfg)]
|
||||||
|
|
||||||
|
## Buttons.
|
||||||
|
#
|
||||||
|
ttk::style configure TButton -padding "10 0"
|
||||||
|
ttk::style layout TButton {
|
||||||
|
Button.button -children {
|
||||||
|
Button.focus -children {
|
||||||
|
Button.padding -children {
|
||||||
|
Button.label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ttk::style element create button image \
|
||||||
|
[list $I(button-n) pressed $I(button-p) active $I(button-h)] \
|
||||||
|
-border 4 -sticky ew
|
||||||
|
|
||||||
|
ttk::style element create Checkbutton.indicator image \
|
||||||
|
[list $I(check-nu) \
|
||||||
|
{!disabled active selected} $I(check-hc) \
|
||||||
|
{!disabled active} $I(check-hu) \
|
||||||
|
{!disabled selected} $I(check-nc) \
|
||||||
|
] \
|
||||||
|
-width 24 -sticky w
|
||||||
|
|
||||||
|
ttk::style element create Radiobutton.indicator image \
|
||||||
|
[list $I(radio-nu) \
|
||||||
|
{!disabled active selected} $I(radio-hc) \
|
||||||
|
{!disabled active} $I(radio-hu) \
|
||||||
|
selected $I(radio-nc) \
|
||||||
|
] \
|
||||||
|
-width 24 -sticky w
|
||||||
|
|
||||||
|
ttk::style configure TMenubutton -relief raised -padding {10 2}
|
||||||
|
ttk::style configure TRadiobutton -padding 1
|
||||||
|
ttk::style configure TCheckbutton -padding 1
|
||||||
|
|
||||||
|
## Toolbar buttons.
|
||||||
|
#
|
||||||
|
ttk::style configure Toolbutton \
|
||||||
|
-width 0 -relief flat -borderwidth 2 -padding 4 \
|
||||||
|
-background $colors(-frame) -foreground #000000 ;
|
||||||
|
ttk::style map Toolbutton -background [list active $colors(-selectbg)]
|
||||||
|
ttk::style map Toolbutton -foreground [list active $colors(-selectfg)]
|
||||||
|
ttk::style map Toolbutton -relief {
|
||||||
|
disabled flat
|
||||||
|
selected sunken
|
||||||
|
pressed sunken
|
||||||
|
active raised
|
||||||
|
}
|
||||||
|
|
||||||
|
## Entry widgets.
|
||||||
|
#
|
||||||
|
ttk::style configure TEntry \
|
||||||
|
-selectborderwidth 1 -padding 2 -insertwidth 2 -font TkTextFont
|
||||||
|
ttk::style configure TCombobox \
|
||||||
|
-selectborderwidth 1 -padding 2 -insertwidth 2 -font TkTextFont
|
||||||
|
|
||||||
|
## Notebooks.
|
||||||
|
#
|
||||||
|
ttk::style configure TNotebook.Tab -padding {4 2 4 2}
|
||||||
|
ttk::style map TNotebook.Tab \
|
||||||
|
-background \
|
||||||
|
[list selected $colors(-frame) active $colors(-lighter)] \
|
||||||
|
-padding [list selected {4 4 4 2}]
|
||||||
|
|
||||||
|
## Labelframes.
|
||||||
|
#
|
||||||
|
ttk::style configure TLabelframe -borderwidth 2 -relief groove
|
||||||
|
|
||||||
|
## Scrollbars.
|
||||||
|
#
|
||||||
|
ttk::style layout Vertical.TScrollbar {
|
||||||
|
Scrollbar.trough -children {
|
||||||
|
Scrollbar.uparrow -side top
|
||||||
|
Scrollbar.downarrow -side bottom
|
||||||
|
Scrollbar.uparrow -side bottom
|
||||||
|
Vertical.Scrollbar.thumb -side top -expand true -sticky ns
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ttk::style layout Horizontal.TScrollbar {
|
||||||
|
Scrollbar.trough -children {
|
||||||
|
Scrollbar.leftarrow -side left
|
||||||
|
Scrollbar.rightarrow -side right
|
||||||
|
Scrollbar.leftarrow -side right
|
||||||
|
Horizontal.Scrollbar.thumb -side left -expand true -sticky we
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ttk::style element create Horizontal.Scrollbar.thumb image \
|
||||||
|
[list $I(sb-thumb) {pressed !disabled} $I(sb-thumb-p)] -border 3
|
||||||
|
|
||||||
|
ttk::style element create Vertical.Scrollbar.thumb image \
|
||||||
|
[list $I(sb-vthumb) {pressed !disabled} $I(sb-vthumb-p)] -border 3
|
||||||
|
|
||||||
|
foreach dir {up down left right} {
|
||||||
|
ttk::style element create ${dir}arrow image \
|
||||||
|
[list $I(arrow${dir}) \
|
||||||
|
disabled $I(arrow${dir}) \
|
||||||
|
pressed $I(arrow${dir}-p) \
|
||||||
|
active $I(arrow${dir}-h) \
|
||||||
|
] \
|
||||||
|
-border 1 -sticky {}
|
||||||
|
}
|
||||||
|
|
||||||
|
## Scales.
|
||||||
|
#
|
||||||
|
ttk::style element create Scale.slider \
|
||||||
|
image [list $I(slider) {pressed !disabled} $I(slider-p)]
|
||||||
|
|
||||||
|
ttk::style element create Vertical.Scale.slider \
|
||||||
|
image [list $I(vslider) {pressed !disabled} $I(vslider-p)]
|
||||||
|
|
||||||
|
ttk::style element create Horizontal.Progress.bar \
|
||||||
|
image [list $I(sb-thumb)] -border 2
|
||||||
|
ttk::style element create Vertical.Progress.bar \
|
||||||
|
image [list $I(sb-vthumb)] -border 2
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
# Package index for tile demo pixmap themes.
|
# Package index for tile demo pixmap themes.
|
||||||
|
|
||||||
if {[file isdirectory [file join $dir blue]]} {
|
if {[file isdirectory [file join $dir blue]]} {
|
||||||
package ifneeded tile::theme::blue 0.7 \
|
if {[package vsatisfies [package require tile] 0.8.0]} {
|
||||||
[list source [file join $dir blue.tcl]]
|
package ifneeded ttk::theme::blue 0.7 \
|
||||||
|
[list source [file join $dir blue8.5.tcl]]
|
||||||
|
} else {
|
||||||
|
package ifneeded tile::theme::blue 0.7 \
|
||||||
|
[list source [file join $dir blue8.4.tcl]]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
335
data/themes/clearlooks/clearlooks8.5.tcl
Normal file
335
data/themes/clearlooks/clearlooks8.5.tcl
Normal file
|
@ -0,0 +1,335 @@
|
||||||
|
# clearlooks.tcl
|
||||||
|
|
||||||
|
namespace eval ttk::theme::clearlooks {
|
||||||
|
|
||||||
|
package provide ttk::theme::clearlooks 0.1
|
||||||
|
|
||||||
|
proc LoadImages {imgdir {patterns {*.gif}}} {
|
||||||
|
foreach pattern $patterns {
|
||||||
|
foreach file [glob -directory $imgdir $pattern] {
|
||||||
|
set img [file tail [file rootname $file]]
|
||||||
|
if {![info exists images($img)]} {
|
||||||
|
set images($img) [image create photo -file $file]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [array get images]
|
||||||
|
}
|
||||||
|
|
||||||
|
variable I
|
||||||
|
array set I [LoadImages \
|
||||||
|
[file join [file dirname [info script]] clearlooks] *.gif]
|
||||||
|
|
||||||
|
variable colors
|
||||||
|
|
||||||
|
array set colors {
|
||||||
|
-frame "#efebe7"
|
||||||
|
-lighter "#f5f3f0"
|
||||||
|
-dark "#cfcdc8"
|
||||||
|
-darker "#9e9a9e"
|
||||||
|
-darkest "#d4cfca"
|
||||||
|
-selectbg "#7c99ad"
|
||||||
|
-selectfg "#ffffff"
|
||||||
|
-disabledfg "#b5b3ac"
|
||||||
|
-entryfocus "#6f9dc6"
|
||||||
|
-tabbg "#c9c1bc"
|
||||||
|
-tabborder "#b5aca7"
|
||||||
|
-troughcolor "#d7cbbe"
|
||||||
|
-troughborder "#ae9e8e"
|
||||||
|
-checklight "#f5f3f0"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ttk::style theme create clearlooks -parent clam -settings {
|
||||||
|
|
||||||
|
ttk::style configure . \
|
||||||
|
-borderwidth 1 \
|
||||||
|
-background $colors(-frame) \
|
||||||
|
-foreground black \
|
||||||
|
-bordercolor $colors(-darkest) \
|
||||||
|
-darkcolor $colors(-dark) \
|
||||||
|
-lightcolor $colors(-lighter) \
|
||||||
|
-troughcolor $colors(-troughcolor) \
|
||||||
|
-selectforeground $colors(-selectfg) \
|
||||||
|
-selectbackground $colors(-selectbg) \
|
||||||
|
-font TkDefaultFont \
|
||||||
|
;
|
||||||
|
|
||||||
|
ttk::style map . \
|
||||||
|
-background [list disabled $colors(-frame) \
|
||||||
|
active $colors(-lighter)] \
|
||||||
|
-foreground [list disabled $colors(-disabledfg)] \
|
||||||
|
-selectbackground [list !focus $colors(-darker)] \
|
||||||
|
-selectforeground [list !focus white] \
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
# ttk::style configure Frame.border -relief groove
|
||||||
|
|
||||||
|
## Treeview.
|
||||||
|
#
|
||||||
|
ttk::style element create Treeheading.cell image \
|
||||||
|
[list $I(tree-n) \
|
||||||
|
selected $I(tree-p) \
|
||||||
|
disabled $I(tree-d) \
|
||||||
|
pressed $I(tree-p) \
|
||||||
|
active $I(tree-h) \
|
||||||
|
] \
|
||||||
|
-border 4 -sticky ew
|
||||||
|
|
||||||
|
#ttk::style configure Treeview -fieldbackground white
|
||||||
|
ttk::style configure Row -background "#efefef"
|
||||||
|
ttk::style map Row -background [list \
|
||||||
|
{focus selected} "#71869e" \
|
||||||
|
selected "#969286" \
|
||||||
|
alternate white]
|
||||||
|
ttk::style map Item -foreground [list selected white]
|
||||||
|
ttk::style map Cell -foreground [list selected white]
|
||||||
|
|
||||||
|
|
||||||
|
## Buttons.
|
||||||
|
#
|
||||||
|
ttk::style configure TButton -padding {10 0}
|
||||||
|
ttk::style layout TButton {
|
||||||
|
Button.button -children {
|
||||||
|
Button.focus -children {
|
||||||
|
Button.padding -children {
|
||||||
|
Button.label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ttk::style element create button image \
|
||||||
|
[list $I(button-n) \
|
||||||
|
pressed $I(button-p) \
|
||||||
|
{selected active} $I(button-pa) \
|
||||||
|
selected $I(button-p) \
|
||||||
|
active $I(button-a) \
|
||||||
|
disabled $I(button-d) \
|
||||||
|
] \
|
||||||
|
-border 4 -sticky ew
|
||||||
|
|
||||||
|
|
||||||
|
## Checkbuttons.
|
||||||
|
#
|
||||||
|
ttk::style element create Checkbutton.indicator image \
|
||||||
|
[list $I(check-nu) \
|
||||||
|
{disabled selected} $I(check-dc) \
|
||||||
|
disabled $I(check-du) \
|
||||||
|
{pressed selected} $I(check-pc) \
|
||||||
|
pressed $I(check-pu) \
|
||||||
|
{active selected} $I(check-ac) \
|
||||||
|
active $I(check-au) \
|
||||||
|
selected $I(check-nc) ] \
|
||||||
|
-width 24 -sticky w
|
||||||
|
|
||||||
|
ttk::style map TCheckbutton -background [list active $colors(-checklight)]
|
||||||
|
ttk::style configure TCheckbutton -padding 1
|
||||||
|
|
||||||
|
|
||||||
|
## Radiobuttons.
|
||||||
|
#
|
||||||
|
ttk::style element create Radiobutton.indicator image \
|
||||||
|
[list $I(radio-nu) \
|
||||||
|
{disabled selected} $I(radio-dc) \
|
||||||
|
disabled $I(radio-du) \
|
||||||
|
{pressed selected} $I(radio-pc) \
|
||||||
|
pressed $I(radio-pu) \
|
||||||
|
{active selected} $I(radio-ac) \
|
||||||
|
active $I(radio-au) \
|
||||||
|
selected $I(radio-nc) ] \
|
||||||
|
-width 24 -sticky w
|
||||||
|
|
||||||
|
ttk::style map TRadiobutton -background [list active $colors(-checklight)]
|
||||||
|
ttk::style configure TRadiobutton -padding 1
|
||||||
|
|
||||||
|
|
||||||
|
## Menubuttons.
|
||||||
|
#
|
||||||
|
#ttk::style configure TMenubutton -relief raised -padding {10 2}
|
||||||
|
# ttk::style element create Menubutton.border image $I(toolbutton-n) \
|
||||||
|
# -map [list \
|
||||||
|
# pressed $I(toolbutton-p) \
|
||||||
|
# selected $I(toolbutton-p) \
|
||||||
|
# active $I(toolbutton-a) \
|
||||||
|
# disabled $I(toolbutton-n)] \
|
||||||
|
# -border {4 7 4 7} -sticky nsew
|
||||||
|
|
||||||
|
ttk::style element create Menubutton.border image \
|
||||||
|
[list $I(button-n) \
|
||||||
|
selected $I(button-p) \
|
||||||
|
disabled $I(button-d) \
|
||||||
|
active $I(button-a) \
|
||||||
|
] \
|
||||||
|
-border 4 -sticky ew
|
||||||
|
|
||||||
|
|
||||||
|
## Toolbar buttons.
|
||||||
|
#
|
||||||
|
ttk::style configure Toolbutton -padding -5 -relief flat
|
||||||
|
ttk::style configure Toolbutton.label -padding 0 -relief flat
|
||||||
|
|
||||||
|
ttk::style element create Toolbutton.border image \
|
||||||
|
[list $I(blank) \
|
||||||
|
pressed $I(toolbutton-p) \
|
||||||
|
{selected active} $I(toolbutton-pa) \
|
||||||
|
selected $I(toolbutton-p) \
|
||||||
|
active $I(toolbutton-a) \
|
||||||
|
disabled $I(blank)] \
|
||||||
|
-border 11 -sticky nsew
|
||||||
|
|
||||||
|
|
||||||
|
## Entry widgets.
|
||||||
|
#
|
||||||
|
ttk::style configure TEntry -padding 1 -insertwidth 1 \
|
||||||
|
-fieldbackground white
|
||||||
|
|
||||||
|
ttk::style map TEntry \
|
||||||
|
-fieldbackground [list readonly $colors(-frame)] \
|
||||||
|
-bordercolor [list focus $colors(-selectbg)] \
|
||||||
|
-lightcolor [list focus $colors(-entryfocus)] \
|
||||||
|
-darkcolor [list focus $colors(-entryfocus)] \
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
## Combobox.
|
||||||
|
#
|
||||||
|
ttk::style configure TCombobox -selectbackground
|
||||||
|
|
||||||
|
ttk::style element create Combobox.downarrow image \
|
||||||
|
[list $I(comboarrow-n) \
|
||||||
|
disabled $I(comboarrow-d) \
|
||||||
|
pressed $I(comboarrow-p) \
|
||||||
|
active $I(comboarrow-a) \
|
||||||
|
] \
|
||||||
|
-border 1 -sticky {}
|
||||||
|
|
||||||
|
ttk::style element create Combobox.field image \
|
||||||
|
[list $I(combo-n) \
|
||||||
|
{readonly disabled} $I(combo-rd) \
|
||||||
|
{readonly pressed} $I(combo-rp) \
|
||||||
|
{readonly focus} $I(combo-rf) \
|
||||||
|
readonly $I(combo-rn) \
|
||||||
|
] \
|
||||||
|
-border 4 -sticky ew
|
||||||
|
|
||||||
|
|
||||||
|
## Notebooks.
|
||||||
|
#
|
||||||
|
# ttk::style element create tab image $I(tab-a) -border {2 2 2 0} \
|
||||||
|
# -map [list selected $I(tab-n)]
|
||||||
|
|
||||||
|
ttk::style configure TNotebook.Tab -padding {6 2 6 2}
|
||||||
|
ttk::style map TNotebook.Tab \
|
||||||
|
-padding [list selected {6 4 6 2}] \
|
||||||
|
-background [list selected $colors(-frame) {} $colors(-tabbg)] \
|
||||||
|
-lightcolor [list selected $colors(-lighter) {} $colors(-dark)] \
|
||||||
|
-bordercolor [list selected $colors(-darkest) {} $colors(-tabborder)] \
|
||||||
|
;
|
||||||
|
|
||||||
|
## Labelframes.
|
||||||
|
#
|
||||||
|
ttk::style configure TLabelframe -borderwidth 2 -relief groove
|
||||||
|
|
||||||
|
|
||||||
|
## Scrollbars.
|
||||||
|
#
|
||||||
|
ttk::style layout Vertical.TScrollbar {
|
||||||
|
Scrollbar.trough -sticky ns -children {
|
||||||
|
Scrollbar.uparrow -side top
|
||||||
|
Scrollbar.downarrow -side bottom
|
||||||
|
Vertical.Scrollbar.thumb -side top -expand true -sticky ns
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ttk::style layout Horizontal.TScrollbar {
|
||||||
|
Scrollbar.trough -sticky we -children {
|
||||||
|
Scrollbar.leftarrow -side left
|
||||||
|
Scrollbar.rightarrow -side right
|
||||||
|
Horizontal.Scrollbar.thumb -side left -expand true -sticky we
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ttk::style element create Horizontal.Scrollbar.thumb image \
|
||||||
|
[list $I(sbthumb-hn) \
|
||||||
|
disabled $I(sbthumb-hd) \
|
||||||
|
pressed $I(sbthumb-ha) \
|
||||||
|
active $I(sbthumb-ha)] \
|
||||||
|
-border 3
|
||||||
|
|
||||||
|
ttk::style element create Vertical.Scrollbar.thumb image \
|
||||||
|
[list $I(sbthumb-vn) \
|
||||||
|
disabled $I(sbthumb-vd) \
|
||||||
|
pressed $I(sbthumb-va) \
|
||||||
|
active $I(sbthumb-va)] \
|
||||||
|
-border 3
|
||||||
|
|
||||||
|
foreach dir {up down left right} {
|
||||||
|
ttk::style element create ${dir}arrow image \
|
||||||
|
[list $I(arrow${dir}-n) \
|
||||||
|
disabled $I(arrow${dir}-d) \
|
||||||
|
pressed $I(arrow${dir}-p) \
|
||||||
|
active $I(arrow${dir}-a)] \
|
||||||
|
-border 1 -sticky {}
|
||||||
|
}
|
||||||
|
|
||||||
|
ttk::style configure TScrollbar -bordercolor $colors(-troughborder)
|
||||||
|
|
||||||
|
|
||||||
|
## Scales.
|
||||||
|
#
|
||||||
|
ttk::style element create Scale.slider image \
|
||||||
|
[list $I(scale-hn) \
|
||||||
|
disabled $I(scale-hd) \
|
||||||
|
active $I(scale-ha) \
|
||||||
|
]
|
||||||
|
|
||||||
|
ttk::style element create Scale.trough image $I(scaletrough-h) \
|
||||||
|
-border 2 -sticky ew -padding 0
|
||||||
|
|
||||||
|
ttk::style element create Vertical.Scale.slider image \
|
||||||
|
[list $I(scale-vn) \
|
||||||
|
disabled $I(scale-vd) \
|
||||||
|
active $I(scale-va) \
|
||||||
|
]
|
||||||
|
ttk::style element create Vertical.Scale.trough image $I(scaletrough-v) \
|
||||||
|
-border 2 -sticky ns -padding 0
|
||||||
|
|
||||||
|
ttk::style configure TScale -bordercolor $colors(-troughborder)
|
||||||
|
|
||||||
|
|
||||||
|
## Progressbar.
|
||||||
|
#
|
||||||
|
ttk::style element create Horizontal.Progressbar.pbar image $I(progress-h) \
|
||||||
|
-border {2 2 1 1}
|
||||||
|
ttk::style element create Vertical.Progressbar.pbar image $I(progress-v) \
|
||||||
|
-border {2 2 1 1}
|
||||||
|
|
||||||
|
ttk::style configure TProgressbar -bordercolor $colors(-troughborder)
|
||||||
|
|
||||||
|
|
||||||
|
## Statusbar parts.
|
||||||
|
#
|
||||||
|
ttk::style element create sizegrip image $I(sizegrip)
|
||||||
|
|
||||||
|
|
||||||
|
## Paned window parts.
|
||||||
|
#
|
||||||
|
# ttk::style element create hsash image $I(hseparator-n) -border {2 0} \
|
||||||
|
# -map [list {active !disabled} $I(hseparator-a)]
|
||||||
|
# ttk::style element create vsash image $I(vseparator-n) -border {0 2} \
|
||||||
|
# -map [list {active !disabled} $I(vseparator-a)]
|
||||||
|
|
||||||
|
ttk::style configure Sash -sashthickness 6 -gripcount 16
|
||||||
|
|
||||||
|
|
||||||
|
## Separator.
|
||||||
|
#
|
||||||
|
#ttk::style element create separator image $I(sep-h)
|
||||||
|
#ttk::style element create hseparator image $I(sep-h)
|
||||||
|
#ttk::style element create vseparator image $I(sep-v)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
# Package index for tile demo pixmap themes.
|
# Package index for tile demo pixmap themes.
|
||||||
|
|
||||||
if {[file isdirectory [file join $dir clearlooks]]} {
|
if {[file isdirectory [file join $dir clearlooks]]} {
|
||||||
package ifneeded tile::theme::clearlooks 0.1 \
|
if {[package vsatisfies [package require tile] 0.8.0]} {
|
||||||
[list source [file join $dir clearlooks.tcl]]
|
package ifneeded ttk::theme::clearlooks 0.1 \
|
||||||
|
[list source [file join $dir clearlooks8.5.tcl]]
|
||||||
|
} else {
|
||||||
|
package ifneeded tile::theme::clearlooks 0.1 \
|
||||||
|
[list source [file join $dir clearlooks8.4.tcl]]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,7 @@ class Options:
|
||||||
('toolbar_compound', 'str'),
|
('toolbar_compound', 'str'),
|
||||||
('toolbar_size', 'int'),
|
('toolbar_size', 'int'),
|
||||||
('statusbar', 'bool'),
|
('statusbar', 'bool'),
|
||||||
|
('statusbar_game_number', 'bool'),
|
||||||
('num_cards', 'bool'),
|
('num_cards', 'bool'),
|
||||||
('helpbar', 'bool'),
|
('helpbar', 'bool'),
|
||||||
('num_recent_games', 'int'),
|
('num_recent_games', 'int'),
|
||||||
|
@ -194,6 +195,7 @@ class Options:
|
||||||
for w in TOOLBAR_BUTTONS:
|
for w in TOOLBAR_BUTTONS:
|
||||||
self.toolbar_vars[w] = True # show all buttons
|
self.toolbar_vars[w] = True # show all buttons
|
||||||
self.statusbar = True
|
self.statusbar = True
|
||||||
|
self.statusbar_game_number = False # show game number in statusbar
|
||||||
self.num_cards = False
|
self.num_cards = False
|
||||||
self.helpbar = False
|
self.helpbar = False
|
||||||
self.splashscreen = True
|
self.splashscreen = True
|
||||||
|
@ -399,9 +401,6 @@ class Options:
|
||||||
config.write(file(filename, 'w'))
|
config.write(file(filename, 'w'))
|
||||||
#config.write(sys.stdout)
|
#config.write(sys.stdout)
|
||||||
|
|
||||||
def printOptError(self, key):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def _getOption(self, section, key, t):
|
def _getOption(self, section, key, t):
|
||||||
config = self._config
|
config = self._config
|
||||||
try:
|
try:
|
||||||
|
@ -869,11 +868,13 @@ class Application:
|
||||||
try:
|
try:
|
||||||
self.loadStatistics()
|
self.loadStatistics()
|
||||||
except:
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
pass
|
pass
|
||||||
# try to load comments
|
# try to load comments
|
||||||
try:
|
try:
|
||||||
self.loadComments()
|
self.loadComments()
|
||||||
except:
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
pass
|
pass
|
||||||
# startup information
|
# startup information
|
||||||
if self.getGameClass(self.opt.last_gameid):
|
if self.getGameClass(self.opt.last_gameid):
|
||||||
|
@ -886,6 +887,7 @@ class Application:
|
||||||
try:
|
try:
|
||||||
game = tmpgame._loadGame(self.fn.holdgame, self)
|
game = tmpgame._loadGame(self.fn.holdgame, self)
|
||||||
except:
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
game = None
|
game = None
|
||||||
if game:
|
if game:
|
||||||
if game.id == self.opt.game_holded and game.gstats.holded:
|
if game.id == self.opt.game_holded and game.gstats.holded:
|
||||||
|
@ -903,6 +905,7 @@ class Application:
|
||||||
self.nextgame.loadedgame = tmpgame._loadGame(self.commandline.loadgame, self)
|
self.nextgame.loadedgame = tmpgame._loadGame(self.commandline.loadgame, self)
|
||||||
self.nextgame.loadedgame.gstats.holded = 0
|
self.nextgame.loadedgame.gstats.holded = 0
|
||||||
except:
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
self.nextgame.loadedgame = None
|
self.nextgame.loadedgame = None
|
||||||
elif self.commandline.game is not None:
|
elif self.commandline.game is not None:
|
||||||
gameid = self.gdb.getGameByName(self.commandline.game)
|
gameid = self.gdb.getGameByName(self.commandline.game)
|
||||||
|
@ -926,6 +929,7 @@ class Application:
|
||||||
# create the statusbar(s)
|
# create the statusbar(s)
|
||||||
self.statusbar = PysolStatusbar(self.top)
|
self.statusbar = PysolStatusbar(self.top)
|
||||||
self.statusbar.show(self.opt.statusbar)
|
self.statusbar.show(self.opt.statusbar)
|
||||||
|
self.statusbar.config('gamenumber', self.opt.statusbar_game_number)
|
||||||
self.helpbar = HelpStatusbar(self.top)
|
self.helpbar = HelpStatusbar(self.top)
|
||||||
self.helpbar.show(self.opt.helpbar)
|
self.helpbar.show(self.opt.helpbar)
|
||||||
# create the canvas
|
# create the canvas
|
||||||
|
@ -956,7 +960,15 @@ class Application:
|
||||||
assert self.cardset is not None
|
assert self.cardset is not None
|
||||||
id, random = self.nextgame.id, self.nextgame.random
|
id, random = self.nextgame.id, self.nextgame.random
|
||||||
self.nextgame.id, self.nextgame.random = 0, None
|
self.nextgame.id, self.nextgame.random = 0, None
|
||||||
self.runGame(id, random)
|
try:
|
||||||
|
self.runGame(id, random)
|
||||||
|
except:
|
||||||
|
# try Klondike if current game fails
|
||||||
|
if id == 2:
|
||||||
|
raise # internal error?
|
||||||
|
traceback.print_exc()
|
||||||
|
self.nextgame.id = 2
|
||||||
|
continue
|
||||||
if self.nextgame.holdgame:
|
if self.nextgame.holdgame:
|
||||||
assert self.nextgame.id <= 0
|
assert self.nextgame.id <= 0
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -47,7 +47,7 @@ from app import Application
|
||||||
from pysolaudio import AbstractAudioClient, PysolSoundServerModuleClient
|
from pysolaudio import AbstractAudioClient, PysolSoundServerModuleClient
|
||||||
from pysolaudio import Win32AudioClient, OSSAudioClient, PyGameAudioClient
|
from pysolaudio import Win32AudioClient, OSSAudioClient, PyGameAudioClient
|
||||||
from settings import PACKAGE, SOUND_MOD
|
from settings import PACKAGE, SOUND_MOD
|
||||||
from winsystems import initRootWindow
|
from winsystems import init_root_window
|
||||||
|
|
||||||
# Toolkit imports
|
# Toolkit imports
|
||||||
from pysoltk import loadImage
|
from pysoltk import loadImage
|
||||||
|
@ -250,7 +250,7 @@ def pysol_init(app, args):
|
||||||
app.opt.sound_mode = 0
|
app.opt.sound_mode = 0
|
||||||
|
|
||||||
# init toolkit 2)
|
# init toolkit 2)
|
||||||
initRootWindow(top, app)
|
init_root_window(top, app)
|
||||||
|
|
||||||
# check games
|
# check games
|
||||||
if len(app.gdb.getGamesIdSortedByName()) == 0:
|
if len(app.gdb.getGamesIdSortedByName()) == 0:
|
||||||
|
|
|
@ -2,24 +2,28 @@
|
||||||
|
|
||||||
import Tkinter
|
import Tkinter
|
||||||
|
|
||||||
|
TileVersion = None
|
||||||
|
_tile_prefix = '' # XXX
|
||||||
|
|
||||||
def initialize(root=None):
|
def initialize(root=None):
|
||||||
|
global TileVersion, _tile_prefix
|
||||||
if root is None:
|
if root is None:
|
||||||
root = Tkinter._default_root
|
root = Tkinter._default_root
|
||||||
root.tk.call("package", "require", "tile", "0.7.8")
|
TileVersion = root.tk.call("package", "require", "tile", "0.7.8")
|
||||||
# This forces an update of the available packages list.
|
if TileVersion >= '0.8':
|
||||||
# It's required for package names to find the themes in data/themes/
|
_tile_prefix = 'ttk::' # XXX
|
||||||
root.tk.call('eval', '[package unknown]', 'Tcl', '[package provide Tcl]')
|
|
||||||
|
|
||||||
def availableThemes(root=None):
|
def availableThemes(root=None):
|
||||||
if root is None:
|
if root is None:
|
||||||
root = Tkinter._default_root
|
root = Tkinter._default_root
|
||||||
|
if TileVersion >= '0.8':
|
||||||
|
return root.tk.call("ttk::themes")
|
||||||
return root.tk.call("tile::availableThemes")
|
return root.tk.call("tile::availableThemes")
|
||||||
|
|
||||||
def setTheme(root=None, theme=None):
|
def setTheme(root=None, theme=None):
|
||||||
if root is None:
|
if root is None:
|
||||||
root = Tkinter._default_root
|
root = Tkinter._default_root
|
||||||
return root.tk.call("tile::setTheme", theme)
|
return root.tk.call(_tile_prefix+"setTheme", theme)
|
||||||
|
|
||||||
|
|
||||||
class Style(Tkinter.Misc):
|
class Style(Tkinter.Misc):
|
||||||
|
@ -31,7 +35,7 @@ class Style(Tkinter.Misc):
|
||||||
def default(self, style, **kw):
|
def default(self, style, **kw):
|
||||||
"""Sets the default value of the specified option(s) in style"""
|
"""Sets the default value of the specified option(s) in style"""
|
||||||
opts = self._options(kw)
|
opts = self._options(kw)
|
||||||
return self.tk.call("style", "default", style, *opts)
|
return self.tk.call(_tile_prefix+"style", "default", style, *opts)
|
||||||
|
|
||||||
def map_style(self, **kw):
|
def map_style(self, **kw):
|
||||||
"""Sets dynamic values of the specified option(s) in style. See
|
"""Sets dynamic values of the specified option(s) in style. See
|
||||||
|
@ -56,7 +60,7 @@ class Style(Tkinter.Misc):
|
||||||
|
|
||||||
def element_names(self):
|
def element_names(self):
|
||||||
"""Returns a list of all elements defined in the current theme."""
|
"""Returns a list of all elements defined in the current theme."""
|
||||||
return self.tk.call("style", "elements", "names")
|
return self.tk.call(_tile_prefix+"style", "elements", "names")
|
||||||
|
|
||||||
def theme_create(self, name, parent=None, basedon=None):
|
def theme_create(self, name, parent=None, basedon=None):
|
||||||
"""Creates a new theme. It is an error if themeName already exists.
|
"""Creates a new theme. It is an error if themeName already exists.
|
||||||
|
@ -76,17 +80,17 @@ class Style(Tkinter.Misc):
|
||||||
|
|
||||||
def theme_names(self):
|
def theme_names(self):
|
||||||
"""Returns a list of the available themes."""
|
"""Returns a list of the available themes."""
|
||||||
return self.tk.call("style", "theme", "names")
|
return self.tk.call(_tile_prefix+"style", "theme", "names")
|
||||||
|
|
||||||
def theme_use(self, theme):
|
def theme_use(self, theme):
|
||||||
"""Sets the current theme to themeName, and refreshes all widgets."""
|
"""Sets the current theme to themeName, and refreshes all widgets."""
|
||||||
return self.tk.call("style", "theme", "use", theme)
|
return self.tk.call(_tile_prefix+"style", "theme", "use", theme)
|
||||||
|
|
||||||
def configure(self, style, cnf={}, **kw):
|
def configure(self, style, cnf={}, **kw):
|
||||||
"""Sets the default value of the specified option(s)
|
"""Sets the default value of the specified option(s)
|
||||||
in style."""
|
in style."""
|
||||||
opts = self._options(cnf, kw)
|
opts = self._options(cnf, kw)
|
||||||
return self.tk.call("style", "configure", style, *opts)
|
return self.tk.call(_tile_prefix+"style", "configure", style, *opts)
|
||||||
config = configure
|
config = configure
|
||||||
|
|
||||||
def lookup(self, style, option, state=None, default=None):
|
def lookup(self, style, option, state=None, default=None):
|
||||||
|
@ -102,7 +106,8 @@ class Style(Tkinter.Misc):
|
||||||
opts = [state]
|
opts = [state]
|
||||||
if default:
|
if default:
|
||||||
opts.append(default)
|
opts.append(default)
|
||||||
return self.tk.call("style", "lookup", style, "-"+option, *opts)
|
return self.tk.call(_tile_prefix+"style", "lookup", style,
|
||||||
|
"-"+option, *opts)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -98,12 +98,16 @@ class ColorsDialog(MfxDialog):
|
||||||
self.not_matching_color = self.not_matching_var.get()
|
self.not_matching_color = self.not_matching_var.get()
|
||||||
|
|
||||||
def selectColor(self, label):
|
def selectColor(self, label):
|
||||||
c = askcolor(parent=self.top, initialcolor=label.cget('bg'),
|
try:
|
||||||
title=_("Select color"))
|
c = askcolor(parent=self.top, initialcolor=label.cget('bg'),
|
||||||
if c and c[1]:
|
title=_("Select color"))
|
||||||
label.configure(bg=c[1])
|
except:
|
||||||
#label.configure(text=c[1]) # don't work
|
pass
|
||||||
label.setvar(label.cget('textvariable'), c[1])
|
else:
|
||||||
|
if c and c[1]:
|
||||||
|
label.configure(bg=c[1])
|
||||||
|
#label.configure(text=c[1]) # don't work
|
||||||
|
label.setvar(label.cget('textvariable'), c[1])
|
||||||
|
|
||||||
def initKw(self, kw):
|
def initKw(self, kw):
|
||||||
kw = KwStruct(kw,
|
kw = KwStruct(kw,
|
||||||
|
|
|
@ -66,6 +66,7 @@ class MfxStatusbar:
|
||||||
self._row = row
|
self._row = row
|
||||||
self._column = column
|
self._column = column
|
||||||
self._columnspan = columnspan
|
self._columnspan = columnspan
|
||||||
|
self._label_column = 0
|
||||||
#
|
#
|
||||||
self.padx = 1
|
self.padx = 1
|
||||||
self.label_relief = 'sunken'
|
self.label_relief = 'sunken'
|
||||||
|
@ -76,13 +77,19 @@ class MfxStatusbar:
|
||||||
self.frame.pack(side='left', expand=True, fill='both', padx=0, pady=1)
|
self.frame.pack(side='left', expand=True, fill='both', padx=0, pady=1)
|
||||||
|
|
||||||
# util
|
# util
|
||||||
def _createLabel(self, name, side='left', fill='none',
|
def _createLabel(self, name, expand=False, width=0, tooltip=None):
|
||||||
expand=False, width=0, tooltip=None):
|
|
||||||
frame = Tile.Frame(self.frame, borderwidth=1, relief=self.label_relief)
|
frame = Tile.Frame(self.frame, borderwidth=1, relief=self.label_relief)
|
||||||
frame.pack(side=side, fill=fill, padx=self.padx, expand=expand)
|
frame.grid(row=0, column=self._label_column,
|
||||||
|
sticky='nsew', padx=self.padx)
|
||||||
|
if expand:
|
||||||
|
self.frame.grid_columnconfigure(self._label_column,
|
||||||
|
weight=1)
|
||||||
|
self._label_column += 1
|
||||||
|
setattr(self, name + '_frame', frame)
|
||||||
|
self._widgets.append(frame)
|
||||||
label = Tile.Label(frame, width=width)
|
label = Tile.Label(frame, width=width)
|
||||||
label.pack(expand=True, fill='both')
|
label.pack(expand=True, fill='both')
|
||||||
setattr(self, name + "_label", label)
|
setattr(self, name + '_label', label)
|
||||||
self._widgets.append(label)
|
self._widgets.append(label)
|
||||||
if tooltip:
|
if tooltip:
|
||||||
b = MfxTooltip(label)
|
b = MfxTooltip(label)
|
||||||
|
@ -101,25 +108,32 @@ class MfxStatusbar:
|
||||||
|
|
||||||
def updateText(self, **kw):
|
def updateText(self, **kw):
|
||||||
for k, v in kw.items():
|
for k, v in kw.items():
|
||||||
label = getattr(self, k + "_label")
|
label = getattr(self, k + '_label')
|
||||||
text = unicode(v)
|
text = unicode(v)
|
||||||
width = label['width']
|
width = label['width']
|
||||||
if width and len(text) > width:
|
if width and len(text) > width:
|
||||||
label['width'] = len(text)
|
label['width'] = len(text)
|
||||||
label["text"] = text
|
label['text'] = text
|
||||||
|
|
||||||
|
def config(self, name, show):
|
||||||
|
frame = getattr(self, name + '_frame')
|
||||||
|
if show:
|
||||||
|
frame.grid()
|
||||||
|
else:
|
||||||
|
frame.grid_remove()
|
||||||
|
|
||||||
def configLabel(self, name, **kw):
|
def configLabel(self, name, **kw):
|
||||||
if 'fg' in kw:
|
if 'fg' in kw:
|
||||||
kw['foreground'] = kw['fg']
|
kw['foreground'] = kw['fg']
|
||||||
del kw['fg']
|
del kw['fg']
|
||||||
label = getattr(self, name + "_label")
|
label = getattr(self, name + '_label')
|
||||||
label.config(**kw)
|
label.config(**kw)
|
||||||
|
|
||||||
def show(self, show=True, resize=False):
|
def show(self, show=True, resize=False):
|
||||||
if self._show == show:
|
if self._show == show:
|
||||||
return False
|
return False
|
||||||
if resize:
|
if resize:
|
||||||
self.top.wm_geometry("") # cancel user-specified geometry
|
self.top.wm_geometry('') # cancel user-specified geometry
|
||||||
if not show:
|
if not show:
|
||||||
# hide
|
# hide
|
||||||
self.top_frame.grid_forget()
|
self.top_frame.grid_forget()
|
||||||
|
@ -147,15 +161,14 @@ class PysolStatusbar(MfxStatusbar):
|
||||||
MfxStatusbar.__init__(self, top, row=4, column=0, columnspan=3)
|
MfxStatusbar.__init__(self, top, row=4, column=0, columnspan=3)
|
||||||
#
|
#
|
||||||
for n, t, w in (
|
for n, t, w in (
|
||||||
("time", _("Playing time"), 10),
|
('time', _('Playing time'), 10),
|
||||||
("moves", _('Moves/Total moves'), 10),
|
('moves', _('Moves/Total moves'), 10),
|
||||||
("gamenumber", _("Game number"), 26),
|
('gamenumber', _('Game number'), 26),
|
||||||
("stats", _("Games played: won/lost"), 12),
|
('stats', _('Games played: won/lost'), 12),
|
||||||
):
|
):
|
||||||
self._createLabel(n, tooltip=t, width=w)
|
self._createLabel(n, tooltip=t, width=w)
|
||||||
#
|
#
|
||||||
l = self._createLabel("info", fill='both', expand=True)
|
l = self._createLabel('info', expand=True)
|
||||||
##l.config(text="", justify="left", anchor='w')
|
|
||||||
l.config(padding=(8, 0))
|
l.config(padding=(8, 0))
|
||||||
self._createSizegrip()
|
self._createSizegrip()
|
||||||
|
|
||||||
|
@ -163,15 +176,16 @@ class PysolStatusbar(MfxStatusbar):
|
||||||
class HelpStatusbar(MfxStatusbar):
|
class HelpStatusbar(MfxStatusbar):
|
||||||
def __init__(self, top):
|
def __init__(self, top):
|
||||||
MfxStatusbar.__init__(self, top, row=3, column=0, columnspan=3)
|
MfxStatusbar.__init__(self, top, row=3, column=0, columnspan=3)
|
||||||
l = self._createLabel("info", fill='both', expand=True)
|
l = self._createLabel('info', expand=True)
|
||||||
l.config(justify="left", anchor='w', padding=(8, 0))
|
l.config(justify='left', anchor='w', padding=(8, 0))
|
||||||
|
|
||||||
|
|
||||||
class HtmlStatusbar(MfxStatusbar):
|
class HtmlStatusbar(MfxStatusbar):
|
||||||
def __init__(self, top, row, column, columnspan):
|
def __init__(self, top, row, column, columnspan):
|
||||||
MfxStatusbar.__init__(self, top, row=row, column=column, columnspan=columnspan)
|
MfxStatusbar.__init__(self, top, row=row, column=column,
|
||||||
l = self._createLabel("url", fill='both', expand=True)
|
columnspan=columnspan)
|
||||||
l.config(justify="left", anchor='w', padding=(8, 0))
|
l = self._createLabel('url', expand=True)
|
||||||
|
l.config(justify='left', anchor='w', padding=(8, 0))
|
||||||
self._createSizegrip()
|
self._createSizegrip()
|
||||||
|
|
||||||
|
|
||||||
|
@ -184,8 +198,8 @@ class TestStatusbar(PysolStatusbar):
|
||||||
def __init__(self, top, args):
|
def __init__(self, top, args):
|
||||||
PysolStatusbar.__init__(self, top)
|
PysolStatusbar.__init__(self, top)
|
||||||
# test some settings
|
# test some settings
|
||||||
self.updateText(moves=999, gamenumber="#0123456789ABCDEF0123")
|
self.updateText(moves=999, gamenumber='#0123456789ABCDEF0123')
|
||||||
self.updateText(info="Some info text.")
|
self.updateText(info='Some info text.')
|
||||||
|
|
||||||
def statusbar_main(args):
|
def statusbar_main(args):
|
||||||
tk = Tkinter.Tk()
|
tk = Tkinter.Tk()
|
||||||
|
@ -193,7 +207,7 @@ def statusbar_main(args):
|
||||||
tk.mainloop()
|
tk.mainloop()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == '__main__':
|
||||||
sys.exit(statusbar_main(sys.argv))
|
sys.exit(statusbar_main(sys.argv))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -433,13 +433,20 @@ class AllGamesFrame(Tile.Frame):
|
||||||
#
|
#
|
||||||
frame = Tile.Frame(self)
|
frame = Tile.Frame(self)
|
||||||
frame.pack(fill='both', expand=True, padx=10, pady=10)
|
frame.pack(fill='both', expand=True, padx=10, pady=10)
|
||||||
sb = Tile.Scrollbar(frame)
|
vsb = Tile.Scrollbar(frame)
|
||||||
sb.pack(side='right', fill='y')
|
vsb.grid(row=0, column=1, sticky='ns')
|
||||||
self.tree = Tile.Treeview(frame, columns=self.COLUMNS,
|
self.tree = Tile.Treeview(frame, columns=self.COLUMNS,
|
||||||
selectmode='browse')
|
selectmode='browse')
|
||||||
self.tree.pack(side='left', fill='both', expand=True)
|
self.tree.grid(row=0, column=0, sticky='nsew')
|
||||||
self.tree.config(yscrollcommand=sb.set)
|
self.tree.config(yscrollcommand=vsb.set)
|
||||||
sb.config(command=self.tree.yview)
|
vsb.config(command=self.tree.yview)
|
||||||
|
frame.rowconfigure(0, weight=1)
|
||||||
|
frame.columnconfigure(0, weight=1)
|
||||||
|
if Tile.TileVersion >= '0.8':
|
||||||
|
hsb = Tile.Scrollbar(frame, orient='horizontal')
|
||||||
|
hsb.grid(row=1, column=0, sticky='ew')
|
||||||
|
self.tree.config(xscrollcommand=hsb.set)
|
||||||
|
hsb.config(command=self.tree.xview)
|
||||||
bind(self.tree, '<<TreeviewSelect>>', self.treeviewSelected)
|
bind(self.tree, '<<TreeviewSelect>>', self.treeviewSelected)
|
||||||
#
|
#
|
||||||
self.formatter = TreeFormatter(self.app, self.tree, self,
|
self.formatter = TreeFormatter(self.app, self.tree, self,
|
||||||
|
|
|
@ -138,9 +138,9 @@ def makeToplevel(parent, title=None):
|
||||||
|
|
||||||
def make_help_toplevel(app, title=None):
|
def make_help_toplevel(app, title=None):
|
||||||
# Create an independent Toplevel window.
|
# Create an independent Toplevel window.
|
||||||
from pysollib.winsystems import initRootWindow
|
from pysollib.winsystems import init_root_window
|
||||||
window = Tkinter.Tk(className=PACKAGE)
|
window = Tkinter.Tk(className=PACKAGE)
|
||||||
initRootWindow(window, app)
|
init_root_window(window, app)
|
||||||
return window
|
return window
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -99,12 +99,16 @@ class ColorsDialog(MfxDialog):
|
||||||
self.not_matching_color = self.not_matching_var.get()
|
self.not_matching_color = self.not_matching_var.get()
|
||||||
|
|
||||||
def selectColor(self, label):
|
def selectColor(self, label):
|
||||||
c = askcolor(parent=self.top, initialcolor=label.cget('bg'),
|
try:
|
||||||
title=_("Select color"))
|
c = askcolor(parent=self.top, initialcolor=label.cget('bg'),
|
||||||
if c and c[1]:
|
title=_("Select color"))
|
||||||
label.configure(bg=c[1])
|
except:
|
||||||
#label.configure(text=c[1]) # don't work
|
pass
|
||||||
label.setvar(label.cget('textvariable'), c[1])
|
else:
|
||||||
|
if c and c[1]:
|
||||||
|
label.configure(bg=c[1])
|
||||||
|
#label.configure(text=c[1]) # don't work
|
||||||
|
label.setvar(label.cget('textvariable'), c[1])
|
||||||
|
|
||||||
def initKw(self, kw):
|
def initKw(self, kw):
|
||||||
kw = KwStruct(kw,
|
kw = KwStruct(kw,
|
||||||
|
|
|
@ -66,6 +66,7 @@ class MfxStatusbar:
|
||||||
self._row = row
|
self._row = row
|
||||||
self._column = column
|
self._column = column
|
||||||
self._columnspan = columnspan
|
self._columnspan = columnspan
|
||||||
|
self._label_column = 0
|
||||||
#
|
#
|
||||||
self.padx = 1
|
self.padx = 1
|
||||||
self.label_relief = 'sunken'
|
self.label_relief = 'sunken'
|
||||||
|
@ -82,22 +83,18 @@ class MfxStatusbar:
|
||||||
self.padx = 0
|
self.padx = 0
|
||||||
|
|
||||||
# util
|
# util
|
||||||
def _createLabel(self, name, side='left', fill='none',
|
def _createLabel(self, name, expand=False, width=0, tooltip=None):
|
||||||
expand=False, width=0, tooltip=None):
|
label = Tkinter.Label(self.frame, width=width,
|
||||||
if 0:
|
relief=self.label_relief, bd=1,
|
||||||
frame = Tkinter.Frame(self.frame, bd=1, relief=self.label_relief,
|
highlightbackground='black'
|
||||||
highlightbackground='#9e9a9e',
|
)
|
||||||
highlightthickness=1)
|
label.grid(row=0, column=self._label_column,
|
||||||
frame.pack(side=side, fill=fill, padx=self.padx, expand=expand)
|
sticky='nsew', padx=self.padx)
|
||||||
label = Tkinter.Label(frame, width=width, bd=0)
|
if expand:
|
||||||
label.pack(expand=True, fill='both')
|
self.frame.grid_columnconfigure(self._label_column,
|
||||||
else:
|
weight=1)
|
||||||
label = Tkinter.Label(self.frame, width=width,
|
self._label_column += 1
|
||||||
relief=self.label_relief, bd=1,
|
setattr(self, name + '_label', label)
|
||||||
highlightbackground='black'
|
|
||||||
)
|
|
||||||
label.pack(side=side, fill=fill, padx=self.padx, expand=expand)
|
|
||||||
setattr(self, name + "_label", label)
|
|
||||||
self._widgets.append(label)
|
self._widgets.append(label)
|
||||||
if tooltip:
|
if tooltip:
|
||||||
b = MfxTooltip(label)
|
b = MfxTooltip(label)
|
||||||
|
@ -112,22 +109,29 @@ class MfxStatusbar:
|
||||||
|
|
||||||
def updateText(self, **kw):
|
def updateText(self, **kw):
|
||||||
for k, v in kw.items():
|
for k, v in kw.items():
|
||||||
label = getattr(self, k + "_label")
|
label = getattr(self, k + '_label')
|
||||||
text = unicode(v)
|
text = unicode(v)
|
||||||
width = label['width']
|
width = label['width']
|
||||||
if width and len(text) > width:
|
if width and len(text) > width:
|
||||||
label['width'] = len(text)
|
label['width'] = len(text)
|
||||||
label["text"] = text
|
label['text'] = text
|
||||||
|
|
||||||
|
def config(self, name, show):
|
||||||
|
label = getattr(self, name + '_label')
|
||||||
|
if show:
|
||||||
|
label.grid()
|
||||||
|
else:
|
||||||
|
label.grid_remove()
|
||||||
|
|
||||||
def configLabel(self, name, **kw):
|
def configLabel(self, name, **kw):
|
||||||
label = getattr(self, name + "_label")
|
label = getattr(self, name + '_label')
|
||||||
label.config(**kw)
|
label.config(**kw)
|
||||||
|
|
||||||
def show(self, show=True, resize=False):
|
def show(self, show=True, resize=False):
|
||||||
if self._show == show:
|
if self._show == show:
|
||||||
return False
|
return False
|
||||||
if resize:
|
if resize:
|
||||||
self.top.wm_geometry("") # cancel user-specified geometry
|
self.top.wm_geometry('') # cancel user-specified geometry
|
||||||
if not show:
|
if not show:
|
||||||
# hide
|
# hide
|
||||||
self.frame.grid_forget()
|
self.frame.grid_forget()
|
||||||
|
@ -155,30 +159,30 @@ class PysolStatusbar(MfxStatusbar):
|
||||||
MfxStatusbar.__init__(self, top, row=3, column=0, columnspan=3)
|
MfxStatusbar.__init__(self, top, row=3, column=0, columnspan=3)
|
||||||
#
|
#
|
||||||
for n, t, w in (
|
for n, t, w in (
|
||||||
("time", _("Playing time"), 10),
|
('time', _('Playing time'), 10),
|
||||||
("moves", _('Moves/Total moves'), 10),
|
('moves', _('Moves/Total moves'), 10),
|
||||||
("gamenumber", _("Game number"), 26),
|
('gamenumber', _('Game number'), 26),
|
||||||
("stats", _("Games played: won/lost"), 12),
|
('stats', _('Games played: won/lost'), 12),
|
||||||
):
|
):
|
||||||
self._createLabel(n, tooltip=t, width=w)
|
self._createLabel(n, tooltip=t, width=w)
|
||||||
#
|
#
|
||||||
l = self._createLabel("info", fill='both', expand=True)
|
l = self._createLabel('info', expand=True)
|
||||||
##l.config(text="", justify="left", anchor='w')
|
##l.config(text='', justify='left', anchor='w')
|
||||||
l.config(padx=8)
|
l.config(padx=8)
|
||||||
|
|
||||||
|
|
||||||
class HelpStatusbar(MfxStatusbar):
|
class HelpStatusbar(MfxStatusbar):
|
||||||
def __init__(self, top):
|
def __init__(self, top):
|
||||||
MfxStatusbar.__init__(self, top, row=4, column=0, columnspan=3)
|
MfxStatusbar.__init__(self, top, row=4, column=0, columnspan=3)
|
||||||
l = self._createLabel("info", fill='both', expand=True)
|
l = self._createLabel('info', expand=True)
|
||||||
l.config(justify="left", anchor='w', padx=8)
|
l.config(justify='left', anchor='w', padx=8)
|
||||||
|
|
||||||
|
|
||||||
class HtmlStatusbar(MfxStatusbar):
|
class HtmlStatusbar(MfxStatusbar):
|
||||||
def __init__(self, top, row, column, columnspan):
|
def __init__(self, top, row, column, columnspan):
|
||||||
MfxStatusbar.__init__(self, top, row=row, column=column, columnspan=columnspan)
|
MfxStatusbar.__init__(self, top, row=row, column=column, columnspan=columnspan)
|
||||||
l = self._createLabel("url", fill='both', expand=True)
|
l = self._createLabel('url', expand=True)
|
||||||
l.config(justify="left", anchor='w', padx=8)
|
l.config(justify='left', anchor='w', padx=8)
|
||||||
|
|
||||||
|
|
||||||
# /***********************************************************************
|
# /***********************************************************************
|
||||||
|
@ -190,8 +194,8 @@ class TestStatusbar(PysolStatusbar):
|
||||||
def __init__(self, top, args):
|
def __init__(self, top, args):
|
||||||
PysolStatusbar.__init__(self, top)
|
PysolStatusbar.__init__(self, top)
|
||||||
# test some settings
|
# test some settings
|
||||||
self.updateText(moves=999, gamenumber="#0123456789ABCDEF0123")
|
self.updateText(moves=999, gamenumber='#0123456789ABCDEF0123')
|
||||||
self.updateText(info="Some info text.")
|
self.updateText(info='Some info text.')
|
||||||
|
|
||||||
def statusbar_main(args):
|
def statusbar_main(args):
|
||||||
tk = Tkinter.Tk()
|
tk = Tkinter.Tk()
|
||||||
|
@ -199,7 +203,7 @@ def statusbar_main(args):
|
||||||
tk.mainloop()
|
tk.mainloop()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == '__main__':
|
||||||
sys.exit(statusbar_main(sys.argv))
|
sys.exit(statusbar_main(sys.argv))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -139,9 +139,9 @@ def makeToplevel(parent, title=None):
|
||||||
|
|
||||||
def make_help_toplevel(app, title=None):
|
def make_help_toplevel(app, title=None):
|
||||||
# Create an independent Toplevel window.
|
# Create an independent Toplevel window.
|
||||||
from pysollib.winsystems import initRootWindow
|
from pysollib.winsystems import init_root_window
|
||||||
window = Tkinter.Tk(className=PACKAGE)
|
window = Tkinter.Tk(className=PACKAGE)
|
||||||
initRootWindow(window, app)
|
init_root_window(window, app)
|
||||||
return window
|
return window
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -196,7 +196,8 @@ class MfxDialog: # ex. _ToplevelDialog
|
||||||
b.pack(side=kw.image_side, padx=kw.image_padx, pady=kw.image_pady)
|
b.pack(side=kw.image_side, padx=kw.image_padx, pady=kw.image_pady)
|
||||||
|
|
||||||
def createButtons(self, frame, kw):
|
def createButtons(self, frame, kw):
|
||||||
button = column = -1
|
button = -1
|
||||||
|
column = 0
|
||||||
padx, pady = kw.get("buttonpadx", 10), kw.get("buttonpady", 10)
|
padx, pady = kw.get("buttonpadx", 10), kw.get("buttonpady", 10)
|
||||||
focus = None
|
focus = None
|
||||||
max_len = 0
|
max_len = 0
|
||||||
|
@ -249,13 +250,13 @@ class MfxDialog: # ex. _ToplevelDialog
|
||||||
## img = self.button_img.get(s)
|
## img = self.button_img.get(s)
|
||||||
## b.config(compound='left', image=img)
|
## b.config(compound='left', image=img)
|
||||||
column += 1
|
column += 1
|
||||||
b.grid(column=column, row=0, sticky="nse", padx=padx, pady=pady)
|
b.grid(column=column, row=0, sticky="ns", padx=padx, pady=pady)
|
||||||
if focus is not None:
|
if focus is not None:
|
||||||
l = (lambda event=None, self=self, button=kw.default: self.mDone(button))
|
l = (lambda event=None, self=self, button=kw.default: self.mDone(button))
|
||||||
bind(self.top, "<Return>", l)
|
bind(self.top, "<Return>", l)
|
||||||
bind(self.top, "<KP_Enter>", l)
|
bind(self.top, "<KP_Enter>", l)
|
||||||
# left justify
|
frame.columnconfigure(0, weight=1)
|
||||||
##frame.columnconfigure(0, weight=1)
|
frame.columnconfigure(99, weight=1)
|
||||||
return focus
|
return focus
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ class WizardDialog(MfxDialog):
|
||||||
v = p[w.var_name]
|
v = p[w.var_name]
|
||||||
else:
|
else:
|
||||||
v = w.default
|
v = w.default
|
||||||
if w.widget in ('menu', 'preset'):
|
if w.widget in ('menu', 'preset', 'entry'):
|
||||||
v = _(v)
|
v = _(v)
|
||||||
w.variable.set(v)
|
w.variable.set(v)
|
||||||
|
|
||||||
|
|
|
@ -64,14 +64,6 @@ import sys, os
|
||||||
from settings import DATA_DIRS, TOOLKIT
|
from settings import DATA_DIRS, TOOLKIT
|
||||||
from mfxutil import Image
|
from mfxutil import Image
|
||||||
|
|
||||||
# PIL
|
|
||||||
Image = ImageTk = ImageOps = None
|
|
||||||
if TOOLKIT == 'tk':
|
|
||||||
try:
|
|
||||||
import Image, ImageTk, ImageOps
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
# /***********************************************************************
|
# /***********************************************************************
|
||||||
# // constants
|
# // constants
|
||||||
|
|
|
@ -28,5 +28,5 @@ elif WIN_SYSTEM == 'aqua':
|
||||||
else: # 'x11'
|
else: # 'x11'
|
||||||
import x11 as gui
|
import x11 as gui
|
||||||
|
|
||||||
initRootWindow = gui.initRootWindow
|
init_root_window = gui.init_root_window
|
||||||
TkSettings = gui.TkSettings
|
TkSettings = gui.TkSettings
|
||||||
|
|
|
@ -26,28 +26,27 @@ from pysollib.settings import TOOLKIT, USE_TILE
|
||||||
from pysollib.tile import Tile
|
from pysollib.tile import Tile
|
||||||
from pysollib.macosx.appSupport import hideTkConsole
|
from pysollib.macosx.appSupport import hideTkConsole
|
||||||
|
|
||||||
from common import baseInitRootWindow, BaseTkSettings
|
from common import base_init_root_window, BaseTkSettings
|
||||||
|
|
||||||
|
|
||||||
class initRootWindow(baseInitRootWindow):
|
def init_root_window(root, app):
|
||||||
def __init__(self, root, app):
|
base_init_root_window(root, app)
|
||||||
baseInitRootWindow.__init__(self, root, app)
|
if TOOLKIT == 'tk':
|
||||||
if TOOLKIT == 'tk':
|
hideTkConsole(root)
|
||||||
hideTkConsole(root)
|
if TOOLKIT == 'gtk':
|
||||||
if TOOLKIT == 'gtk':
|
pass
|
||||||
pass
|
elif USE_TILE:
|
||||||
elif USE_TILE:
|
style = Tile.Style(root)
|
||||||
style = Tile.Style(root)
|
color = style.lookup('.', 'background')
|
||||||
color = style.lookup('.', 'background')
|
if color:
|
||||||
if color:
|
root.tk_setPalette(color) # for non-Tile widgets
|
||||||
root.tk_setPalette(color) # for non-Tile widgets
|
|
||||||
|
|
||||||
# standard Tk scrollbars work on OS X, but Tile ones look weird
|
# standard Tk scrollbars work on OS X, but Tile ones look weird
|
||||||
Tile.Scrollbar = Tkinter.Scrollbar
|
Tile.Scrollbar = Tkinter.Scrollbar
|
||||||
|
|
||||||
else: # pure Tk
|
else: # pure Tk
|
||||||
#root.option_add(...)
|
#root.option_add(...)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TkSettings(BaseTkSettings):
|
class TkSettings(BaseTkSettings):
|
||||||
|
|
|
@ -30,10 +30,22 @@ from pysollib.tile import Tile
|
||||||
|
|
||||||
|
|
||||||
def init_tile(app, top):
|
def init_tile(app, top):
|
||||||
|
Tile.initialize(top)
|
||||||
|
# load available themes
|
||||||
d = os.path.join(app.dataloader.dir, 'themes')
|
d = os.path.join(app.dataloader.dir, 'themes')
|
||||||
if os.path.isdir(d):
|
if os.path.isdir(d):
|
||||||
top.tk.call('lappend', 'auto_path', d)
|
top.tk.call('lappend', 'auto_path', d)
|
||||||
Tile.initialize(top)
|
for t in os.listdir(d):
|
||||||
|
if os.path.exists(os.path.join(d, t, 'pkgIndex.tcl')):
|
||||||
|
try:
|
||||||
|
if Tile.TileVersion < '0.8':
|
||||||
|
top.tk.call('package', 'require', 'tile::theme::'+t)
|
||||||
|
else:
|
||||||
|
top.tk.call('package', 'require', 'ttk::theme::'+t)
|
||||||
|
#print 'load theme:', t
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def set_theme(app, top, theme):
|
def set_theme(app, top, theme):
|
||||||
|
@ -64,6 +76,8 @@ def get_font_name(font):
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
else:
|
else:
|
||||||
fa = f.actual()
|
fa = f.actual()
|
||||||
|
if fa['size'] > 0:
|
||||||
|
fa['size'] = -fa['size']
|
||||||
font_name = (fa['family'],
|
font_name = (fa['family'],
|
||||||
fa['size'],
|
fa['size'],
|
||||||
fa['slant'],
|
fa['slant'],
|
||||||
|
@ -71,28 +85,28 @@ def get_font_name(font):
|
||||||
return font_name
|
return font_name
|
||||||
|
|
||||||
|
|
||||||
class baseInitRootWindow:
|
def base_init_root_window(root, app):
|
||||||
def __init__(self, root, app):
|
#root.wm_group(root)
|
||||||
#root.wm_group(root)
|
root.wm_title(PACKAGE + ' ' + VERSION)
|
||||||
root.wm_title(PACKAGE + ' ' + VERSION)
|
root.wm_iconname(PACKAGE + ' ' + VERSION)
|
||||||
root.wm_iconname(PACKAGE + ' ' + VERSION)
|
# set minsize
|
||||||
# set minsize
|
sw, sh, sd = (root.winfo_screenwidth(),
|
||||||
sw, sh, sd = (root.winfo_screenwidth(),
|
root.winfo_screenheight(),
|
||||||
root.winfo_screenheight(),
|
root.winfo_screendepth())
|
||||||
root.winfo_screendepth())
|
if sw < 640 or sh < 480:
|
||||||
if sw < 640 or sh < 480:
|
root.wm_minsize(400, 300)
|
||||||
root.wm_minsize(400, 300)
|
else:
|
||||||
else:
|
root.wm_minsize(520, 360)
|
||||||
root.wm_minsize(520, 360)
|
|
||||||
|
if TOOLKIT == 'gtk':
|
||||||
|
pass
|
||||||
|
elif USE_TILE:
|
||||||
|
theme = app.opt.tile_theme
|
||||||
|
init_tile(app, root)
|
||||||
|
set_theme(app, root, theme)
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
if TOOLKIT == 'gtk':
|
|
||||||
pass
|
|
||||||
elif USE_TILE:
|
|
||||||
theme = app.opt.tile_theme
|
|
||||||
init_tile(app, root)
|
|
||||||
set_theme(app, root, theme)
|
|
||||||
else:
|
|
||||||
pass
|
|
||||||
|
|
||||||
class BaseTkSettings:
|
class BaseTkSettings:
|
||||||
canvas_padding = (0, 0)
|
canvas_padding = (0, 0)
|
||||||
|
|
|
@ -24,29 +24,28 @@ import sys, os
|
||||||
from pysollib.settings import TOOLKIT, USE_TILE
|
from pysollib.settings import TOOLKIT, USE_TILE
|
||||||
from pysollib.tile import Tile
|
from pysollib.tile import Tile
|
||||||
|
|
||||||
from common import baseInitRootWindow, BaseTkSettings
|
from common import base_init_root_window, BaseTkSettings
|
||||||
|
|
||||||
|
|
||||||
class initRootWindow(baseInitRootWindow):
|
def init_root_window(root, app):
|
||||||
def __init__(self, root, app):
|
base_init_root_window(root, app)
|
||||||
baseInitRootWindow.__init__(self, root, app)
|
if TOOLKIT == 'gtk':
|
||||||
if TOOLKIT == 'gtk':
|
pass
|
||||||
pass
|
elif USE_TILE:
|
||||||
elif USE_TILE:
|
theme = app.opt.tile_theme
|
||||||
theme = app.opt.tile_theme
|
style = Tile.Style(root)
|
||||||
style = Tile.Style(root)
|
if theme not in ('winnative', 'xpnative'):
|
||||||
if theme not in ('winnative', 'xpnative'):
|
color = style.lookup('.', 'background')
|
||||||
color = style.lookup('.', 'background')
|
if color:
|
||||||
if color:
|
root.tk_setPalette(color)
|
||||||
root.tk_setPalette(color)
|
##root.option_add('*Menu.foreground', 'black')
|
||||||
##root.option_add('*Menu.foreground', 'black')
|
root.option_add('*Menu.activeBackground', '#08246b')
|
||||||
root.option_add('*Menu.activeBackground', '#08246b')
|
root.option_add('*Menu.activeForeground', 'white')
|
||||||
root.option_add('*Menu.activeForeground', 'white')
|
if theme == 'winnative':
|
||||||
if theme == 'winnative':
|
style.configure('Toolbutton', padding=2)
|
||||||
style.configure('Toolbutton', padding=2)
|
else:
|
||||||
else:
|
#root.option_add(...)
|
||||||
#root.option_add(...)
|
pass
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class TkSettings(BaseTkSettings):
|
class TkSettings(BaseTkSettings):
|
||||||
|
|
|
@ -28,106 +28,119 @@ from pysollib.settings import PACKAGE
|
||||||
from pysollib.settings import TOOLKIT, USE_TILE
|
from pysollib.settings import TOOLKIT, USE_TILE
|
||||||
from pysollib.tile import Tile
|
from pysollib.tile import Tile
|
||||||
|
|
||||||
from common import baseInitRootWindow, BaseTkSettings, get_font_name
|
from common import base_init_root_window, BaseTkSettings, get_font_name
|
||||||
|
|
||||||
|
|
||||||
# /***********************************************************************
|
# /***********************************************************************
|
||||||
# // Init root window
|
# // Init root window
|
||||||
# ************************************************************************/
|
# ************************************************************************/
|
||||||
|
|
||||||
class initRootWindow(baseInitRootWindow):
|
def init_root_window(root, app):
|
||||||
def __init__(self, root, app):
|
|
||||||
baseInitRootWindow.__init__(self, root, app)
|
base_init_root_window(root, app)
|
||||||
|
|
||||||
## if TOOLKIT == 'tk':
|
## if TOOLKIT == 'tk':
|
||||||
## window.wm_iconbitmap("@"+filename)
|
## window.wm_iconbitmap("@"+filename)
|
||||||
## window.wm_iconmask("@"+filename)
|
## window.wm_iconmask("@"+filename)
|
||||||
|
|
||||||
##root.self.wm_maxsize(9999, 9999) # unlimited
|
##root.self.wm_maxsize(9999, 9999) # unlimited
|
||||||
if TOOLKIT == 'gtk':
|
if TOOLKIT == 'gtk':
|
||||||
pass
|
pass
|
||||||
elif USE_TILE:
|
elif USE_TILE:
|
||||||
f = os.path.join(app.dataloader.dir, 'tcl', 'menu8.4.tcl')
|
f = os.path.join(app.dataloader.dir, 'tcl', 'menu8.4.tcl')
|
||||||
if os.path.exists(f):
|
if os.path.exists(f):
|
||||||
try:
|
try:
|
||||||
root.tk.call('source', f)
|
root.tk.call('source', f)
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
f = os.path.join(app.dataloader.dir, 'tcl', 'clrpick.tcl')
|
f = 'clrpick8.4.tcl'
|
||||||
if os.path.exists(f):
|
if Tile.TileVersion >= '0.8':
|
||||||
try:
|
f = 'clrpick8.5.tcl'
|
||||||
root.tk.call('source', f)
|
f = os.path.join(app.dataloader.dir, 'tcl', f)
|
||||||
except:
|
if os.path.exists(f):
|
||||||
traceback.print_exc()
|
try:
|
||||||
f = os.path.join(app.dataloader.dir, 'tcl', 'fsdialog.tcl')
|
root.tk.call('source', f)
|
||||||
if os.path.exists(f):
|
except:
|
||||||
try:
|
traceback.print_exc()
|
||||||
root.tk.call('source', f)
|
f = 'fsdialog8.4.tcl'
|
||||||
except:
|
if Tile.TileVersion >= '0.8':
|
||||||
traceback.print_exc()
|
f = 'fsdialog8.5.tcl'
|
||||||
else:
|
f = os.path.join(app.dataloader.dir, 'tcl', f)
|
||||||
import tkFileDialog
|
if os.path.exists(f):
|
||||||
tkFileDialog.Open.command = 'ttk::getOpenFile'
|
try:
|
||||||
tkFileDialog.SaveAs.command = 'ttk::getSaveFile'
|
root.tk.call('source', f)
|
||||||
tkFileDialog.Directory.command = 'ttk::chooseDirectory'
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
else:
|
||||||
|
import tkFileDialog
|
||||||
|
tkFileDialog.Open.command = 'ttk::getOpenFile'
|
||||||
|
tkFileDialog.SaveAs.command = 'ttk::getSaveFile'
|
||||||
|
tkFileDialog.Directory.command = 'ttk::chooseDirectory'
|
||||||
|
|
||||||
style = Tile.Style(root)
|
style = Tile.Style(root)
|
||||||
color = style.lookup('.', 'background')
|
color = style.lookup('.', 'background')
|
||||||
if color:
|
if color:
|
||||||
root.tk_setPalette(color)
|
root.tk_setPalette(color)
|
||||||
|
|
||||||
root.option_add('*Menu.borderWidth', 1, 60)
|
root.option_add('*Menu.borderWidth', 1, 60)
|
||||||
root.option_add('*Menu.activeBorderWidth', 1, 60)
|
root.option_add('*Menu.activeBorderWidth', 1, 60)
|
||||||
color = style.lookup('.', 'background', 'active')
|
color = style.lookup('.', 'background', 'active')
|
||||||
if color:
|
if color:
|
||||||
root.option_add('*Menu.activeBackground', color, 60)
|
root.option_add('*Menu.activeBackground', color, 60)
|
||||||
|
|
||||||
root.option_add('*Listbox.background', 'white', 60)
|
root.option_add('*Listbox.background', 'white', 60)
|
||||||
root.option_add('*Listbox.foreground', 'black', 60)
|
root.option_add('*Listbox.foreground', 'black', 60)
|
||||||
root.option_add('*Listbox*selectBackground', '#0a5f89', 60)
|
root.option_add('*Listbox*selectBackground', '#0a5f89', 60)
|
||||||
root.option_add('*Listbox*selectForeground', 'white', 60)
|
root.option_add('*Listbox*selectForeground', 'white', 60)
|
||||||
|
|
||||||
font = root.option_get('font', PACKAGE)
|
font = root.option_get('font', PACKAGE)
|
||||||
|
if font:
|
||||||
|
# use font from xrdb
|
||||||
|
fn = get_font_name(font)
|
||||||
|
if fn:
|
||||||
|
root.option_add('*font', font)
|
||||||
|
style.configure('.', font=font)
|
||||||
|
app.opt.fonts['default'] = fn
|
||||||
|
# treeview heading
|
||||||
|
f = root.tk.splitlist(root.tk.call('font', 'actual', fn))
|
||||||
|
root.tk.call('font', 'configure', 'TkHeadingFont', *f)
|
||||||
|
else:
|
||||||
|
# use font from Tile settings
|
||||||
|
font = style.lookup('.', 'font')
|
||||||
if font:
|
if font:
|
||||||
# use font from xrdb
|
|
||||||
fn = get_font_name(font)
|
fn = get_font_name(font)
|
||||||
if fn:
|
if fn:
|
||||||
root.option_add('*font', font)
|
root.option_add('*font', font)
|
||||||
style.configure('.', font=font)
|
|
||||||
app.opt.fonts['default'] = fn
|
app.opt.fonts['default'] = fn
|
||||||
# treeview heading
|
if app.opt.tile_theme in ('clam', 'clearlooks'):
|
||||||
f = root.tk.splitlist(root.tk.call('font', 'actual', fn))
|
root.wm_minsize(550, 360)
|
||||||
root.tk.call('font', 'configure', 'TkHeadingFont', *f)
|
style.configure('TLabelframe', labeloutside=False,
|
||||||
else:
|
labelmargins=(8, 0, 8, 0))
|
||||||
# use font from Tile settings
|
|
||||||
font = style.lookup('.', 'font')
|
|
||||||
if font:
|
|
||||||
fn = get_font_name(font)
|
|
||||||
if fn:
|
|
||||||
root.option_add('*font', font)
|
|
||||||
app.opt.fonts['default'] = fn
|
|
||||||
if app.opt.tile_theme in ('clam', 'clearlooks'):
|
|
||||||
root.wm_minsize(550, 360)
|
|
||||||
style.configure('TLabelframe', labeloutside=False,
|
|
||||||
labelmargins=(8, 0, 8, 0))
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
else:
|
||||||
|
root.option_add('*Entry.background', 'white', 60)
|
||||||
|
root.option_add('*Entry.foreground', 'black', 60)
|
||||||
|
root.option_add('*Listbox.background', 'white', 60)
|
||||||
|
root.option_add('*Listbox.foreground', 'black', 60)
|
||||||
|
root.option_add('*Listbox*selectBackground', '#0a5f89', 60)
|
||||||
|
root.option_add('*Listbox*selectForeground', 'white', 60)
|
||||||
|
##root.option_add('*borderWidth', '1', 50)
|
||||||
|
##root.option_add('*Button.borderWidth', '1', 50)
|
||||||
|
root.option_add('*Scrollbar.elementBorderWidth', 1, 60)
|
||||||
|
root.option_add('*Scrollbar.borderWidth', 1, 60)
|
||||||
|
root.option_add('*Menu.borderWidth', 1, 60)
|
||||||
|
root.option_add('*Menu.activeBorderWidth', 1, 60)
|
||||||
|
#root.option_add('*Button.HighlightBackground', '#595d59')
|
||||||
|
#root.option_add('*Button.HighlightThickness', '1')
|
||||||
|
font = root.option_get('font', PACKAGE)
|
||||||
|
if font:
|
||||||
|
fn = get_font_name(font)
|
||||||
|
app.opt.fonts['default'] = fn
|
||||||
else:
|
else:
|
||||||
root.option_add('*Entry.background', 'white', 60)
|
root.option_add('*font', 'helvetica -12', 60)
|
||||||
root.option_add('*Entry.foreground', 'black', 60)
|
app.opt.fonts['default'] = ('helvetica', -12,
|
||||||
root.option_add('*Listbox.background', 'white', 60)
|
'roman', 'normal')
|
||||||
root.option_add('*Listbox.foreground', 'black', 60)
|
|
||||||
root.option_add('*Listbox*selectBackground', '#0a5f89', 60)
|
|
||||||
root.option_add('*Listbox*selectForeground', 'white', 60)
|
|
||||||
##root.option_add('*borderWidth', '1', 50)
|
|
||||||
##root.option_add('*Button.borderWidth', '1', 50)
|
|
||||||
root.option_add('*Scrollbar.elementBorderWidth', 1, 60)
|
|
||||||
root.option_add('*Scrollbar.borderWidth', 1, 60)
|
|
||||||
root.option_add('*Menu.borderWidth', 1, 60)
|
|
||||||
root.option_add('*Menu.activeBorderWidth', 1, 60)
|
|
||||||
#root.option_add('*Button.HighlightBackground', '#595d59')
|
|
||||||
#root.option_add('*Button.HighlightThickness', '1')
|
|
||||||
root.option_add('*font', 'helvetica 12', 60)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue