Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Oct 2003
Posts: 7
L
Junior Member
OP Offline
Junior Member
L
Joined: Oct 2003
Posts: 7
Anyone play with this at all?

http://gtk.php.net

Prety cool stuff. Of course it works for Linux as well but I like using it in windows. What you can do with little effort is so cool. I am just getting started so I am looking for anyone who might have some tips.

Joined: Mar 2002
Posts: 1,041
I
UGN Elite Poster
Offline
UGN Elite Poster
I
Joined: Mar 2002
Posts: 1,041
I do Gtk-perl. Much fun, and not that hard. Unfortunately, there is no windows port yet, but I don't really want to program windows anyways :p

Infinite

Joined: Oct 2003
Posts: 7
L
Junior Member
OP Offline
Junior Member
L
Joined: Oct 2003
Posts: 7
Okay so I am starting on this. This is my first thing. I modified the sample hello.php code that came with the zip file.

php-gtk-0.5.2a-win32.zip

Code
 
<?php
/* $Id: hello.php,v 1.6 2002/11/25 18:22:05 fmk Exp $ */


if (!class_exists('gtk')) {
	if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
		dl('php_gtk.dll');
	else
		dl('php_gtk.so');
}


function delete_event()
{
	return false;
}



function destroy()
{
	Gtk::main_quit();
}



function buttons()
{
	global	$window;
	print 'Closing window\n';
	$window->destroy();
}



$window = &new GtkWindow();
$window->connect('destroy', 'destroy');
$window->connect('delete-event', 'delete_event');
$window->set_border_width(10);




$button = &new GtkButton('Close');
$button->connect('clicked', 'buttons');
$window->add($button);




$tt = &new GtkTooltips();
$tt->set_delay(200);
$tt->set_tip($button, 'Closes out this Window', '');
$tt->enable();




/*realize the underlying GdkWindow, flag the GtkWindow's visibility and map
  it onto the screen, all in one simple line*/

$window->show_all();




/*without the main loop, there is no PHP-GTK script*/



Gtk::main();


?>

 
I can get it up and running and it dose what I want it to but I have trouble adding widgets to it. The whole adding a child widget to the parrent is screwing me up or maybe my syntax is [censored]. Can anyone breake this down for me in forest gump terms? I know a widget is basicaly equal to an object in other languages. I am talking the child parent relationship

Why some widgets can only have one child and others unlimited.

Joined: Dec 2002
Posts: 3,255
Likes: 3
UGN Elite
Offline
UGN Elite
Joined: Dec 2002
Posts: 3,255
Likes: 3
Okay I am catching on. In order to set a widget inside another you have to specify using something like

$window->add($vbox);

This puts a verticle box inside the window. A sort of likeness to tables in HTML Here is what I have so far.

Quote:
For all those geeks who might still be wondering what is happening. Just do this... Unzip the zip package into the c:\ directory - that will do. And then start rolling. Check whether it is working by going into c:\php4 and typing this php c:\test\gtk.php

Joined: Oct 2003
Posts: 7
L
Junior Member
OP Offline
Junior Member
L
Joined: Oct 2003
Posts: 7
Okay moving along. My little learning script can connect to a database. I want to place an image in this puppy. A red sphear if it can not connect and a blue one if it can. To do this I need to use the Gdk widget GtkPixmap

Now here is what I have found so far on this

http://gtk.php.net/manual/en/gtk.gtkpixmap.php

Quote:

pixmap_create_from_xpm can not load c:\path\to\image\my_image.png
So duh, It is looking for an image with an xmp extension right? How the hell do I create on. I have photoshop, paint(of course), Flash, and paintshop pro. None of which will creat a xmp extension. Or I can create it but it is not truely creating this extension file type. Any help?

My code so far is shown below. It will now connect to a MySQL database and extrat data to dissplay in the GUI. I will get to making that more dynamic later.
Code
  
