Event Handling Questions

I have defined several wx.ListCtrl without specifying choices; that's for
the user to do. To allow the user to enter a string, I placed an 'Add'
button; it's wx.EVT_BUTTON calls a text entry dialog. All this works well,
and I can enter a string in the widget.

   A representative method that calls the dialog is,

   def OnNatAdd(self, event):
     self.TextEntryDlg(event)
     event.Skip()

and the text entry dialog is,

   def TextEntryDlg(self, event):
     " Used to get a new variable name"
     newVar = wx.TextEntryDialog(self, 'Enter the name of a new variable.',
                                 'Variable Name:', style=wx.OK|wx.CANCEL|wx.CENTER)
     if (newVar.ShowModal() == wx.OK):
       wx.MessageDialog(self, 'You entered: %s % newVar\n', 'Text Entered',
                        style=wx.OK|wx.ICON_INFORMATION)
       newVar.Destroy()

   I know that the event.Skip() needs to be replaced with code that will add
the returned text to the list control. Since up to eight strings can be
entered in the list control, what is the recommended way of adding them, one
at a time? What I'm asking, in simple terms, is how I modify both the text
entry dialog and OnNatAdd method so a returned string is added to the list
control, and this can be done repeatedly without overwriting a previously
entered string.

Thanks,

Rich

···

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

   I have defined several wx.ListCtrl without specifying choices; that's for
the user to do. To allow the user to enter a string, I placed an 'Add'
button; it's wx.EVT_BUTTON calls a text entry dialog. All this works well,
and I can enter a string in the widget.

   A representative method that calls the dialog is,

   def OnNatAdd(self, event):
     self.TextEntryDlg(event)
     event.Skip()

   def OnNatAdd(self, event):
     text = self.TextEntryDlg()
     if text is not None:
       self.lst.InsertStringItem(self.lst.GetItemCount(), text)

and the text entry dialog is,

   def TextEntryDlg(self, event):
     " Used to get a new variable name"
     newVar = wx.TextEntryDialog(self, 'Enter the name of a new variable.',
                                 'Variable Name:', style=wx.OK|wx.CANCEL|wx.CENTER)
     if (newVar.ShowModal() == wx.OK):
       wx.MessageDialog(self, 'You entered: %s % newVar\n', 'Text Entered',
                        style=wx.OK|wx.ICON_INFORMATION)
       newVar.Destroy()

   def TextEntryDlg(self):
     " Used to get a new variable name"
     newVar = wx.TextEntryDialog(self, 'Enter the name of a new variable.',
                                 'Variable Name:', style=wx.OK|wx.CANCEL|wx.CENTER)
     txt = None
     if (newVar.ShowModal() == wx.OK):
       txt = newVar.GetValue()
       wx.MessageDialog(self, 'You entered: %s\n'%repr(txt),
                        'Text Entered',
                        style=wx.OK|wx.ICON_INFORMATION)

     newVar.Destroy()
     return txt

   I know that the event.Skip() needs to be replaced with code that will add
the returned text to the list control. Since up to eight strings can be
entered in the list control, what is the recommended way of adding them, one
at a time?

However you feel like you want to enter text. Are the users going to be
entering a variable number of entries (0-8)? Are the entries named
(firstname, lastname, age, ...)?

What I'm asking, in simple terms, is how I modify both the text
entry dialog and OnNatAdd method so a returned string is added to the list
control, and this can be done repeatedly without overwriting a previously
entered string.

I've done that.

- Josiah

···

Rich Shepard <rshepard@appl-ecosys.com> wrote:

  def OnNatAdd(self, event):
    text = self.TextEntryDlg()
    if text is not None:
      self.lst.InsertStringItem(self.lst.GetItemCount(), text)

   Thanks very much, Josiah, for pointing me in the right direction with this
method and the next one. Now I see just what I did incorrectly.

However you feel like you want to enter text. Are the users going to be
entering a variable number of entries (0-8)? Are the entries named
(firstname, lastname, age, ...)?

   Yes, there may be 1-8 entries, and I've not yet assigned them names.

I've done that.

   Again, thanks!

Rich

···

On Wed, 7 Dec 2005, Josiah Carlson wrote:

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

Really the question comes down to whether the 1-8 entries are different
types of information, or really just different selectable options. If
they are all the same type (all names, all email addresses, all
categories for the type of reports, etc.). It also matters if you can
only select 1, or if you can select some or all of the 1-8.

If it is something like a contact manager where each entry is of a
different type, and each type has a name, you would perhaps be better
off creating a panel with wx.StaticText + wx.TextCtrl pairs (name, value).

If they are all the same kind of information, then using the wx.ListCtrl
probably makes the most sense (I'm personally not a real big fan of
wx.ComboBox controls, even though I use them in my own applications).

- Josiah

···

Rich Shepard <rshepard@appl-ecosys.com> wrote:

On Wed, 7 Dec 2005, Josiah Carlson wrote:
> However you feel like you want to enter text. Are the users going to be
> entering a variable number of entries (0-8)? Are the entries named
> (firstname, lastname, age, ...)?

   Yes, there may be 1-8 entries, and I've not yet assigned them names.

Really the question comes down to whether the 1-8 entries are different
types of information, or really just different selectable options. If they
are all the same type (all names, all email addresses, all categories for
the type of reports, etc.). It also matters if you can only select 1, or if
you can select some or all of the 1-8.

   They are lists of component names. In each of three categories. When the
lists are complete, they are saved for further manipulation.

If they are all the same kind of information, then using the wx.ListCtrl
probably makes the most sense (I'm personally not a real big fan of
wx.ComboBox controls, even though I use them in my own applications).

   Words. Just words. A ComboBox would not be as good as the ListCtrl.

Rich

···

On Wed, 7 Dec 2005, Josiah Carlson wrote:

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

What is the status of WebKit for Mac. Is there a sample anywhere. I have tried create an instance and I receive a NotImplemented error.

Regards
David

Are the lists' content (item order, individual item value, etc.)
editable afterwards?

- Josiah

···

Rich Shepard <rshepard@appl-ecosys.com> wrote:

On Wed, 7 Dec 2005, Josiah Carlson wrote:
> Really the question comes down to whether the 1-8 entries are different
> types of information, or really just different selectable options. If they
> are all the same type (all names, all email addresses, all categories for
> the type of reports, etc.). It also matters if you can only select 1, or if
> you can select some or all of the 1-8.

   They are lists of component names. In each of three categories. When the
lists are complete, they are saved for further manipulation.

Josiah,

   Yes, they are. It's not too likely that they will be, but I have two
methods attached to the wx.ListCtrl: one for adding a new string and one for
editing an existing string.

Rich

···

On Thu, 8 Dec 2005, Josiah Carlson wrote:

Are the lists' content (item order, individual item value, etc.) editable
afterwards?

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863