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

Re: [PATCH] git-gui: use tk_messageBox for ask yes/no

From
Johannes Sixt <j6t@kdbg.org>
Date
Aug 28, 2025, 21:18 UTC
Message-ID
<d89cf43f-78c7-46df-878e-b12044c4aa5c@kdbg.org>
In-Reply-To
<20250828133301.74328-1-mlevedahl@gmail.com>
Am 28.08.25 um 15:33 schrieb Mark Levedahl:
> git-gui includes git-gui--yesno that relies upon Tk 8.5 constructs, and
/--yesno/--askyesno/? BTW, I wonder which constructs you mean.
> this dialog box is not supported with Tk 9.0.  Tk provides tk_messagebox
> for this same purpose, fully supported in Tk 8.5+, so use tk_messagebox
> instead.

Which "this dialog box" do you mean here? The old code looks like a usual Tk main window to me.

Show 58 quoted lines
> 
> Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
> ---
>  git-gui--askyesno | 35 +++++++----------------------------
>  1 file changed, 7 insertions(+), 28 deletions(-)
> 
> diff --git a/git-gui--askyesno b/git-gui--askyesno
> index 142d1bc..cd986f2 100755
> --- a/git-gui--askyesno
> +++ b/git-gui--askyesno
> @@ -10,12 +10,6 @@ exec wish "$0" -- "$@"
>  # overridden via the optional `--title` command-line
>  # option.
>  
> -set NS {}
> -set use_ttk [package vsatisfies [package provide Tk] 8.5]
> -if {$use_ttk} {
> -	set NS ttk
> -}
> -
>  set title "Question?"
>  if {$argc < 1} {
>  	puts stderr "Usage: $argv0 <question>"
> @@ -28,25 +22,7 @@ if {$argc < 1} {
>  	set prompt [join $argv " "]
>  }
>  
> -${NS}::frame .t
> -${NS}::label .t.m -text $prompt -justify center -width 40
> -.t.m configure -wraplength 400
> -pack .t.m -side top -fill x -padx 20 -pady 20 -expand 1
> -pack .t -side top -fill x -ipadx 20 -ipady 20 -expand 1
> -
> -${NS}::frame .b
> -${NS}::frame .b.left -width 200
> -${NS}::button .b.yes -text Yes -command {exit 0}
> -${NS}::button .b.no  -text No  -command {exit 1}
> -
> -pack .b.left -side left -expand 1 -fill x
> -pack .b.yes -side left -expand 1
> -pack .b.no -side right -expand 1 -ipadx 5
> -pack .b -side bottom -fill x -ipadx 20 -ipady 15
> -
> -bind . <Key-Return> {exit 0}
> -bind . <Key-Escape> {exit 1}
> -
> +set dlgicon {question}
>  if {$::tcl_platform(platform) eq {windows}} {
>  	set icopath [file dirname [file normalize $argv0]]
>  	if {[file tail $icopath] eq {git-core}} {
> @@ -55,9 +31,12 @@ if {$::tcl_platform(platform) eq {windows}} {
>  	set icopath [file dirname $icopath]
>  	set icopath [file join $icopath share git git-for-windows.ico]
>  	if {[file exists $icopath]} {
> -		wm iconbitmap . -default $icopath
> +		set dlgicon $icopath
>  	}
>  }

I think there is a misunderstanding what the purpose of this icon is. It is the icon shown on the window frame/decoration, not the icon next to the text.

Show 6 quoted lines
>  
> -wm title . $title
> -tk::PlaceWindow .
> +wm withdraw .
> +
> +option add *Dialog.msg.font {Sans 10}

Is this to replicate the old appearance? I don't think it is necessary. Let's assume tk_messageBox does a sensible thing.

> +set ans [tk_messageBox -icon $dlgicon -message $prompt -title $title -type yesno]

This option -icon can only be one of the words error, info, question or warning. It has nothing to do with the icon above.

> +exit [expr $ans eq {no}]
-- Hannes
Previous: Johannes Schindelin
Message 19 of 19 in “git-gui: GIT_ASK_YESNO/GIT_ASKPASS patches from Git for Windows”
  1. 0/4 git-gui: GIT_ASK_YESNO/GIT_ASKPASS patches from Git for WindowsJohannes Schindelin via GitGitGadget, Sep 26, 2019
  2. 1/4 git-gui: provide question helper for retry fallback on WindowsHeiko Voigt via GitGitGadget, Sep 26, 2019
  3. Pratyush YadavSep 29, 2019
  4. 2/4 git gui: set GIT_ASKPASS=git-gui--askpass if not set yetJohannes Schindelin via GitGitGadget, Sep 26, 2019
  5. Pratyush YadavSep 29, 2019
  6. 3/4 git-gui--askyesno: allow overriding the window titleJohannes Schindelin via GitGitGadget, Sep 26, 2019
  7. Pratyush YadavSep 29, 2019
  8. 4/4 git-gui--askyesno (mingw): use Git for Windows' icon, if availableJohannes Schindelin via GitGitGadget, Sep 26, 2019
  9. Pratyush YadavSep 29, 2019
  10. 0/4 git-gui: GIT_ASK_YESNO/GIT_ASKPASS patches from Git for WindowsJohannes Schindelin via GitGitGadget, Aug 28, 2025
  11. 1/4 git-gui: provide question helper for retry fallback on WindowsHeiko Voigt via GitGitGadget, Aug 28, 2025
  12. 2/4 git gui: set GIT_ASKPASS=git-gui--askpass if not set yetJohannes Schindelin via GitGitGadget, Aug 28, 2025
  13. Johannes SixtAug 28, 2025
  14. Johannes SchindelinNov 17, 2025
  15. 3/4 git-gui--askyesno: allow overriding the window titleJohannes Schindelin via GitGitGadget, Aug 28, 2025
  16. 4/4 git-gui--askyesno (mingw): use Git for Windows' icon, if availableJohannes Schindelin via GitGitGadget, Aug 28, 2025
  17. git-gui: use tk_messageBox for ask yes/noMark Levedahl, Aug 28, 2025
  18. Johannes SchindelinAug 28, 2025
  19. Johannes SixtAug 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.