<?php
/* $Id: hello.php,v 1.6 2002/11/25 18:22:05 fmk Exp $ */
//
//
if (!class_exists('gtk')) {
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
dl('php_gtk.dll');
else
dl('php_gtk.so');
}
//
function delete_event(){
return false;
}
//
function destroy(){
Gtk::main_quit();
}
//
function buttons(){
global $window;
gdk::beep();
$window->destroy();
}
//
$window = &new GtkWindow();
$window->connect('destroy', 'destroy');
$window->connect('delete-event', 'delete_event');
$window->set_border_width(10);
$window->show();
//
$Hbox_start = &new GtkHBox(false, 5); 
$window->add($Hbox_start);
//
$vbox = &new GtkVBox(false, 5);
$Hbox_start->add($vbox);
//
//
//
$frame = &new GtkFrame("Close section");
$frame->set_label("Click to exit"); 
$frame->set_label_align(0.0, 0.5); 
$frame->set_shadow_type(GTK_SHADOW_ETCHED_IN);
$frame->show();
$vbox->pack_start($frame, true, true, 5);
//
//
$hbox1 = &new GtkHBox(false, 5);
//
//
$label = &new GtkLabel();
	$label->set_text("To close this window all you have \n
to do is click on the button below. \n
But be warned!! I can not be held \n
responsible for what else it might do.");
	$label->set_justify(GTK_JUSTIFY_LEFT);
$frame->add($label);
	$label->show();
//
//
$hbox2 = &new GtkHBox(false, 5);
$vbox->add($hbox2);
//
//
$button = &new GtkButton('Close');
$button->connect('clicked', 'buttons');
$button->show();
$hbox2->pack_start($button, true, true, 5);
//
//
//
$tt = &new GtkTooltips();
$tt->set_delay(200);
$tt->set_tip($button, 'Closes out this Window', '');
$tt->enable();
//
$vbox_section2 = &new GtkVBox(false, 5);
$Hbox_start->add($vbox_section2);
//
$frame2 = &new GtkFrame("Close section");
	$frame2->set_label("Database connection"); 
	$frame2->set_label_align(0.0, 0.5); 
	$frame2->set_shadow_type(GTK_SHADOW_ETCHED_IN);
	$frame2->show();
	$vbox_section2->pack_start($frame2, true, true, 5);
//
//
$db_conn = mysql_connect ("address to server", Login, password);
mysql_select_db(Login, $db_conn);
	$name = mysql_query("SELECT * FROM Userinfo Where id = '1'"); 
		while($name2 = mysql_fetch_array($name)) {
   			$handle = "".$name2['First']." ".$name2['Last']."";
		}
//
if ($db_conn){
$label2 = &new GtkLabel();
	$label2->set_text("Hello $handle, \n   
If you are reading this \n
then you are connected \n
to the database.");
	$label2->set_justify(GTK_JUSTIFY_LEFT);
$frame2->add($label2);
	$label2->show();
	
		}else{
		
$label2 = &new GtkLabel();
	$label2->set_text("mySQL Error: ".mysql_error());
	$label2->set_justify(GTK_JUSTIFY_LEFT);
$frame2->add($label2);
	$label2->show();
	}	
//	
/*realize the underlying GdkWindow, flag the GtkWindow's visibility and map
it onto the screen, all in one simple line*/
//
$window->show_all();
//
/*without the main loop, there is no PHP-GTK script*/
//
Gtk::main();
?>


Link Copied to Clipboard
Member Spotlight
Posts: 43
Joined: November 2002
Forum Statistics
Forums41
Topics33,840
Posts68,858
Average Daily Posts1
Members2,176
Most Online3,253
Jan 13th, 2020
Latest Postings
Where and how do you torrent?
by danni75 - 03/01/24 05:58 AM
Animation,
by JohanKaariainen - 08/15/19 01:18 AM
Blackbeard.....
by Gremelin - 10/03/18 07:02 PM
my old account still exists!
by Crime - 08/10/18 02:47 PM
Okay WTF?
by HenryMiring - 09/27/17 01:45 AM
The History Thread...
by Gremelin - 08/11/17 12:11 PM
My friend NEEDS your HELP!
by Lena01 - 07/21/17 12:06 AM
I'm having fun with this guy.
by gabithompson730 - 07/20/17 01:50 AM
I want to upgrade my phone
by gabithompson730 - 07/20/17 01:49 AM
Doom 3
by Cyrez - 09/11/14 08:58 PM
Amazon Gift Card Generator/KeyGen?te
by Gecko666 - 08/22/14 09:21 AM
AIM scene 99-03
by lavos - 09/02/13 08:06 AM
Planetside 2
by Crime - 03/04/13 07:10 AM
Beta Testers Wanted
by Crime - 03/04/13 06:55 AM
Hello Everyone
by Gremelin - 02/12/12 06:01 PM
Tracfone ESN Generator
by Zanvin Green - 01/18/12 01:31 PM
Python 3 issue
by Testing - 12/17/11 09:28 PM
tracfone airtime
by Drache86 - 07/30/11 03:37 AM
Backdoors and the Infinite
by ZeroCoolStar - 07/10/11 03:52 AM
HackThisZIne #12 Releaseed!
by Pipat2 - 04/28/11 09:20 PM
gang wars? l33t-wars?
by Gremelin - 04/28/11 05:56 AM
Consolidate Forums
by diggin2deep - 04/21/11 10:02 AM
LAN Hacking Noob
by Gremelin - 03/12/11 12:42 AM
Top Posters
UGN Security 41,392
Gremelin 7,203
§intå× 3,255
SilentRage 1,273
Ice 1,146
pergesu 1,136
Infinite 1,041
jonconley 955
Girlie 908
unreal 860
Top Likes Received
Ghost 2
unreal 1
Crime 1
Ice 1
Dartur 1
Powered by UBB.threads™ PHP Forum Software 7.7.5