need some help with a dialogue/frontend to a conf file

Dear users,

My name’s shane Davidson, and I’m a brand knew member
to this list.

I’m hoping someone can help me out here or direct me
to a forum or mailing list that can.

I’m in the middle of developing an accessible twitter
client for twitter, and one of the parts is an interface to one of my conf
files, mainly, keymap.conf

The theory behind the way this should work is this

You press the keystroke, in this case, ctrl+shift+win+k.

You are presented with a dialogue, that contains the
following controls in tab order

The combo box, containing all defined functions in
keymap.conf

An edit box that contains the currently assigned key for the
function highlighted in the proceeding combobox

The ok button

The cancel button

Herein lies the problem.

The combo box contains all the functions, but the edit box
following it never populates with the keystroke assigned to that function.

Here is the code I have in interface.py

begin code

def KeymapDialog():

kmpd=dialogs.KeymapDialog(globals.frame, wx.ID_ANY)

val=kmpd.ShowModal()

if val==wx.ID_OK:

logging.debug(“Current keymap is %s”
%str(keys))

keys.write()

else:

keys=kmpd.origKeys

keys.write()

output.Speak(“Cancelling keymap dialog; no
changes were made.”)

end code

And now the code that’s present in dialogues.py

begin code

class KeymapDialog(sc.SizedDialog):

“”"

KeymapDialog: A class which implements a dialog for
changing the Tweet Speak keymap.

This is a frontend to the keymap.conf file, since most
users might not necessarily want to edit that file by hand.

Author: Shane Davidson

“”"

origKeys=keys

def init(self, parent, id):

sc.SizedDialog.init(self, parent, id,
title=“Change Keymap”, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)

globals.frame.Raise()

self.cPane=self.GetContentsPane()

self.cPane.SetSizerType(“form”)

wx.StaticText(self.cPane, -1, “Choose a function
in the list, then tab to the edit box and modify the keys associated with the
function by editing the text. Keys are all in lowercase.”)

fList=[f for f in keys]

self.functions=wx.ComboBox(self.cPane, -1,
value=fList[0], choices=fList, style=wx.CB_READONLY)

self.functions.SetSizerProps(expand=True)

self.Bind(wx.EVT_COMBOBOX, self.itemChange, self.functions)

wx.StaticText(self.cPane, -1, “Key for selected
function:”)

self.text=wx.TextCtrl(self.cPane, -1, “”)

self.text.SetSizerProps(expand=True)

self.text.Bind(wx.EVT_TEXT, self.keymapChanged)

self.SetButtonSizer(self.CreateStdDialogButtonSizer(wx.OK|wx.CANCEL))

self.Fit()

self.SetMinSize(self.GetSize())

self.functions.SetFocus()

def itemChange(self, evt):

evt.Skip()

self.text.SetValue(keys[self.functions.GetValue()])

def keymapChanged(self, evt):

evt.Skip()

fValue=self.functions.GetValue()

keys[fValue]=self.text.GetValue()

end code

I’m more than happy to give someone access to the svn
to download, and attempt to run and help me debug this issue.

Any help you can offer is most certainly welcome

With warmist regards,

Shane Davidson

__________ Information from ESET Smart Security, version of virus signature database 4553 (20091028) __________

The message was checked by ESET Smart Security.

http://www.eset.com

···

Date: 2009-10-25

Hi Shane,

···

On Thu, Oct 29, 2009 at 4:20 AM, Shane Davidson va3duk@gmail.com wrote:

Dear users,

My name’s shane Davidson, and I’m a brand knew member
to this list.

I’m hoping someone can help me out here or direct me
to a forum or mailing list that can.

I’m in the middle of developing an accessible twitter
client for twitter, and one of the parts is an interface to one of my conf
files, mainly, keymap.conf

The theory behind the way this should work is this

You press the keystroke, in this case, ctrl+shift+win+k.

You are presented with a dialogue, that contains the
following controls in tab order

The combo box, containing all defined functions in
keymap.conf

An edit box that contains the currently assigned key for the
function highlighted in the proceeding combobox

The ok button

The cancel button

Herein lies the problem.

The combo box contains all the functions, but the edit box
following it never populates with the keystroke assigned to that function.

So you’re saying that the TextCtrl (or whatever) never shows the key strokes? I don’t see anywhere in your code where you are binding to EVT_CHAR, EVT_KEY_DOWN or EVT_KEY_UP. You really only need the first and maybe the second to catch this sort of thing. Maybe this article will help:

http://www.blog.pythonlibrary.org/2009/08/29/wxpython-catching-key-and-char-events/

HTH


Mike Driscoll

Blog: http://blog.pythonlibrary.org

Yes, I am replying to my own post…I spent some time yesterday and this morning trying to figure out how to catch key combos and put them into a text control. I got it partially working in that the attached script will catch CTRL+SHIFT+SomeLetter, but I can’t get it to catch ALT at all and I don’t know how to grab number keys or function keys. Anyway, this should get you started…unless I have completely misunderstood your problem…either way, it was a fun exercise.

key-char-events.py (1.69 KB)

···

On Thu, Oct 29, 2009 at 11:15 AM, Mike Driscoll mike@pythonlibrary.org wrote:

Hi Shane,

On Thu, Oct 29, 2009 at 4:20 AM, Shane Davidson va3duk@gmail.com wrote:

Dear users,

My name’s shane Davidson, and I’m a brand knew member
to this list.

I’m hoping someone can help me out here or direct me
to a forum or mailing list that can.

I’m in the middle of developing an accessible twitter
client for twitter, and one of the parts is an interface to one of my conf
files, mainly, keymap.conf

The theory behind the way this should work is this

You press the keystroke, in this case, ctrl+shift+win+k.

You are presented with a dialogue, that contains the
following controls in tab order

The combo box, containing all defined functions in
keymap.conf

An edit box that contains the currently assigned key for the
function highlighted in the proceeding combobox

The ok button

The cancel button

Herein lies the problem.

The combo box contains all the functions, but the edit box
following it never populates with the keystroke assigned to that function.

So you’re saying that the TextCtrl (or whatever) never shows the key strokes? I don’t see anywhere in your code where you are binding to EVT_CHAR, EVT_KEY_DOWN or EVT_KEY_UP. You really only need the first and maybe the second to catch this sort of thing. Maybe this article will help:

http://www.blog.pythonlibrary.org/2009/08/29/wxpython-catching-key-and-char-events/

HTH


Mike Driscoll


Mike Driscoll

Blog: http://blog.pythonlibrary.org