On Oct 26, 2017, at 10:29 AM, Daniel Gurnon <danielgurnon@depauw.edu> wrote:Hi everyone,
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.Here's how Shuto describes the issue:----I am trying to create a Chimera GUI extension that asks Chimera to fetch a PDB ID and then to highlight residue positions within the structure, with the PDB and positions taken from a CSV file. I started with a Python script, and it works as intended if I import it from IDLE.However, when I tried to create a GUI using this guideI ran into an error. 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.The code snippet is as follows:############################################################ ## class MutationDialog(ModelessDialog): name = "mutation highlighter"title = "Rare Genetic Mutation Highlighter”
master = Tk()master.title("Rare Genetic Disease Mutation Highlighter")master.geometry('{}x{}'.format(500, 100))
global varvar = StringVar(master)var.set(proteinNames[0])# proteinNames is a list of protein options that a user choosesoptions = OptionMenu(master, var, *proteinNames)options.pack()
def Apply():# this functionality worksprotein_num = proteinMap[var.get()]mh.highlightMutation(filename, protein_num)button = Button(master, text = "Apply", command = Apply)button.pack()
chimera.dialogs.register(MutationDialog.name, MutationDialog) dir, file = os.path.split(__file__)icon = os.path.join(dir, 'ExtensionUI.tiff')chimera.tkgui.app.toolbar.add(icon, lambda d=chimera.dialogs.display, n=MutationDialog.name: d(n), 'Highlight Mutations', None)
_______________________________________________############################################################ ## I suspect that MutationDialog class is not working as a proper callback class.Do you have any suggestions for the proper structure of the class?We're alsoSincerely,Shuto---Thanks for any advice!Dan____________________________Daniel Gurnon, Ph. D.Associate Professor of Chemistry and BiochemistryDirector, Science Research Fellows Program
DePauw UniversityGreencastle, IN 46135
Chimera-dev mailing list
Chimera-dev@cgl.ucsf.edu
http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev