Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

widget::dialog

6 views
Skip to first unread message

gary sachs

unread,
Oct 23, 2012, 7:20:24 AM10/23/12
to Tcl/ Tk Mailing List
Good Day,

Looking at the various option of using a dialog widget from PERL via Tkx,
widget::dialog was my best choice because it is themed. But I was curious

as to why it does not allow for specifying a default button like the other
dialog widgets, i.e. - tk__dialog.

thanks,
gary

Jeff Hobbs

unread,
Oct 25, 2012, 1:43:56 AM10/25/12
to gary sachs, Tcl/ Tk Mailing List
widget::dialog tries to act like a proper dialog shell with some widget-like interaction and a lot of flexibility. tk_dialog is a more limited dialog shell only (taking just a message and names of buttons). Indeed, that's been replaced by the core tk_messageBox which is similarly restrictive because it delegates out to the native OS message box.

Jeff

gary sachs

unread,
Oct 25, 2012, 7:06:52 AM10/25/12
to Jeff Hobbs, Tcl/ Tk Mailing List
Jeff,

any chance that widget::dialog could be enhanced to include the specification of a default button?
Is there anyway to specify the "blocking synchronization" of a dialog box in a top-level widget?

Thanks again.


gary


________________________________
From: Jeff Hobbs <je...@activestate.com>
To: gary sachs <converse...@yahoo.com>
Cc: 'Tcl/ Tk Mailing List' <tc...@perl.org>
Sent: Wednesday, October 24, 2012 11:43 PM
Subject: Re: widget::dialog

Jeff Hobbs

unread,
Oct 25, 2012, 3:18:06 PM10/25/12
to gary sachs, Tcl/ Tk Mailing List
You could make an extended megawidget which would add the button, or
just encapsulate that in a simple subroutine. Did you know that it
has a '-type' option that will add a default set of button(s)?

There is a sample in the code that show you how to use this in a sync
manner (in Tcl, but easily translatable):

# Using -synchronous with a -type custom dialog requires that the
# custom buttons call [$dlg close $reason] to trigger the close
set dlg [widget::dialog .pkgerr -title "Yes/No Dialog" -separator 1 \
-parent . -type custom]
set frame [frame $dlg.f]
label $frame.lbl -text "Type Something In:"
entry $frame.ent
grid $frame.lbl $frame.ent -sticky ew
grid columnconfigure $frame 1 -weight 1
$dlg setwidget $frame
$dlg add button -text "Yes" -command [list $dlg close yes]
$dlg add button -text "No" -command [list $dlg close no]
puts [$dlg display]

Jeff

gary sachs

unread,
Oct 25, 2012, 3:42:41 PM10/25/12
to Jeff Hobbs, Tcl/ Tk Mailing List
Roger that, I have been able to specify custom buttons.

I'm sorry I may not have stated this correctly...

With tk__dialog I can specify what buttons I want by passing in a list of strings, cool!
But along with that I can also indicate that I want button x to be the default so that when I
hit <Return> when the dialog box is active, button x is invoked. Unfortunately, the tk__dialog does not used themed widgets, hence my desire to use widget::dialog. I tried to figure out setting the themes for tk__dialog, but I was missing something in the documentation and I also had trouble finding the style/theme associated with buttons used by tk__dialog.

So, with widget::dialog themed and easy enough to work with I was looking to find out whether in a future releases if it would be possible to indicate which button, whether custom or not, could be indicated as the default, thus allowing a user to just press <Return> and then that button would be invoked.

I hope I got it right this time... and if I am crossing paths, my apologies.

gary

________________________________
From: Jeff Hobbs <je...@activestate.com>
To: gary sachs <converse...@yahoo.com>
Cc: Tcl/ Tk Mailing List <tc...@perl.org>

Sent: Thursday, October 25, 2012 1:18 PM

Jeff Hobbs

unread,
Oct 25, 2012, 4:48:58 PM10/25/12
to gary sachs, Tcl/ Tk Mailing List
Hi Gary,

If you take the example below, you can modify it like so (assuming "No" should be the default):

set nobtn [$dlg add button -text "No" …]
$dlg configure -focus $nobtn
bind $dlg <Return> [list $nobtn invoke]

and that will get what you want.

Jeff

On 2012-10-25, at 12:42 PM, gary sachs <converse...@yahoo.com> wrote:

> Roger that, I have been able to specify custom buttons.
>
> I'm sorry I may not have stated this correctly...
>
> With tk__dialog I can specify what buttons I want by passing in a list of strings, cool!
> But along with that I can also indicate that I want button x to be the default so that when I
> hit <Return> when the dialog box is active, button x is invoked. Unfortunately, the tk__dialog does not used themed widgets, hence my desire to use widget::dialog. I tried to figure out setting the themes for tk__dialog, but I was missing something in the documentation and I also had trouble finding the style/theme associated with buttons used by tk__dialog.
>
> So, with widget::dialog themed and easy enough to work with I was looking to find out whether in a future releases if it would be possible to indicate which button, whether custom or not, could be indicated as the default, thus allowing a user to just press <Return> and then that button would be invoked.
>
> I hope I got it right this time... and if I am crossing paths, my apologies.
>
> gary
>
>

gary sachs

unread,
Oct 26, 2012, 6:53:44 AM10/26/12
to Jeff Hobbs, Tcl/ Tk Mailing List
I see what you mean. Thanks again!

gary

________________________________
From: Jeff Hobbs <je...@activestate.com>
To: gary sachs <converse...@yahoo.com>
Cc: Tcl/ Tk Mailing List <tc...@perl.org>

Sent: Thursday, October 25, 2012 2:48 PM
Subject: Re: widget::dialog

Hi Gary,

If you take the example below, you can modify it like so (assuming "No" should be the default):

set nobtn [$dlg add button -text "No" …]
$dlg configure -focus $nobtn
bind $dlg <Return> [list $nobtn invoke]

and that will get what you want.

Jeff


On 2012-10-25, at 12:42 PM, gary sachs <converse...@yahoo.com> wrote:

Roger that, I have been able to specify custom buttons.
>
>I'm sorry I may not have stated this correctly...
>
>With tk__dialog I can specify what buttons I want by passing in a list of strings, cool!
>But along with that I can also indicate that I want button x to be the default so that when I
>hit <Return> when the dialog box is active, button x is invoked. Unfortunately, the tk__dialog does not used themed widgets, hence my desire to use widget::dialog. I tried to figure out setting the themes for tk__dialog, but I was missing something in the documentation and I also had trouble finding the style/theme associated with buttons used by tk__dialog.
>
>So, with widget::dialog themed and easy enough to work with I was looking to find out whether in a future releases if it would be possible to
indicate which button, whether custom or not, could be indicated as the default, thus allowing a user to just press <Return> and then that button would be invoked.
>
>I hope I got it right this time... and if I am crossing paths, my apologies.
>
>gary
>
>
>
>
>
>

0 new messages