[Main Page] [Edit #1] [Edit #2] [Edit #3] [Edit #4] [Edit #5]

An editor - the foundations

In this series of exercises we'll be creating our own Emacs - more or less. Or rather, less. It's remarkably easy to build a functional gui editor, since most gui toolkits come with a multi-line editor widget. Of course, those widgets are seldom capable of great things, even when heavily subclassed. Indeed, the Qt documentation tells us about the QMultiLineEdit:

The QMultiLineEdit widget is a simple editor for inputting text.

The QMultiLineEdit widget provides multiple line text input and display. It is intended for moderate amounts of text. There are no arbitrary limitations, but if you try to handle megabytes of data, performance will suffer.

Keeping that wise advice in mind, we'll proceed upon our chosen path and start kreating kedit. Sorry, let that be 'creating edit'. Aren't you getting tired of applications beginning with a gratuitous k, g or x? Well, I am, and I hereby sincerely vow to name all my applications-to-be with sensible names. Let's start with Edit. The next will be Aranea, my website structure viewer.

#!/usr/bin/env python

import sys
from kdeui import *

class Edit(KTMainWindow):
  def __init__ (self):
    self.view=QMultiLineEdit(self, "Main View")

Well, we know the basics of a KDE application by now. These are:

I will readily admit that this framework doesn't have much in the way of buttonbars, menubars or statusbars, but what isn't can become, and that's a fit subject for the next exercise. What you can do is write text, select it and paste it in other applications, and be reasonably sure that if you've left it running when logging out from KDE, it'd reappear next time you start KDE up.