<div dir="ltr">Thank you Eric!</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><br></div><div dir="ltr"><span style="font-size:12.8px">_</span><span style="font-size:12.8px">_</span><span style="font-size:12.8px">__________________________</span><br></div><div dir="ltr"><br></div><div dir="ltr">Daniel Gurnon, Ph. D.<div>Associate Professor of Chemistry and Biochemistry</div><div>Director, Science Research Fellows Program<br>DePauw University<br></div><div>Greencastle, IN 46135</div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Oct 26, 2017 at 7:17 PM, Eric Pettersen <span dir="ltr"><<a href="mailto:pett@cgl.ucsf.edu" target="_blank">pett@cgl.ucsf.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><blockquote type="cite"><div>On Oct 26, 2017, at 10:29 AM, Daniel Gurnon <<a href="mailto:danielgurnon@depauw.edu" target="_blank">danielgurnon@depauw.edu</a>> wrote:</div><br class="m_5410873526390244196Apple-interchange-newline"><div><div dir="ltr">Hi everyone,</div></div></blockquote><div><br></div>Hi Dan, Shuto,</div><div><span class=""><br><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>I'm working with a undergraduate computer science student, Shuto Araki, on a Chimera development project that involves creating a GUI. I'm not a programmer, and he's learning Python as he goes- so we've run into the inevitable snag, and we're looking for some help.</div><div><br></div><div>Here's how Shuto describes the issue:</div><div>----</div><div><br></div><div><div><div class="m_5410873526390244196gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-size:12.8px;word-wrap:break-word"><div>I am trying to create a Chimera GUI extension that asks <span style="font-size:12.8px">Chimera to fetch a PDB ID and then to highlight residue positions within the structure, with the PDB and positions </span><span style="font-size:12.8px">taken from a CSV file.</span><span style="font-size:12.8px"> </span>I started with a Python script, and it works <span style="font-size:12.8px">as intended if I import it from IDLE.</span></div><div><br></div><div><span style="font-size:12.8px">However, when I tried to create a GUI using this guide</span></div><div><span style="font-size:12.8px"> </span><a href="https://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/Examples/Main_ExtensionUI.html" style="font-size:12.8px" target="_blank">https://www.cgl.ucsf.edu/chim<wbr>era/docs/ProgrammersGuide/Exam<wbr>ples/Main_ExtensionUI.html</a><span style="font-size:12.8px"><br></span></div><div>I ran into an error.<span style="font-size:12.8px"> When I click on the button that I added on toolbar, the callback function does not seem to work properly. It just pops up an empty window with OK, Apply and Cancel buttons.</span></div><div><br></div><div><br></div><div>The code snippet is as follows:</div><div><br></div><div>##############################<wbr>##############################<wbr>##</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>class MutationDialog(ModelessDialog)<wbr>:</div><div><br></div><div> name = "mutation highlighter"</div><div> title = "Rare Genetic Mutation Highlighter”</div></blockquote></div></div></div></div></div></div></div></div></div></blockquote><div><br></div></span>So far so good, but this is where you begin to go off the rails. As per the example you were trying to follow, the creation of your custom user interface happens in the ‘fillInUI’ method, and your widgets should be children of the ‘parent’ argument that is passed into that method. So the next line should be:</div><div><br></div><div><span class="m_5410873526390244196Apple-tab-span" style="white-space:pre-wrap"> </span>def fillInUI(self, parent):</div><div><span class=""><br><blockquote type="cite"><div><div dir="ltr"><div><div><div class="m_5410873526390244196gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-size:12.8px;word-wrap:break-word"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><br></div><div><strike> master = Tk()</strike></div><div><strike> master.title("Rare Genetic Disease Mutation Highlighter")</strike></div><div><strike> master.geometry('{}x{}'.format<wbr>(500, 100))</strike></div></blockquote></div></div></div></div></div></div></div></div></div></blockquote><div><br></div></span>Don’t need any of the above three lines. Take them out.</div><div><span class=""><br><blockquote type="cite"><div><div dir="ltr"><div><div><div class="m_5410873526390244196gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-size:12.8px;word-wrap:break-word"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><br></div><div><br></div><div> global var</div><div> var = StringVar(master)</div><div> var.set(proteinNames[0])</div><div><br></div><div> # proteinNames is a list of protein options that a user chooses</div><div> options = OptionMenu(master, var, *proteinNames)</div><div> options.pack()</div></blockquote></div></div></div></div></div></div></div></div></div></blockquote><div><br></div></span>The above lines are okay, but instead of ‘master’ use ‘parent’.</div><div><span class=""><br><blockquote type="cite"><div><div dir="ltr"><div><div><div class="m_5410873526390244196gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-size:12.8px;word-wrap:break-word"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div> def Apply():</div><div> # this functionality works</div><div> protein_num = proteinMap[var.get()]</div><div> mh.highlightMutation(filename, protein_num)</div><div><br></div><div> button = Button(master, text = "Apply", command = Apply)</div><div> button.pack()</div></blockquote></div></div></div></div></div></div></div></div></div></blockquote><div><br></div></span>Okay, sort of, but no. :-) The ModelessDialog class will automatically create OK, Apply, and Close buttons (though that behavior can be overridden). All you have to do is define a class method named Apply and that method will be called when OK or Apply is clicked. So:</div><div><br></div><div><span class="m_5410873526390244196Apple-tab-span" style="white-space:pre-wrap"> </span>def Apply(self):</div><div><span class="m_5410873526390244196Apple-tab-span" style="white-space:pre-wrap"> </span># rest of what you were doing in Apply is okay…</div><div><br></div><div>You definitely don’t need the code that explicitly creates an Apply button.</div><div><br></div><div><span class=""><blockquote type="cite"><div><div dir="ltr"><div><div><div class="m_5410873526390244196gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-size:12.8px;word-wrap:break-word"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><br></div><div>chimera.dialogs.register(Mutat<wbr>ionDialog.name, MutationDialog)</div><div><br></div><div><br></div><div>dir, file = os.path.split(__file__)</div><div>icon = os.path.join(dir, 'ExtensionUI.tiff')</div><div>chimera.tkgui.app.toolbar.add(<wbr>icon, lambda d=chimera.dialogs.display,</div><div>n=MutationDialog.name: d(n), 'Highlight Mutations', None)</div></blockquote></div></div></div></div></div></div></div></div></div></blockquote><div><br></div></span>The rest of the code is fine. Let me know if you run into further problems.</div><div><br></div><div>—Eric</div><div><br></div><div><div><div style="word-wrap:break-word"><div><span class="m_5410873526390244196Apple-tab-span" style="white-space:pre-wrap"> </span>Eric Pettersen</div><div><span class="m_5410873526390244196Apple-tab-span" style="white-space:pre-wrap"> </span>UCSF Computer Graphics Lab</div></div></div><br><div><blockquote type="cite"></blockquote></div><blockquote type="cite"><div><span class=""><div dir="ltr"><div><div><div class="m_5410873526390244196gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-size:12.8px;word-wrap:break-word"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><br></div></blockquote>##############################<wbr>##############################<wbr>##<div><br></div><div>I suspect that MutationDialog class is not working as a proper callback class.</div><div><br></div><div><b>Do you have any suggestions for the proper structure of the class?</b></div><div>We're also </div><div><br></div><div>Sincerely, </div></div><br style="font-size:12.8px"><div style="font-size:12.8px;word-wrap:break-word"><div></div><div>Shuto</div><div><br></div><div>---</div><div><br></div><div>Thanks for any advice!</div><div>Dan</div></div></div><div dir="ltr"><span style="font-size:12.8px">_</span><span style="font-size:12.8px">_</span><span style="font-size:12.8px">__________________________</span><br></div><div dir="ltr"><br></div><div dir="ltr">Daniel Gurnon, Ph. D.<div>Associate Professor of Chemistry and Biochemistry</div><div>Director, Science Research Fellows Program<br>DePauw University<br></div><div>Greencastle, IN 46135</div></div></div></div></div></div>
</div></div></span>
______________________________<wbr>_________________<br>Chimera-dev mailing list<br><a href="mailto:Chimera-dev@cgl.ucsf.edu" target="_blank">Chimera-dev@cgl.ucsf.edu</a><br><a href="http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev" target="_blank">http://plato.cgl.ucsf.edu/<wbr>mailman/listinfo/chimera-dev</a><br></div></blockquote></div><br></div></blockquote></div><br></div>