PHP-GTK Tutorial: Creating menus in PHP-GTK using GTK+

This article is brought to you by Ben Stones, guest editor for DPS Computing Ltd.

What is PHP-GTK?

First and foremost, what is GTK+? GTK (short for GIMP Tool Kit) is an extensive library of methods for creating cross-platform graphical user interfaces using the GTK+ library with a language of your choice. There are extensive language bindings to GTK+ – from Python, to C++, C# and much more – including PHP-GTK.

PHP-GTK is not as widely used as one would hope, but there is a community of PHP-GTK developers and the #php-gtk channel in Freenode is a good place to get help on matters concerning PHP-GTK – although sometimes you may be waiting a short while for a response – but the channel is active daily.

So with the ease and use and flexibility of the PHP programming language – one would wish it could be used to create desktop applications. And of course, with PHP-GTK, this is possible using the GTK+ library. Installing PHP-GTK is not as easy as it could be; although for Windows users, you’re in luck – there are pre-compiled binaries for you to download and use without requiring any complicated installation procedures. However, for installing on Linux distributions, it is fairly easy. If you Google “How to install PHP-GTK on Ubuntu” you’ll find a post on another forum with instructions on how to install PHP-GTK on Linux distributions, including Ubuntu.

How do I create menus in PHP-GTK?

Creating menus are not as simple as you would first imagine. But once you understand how the methods work, it will make sense. Essentially, the GtkMenuItem is not just for menu items within a menu option. They are also used to create a top-level menu item, too. Let’s take a look at some sample PHP-GTK code.

// add menu bar

public function addMenu()
/* create the menu */
$file = new GtkMenuItem(“File”);
$help = new GtkMenuItem(“Help”);

// create the menubar
$menubar = new GtkMenuBar();

// append the menu options
$menu = new GtkMenu();

$menu2 = new GtkMenu();

$open = new GtkMenuItem(“Open”);
$this->menuSaveItem = new GtkMenuItem(“Save As…”);
$quit = new GtkMenuItem(“Quit”);

$about = new GtkMenuItem(“About”);

// connect the signals







Original publication – August 2012.

Disclaimer: DPS Computing Ltd., its employees and the author of this article disclaims all liability with respect to the accuracy, reliability and security of any application code and routines that are provided in this article, as well as in respect to the accuracy and reliability of the article itself. We cannot guarantee that the application code in this article will work as expected or not cause any damage to your operating system, any software or not cause loss of, or damage to, data. Your use of the application code and routines provided in this article is at your sole risk and responsibility.

Sky+ Box – No Signal / Won’t Switch On Fix & *KEEP* your existing recordings

SkyMany of us have Sky+ boxes of all different varieties – old ones, new ones, white ones, black ones, Amstrad, Thompson, HD, wireless etc etc.  The majority of us will also have had problems with our Sky box from time to time – I don’t think I’ve met anyone yet who has had Sky for a year or more who hasn’t had any problems.

Of course you can ring Sky – or nowadays, do a LiveChat online, but this can be a frustrating experience to say the least.

One of the most frustrating problems has to be when your Sky box won’t power up (switch on) properly, it becomes unresponsive or you get a constant ‘no signal’ message – even though there is actually a signal.

But fear not – don’t be reaching for your wallet to pay £249 for a new Sky box just quite yet – 99% of the time following the simple steps below will resolve your problem.


The symptoms of this kind of problem are usually:

  • Constant ‘No Signal’ message – even though you are sure there is a signal.
  • Box won’t switch on or freezes during power up
  • Box light stays on red or amber and doesn’t switch to green in response to pressing buttons (like ‘Sky’) on the remote or the box.
  • Box is on and/or powers up but it is totally unresponsive to both the remote control and the buttons located on the Sky box itself.

How to Fix (in relatively easy and definitely cheaper steps!)

First up, it’s the old favourite – unless you’ve already tried it, in which case feel free to move on.

