Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Are you perchance running on a 64-bit machine? -- Larry Wall in <199711102149.NAA16878@wall.org>


devel / comp.lang.tcl / How do I get the selection of a BWidget ComboBox?

SubjectAuthor
* How do I get the selection of a BWidget ComboBox?Luc
`* Re: How do I get the selection of a BWidget ComboBox?nemethi
 `* Re: How do I get the selection of a BWidget ComboBox?Luc
  `- Re: How do I get the selection of a BWidget ComboBox?nemethi

1
How do I get the selection of a BWidget ComboBox?

<20240307004412.692a552e@lud1.home>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=13117&group=comp.lang.tcl#13117

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: luc...@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: How do I get the selection of a BWidget ComboBox?
Date: Thu, 7 Mar 2024 00:44:12 -0300
Organization: A noiseless patient Spider
Lines: 59
Message-ID: <20240307004412.692a552e@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="99941bec0be174695c88e9cdcfe1a95c";
logging-data="917916"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX185w5Zs0q0DgYyorNIGD26sWSVm0rJ13Tc="
Cancel-Lock: sha1:WHDYh7lTjx0NxRaSqI5dOKdjzEU=
 by: Luc - Thu, 7 Mar 2024 03:44 UTC

I have a BWidget ComboBox with a lot of items.

set SomeVar "hello"
set combotext "Take your pick"
$::c1.outerframe.frame4.combo configure -text "Take your pick"

I select one item from the ComboBox:

$::c1.outerframe.frame4.combo configure -modifycmd "puts
[$::c1.outerframe.frame4.combo get]"

Take your pick

It doesn't matter which item I pick:

Take your pick
Take your pick
Take your pick

Add a new line:

$::c1.outerframe.frame4.combo configure -textvariable SomeVar

I select one item from the ComboBox:

$::c1.outerframe.frame4.combo configure -modifycmd "puts $SomeVar"

hello

It doesn't matter which item I pick:

hello
hello
hello

The manual also says,

"pathName getvalue
Returns the index of the current text of the ComboBox in the list of
values, or -1 if it doesn't match any value."

Well, I cannot choose anything that is not in my values list, but no
matter what I choose, pathName getvalue returns -1.

How do I capture the current selection of a BWidget ComboBox?

The only page I could find with that specific question has been
unanswered for 10 years.

https://stackoverflow.com/questions/17424489/tcl-bwidget-how-can-i-pass-my-combobox-selected-value-to-the-command

--
Luc
>>

Re: How do I get the selection of a BWidget ComboBox?

<uscmnp$125s1$1@tota-refugium.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=13125&group=comp.lang.tcl#13125

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.tota-refugium.de!.POSTED!not-for-mail
From: csaba.ne...@t-online.de (nemethi)
Newsgroups: comp.lang.tcl
Subject: Re: How do I get the selection of a BWidget ComboBox?
Date: Thu, 7 Mar 2024 16:33:13 +0100
Message-ID: <uscmnp$125s1$1@tota-refugium.de>
References: <20240307004412.692a552e@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 7 Mar 2024 15:33:13 -0000 (UTC)
Injection-Info: tota-refugium.de;
logging-data="1120129"; mail-complaints-to="abuse@news.tota-refugium.de"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:jdkpIOOiBnhKWU/99moxR9G4/WQ=
In-Reply-To: <20240307004412.692a552e@lud1.home>
X-User-ID: eJwFwYEBwDAEBMCVCE87TvD2HyF3sNDo9EA4FvsfFV0Fe7oMNbFXJ+j85uRkUpLFvFg3iD0quxGO
Content-Language: en-US
 by: nemethi - Thu, 7 Mar 2024 15:33 UTC

Am 07.03.24 um 04:44 schrieb Luc:
> I have a BWidget ComboBox with a lot of items.
>
> set SomeVar "hello"
> set combotext "Take your pick"
> $::c1.outerframe.frame4.combo configure -text "Take your pick"
>
> I select one item from the ComboBox:
>
> $::c1.outerframe.frame4.combo configure -modifycmd "puts
> [$::c1.outerframe.frame4.combo get]"
>
> Take your pick
>
> It doesn't matter which item I pick:
>
> Take your pick
> Take your pick
> Take your pick
>
>
> Add a new line:
>
> $::c1.outerframe.frame4.combo configure -textvariable SomeVar
>
> I select one item from the ComboBox:
>
> $::c1.outerframe.frame4.combo configure -modifycmd "puts $SomeVar"
>
> hello
>
> It doesn't matter which item I pick:
>
> hello
> hello
> hello
>
>
> The manual also says,
>
> "pathName getvalue
> Returns the index of the current text of the ComboBox in the list of
> values, or -1 if it doesn't match any value."
>
> Well, I cannot choose anything that is not in my values list, but no
> matter what I choose, pathName getvalue returns -1.
>
>
> How do I capture the current selection of a BWidget ComboBox?
>
> The only page I could find with that specific question has been
> unanswered for 10 years.
>
> https://stackoverflow.com/questions/17424489/tcl-bwidget-how-can-i-pass-my-combobox-selected-value-to-the-command
>

I see several problems here:

1. The line

$::c1.outerframe.frame4.combo configure -modifycmd "puts
[$::c1.outerframe.frame4.combo get]"

sets the -modifycmd option of the combobox to "puts Take your pick",
which will throw an error message rather than printing "Take your pick".
Are you sure you have this same line in your script?

2. To get rid of the error message, you could change the above line to
become

$::c1.outerframe.frame4.combo configure -modifycmd [list puts
[$::c1.outerframe.frame4.combo get]]

which would produce the output "Take your pick" whenever an item is
selected, as stated in your posting. This is, however, not the expected
behavior.

3. To solve the problem, you should change the above line to become

$::c1.outerframe.frame4.combo configure -modifycmd { puts
[$::c1.outerframe.frame4.combo get] }

which will work as expected, due to the use of braces instead of
quotation marks. Even better (the recommended way):

$::c1.outerframe.frame4.combo configure -modifycmd [list modifCmd
$::c1.outerframe.frame4.combo]
proc modifCmd w { puts [$w get] }

4. The ComboBox getvalue command works for me as expected (it returns 0,
1, ... rather than -1). You have probably made a similar mistake as in
connection with the -modifycmd option.

--
Csaba Nemethi https://www.nemethi.de mailto:csaba.nemethi@t-online.de

Re: How do I get the selection of a BWidget ComboBox?

<20240308171841.09b79f37@lud1.home>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=13126&group=comp.lang.tcl#13126

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: luc...@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: How do I get the selection of a BWidget ComboBox?
Date: Fri, 8 Mar 2024 17:18:41 -0300
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <20240308171841.09b79f37@lud1.home>
References: <20240307004412.692a552e@lud1.home>
<uscmnp$125s1$1@tota-refugium.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="eb36611986d7b57b53c36fe3ce496896";
logging-data="1997417"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Pc0cLDoPe3PQYMDuLuK2SOuj1Ww+NtA0="
Cancel-Lock: sha1:p47jqZcdfAQARTAU9EdaeKlKIoQ=
 by: Luc - Fri, 8 Mar 2024 20:18 UTC

On Thu, 7 Mar 2024 16:33:13 +0100, nemethi wrote:

>3. To solve the problem, you should change the above line to become
>
> $::c1.outerframe.frame4.combo configure -modifycmd { puts
>[$::c1.outerframe.frame4.combo get] }
>
>which will work as expected, due to the use of braces instead of
>quotation marks. Even better (the recommended way):
>
> $::c1.outerframe.frame4.combo configure -modifycmd [list modifCmd
>$::c1.outerframe.frame4.combo]
> proc modifCmd w { puts [$w get] }
**************************

That works. Thanks.

Would you by any chance know how to control the background color of
a ttk::spinbox? Mine looks gray and strange.

I tried setting it to #FFFFFF but that changes the color of the arrows'
background, not the value input box as I expected.

--
Luc
>>

Re: How do I get the selection of a BWidget ComboBox?

<usg03t$1495g$1@tota-refugium.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=13127&group=comp.lang.tcl#13127

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.tota-refugium.de!.POSTED!not-for-mail
From: csaba.ne...@t-online.de (nemethi)
Newsgroups: comp.lang.tcl
Subject: Re: How do I get the selection of a BWidget ComboBox?
Date: Fri, 8 Mar 2024 22:31:41 +0100
Message-ID: <usg03t$1495g$1@tota-refugium.de>
References: <20240307004412.692a552e@lud1.home>
<uscmnp$125s1$1@tota-refugium.de> <20240308171841.09b79f37@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 8 Mar 2024 21:31:41 -0000 (UTC)
Injection-Info: tota-refugium.de;
logging-data="1189040"; mail-complaints-to="abuse@news.tota-refugium.de"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:fd7nwSlRIgCCyHH5c9dPeOycW/g=
Content-Language: en-US
X-User-ID: eJwFwYEBACAEBMCVXnlpHML+I3THbWLvqNGUwwl6l2NBnXK8JCgXPn3B9pVAvto6Kkhq9AcIGBCU
In-Reply-To: <20240308171841.09b79f37@lud1.home>
 by: nemethi - Fri, 8 Mar 2024 21:31 UTC

Am 08.03.24 um 21:18 schrieb Luc:
> On Thu, 7 Mar 2024 16:33:13 +0100, nemethi wrote:
>
>> 3. To solve the problem, you should change the above line to become
>>
>> $::c1.outerframe.frame4.combo configure -modifycmd { puts
>> [$::c1.outerframe.frame4.combo get] }
>>
>> which will work as expected, due to the use of braces instead of
>> quotation marks. Even better (the recommended way):
>>
>> $::c1.outerframe.frame4.combo configure -modifycmd [list modifCmd
>> $::c1.outerframe.frame4.combo]
>> proc modifCmd w { puts [$w get] }
> **************************
>
> That works. Thanks.
>
> Would you by any chance know how to control the background color of
> a ttk::spinbox? Mine looks gray and strange.
>
> I tried setting it to #FFFFFF but that changes the color of the arrows'
> background, not the value input box as I expected.
>

ttk::style map TSpinbox -fieldbackground {readonly white}

--
Csaba Nemethi https://www.nemethi.de mailto:csaba.nemethi@t-online.de

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor