5

How to Use Tk to Make GUI Applications with PHP

 3 years ago
source link: https://www.devdungeon.com/content/how-use-tk-make-gui-applications-php
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to Use Tk to Make GUI Applications with PHP

Submitted by NanoDano on Mon, 07/27/2015 - 20:53

PHP/TK implements object oriented bindings for TCL/TK that can be used to create GUI applications. It only works on Unix systems. PHP must be configured to allow dynamic linking with enable_dl = On in the php.ini. The shared object file (tk.so) can be downloaded manually from PECL. The shared object file goes inside your php modules folder which is typically something like /usr/lib/php/modules. Look for the folder with other .so files or refer to your particular distribution documentation. The binary file that comes with the download is a 32-bit ELF so if you want the 64-bit version you have to compile it yourself.

It is not very well supported and can be a big hassle to get up and running on certain distributions. I don't recommend using Tk with PHP, but you can do it. For more information, refer to the official documentation.

#!/usr/local/bin/php -q
<?php
dl('tk.so');
$root = new Tk();
$root->wmTitle('"Hello World"');
$label = new Label($root, '-text "Hello, world!"');
$label->pack('-side left', '-padx 15', '-pady 15');
Tk_MainLoop();

Advertisement


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK