PHP-GTK2 Newsletter

PHP-GTK2 Tips & Techniques
FREE Newsletter
by kksou



Sample Code 114: How to set the background color of GtkEntry?
Written by kksou   
Sunday, 10 December 2006
Problem

You want to change the background color, set the font and also the font color of a GtkEntry as shown below:

How to set the background color of GtkEntry?


Solution

Sample Code
1   
2   
3   
4   
5   
6   
7   
8   
9   
10   
11   
12   
13   
14   
15   
16   
17   
18   
<?php
$window = new GtkWindow();
$window->set_size_request(400, 200);
$window->connect_simple('destroy', array('Gtk','main_quit'));
$window->add($vbox = new GtkVBox());

// display title
$title = new GtkLabel("Change the background color and\nset the font and color of GtkEntry");
$title->modify_font(new PangoFontDescription("Times New Roman Italic 10"));
$title->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#0000ff"));
$title->set_size_request(-1, 40);
$vbox->pack_start($title, 0, 0);

$entry = new GtkEntry;
$entry->modify_base(Gtk::STATE_NORMAL, GdkColor::parse('#ffff00')); // note 1
$entry->modify_text(Gtk::STATE_NORMAL, GdkColor::parse('#0000ff')); // note 2
$entry->modify_font(new PangoFontDescription("Arial Black 12")); // note 3

  • Note that this is only 70% of the sample code. You have to be a registered member to see the entire sample code. Please login or register.
  • Registration is free and immediate.
  • Have some doubt about the registration? Please read this forum article.
Explanation
  1. Set the background color of the GtkEntry.
  2. Set the font color of the GtkEntry.
  3. Set the font of the GtkEntry.

Related Links

User reviews

There are no user reviews yet.

Note: You have to be a registered member to leave a comment. Free registration here.

 
< Prev   Next >

Copyright © 2006-2008. kksou.com. All Rights Reserved