<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">While I can't help you with the wx specific part of the question, I can<div>offer help with the reuse question. Here is one approach. Add an</div><div>controller identifier to fpCallback. Then use lambda expressions for the</div><div>actual callback, where the lambda expressions pass in a fixed value for the</div><div>identifier.</div><div><br class="webkit-block-placeholder"></div><div>Modified code:</div><div><br class="webkit-block-placeholder"></div><div><blockquote type="cite"></blockquote><blockquote type="cite"><blockquote type="cite"></blockquote><blockquote type="cite"><blockquote type="cite"></blockquote></blockquote></blockquote> self.fp1 = filebrowse.FileBrowseButtonWithHistory(pnl, -1, size=(300, -1), <br> labelText='', fileMask='*.*', fileMode=wx.OPEN, <br> dialogTitle='Select the file containing UCF claims',</div><div> changeCallback= lambda x: self.fpCallback('fp1', x)</div><div> )<br> self.fp2 = filebrowse.FileBrowseButtonWithHistory(pnl, -1, size=(300, -1), <br> labelText='', fileMask='FI*.*', fileMode=wx.OPEN, <br> dialogTitle='Select the form-image file - generally starts with FI',</div><div> changeCallback= lambda x: self.fpCallback('fp2', x)</div><div> )<br> [snip]<br> def fpCallback(self, controlID, evt):<br> print evt.__dict__<br> print help(evt)<br> value = evt.GetString()<br> [snip]<br><br><br></div><div><br class="webkit-block-placeholder"></div><div>- Jeff Younker - <a href="mailto:jeff@drinktomi.com">jeff@drinktomi.com</a> - </div><div><div apple-content-edited="true"><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><br class="Apple-interchange-newline"></span> </div><br><div><div>On Dec 6, 2007, at 9:12 AM, Marc Tompkins wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">I have a specific question - how can I generalize a FileBrowseButtonWithHistory - and I realized, as I was trying to word my question, that my real question is a bit more generic.<br><br>First, the specific question: The FileBrowseButtonWithHistory requires a callback override and some custom code to straighten out handling the history. So far, so good. However, I wish to use more than one FBBWH on my form, and I can't figure out how to re-use the custom callback so it will work for both controls. (It makes me sick to my stomach when I look at my code and see duplicate blocks!) Don't get me wrong - it's working right now, it's just that my code is fugly and I want to clean it up. <br><br>In more general terms, how can I set more than one control to use the same block of code as a custom callback, and figure out at runtime which control I'm responding to? Doesn't the Event or CommandEvent carry any information about itself? <br>I've tried this:<br><br> [snip]<br> self.fp1 = filebrowse.FileBrowseButtonWithHistory(pnl, -1, size=(300, -1), <br> labelText='', fileMask='*.*', fileMode=wx.OPEN, <br> dialogTitle='Select the file containing UCF claims', changeCallback= self.fp1Callback)<br> self.fp2 = filebrowse.FileBrowseButtonWithHistory(pnl, -1, size=(300, -1), <br> labelText='', fileMask='FI*.*', fileMode=wx.OPEN, <br> dialogTitle='Select the form-image file - generally starts with FI', changeCallback= self.fp2Callback)<br> [snip]<br> def fp1Callback(self, evt):<br> print evt.__dict__<br> print help(evt)<br> value = evt.GetString()<br> [snip]<br> def fp2Callback(self, evt):<br> print evt.__dict__<br> print help(evt)<br> value = evt.GetString()<br> [snip]<br> <br>All I get from "print evt.__dict__" is: {'_string': u'E:\\ultrahld\\report\\FILE'}<br><br>and all I get from help is:<br>Help on instance of LocalEvent in module wx.lib.filebrowsebutton object:class instance(object) <br> | instance(class[, dict])<br> | <br> | Create an instance without calling its __init__() method.<br> | The class must be a classic class.<br> | If present, dict must be a dictionary or None.<br> | <br> | Methods defined here: <br> | <br> | __abs__(...)<br> | x.__abs__() <==> abs(x)<br> | <br>... in other words, I might as well have typed "help(object)".<br>I only know that the method "evt.GetString()" exists because the example in the demo uses it. <br>I've Googled, and Gmaned, and read the wx docs (such as they are), but I'm not seeing anything I can use.<br> <br>I know that this is a wxPython question, and that this is the Python list... but y'all have answered some wx questions in the past, and I hate to join another list for one question. If I must, I will... but thanks in advance for any light you can shed. <br><br>-- <br><a href="http://www.fsrtechnologies.com">www.fsrtechnologies.com</a> _______________________________________________<br>Tutor maillist - <a href="mailto:Tutor@python.org">Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a><br></blockquote></div><br></div></body></html>