Java: Native GTK+ GUIs on Gnome using Java-Gnome
In this post we’ll see how to create a simple text editor for Linux systems using Java and GTK+.
First of all we will need to have a Linux system with:
- JRE and JDK
- GTK (if you are using a Gnome-based distro like Ubuntu it’s already there)
- Gnome-Java GTK+ bindings for Java
If you are using Ubuntu Karmic you can install these with:
sudo apt-get install libjava-gnome-java libjava-gnome-jni libjava-gnome-java-doc
Otherwise you can grab the bindings from here and follow these instructions for manual installation. - Glade Interface Designer (It must be available through your distribution’s package management tool)
- Your favorite Java editor/IDE – I’ll be using Netbeans (if you don’t, make sure you have a grasp of how the classpath works).
Διορθώστε το χρώμα της tab bar στον Chromium
Ο Chromium (όπως και ο Chrome) σε πολλές περιπτώσεις δεν χρησιμοποιούν το κατάλληλο χρώμα ώστε η tab bar να μοιάζει ως συνέχεια του πλαισίου του παραθύρου (όταν βέβαια έχουμε επιλέξει να γίνεται χρήση του GTK theme και των πλαισίων παραθύρων του συστήματος).
Για να το διορθώσουμε αυτό, πρέπει να επέμβουμε στο αρχείο .gtkrc του θέματος που χρησιμοποιούμε.
A simple weather program in Python
The following program fetches an XML file from http://weather.yahooapis.com and displays the current weather information the file contains.
I wrote this program in order to use it in combination with conky. The result looks like this:
Basic HTTP Authentication in Python using API keys
Python’s standard library provides a great and simple way – via PasswordMgr and HTTPBasicAuthHandler – to provide credentials used for basic HTTP authentication, but (at least as far as I know) it can be used only for username-password pairs.
The problem is that sometimes – for example if you want to retrieve an xml file from gnome-look.org – you want to use an API key for authentication. To achieve that all we have to do is encode the API key with the Base64 algorith and then send it along with our HTTP request included in a basic authentication header (Note: For some reason the encoded string that I got using Python’s Base64 implementation included a line break that messed things up, so it might be wise to encode the API key by hand and then insert it to your code):
def download_file(url, API_KEY_BASE_64): req = urllib2.Request(url) req.add_header("Authorization", "Basic "+API_KEY_BASE_64) return urllib2.urlopen(req)
Of course you will have to import urllib2 (urllib in Python3).





2 σχόλια