Switch it off (at the plug, don’t place it in standby), leave it 30 seconds and switch it back on – see if the problem is resolved.  I know you’ve probably already tried this but it’s always worth mentioning just in case!

Now, I’ll presume most of you are here because that hasn’t worked – read on.

Note: Sky probably would be able to help you fix this after a possibly long, expensive and painful telephone call – but, based on reports I’ve heard, they suggest a solution that will delete all your recordings and clear your planner (i.e. any scheduled recordings) – whilst you may have to ultimately do this, don’t try this as the first option – it’s probably unnecessary!

Unfortunately, we’re going to have to turn the box off again if you already have – we need it to have a cold start.  Unplug your box from the wall (or take the power lead out of the back of the Sky box – whichever is easier for you).

Give it a minute – make a brew, feed the dog etc.

Plug the lead/socket back into the power and, whilst doing this, ensure you are holding down the ‘Backup’ button on the Sky box itself (not on the remote control – that won’t work).

Keep holding.  After a little bit of time you’ll notice that the lights on your Sky box come on.  After this you’re free to take your finger off the button.

Now leave your Sky box alone for a bit.  Depending on various factors this could be 5, 10, 15 or 20 minutes.  You’ll know when it’s done because the lights should go out on the box and eventually rest on the ‘Amber’ standby light that you normally see when you’re Sky box is plugged in but not switched on.

Press ‘Sky’ on your remote.

Hopefully, by this stage, you’re Sky box problem is well on the way to being fixed.  The light on the front of your Sky box should go green and you should see a message on screen – something like ‘Searching for Listings’.  Don’t worry, this is totally normal – we’ve performed what is known as a ‘soft’ reset – simply put, it’s reset the Sky box software but importantly it has retained your personal data – i.e. your planner and recordings!

After a couple more minutes a channel should appear on screen (probably the Sky Demo channel) and you are once again free to enjoy the wonderful delights of Sky.  Not only are you £249 better off but you’re also less stressed and have used less time than contacting Sky or buying a new box!

It Didn’t Work…

I’m sorry to hear that.  Unfortunately, at this stage, the next step would be to try – as Sky suggest – a ‘hard’ reset.  This will not only reset the software but it’ll also delete your recordings and planner.  This problem can usually be fixed using the method above but unfortunately, in a small number of cases, it’s gone past being fixed by a ‘soft’ reset.

Stop Windows 10 Spying On You


SSLConcerned about your privacy?  Fed up of paying a fortune for a computer that then spies on your shopping habits (after all, you don’t even let your husband know how many pairs of shoes you’ve bought this weekend, so why the hell should Microsoft get to find out?!).

Sorry, that sounded like the start of a corny ad, but stick with me, you’ll be glad you did.

Now lots of people have taken the plunge and got the upgrade to Windows 10 – particularly as it was provided for free (thanks Microsoft!).  But in the post-Snowden leak era, people are understandably getting a bit more picky about who they share their data with and where over the wondrous Internet it is transported to – particularly as data protection laws outside the EU aren’t necessarily as strict as we’re accustomed to.  And Windows 10 likes data – your data to be specific.

Now, don’t get me wrong, Windows 10 isn’t suddenly going to publish your files on PasteBin – but it probably is, as you’re reading, collecting information about your computer (and therefore you) to “make Windows better” and to offer targeted advertising.

If, like me, you go by the premise that you already do enough to “make Windows better” and that if you wanted to purchase something you’d Google it rather than wait for an advert to pop up feel free to read on – you no longer have to share your personal information with Microsoft.

Now the default options, which many people stick with, while installing Windows 10 are not privacy orientated.  There more “share you info so we can provide some cool features” orientated.  Cool features are nice, an over familiar friend (read stalker) not so nice – I’m looking at you Cortana!

Thankfully, there’s no need to wade through 3,000 menus in control panel and try to decrypt Microsoft techno-babble. There’s a fantastic tool by Safer Networking, the creates of the acclaimed Spybot – Search and Destroy software.

