git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] gitk: on themed tk, use uicolor to draw a sash between panes

From
CGChristoph Sommer via GitGitGadget <gitgitgadget@gmail.com>
Date
Apr 28, 2025, 15:56 UTC
Message-ID
<78d87c0ecc87df6c89130a6cbb417b534db8395d.1745855773.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1909.git.1745855773.gitgitgadget@gmail.com>
From: Christoph Sommer <sommer@cms-labs.org>

Add a custom sash (grab/resize handle) where the window is split into panes when using themed Tk as. Other than native Tk which draws sashes by default, themed Tk does not, by default, render such handles leaving users to guess where to click to start resizing window panes. The color used for drawing these is uicolor, which is not needed on themed Tk, allowing the user to make these elements as pronounced or as invisible as desired.

Signed-off-by: Christoph Sommer <sommer@cms-labs.org>
---
 gitk-git/gitk | 48 +++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 45 insertions(+), 3 deletions(-)
diff --git a/gitk-git/gitk b/gitk-git/gitk
index da7507af360..d19f29bbf18 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -2133,7 +2133,31 @@ proc setoptions {} {
     option add *Listbox.font mainfont startupFile
 }
 
+proc createttkimages {} {
+    global uicolor
+
+    image create bitmap img:myVerticalSash -foreground $uicolor -data {
+        #define xbm_width 5
+        #define xbm_height 47
+        static unsigned char xbm_bits[] = {
+        0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+        0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x0e,
+        0x00, 0x00, 0x0e, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+        0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 };
+    }
+
+    image create bitmap img:myHorizontalSash -foreground $uicolor -data {
+        #define xbm_width 47
+        #define xbm_height 5
+        static unsigned char xbm_bits[] = {
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x04, 0x00, 0x00,
+        0xff, 0xff, 0x93, 0xe4, 0xff, 0x7f, 0x00, 0x00, 0x90, 0x04, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+    }
+}
+
 proc setttkstyle {} {
+
     eval font configure TkDefaultFont [fontflags mainfont]
     eval font configure TkTextFont [fontflags textfont]
     eval font configure TkHeadingFont [fontflags mainfont]
@@ -2143,6 +2167,16 @@ proc setttkstyle {} {
     eval font configure TkIconFont    [fontflags uifont]
     eval font configure TkMenuFont    [fontflags uifont]
     eval font configure TkSmallCaptionFont [fontflags uifont]
+
+    createttkimages
+
+    ttk::style element create myVerticalSash image img:myVerticalSash -sticky ew
+
+    ttk::style element create myHorizontalSash image img:myHorizontalSash -sticky ns
+
+    ttk::style layout Vertical.Sash { myVerticalSash }
+
+    ttk::style layout Horizontal.Sash { myHorizontalSash }
 }
 
 # Make a menu and submenus.
@@ -11825,7 +11859,7 @@ proc prefspage_colors {notebook} {
     grid $page.cdisp - -sticky w -pady 10
     label $page.ui -padx 40 -relief sunk -background $uicolor
     ${NS}::button $page.uibut -text [mc "Interface"] \
-       -command [list choosecolor uicolor {} $page.ui [mc "interface"] setui]
+       -command [list choosecolor uicolor {} $page.ui [mc "interface"] setui_dialog]
     grid x $page.uibut $page.ui -sticky w
     label $page.bg -padx 40 -relief sunk -background $bgcolor
     ${NS}::button $page.bgbut -text [mc "Background"] \
@@ -12006,6 +12040,14 @@ proc setui {c} {
     tk_setPalette background $c selectColor $selc
 }
 
+proc setui_dialog {c} {
+    global uicolor
+
+    setui $c
+
+    createttkimages
+}
+
 proc setbg {c} {
     global bglist
 
@@ -12706,8 +12748,6 @@ eval font create textfontbold [fontflags textfont 1]
 parsefont uifont $uifont
 eval font create uifont [fontflags uifont]
 
-setui $uicolor
-
 setoptions
 
 # check that we can find a .git directory somewhere...
@@ -12788,6 +12828,8 @@ if {![info exists have_ttk]} {
 set use_ttk [expr {$have_ttk && $want_ttk}]
 set NS [expr {$use_ttk ? "ttk" : ""}]
 
+setui $uicolor
+
 if {$use_ttk} {
     setttkstyle
 }
-- 
gitgitgadget
Previous: Christoph Sommer via GitGitGadgetNext: Christoph Sommer via GitGitGadget
Message 3 of 4 in “gitk: small quality of life improvements for themed Tk”
  1. 0/3 gitk: small quality of life improvements for themed TkChristoph Sommer via GitGitGadget, Apr 28, 2025
  2. 1/3 gitk: fix text wrapping preferences for unthemed tkChristoph Sommer via GitGitGadget, Apr 28, 2025
  3. 3/3 gitk: on themed tk, use uicolor to draw a sash between panesChristoph Sommer via GitGitGadget, Apr 28, 2025
  4. 2/3 gitk: do not set fg/bg color scheme for themed TkChristoph Sommer via GitGitGadget, Apr 28, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.