Forum: Ruby-Gnome 2 background color

Ad99e25aa2b714d1017fa2c755aa7a7f?d=identicon&s=25 andru mccracken (andru)
on 2013-12-12 11:29
Hi all,
It's been spoken about four times before, so I apologize for being
dense. Does any one have an example of how to change a window's
background color in visual ruby?
VisualRuby does a good job of being simple and straightforward, so it's
tough to know how to port the perl or python examples, or even the ruby
examples.
Thanks,
Andru
D9ba13de4e62fcabffa4403731434e42?d=identicon&s=25 Eric C. (eric_c65)
on 2013-12-12 20:06
Hi Andru:

Normally, I like setting attributes like background color using glade if
I'm going to keep the same color at all times.  However, I don't see any
setting in glade to set the background.

You can always do this:

def before_show
  blue = Gdk::Color.parse("#CFFCFF")
  @builder["window1"].modify_bg(Gtk::STATE_NORMAL, blue)
end

Best,
Eric
Ad99e25aa2b714d1017fa2c755aa7a7f?d=identicon&s=25 andru mccracken (andru)
on 2013-12-15 01:37
Thanks a lot Eric! Works like a charm. I added it to show()
def show()
  load_glade(__FILE__)
  set_glade_all()
    blue = Gdk::Color.parse("#CFFCFF")
   @builder["window1"].modify_bg(Gtk::STATE_NORMAL, blue)
  show_window()
end
A
D9ba13de4e62fcabffa4403731434e42?d=identicon&s=25 Eric C. (eric_c65)
on 2013-12-15 04:24
No problem Andru.

Actually, since the last upgrade of vr, you can rewrite that method like
so:

def before_show()
   blue = Gdk::Color.parse("#CFFCFF")
   @builder["window1"].modify_bg(Gtk::STATE_NORMAL, blue)
end

There is a now a show() method in GladeGUI, and it calls before_show()
before showing the window on the screen.

The load_glade() and set_glade_all() methods don't need to be used in
most programs since the last upgrade.  The glade form is now
automatically loaded and all the variables are automatically set.

In fact, if you don't need to set the background color, you wouldn't
need any "show" type method at all.  Most times you can just make the
control names the same as your variable names, and do this:

MyClass.new.show

Understand?  I'm sorry I haven't documented it yet, but you can
re-install the examples, and they demo the new format.

Thanks,
Eric
Ad99e25aa2b714d1017fa2c755aa7a7f?d=identicon&s=25 andru mccracken (andru)
on 2013-12-15 09:31
I think I do understand.
Eric, you have created a thing of magic. I still can't believe that I
can use Ruby to create a GUI interface. I know that we are all standing
on the shoulders of giants here, but you have created this last link
that works so well for me.
Thanks,
Andru
D9ba13de4e62fcabffa4403731434e42?d=identicon&s=25 Eric C. (eric_c65)
on 2013-12-15 22:42
Thanks so much.  I wish I could take credit for everything, but like you
said, I'm jut putting together great things that others have created.
Without Ruby language then ruby-gnome then visualruby with the
assistance of the glade people none of it is possible.

Not to mention that I've been totally dependent on the geniuses on this
site for advise.  :)

I'd love to see what you make with it.

Eric
Ad99e25aa2b714d1017fa2c755aa7a7f?d=identicon&s=25 andru mccracken (andru)
on 2013-12-16 02:33
Attachment: test.jpg (60 KB)
Attachment: test.jpg (60 KB)
I used to work at a community television station and built their playout
system (kind of as an after work hobby). Now I am volunteering to finish
it off (so someone else can look after it hopefully!).
I'm using a bunch of pieces like VLC and powerpoint to run the station
in a novel way.
I have an image of an early mockup.
It's kind of like a very long chess game.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.