Spybot Anti-Beacon provides a light-weight, easy to understand, simple interface that helps you share only what you want to share – in most cases, that’s probably nothing.  Don’t worry, even if you block everything Windows 10 will still full work – you may just notice things like Cortana doesn’t seem as creepy by knowing your office extension or when you’re going to be home from work.

For most people, on the ‘Protection’ tab, you’ll just want to Immunize all.  You can take a look at the ‘Optional’ tab as well if you like but read the caveats to deactivating each one and things that it may affect.

After you’ve immunised all you should see:


And then you’re all set – no more Windows 10 spying!

Web DynPro ABAP – Context Menu Not Showing?

For the developers and programmers among us adding a context menu to an application is a fairly basic requirement of many pieces of software.  Adding a context menu in Web DynPro looks on the face of it to be an extremely easy process – and it is, as long as you don’t forget anything ;).

Although there are a fair few guides on the Internet that explain how to add a context menu in Web DynPro they all seem to miss out one important detail, which without knowing it, means that your context menu fails to appear at all and can make the process extremely stressful.

That’s why I’m sharing this top tip with you today.  Firstly, follow one of the many guides available such as this one.  And while using this or another guide don’t forget our…..

Context Menu Top Tip

Firstly, note that whether you are implementing a dynamic or a static context menu in your application this tip applies to both.

In newer versions of the SAP GUI, according to reports at least from version 7.00 – maybe even earlier, there is a new option to add a context menu to most User Interface elements in the properties tap (i.e. this no longer has to be done programmatically).

However, most, if not all guides seem to have missed out the fact that as well as setting the context menu you want to use in the properties menu you also have to change the ‘ContextMenuBehaviour‘ property to ‘Provide’ rather than the default setting of ‘Inherit’.

As the name suggest, if you leave this on ‘Inherit’ you will be left puzzled by the fact that no matter what you do, you context menu simply won’t appear – only the default one will.

When this property is pointed out, it becomes fairly obvious – however it can be frustrating until you figure it out and waste time!


The conclusion to all this is that it is frustrating but understandable.  Technically however, I think that the SAP GUI could help you out by ‘defaulting’ the ContextMenuBehaviour property to Provide when you actually pick a context menu in the properties.

However, until that happens, every time you set the context menu on a UI element, don’t forget to set the ContextMenuBehaviour property as well!

Image: mynetx.

How To Print Screen Directly To A File (Windows)

Mac lovers around the world have grown used to the handy functionality that is being able to print screen directly to a file.  In Windows, rather than pressing a key combination to save the screen directly to a file, you instead have to use the ‘Print Screen‘ key (which copies the screen to the clipboard) and then open a image editing program, paste it in and save it.

Time consuming if you are doing a lot, and quite frankly, a complete pain!!

However, Microsoft have cottoned on to this, and although not necessarily a perfect implementation when compared to the OS X way of doing it, it’s definitely an improvement.

Firstly, the bad news, if you’re on Windows 7 or lower this ain’t going to work for you.  Microsoft could in theory release a hotfix for it for Windows 7 but it’s probably not that high on their to do list.

Good news – if you’re on Windows 8 its all good!

How To Screenshot to a File

First thing to note is that the screenshot to a file on Windows is going to send it to your pictures folder (that’s the one in your user folder, next to (ish) documents).  Not as convenient as the good old desktop implementation in OS X but livable!

Second thing to note – you can still just use the print screen (Prt Scr) key to print the screen to the clipboard, the same as usual – no change there.

But now for the awesomeness……

Using the key combination ‘ALT-PRT SCR‘ – thats the alt and print screen keys pressed together – will do the same as print screen but also save it in a file in your pictures folder.

It’s good to note at this point that ALT-PRT SCR also still copies it to your clipboard as well (no need to open the file and copy it manually).

And there you have it, another good OS X feature now making an appearance in Windows!

Image: solylunafamilia.