Main index > Python programming > Text input?

By coledot (User), on Wed Jul 6 22:00:19 2005: Text input?.

Hey all, I'm a bit new to python, and want to get into programming desklets. I have a quick question though: is there a way to give a desklet text input, like just being able to click on an area and type away? I'd like to know, to see if my idea is possible. ;)

By syfou (Core Developer & Desklet Author), on Thu Jul 7 01:43:27 2005.

There is no support for keyboard-related events in adesklets. Of course, this should not prevent you from complementing it with any other tool or even widgets toolkit you desire (tk, for instance), and from there supporting keyboard input from other drawables than the main desklet window. Yours,

By coledot (User), on Thu Jul 7 20:30:28 2005.

Hmm... I've been taking a look at some of this Tkinter stuff, but it's not quite what I had in mind. I was thinking more along the lines of a text field widget embedded into a desklet, but that doesn't seem to be possible. Oh well. Thanks for the info.

By syfou (Core Developer & Desklet Author), on Thu Jul 7 20:52:03 2005.

In the documentation, I wrote:


It [adesklets] does not provide a sophisticated window API, or even access to widgets besides bare, ugly grey menus. You clearly cannot write any GUI application with this ?only ?desklets?.

By mbokil (Desklet Author), on Thu Dec 15 22:18:13 2005.

It would be an interesting idea if adesklets had the ability to listen to the window manager keyboard events. A long time ago before Flash had the ability to create custom textfield widgets I worked on a project where we created a class of TextField for a Flash application. We used a stack like object and added keyboard characters to the stack object and then wrote the keyboard character to the screen directly. We then fudged the look of a text field by adding a depressed image to the background of screen where the text was being drawn to create the look of a text field. It worked for something very simple like a simple search box.

I can imagine one of the problems with a desklet having a textfield would be focus issues. You would have to create a mechanism to prevent the focus from leaving the desklet until the user was done entering text. It is possible to extend the functionality of adesklets using a class that communicates to the window manager API so that you could trap keyboard events?

By syfou (Core Developer & Desklet Author), on Wed Jan 18 16:41:46 2006.

First, the window manager is just a slightly special client to the X server: there is no such thing as a "window manager API" you can use to listen to keyboard events (and that's good news: I dare not imagine what an horrible kludge of half-compatible ad-hoc routines the oh-so-numerous WM would expose then!): if you want keyboard events, you just ask for it to the X server using the normal X11 protocol.

But let's not be pedantic: what you propose breaks all the good practises from the ICMMM; moreover, there are no right way in practise to grab the keyboard focus reliably without breaking the too-numerous ill-behaving clients (xscreensaver, many gtk+ applications, ...).


adesklets is proud to be hosted on:

SourceForge.net Logo

Back to adesklets.sf.net.