Ruby Tk::Tile button not displaying colors

I have some ruby tk code that uses the new Tile styles.

I see no difference at all, when I do this over just a regular button.
Can someone point to what might be the problem?

Here is the code:

I defined the new style Normal.TButton:

Tk::Tile::Style.configure(‘Normal.TButton’, { “background” => ‘blue’,
“foreground” => ‘white’, “padding” => 5})

Now I use it (notice the style ‘Normal.TButton’:

Tk::Tile::Button.new(content) {text lbl; command proc{docommand("%s" %
[k]); style ‘Normal.TButton’} }.grid( :column => 1, :row => (row +=
1),
:sticky => ‘w’)

But the button shows up as if I had not define/used the style.

If it makes a difference: I am running the code on a raspberry pi.And I
have ssh’d from OSX (Yosemite)

If you would like to see the entire code, I can post that. But I wanted
to
show the two lines that are pertinent to the discussion.

Thankyou in advance.
Jerry


Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Arduino developer

The most exciting phrase to hear in science - the one that heralds new
discoveries - is not “Eureka!” but “That’s funny…”.
- Isaac. Asimov

I
*f you give someone a program, you will frustrate them for a day; if you
teach them how to program, you will frustrate them for a lifetime. *-
Anonymous

If writing good code requires very little comments, then writing really
excellent code requires no comments at all!
- Ken Thompson

Hi Jerry D.,

It correctly changed the ‘style’ of the button with this “adapted”
code (just to make your code show up).
So, I don’t see any problem with the fragment of code you showed.

Abinoam Jr.


require ‘tk’
require ‘tkextlib/tile’

Fake values to test the lines bellow

row = 1
lbl = “fake lbl”
k = ‘text “Executed command”’

def docommand(command)
eval command
end

root = TkRoot.new { title “Jerry D.” }
content = Tk::Tile::Frame.new(root) { padding “3 3 12 12” }.grid(
:sticky => ‘nsew’)

Tk::Tile::Style.configure(‘Normal.TButton’, { “background” => ‘blue’,
“foreground” => ‘white’, “padding” => 5})
Tk::Tile::Button.new(content) {text lbl; command proc{docommand("%s" %
[k]); style ‘Normal.TButton’} }.grid( :column => 1, :row => (row +=
1), :sticky => ‘w’)

Tk.mainloop


rvm 1.26.7 (master)

Ruby build with
“rvm reinstall ruby-2.1.5 --enable-shared --enable-pthread --with-tk
–with-tcl”

Mac OS X 10.9.4

Tk::TK_PATCHLEVEL # => “8.5.9”
Tk::Tile::TILE_SPEC_VERSION_ID # => 8

I see what is happening now. The button doesn’t become background blue
and
foreground white, does not actually take effect until the button is
clicked.

What do you do to set the colors in the NORMAL (not clicked or hovered
over)? I am a newbie as far as tk goes, and am trying to understand.

Jerry

On Fri, Jan 2, 2015 at 6:56 PM, Abinoam Jr. [email protected] wrote:

require ‘tk’

Mac OS X 10.9.4

Can someone point to what might be the problem?
Tk::Tile::Button.new(content) {text lbl; command proc{docommand(“%s” %

Extra Ham Operator: K7AZJ

If writing good code requires very little comments, then writing really
excellent code requires no comments at all!

  • Ken Thompson


Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Arduino developer

The most exciting phrase to hear in science - the one that heralds new
discoveries - is not “Eureka!” but “That’s funny…”.
- Isaac. Asimov

I
*f you give someone a program, you will frustrate them for a day; if you
teach them how to program, you will frustrate them for a lifetime. *-
Anonymous

If writing good code requires very little comments, then writing really
excellent code requires no comments at all!
- Ken Thompson

From: Jerry D. [email protected]
Subject: Re: Ruby Tk::Tile button not displaying colors
Date: Fri, 2 Jan 2015 22:04:38 -0700
Message-ID:
CAMyDR6LoSuz78-+26b=Nz2PhHf9BY2vT94S1JUKCROUYVvk=removed_email_address@domain.invalid

I see what is happening now. The button doesn’t become background blue and
foreground white, does not actually take effect until the button is clicked.

What do you do to set the colors in the NORMAL (not clicked or hovered
over)? I am a newbie as far as tk goes, and am trying to understand.

The script sets TButton’s style in the callback.
Please compare the followings.

Tk::Tile::Button.new(content) {
text lbl
command proc{docommand(“%s” %[k]); style ‘Normal.TButton’}
}.grid( :column => 1, :row => (row += 1), :sticky => ‘w’)

On Sat, Jan 3, 2015 at 6:20 AM, Hidetoshi NAGAI [email protected]
wrote:

Tk::Tile::Button.new(content) {
text lbl
command proc{docommand(“%s” %[k])}
style ‘Normal.TButton’
}.grid( :column => 1, :row => (row += 1), :sticky => ‘w’)

thanks. that was a subtlety that I missed.
that helps a lot, and worked the way I wanted.


Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Arduino developer

The most exciting phrase to hear in science - the one that heralds new
discoveries - is not “Eureka!” but “That’s funny…”.
- Isaac. Asimov

I
*f you give someone a program, you will frustrate them for a day; if you
teach them how to program, you will frustrate them for a lifetime. *-
Anonymous

If writing good code requires very little comments, then writing really
excellent code requires no comments at all!
- Ken Thompson

so, just one more question then before this topic ends.

how do I set the style back to Normal in the callback?
(assuming I set say $b to the button I created?

after the eval statement, I put::
$b.configure(:style => ‘Normal.TButton’)

which gave no errors but didn’t do anything either.

thanks

On Sat, Jan 3, 2015 at 8:38 AM, Jerry D. [email protected] wrote:

If writing good code requires very little comments, then writing really
excellent code requires no comments at all!
- Ken Thompson


Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Arduino developer

The most exciting phrase to hear in science - the one that heralds new
discoveries - is not “Eureka!” but “That’s funny…”.
- Isaac. Asimov

I
*f you give someone a program, you will frustrate them for a day; if you
teach them how to program, you will frustrate them for a lifetime. *-
Anonymous

If writing good code requires very little comments, then writing really
excellent code requires no comments at all!
- Ken Thompson