<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. &nbsp; &nbsp; Here is one approach. &nbsp;Add an</div><div>controller identifier to fpCallback. &nbsp;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>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;self.fp1 = filebrowse.FileBrowseButtonWithHistory(pnl, -1, size=(300, -1),&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; labelText='', fileMask='*.*', fileMode=wx.OPEN,&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dialogTitle='Select the file containing UCF claims',</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;changeCallback= lambda x: self.fpCallback('fp1', x)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.fp2 = filebrowse.FileBrowseButtonWithHistory(pnl, -1, size=(300, -1),&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; labelText='', fileMask='FI*.*', fileMode=wx.OPEN,&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dialogTitle='Select the form-image file - generally starts with FI',</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;changeCallback= lambda x: self.fpCallback('fp2', x)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [snip]<br>&nbsp;&nbsp;&nbsp; def fpCallback(self, controlID, evt):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print evt.__dict__<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print help(evt)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value = evt.GetString()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [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> -&nbsp;</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:&nbsp; The FileBrowseButtonWithHistory requires a callback override and some custom code to straighten out handling the history.&nbsp; So far, so good.&nbsp; 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.&nbsp; (It makes me sick to my stomach when I look at my code and see duplicate blocks!)&nbsp;&nbsp; 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.&nbsp; <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?&nbsp; Doesn't the Event or CommandEvent carry any information about itself?&nbsp; <br>I've tried this:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [snip]<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.fp1 = filebrowse.FileBrowseButtonWithHistory(pnl, -1, size=(300, -1), <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; labelText='', fileMask='*.*', fileMode=wx.OPEN, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dialogTitle='Select the file containing UCF claims', changeCallback= self.fp1Callback)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.fp2 = filebrowse.FileBrowseButtonWithHistory(pnl, -1, size=(300, -1), <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; labelText='', fileMask='FI*.*', fileMode=wx.OPEN, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dialogTitle='Select the form-image file - generally starts with FI', changeCallback= self.fp2Callback)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [snip]<br> &nbsp;&nbsp;&nbsp; def fp1Callback(self, evt):<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print evt.__dict__<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print help(evt)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value = evt.GetString()<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [snip]<br> &nbsp;&nbsp;&nbsp; def fp2Callback(self, evt):<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print evt.__dict__<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print help(evt)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value = evt.GetString()<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [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>&nbsp;|&nbsp; instance(class[, dict])<br>&nbsp;|&nbsp; <br>&nbsp;|&nbsp; Create an instance without calling its __init__() method.<br>&nbsp;|&nbsp; The class must be a classic class.<br>&nbsp;|&nbsp; If present, dict must be a dictionary or None.<br>&nbsp;|&nbsp; <br>&nbsp;|&nbsp; Methods defined here: <br>&nbsp;|&nbsp; <br>&nbsp;|&nbsp; __abs__(...)<br>&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x.__abs__() &lt;==&gt; abs(x)<br>&nbsp;|&nbsp; <br>...&nbsp; 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>&nbsp;<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.&nbsp;&nbsp; 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 &nbsp;- &nbsp;<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>