Archive for the ‘New sample codes’ Category

interactive search in GtkTreeView for PHP GTK v2.0

Saturday, June 28th, 2008

If you have tried the latest PHP-GTK v2.0 or v2.0.1 on the windows platform, you will know that there seems to be some bugs with the interactive search for GtkTreeview. The interactive search works in PHP-GTK2 alpha and beta versions, but not in v2.0 or v2.0.1.

Carl shared with us a brilliant work-around he has found.

Using his method, here are a couple of complete sample codes that show how to set up interactive search in PHP-GTK v2.0 and v2.0.1.

/kksou

http://www.kksou.com/php-gtk2
The place for php-gtk2 sample codes

PHP-GTK v2.0.1 with GD2 library

Saturday, June 28th, 2008

The latest windows binary of PHP-GTK v.2.0.1 from gtk.php.net does not come with the GD2 library.

If you need to set up the php_gd2.dll, please refer to the following article:

PHP-GTK v2.0.1 with GD2 library

/kksou

http://www.kksou.com/php-gtk2
The place for php-gtk2 sample codes

Barcode printing on receipt printer

Wednesday, April 16th, 2008

A receipt printer can not only print receipts. It can print barcodes too!

The following article shows you how to print barcode labels with your receipt printer.

Sample Code 479: How to print barcode label - Part 1 - EAN13 barcodes

You can also find a list of ESC/POS Commands here:
Quick Reference: ESC/POS Commands

/kksou

http://www.kksou.com/php-gtk2
The place for php-gtk2 sample codes

Drag-and-drop complex data structures

Monday, April 14th, 2008

If you’re using drag-and-drop and need to include complex data (or multibyte characters) in your drag data, you’ll find that sometimes using PHP’s serialize() doesn’t work. Here’s a solution:

Non-OOP version:
Sample Code 475: How to drag and drop between 2 GtkTreeViews - Part 7 - another method of passing along complex drag info

OOP version:
Sample Code 476: How to drag and drop between 2 GtkTreeViews - Part 8 - another method of passing along complex drag info - OOP ver 1

Sample Code 477: How to drag and drop between 2 GtkTreeViews - Part 9 - another method of passing along complex drag info - OOP ver 2

/kksou

http://www.kksou.com/php-gtk2
The place for php-gtk2 sample codes

Running GtkHTML scripts without using gconfd-2.exe | php script.php

Monday, April 14th, 2008

If you’re using GtkHTML in your PHP-GTK app, learn this wonderful trick shared by Mario Staas that allows you to run these scripts just like a normal php-gtk script without the need to type gconfd-2.exe | php script.php in the command window.

Sample Code 474: How to display html text using gtkhtml - Part 2

/kksou

http://www.kksou.com/php-gtk2
The place for php-gtk2 sample codes

GtkTooltip for GtkTreeView

Wednesday, March 26th, 2008

I finally have some time to sit down and explore the new PHP-GTK v2.0 release.

The first one I tried was displaying tooltip for treeview with the use of the new widget GtkTooltip. It was a lot of trials and errors, because there was not much documentation. I could get the whole row, or whole column to display the same tooltip. But how do you get each individual cell to display different tooltips?

This article Sample Code 461: How to display tooltips in GtkTreeView - Part 4 is the first of a series of articles to share with you some of the new widgets and methods of the new PHP-GTK v2.0 release.

If you’re still wondering whether to switch over to the new version, try out some of these sample codes. I think you’ll never look back again.

/kksou

http://www.kksou.com/php-gtk2
The place for php-gtk2 sample codes

all 400+ sample codes now PHP-GTK v2.0 compatible!

Wednesday, March 5th, 2008

Took me two whole nights to convert all the 400+ sample codes on this website so that all of them can now be run with the latest PHP-GTK v2.0 release!

This means that you have now 400+ ready-to-run examples for the PHP-GTK v2.0 release - with coverage of more than 95% of all the available GTK widgets.

Of course, all these examples are still backward-compatible with the alpha and beta release of PHP-GTK2, in case you decide to stay with the previous release.

I’ve only tested the sample codes on the windows platform using the latest windows binary. If you have different results on the linux or mac platform, please let me know, ok?

/kksou

http://www.kksou.com/php-gtk2
The place for php-gtk2 sample codes

Direct loading of gd2 image into php-gtk

Thursday, February 28th, 2008

The php-gtk2 beta version now supports direct loading of gd2 image into php-gtk.

$im = imagecreate(360, 200);

$pixbuf = GdkPixbuf::new_from_gd($im);

$img = GtkImage::new_from_Pixbuf($pixbuf);

You can view a full sample code here:
How to draw a simple bar graph using GD2?

/kksou

http://www.kksou.com/php-gtk2
The place for php-gtk2 sample codes

Opening an application at last window position

Wednesday, February 20th, 2008

Fragarach 87 posted a question related to opening an application in the second monitor.

After some trials and errors, I came up with a sample code that allows you to open an application at the last window position:

Sample Code 438: How to open an application at last window position - works with multiple monitors?

The above works with multiple monitors too!

/kksou

http://www.kksou.com/php-gtk2
The place for php-gtk2 sample codes

GtkAction and GtkActionGroup

Wednesday, February 20th, 2008

If you have been wondering what’s GtkAction and GtkActionGroup — what are they? what’s their use? — then take a look at some of the sample codes below:

Sample Code 432: How to setup and process a GtkButton using GtkAction - Part 1?

Sample Code 433: How to setup and process a GtkButton using GtkAction - Part 2 - add stock image?

Sample Code 434: How to activate deactivate a bunch of GtkButtons using GtkAction and GtkActionGroup?

Sample Code 435: How to hide unhide a bunch of GtkLabels using GtkAction and GtkActionGroup?

Sample Code 436: How to set up toolbar using GtkAction - Part 1?

Sample Code 437: How to set up toolbar using GtkAction - Part 2 - add accelerators?

If you’re developing serious applications using PHP-GTK2, take a look at these examples. You will soon find that this is a useful widget that has been so little documented, but extremely useful in some occasions.

I’ve only finished half of these sample codes. There are many more to come. You will see true powers of GtkAction and GtkActionGroup when it comes to managing menu items and toolbar items concurrently. It allows you to maintain consistencies across menu items and toolbar items very efficiently as you shall soon see.

/kksou

http://www.kksou.com/php-gtk2
The place for php-gtk2 sample codes