[chimera-dev] creating an extension

Conrad Huang conrad at cgl.ucsf.edu
Mon Dec 9 15:26:41 PST 2013


Sorry for the terse message, Matt.  The link is to how Chimera dialogs 
are initialized in extensions and the example only uses Tkinter widgets. 
  For a new extension, I would follow the example template but use Pmw 
widgets in place of the Tkinter ones.  Tkinter widgets tend to be very 
basic and you have to do a lot of work to get even simple layouts.  Pmw 
widgets (built on top of Tkinter) have more options and require less 
coding.  I really like their documentation 
(http://pmw.sourceforge.net/doc/index.html) and generally just use the 
reference manual pages which contain working example code at the bottom.

Conrad

On 12/9/2013 3:10 PM, Dougherty, Matthew T wrote:
> Hi Conrad,
>
> Thanks for the link.  Not clear  on what is going here.  You suggest
> PMW, but the link involves tkinter.  Not that familiar with pmw or
> tkinter, their overlap or integration. Make sure I am correct on
> this, the link is non pmw?  My inclination is to go pmw, at the same
> want to go with the overall programming methods.
>
> Matthew Dougherty National Center for Macromolecular Imaging Baylor
> College of Medicine ________________________________________ From:
> Conrad Huang [conrad at cgl.ucsf.edu] Sent: Monday, December 09, 2013
> 12:45 PM To: Dougherty, Matthew T; chimera-dev at cgl.ucsf.edu Subject:
> Re: [chimera-dev] creating an extension
>
> Personally, I would just stick with a standard Python GUI like Pmw.
> There's example code that work and it's well documented.  Perhaps
> http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/Examples/Main_ExtensionUI.html
>
>
might help.
>
> Conrad
>
> On 12/7/2013 3:03 PM, Dougherty, Matthew T wrote:
>> Hi,
>>
>> I am trying to create a simple extension that has a column of
>> buttons (qty 10-20) having a corresponding column of user defined
>> text blocks. When I push a button, the corresponding text string
>> will be read and processed as a command string (eg, "reset
>> default", "rock X 3", "move Z 2000")
>>
>> I started with VolumePlanes and whittled it down to the nub to
>> figure out what it was doing relative to what I want; below. I am
>> realizing the buttons defined by this example extension uses some
>> specific chimera GUI strategies. My going with a row of buttons
>> would work as in this volumeplanes example, but is second
>> preference on layout. More visually intuitive to have it side by
>> side. Not sure this is possible with another dozen lines of code,
>> or if I would need to go about it another route using different
>> CGLTk api's and scrap using this volumeplane extension as a boiler
>> plate.
>>
>>
>> So I am realizing that this is putting me into the intricacies of
>> CGLtk.  An alternate would be to go with std python gui code.  I
>> also know you are reinventing chimera, one reason being the tk
>> libraries, which opens up a third approach.  So I am at a crossroad
>> as to how to proceed.  Because the code is relatively small, a
>> rewrite for chimera2 does not seem an issue.  Also there are some
>> issues with parenting I am unfamiliar with (eg, t.withdraw(),
>> columnconfigure).
>>
>> I am thinking this might be a good example of an extension for a
>> beginner, so writing it as such might be useful for others.
>> Particularly for new developers trying to sort out the boundaries
>> between python, chimera, tk, and the extension linkages.
>>
>> Need some direction as to which way to go for the least amount of
>> work of coding.
>>
>> thanks,
>>
>> Matthew Dougherty National Center for Macromolecular Imaging
>> Baylor College of Medicine
>>
>>
>> ===========
>>
>> #
>> -----------------------------------------------------------------------------
>>
>>
>
>>
import chimera
>> from chimera.baseDialog import ModelessDialog import
>> ButtonCommands
>>
>> #
>> -----------------------------------------------------------------------------
>>
>>
>
>>
class Button_Commands_Dialog(ModelessDialog):
>> title = 'Button Commands' name = 'button commands' buttons =
>> ('C1', 'C2', 'C3','Close',)
>>
>> #
>> ---------------------------------------------------------------------------
>>
>>
>
>>
#
> ---------------------------------------------------------------------------
>>
>
def fillInUI(self, parent): t = parent.winfo_toplevel()
>> self.toplevel_widget = t t.withdraw()
>>
>> parent.columnconfigure(2, weight = 2)
>>
>> from CGLtk import Hybrid
>>
>> ps = Hybrid.Scale(parent, 'Cmd1', 0, 10, 1, 0) ps.frame.grid(row =
>> 2, column = 0, sticky = 'ew')
>>
>> ps.callback(self.change_plane_cb)
>> ps.entry.bind('<KeyPress-Return>', self.change_plane_cb) self.plane
>> = ps
>>
>> def change_plane_cb(self, full_size = False): return
>>
>> #
>> ---------------------------------------------------------------------------
>>
>>
>
>>
#
> ---------------------------------------------------------------------------
>>
>
def C1(self): c_1='echo c1' chimera.runCommand(c_1)
>>
>> def C2(self): c_2='echo c2' chimera.runCommand(c_2)
>>
>> def C3(self): c_3='echo c3' chimera.runCommand(c_3)
>>
>> #
>> -----------------------------------------------------------------------------
>>
>>
>
>>
def Button_Commands_dialog(create = False):
>> from chimera import dialogs return
>> dialogs.find(Button_Commands_Dialog.name, create=create)
>>
>> #
>> -----------------------------------------------------------------------------
>>
>>
>
>>
def show_button_commands_dialog():
>> from chimera import dialogs return
>> dialogs.display(Button_Commands_Dialog.name)
>>
>> #
>> -----------------------------------------------------------------------------
>>
>>
>
>>
from chimera import dialogs
>> dialogs.register(Button_Commands_Dialog.name,
>> Button_Commands_Dialog, replace = True)
>>
>> _______________________________________________ Chimera-dev
>> mailing list Chimera-dev at cgl.ucsf.edu
>> http://www.rbvi.ucsf.edu/mailman/listinfo/chimera-dev
>>
>



More information about the Chimera-dev mailing list