KhtSimple is now availble on Ovi Store

Thursday 26 April 2012 / MeeGo, Maemo, Python, KhtSimpleText, editor, Nokia n9

KhtSimpleText 0.3.1

A new release of KhtSimpleText is available in apps4MeeGo. For those who don't know what is it, it s a simple text editor for harmattan specially designed for n9 and n950 device. Currently still in development, the version implement the following features :

  • Browse in the local file system
  • Open / Edit / Save a text file
  • Delete / Rename file

I've also planned to implement other features :

  • Markdown Preview
  • Copy / Move file
  • Preferences for changing font
  • Auto save feature

Some screenshots of an older version :

KhtSimpleText Screenshot 1 KhtSimpleText Screenshot 2 KhtSimpleText Screenshot 3

Of course for more informations (source, bugtracker, ...) : KhtSimpleText

Thursday 22 March 2012 / python, qt, qml, pyside, text, editor, harmattan

Python Apps in QtSimulator on Crunchbang Statler

Dependancies

  • Install QtSDK from qt.nokia.com
  • Install dependancies for PySide
sudo apt-get install cmake build-essential libxml2 libxslt libqt4-dev python-dev git

Prepare Build

So we will use the automated build script, easier :)

git clone https://github.com/PySide/BuildScripts
cd BuildScripts
git submodule init
git submodule update

Apply some patch for building with QtSimulator

  • Apply this patch if still not merged in master: https://github.com/PySide/PySide/pull/108/files
  • Modify the environement.sh in the BuildScripts folder
QT_SDK_HOME="$HOME/QtSDK/Simulator/Qt/gcc"
Q_WS_SIMULATOR="yes"

Build

./build_and_install

Run your apps

#!/bin/bash
set -e

if [ $# -eq 0 ]; then
    echo "Usage: $0 <arguments...>" >&2
    exit 1
fi

base=$(dirname $0)
qt_sdk_dir=$HOME/QtSDK

export LD_LIBRARY_PATH=$base/lib:$qt_sdk_dir/Simulator/Qt/gcc/lib:$LD_LIBRARY_PATH
export PYTHONPATH=$base/lib/python2.6:$PYTHONPATH

python2.6 "$@"

Screenshot

Here is a screenshot of KhtSimpleText which run in the simulator. KhtSimpleText

Monday 05 March 2012 / python, qt, simulator, pyside

Display a Conboy note on your desktop

Update : Due to some question on this little script i update it a bit to works with a recent release of Desktop Commands Execution Widget which execute the scripts now as root, so note wasn't read from user, but root. I also notice that i forgot to report this little script to my new website (Thx to @sphaxx22 (Yves S.)).

Original :

Today while i got the idea to made a plugin to display the content of a Conboy Note on my n900 desktop. I finnally choose the option to use Desktop Commands Execution Widget to display the note content by using the following commands :

python /home/user/conboy_note_to_text.py print noteid

I choose to use noteid instead of text title, as noteid didn't change and also because i didn't maintain an index of all notes, so it s faster.

To list all notes with their title and id in xterm, just use the following commands :

python /home/user/conboy_note_to_text.py list

A screenshot example to see it in action : Conboy note on Maemo desktop And how it look like in conboy : Conboy on Maemo

And of course save the following code to /home/user/

#!/usr/lib/python2.5
#CopyLeft 2010-2012 Benoit HERVIER <khertan@khertan.net>

from xml.dom import minidom
import os.path
import glob
import sys
import re
from xml.sax.handler import ContentHandler
import xml.sax

class NoteList:
   def __init__(self,path):
       self.path = path
       self.noteList = {}
       for infile in glob.glob( os.path.join(self.path, '*.note') ):
         note = Reader(os.path.basename(infile)[:-5])
         if note.title != None:
             self.noteList[note.title]=note.note_id

   def get_note_id_by_title(self,title):
       try:
           return self.noteList[title]
       except:
           return None

class textHandler(ContentHandler):
   def __init__(self):
     ContentHandler.__init__(self)
     self.content = ""
     self.title = ""
     self.selector = None

   def startElement(self, element,attributes):
       if (element == 'note-content') and (self.selector == None):
           self.selector = element
       elif (element == 'title') and (self.selector == None):
           self.selector = element


   def endElement(self, element):
       if (element == self.selector):
           self.selector = None

   def characters(self, ch):
       if self.selector == 'note-content':
           self.content = self.content + unicode(ch)
       elif self.selector == 'title':
           self.title = self.title + unicode(ch)

if __name__ == "__main__":
   try:
       if (sys.argv[1]=='print'):
           try:
               parser = xml.sax.make_parser()
               handler = textHandler()
               parser.setContentHandler(handler)
               parser.parse(os.path.join('/home/user','.conboy',unicode(sys.argv[2])+'.note'))
               print handler.content
           except Exception, e:
               print e

       elif (sys.argv[1]=='list'):
           nlist = NoteList('/home/user/.conboy/').noteList
           for key in nlist.keys():
               print key, ' : ', nlist[key]
       elif (sys.argv[1]=='search'):
           nlist = NoteList('/home/user/.conboy/')
           print nlist.get_note_id_by_title(sys.argv[2])
       else:
           raise
   except Exception, e:
           print """Usage : python conboy_note_reader.py option [note_id or note title]
           Option : 
               - list : list all note by title with id
               - print : print content of note with the given id
               - search : print id of the given title"""
           print e

Wednesday 15 February 2012 / Maemo, Python, Conboy

KhtCMS and Khweeteur

As you have already probably see it, the 23 December 2011, i ve pushed a new Khweeteur version to the maemo repository, this new version include many fixes from Neal Walfield and really few from me. I'm also writing my own CMS, which i now use for my website. While all features aren't yet coded, it s enough for the moment (no twitter feed, not comment from last git commit, ...).

Friday 13 January 2012 / Khweeteur, KhtCMS