EditableListBox

Greetings,
I am working with an EditableListBox and I was wondering if anyone knows if it is possible to get an update on the Item String and it's index when ever the Up or Down arrows are clicked on?

This is what I have so far (I think I'm doing it right):

self.list_1 = self.frame.elb_1.GetListCtrl()
self.list_1up_B = self.frame.elb_1.GetUpButton()
self.list_1dn_B = self.frame.elb_1.GetDownButton()

self.list_1.Bind(wx.EVT_LIST_DELETE_ITEM, self.onDeleteQuestions)
self.list_1.Bind(wx.EVT_LIST_ITEM_SELECTED, self.onFocusQ)
self.list_1up_B.Bind(wx.EVT_BUTTON, self.onChangeRowQ_up)
self.list_1dn_B.Bind(wx.EVT_BUTTON, self.onChangeRowQ_dn)

.

def onFocusQ(self, event):
         self.currentItem = event.m_itemIndex
         print self.list_1.GetItemText(self.currentItem)
  # TODO: notify the map list of the items new index
         event.Skip()

def onChangeRowQ_up(self, event):
         print "Change Row up"
  # TODO: call the onFocusQ method ???
  # OR get the new index value ???
         event.Skip()

def onChangeRowQ_dn(self, event):
         print "Change Row down"
  # TODO: call the onFocusQ method ???
  # OR get the new index value ???
         event.Skip()

  def onDeleteQuestions(self, event):
  # Works fine
         self.currentItem = event.m_itemIndex
         print self.list_1.GetItemText(self.currentItem)
         event.Skip()

What I would like to do is have the onChangeRowQ functions call the onFocusQ function (currently any mouse or keyboard actions call it, this is not what I want to happen), so I guess the question is how do I fake the event for onFocusQ?

Scott

···

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.5.7 - Release Date: 3/1/2005

I didn't realize it was so obvious, did I mention I was new at python and wxWidgets :slight_smile:

The solution for any one who cares (found it one a 2 yr old post at comp.lang.python):

def onChangeRowQ_up(self, event):
  self.currentItem = self.list_1.GetNextItem(-1,
      wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED)
         print self.list_1.GetItemText(self.currentItem),
      self.currentItem - 1
          event.Skip()

def onChangeRowQ_dn(self, event):
          self.currentItem = self.list_1.GetNextItem(-1,
      wx.LIST_NEXT_ALL, wx.LIST_STATE_SELECTED)
         print self.list_1.GetItemText(self.currentItem),
      self.currentItem + 1
          event.Skip()

"self.list_1.GetItemText(self.currentItem)" this returns the text
"self.currentItem + 1" and this returns the CURRENT index (if I removed the +/- 1 it returns where it WAS. Strange, but it works and I am happy.

Scott

Scott Mallory wrote:

···

Greetings,
I am working with an EditableListBox and I was wondering if anyone knows if it is possible to get an update on the Item String and it's index when ever the Up or Down arrows are clicked on?

This is what I have so far (I think I'm doing it right):

self.list_1 = self.frame.elb_1.GetListCtrl()
self.list_1up_B = self.frame.elb_1.GetUpButton()
self.list_1dn_B = self.frame.elb_1.GetDownButton()

self.list_1.Bind(wx.EVT_LIST_DELETE_ITEM, self.onDeleteQuestions)
self.list_1.Bind(wx.EVT_LIST_ITEM_SELECTED, self.onFocusQ)
self.list_1up_B.Bind(wx.EVT_BUTTON, self.onChangeRowQ_up)
self.list_1dn_B.Bind(wx.EVT_BUTTON, self.onChangeRowQ_dn)

.

def onFocusQ(self, event):
        self.currentItem = event.m_itemIndex
        print self.list_1.GetItemText(self.currentItem)
    # TODO: notify the map list of the items new index
        event.Skip()

def onChangeRowQ_up(self, event):
        print "Change Row up"
    # TODO: call the onFocusQ method ???
    # OR get the new index value ???
        event.Skip()

def onChangeRowQ_dn(self, event):
        print "Change Row down"
    # TODO: call the onFocusQ method ???
    # OR get the new index value ???
        event.Skip()

def onDeleteQuestions(self, event):
    # Works fine
        self.currentItem = event.m_itemIndex
        print self.list_1.GetItemText(self.currentItem)
        event.Skip()

What I would like to do is have the onChangeRowQ functions call the onFocusQ function (currently any mouse or keyboard actions call it, this is not what I want to happen), so I guess the question is how do I fake the event for onFocusQ?

Scott

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.5.7 - Release Date: 3/1/2005

Scott Mallory wrote:

Greetings,
I am working with an EditableListBox and I was wondering if anyone knows if it is possible to get an update on the Item String and it's index when ever the Up or Down arrows are clicked on?

This is what I have so far (I think I'm doing it right):

self.list_1 = self.frame.elb_1.GetListCtrl()
self.list_1up_B = self.frame.elb_1.GetUpButton()
self.list_1dn_B = self.frame.elb_1.GetDownButton()

self.list_1.Bind(wx.EVT_LIST_DELETE_ITEM, self.onDeleteQuestions)
self.list_1.Bind(wx.EVT_LIST_ITEM_SELECTED, self.onFocusQ)
self.list_1up_B.Bind(wx.EVT_BUTTON, self.onChangeRowQ_up)
self.list_1dn_B.Bind(wx.EVT_BUTTON, self.onChangeRowQ_dn)

.

def onFocusQ(self, event):
        self.currentItem = event.m_itemIndex
        print self.list_1.GetItemText(self.currentItem)
    # TODO: notify the map list of the items new index
        event.Skip()

def onChangeRowQ_up(self, event):
        print "Change Row up"
    # TODO: call the onFocusQ method ???
    # OR get the new index value ???
        event.Skip()

def onChangeRowQ_dn(self, event):
        print "Change Row down"
    # TODO: call the onFocusQ method ???
    # OR get the new index value ???
        event.Skip()

def onDeleteQuestions(self, event):
    # Works fine
        self.currentItem = event.m_itemIndex
        print self.list_1.GetItemText(self.currentItem)
        event.Skip()

What I would like to do is have the onChangeRowQ functions call the onFocusQ function (currently any mouse or keyboard actions call it, this is not what I want to happen), so I guess the question is how do I fake the event for onFocusQ?

Don't. Create a new function that takes the item and whatever else you need as parameters and call it from both onFocusQ and the onChangeRow functions.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!