Need GUI pop-up to edit a (unicode ?) string
geremy condra
debatem1 at gmail.com
Sat Jan 22 17:57:58 EST 2011
On Sat, Jan 22, 2011 at 12:22 PM, Rikishi42 <skunkworks at rikishi42.net> wrote:
>
> I'm in need for a graphical pop-up that will display a (unicode ?) string in
> a field, allow the user to change it and return the modified string.
>
> Maybe also keep the original one displayed above it.
>
>
> Something like this:
> +-------------------------------------------------+
> | Please confirm or edit the following string |
> | |
> | Original_example_string |
> | |
> | +-------------------------------------------+ |
> | | Original_about_to_be_changed | |
> | +-------------------------------------------+ |
> | |
> | OK |
> | |
> +-------------------------------------------------+
>
>
> I've never used any kind of graphical interface programing before, so I
> don't have a clue where to start.
> This would, however, be the *only* GUI part in the app at this point.
>
> >From what I can see the solution lays with PyQT, but the docs I find are
> courses that aim to teach the whole GUI tool. I only need a little pop-up to
> alow a user to edit part of a filename, for instance.
>
>
> I'm using Python 2.6.x on various Linux platforms (mainly openSUSE and Mint)
> and on Windows. Windows support is not important, in this case.
If windows doesn't matter to you, just use Zenity. Here's a python
function wrapping zenity that does what you want:
import commands
def confirm_or_edit(s):
zenity = 'zenity'
mode = '--entry'
text = "--text='Please confirm or edit the following string:'"
title = "--title='confirm or edit'"
entry = "--entry-text='%s'" % s
cmd = ' '.join([zenity, mode, text, title, entry])
status, output = commands.getstatusoutput(cmd)
if status: raise Exception("Couldn't run zenity")
return output
There's also a full-blown API for zenity, but this should do what you want.
Geremy Condra
More information about the Python-list
mailing list