예제 #1
0
        self.shownButtons.sort()
        index = self.shownButtons.index(name)
        if index == len(self.shownButtons) - 1:
            addFunc = self.actionButtons.add
        else:
            addFunc = self.actionButtons.insert
            kw['beforeComponent'] = self.shownButtons[index + 1]

        but = apply(addFunc, (name, ), kw)
        but.config(default='disabled')
        if balloon:
            help.register(but, balloon=balloon)


import dialogs
dialogs.register(PseudoBondGroupPanel.name, PseudoBondGroupPanel)


# functions used in groups panel buttons; could be called directly also
def setGroupField(groups, field, value):
    for m in groups:
        setattr(m, field, value)


def setGroupFieldOnly(groups, field, onVal=1, offVal=0):
    for group in chimera.PseudoBondMgr.mgr().pseudoBondGroups:
        if group in groups:
            setattr(group, field, onVal)
        else:
            setattr(group, field, offVal)
        tList.sort()
        self.menu.delete(0, Tkinter.END)
        for t in tList:
            self.menu.add_command(
                label=t, command=lambda s=self, t=t: s.__selectTexture(t))
        if cursel not in tList:
            cursel = None
        if not cursel:
            cursel = tList[0]
        self.__selectTexture(cursel)

    def updateTexture(self, image):
        if not self.texture:
            return
        w, h, depth, nc, nb = self.texture.sizes()
        if image.size[0] != w or image.size[1] != h:
            raise ValueError, 'image/texture size mismatch'
        self.texture.image = image

    def __textureHandler(self, trigger, closure, textures):
        if textures.created or textures.deleted:
            self.reloadTextures()
            return
        for t in textures.modified:
            if t == self.texture:
                self.editor.map.redrawIfNeeded()


import dialogs
dialogs.register(TextureDialog.name, TextureDialog)
		self.doFurther.set(0)
		Tkinter.Checkbutton(parent, var=self.doFurther, takefocus=0
					).grid(row=30, column=1, sticky='e')
		furtherFrame = Tkinter.Frame(parent)
		furtherFrame.grid(row=30, column=2, sticky='w')
		self.furtherEntry = Pmw.EntryField(furtherFrame, labelpos='w',
			validate={'validator': 'real', 'min': 0.0},
			value='5.0', label_text='>', entry_width=5)
		self.furtherEntry.grid(row=10, column=1, sticky='e')
		self.furtherEntry.component('entry').focus_set()
		Tkinter.Label(furtherFrame, text='angstroms from currently'
			' selected atoms').grid(row=10, column=2, sticky='w')
		
		self.doResidues = Tkinter.IntVar(parent)
		self.doResidues.set(0)
		Tkinter.Checkbutton(parent, var=self.doResidues, takefocus=0
					).grid(row=40, column=1, sticky='e')
		Tkinter.Label(parent, text='Select all atoms/bonds of any'
			' residue in selection zone').grid(row=40, column=2,
								sticky='w')

		for b in self.buttonWidgets.values():
			b.config(takefocus=0)


	def Apply(self):
		if self.callback:
			self.callback(self)
import dialogs
dialogs.register(ZoneDialog.name, ZoneDialog)
예제 #4
0
                ## registered
                AlreadyRegisteredDialog("\n".join(msgs))

    def subscribe(self, url, username, email):
        param_dict = {
            'email'    : email,
            'fullname' : username
            }
	params = urllib.urlencode(param_dict)
	file = urllib.urlopen(url, params)
	text = file.read()
        print "GOT %s for text" % text
            

import dialogs
dialogs.register(RegDialog.name, RegDialog)


class AlreadyRegisteredDialog(ModelessDialog):
    title = "Registered"
    buttons = ('OK')
    highlight = 'OK'

    def __init__(self, addl_info=None):

        self.addl_info = addl_info
        
        ModelessDialog.__init__(self, oneshot=1)

    def fillInUI(self, parent):
        from chimera.HtmlText import HtmlText
예제 #5
0
		# determine where to add the button...
		self.shownButtons.append(name)
		self.shownButtons.sort()
		index = self.shownButtons.index(name)
		if index == len(self.shownButtons)-1:
			addFunc = self.actionButtons.add
		else:
			addFunc = self.actionButtons.insert
			kw['beforeComponent'] = self.shownButtons[index+1]
		
		but = apply(addFunc, (name,), kw)
		but.config(default='disabled')
		if balloon:
			help.register(but, balloon=balloon)
import dialogs
dialogs.register(PseudoBondGroupPanel.name, PseudoBondGroupPanel)

# functions used in groups panel buttons; could be called directly also
def setGroupField(groups, field, value):
	for m in groups:
		setattr(m, field, value)

def setGroupFieldOnly(groups, field, onVal=1, offVal=0):
	for group in chimera.PseudoBondMgr.mgr().pseudoBondGroups:
		if group in groups:
			setattr(group, field, onVal)
		else:
			setattr(group, field, offVal)

def toggleModelField(groups, field, onVal=1, offVal=0):
	for group in groups:
	#	import dialogs
	#	d = dialogs.display("preferences")
	#	d.setCategoryMenu(IMAGE_SETUP)

	def showImageCreditsDialog(self, *args):
		import dialogs
		d = dialogs.display("preferences")
		d.setCategoryMenu(IMAGE_CREDITS)

	def showPOVRayOptions(self, *args):
		import dialogs
		d = dialogs.display("preferences")
		d.setCategoryMenu(POVRAY_SETUP)

import dialogs
dialogs.register(ImageSaveDialog.name, ImageSaveDialog)

def imageArgs(units, width=None, height=None, supersample=None):
	"""return 3-tuple with horizontal pixels, vertical pixels, supersample"""
	if not width:
		width, height = chimera.viewer.windowSize
	if units == 'pixels':
		scale = 1
	elif preferences.get(IMAGE_SETUP, USE_PRINT_UNITS):
		adjust = convert[units] / convert['inches']
		scale = preferences.get(IMAGE_SETUP, DPI) * adjust
	else:
		# use screen resolution
		scale = convert[units] / convert['pixels']
	if supersample is None:
		supersample = preferences.get(IMAGE_SETUP, SUPERSAMPLE)
    w = Tkinter.Button(parent, text="Hello")
    bg = w.cget("bg")
    fg = w.cget("fg")
    disabledColor = w.cget("disabledforeground")
    b_r, b_g, b_b, b_a = _tkrgb2rgba(w.winfo_rgb(bg))
    f_r, f_g, f_b, f_a = _tkrgb2rgba(w.winfo_rgb(fg))
    w.destroy()
    r = b_r + (f_r - b_r) / 10.0
    g = b_g + (f_g - b_g) / 10.0
    b = b_b + (f_b - b_b) / 10.0
    alt_bg = rgba2tk((r, g, b, b_a))
    return (bg, alt_bg), disabledColor


import dialogs
dialogs.register(TaskPanel.name, TaskPanel)

#
# Code below are examples and not used by Chimera
#


class TestProcess:
    def __init__(self):
        self.checkCount = 0
        self.task = Task("test", self.cancelCB, self.statusCB)

    def cancelCB(self):
        self.finished()

    def statusCB(self):
	def configure(self, klass=None, selected=None):
		if klass is not None and klass in classes:
			self.classMenu.invoke(classes.index(klass))
		if selected is not None:
			if selected:
				self.selUnsel.setvalue("selected")
			else:
				self.selUnsel.setvalue("unselected")

	def Apply(self):
		self._writeSel(self.getPaths()[0])

	def Log(self):
		self.Close()
		self._writeSel("-")
		dialogs.display("reply")

	def _writeSel(self, destination):
		naming = self.naming.get()
		self.prefs[self.PREF_NAMING] = naming

		selected = self.selUnsel.getvalue() == "selected"

		from writeSel import writeSel
		writeSel(destination, namingStyle=naming, selected=selected,
					itemType=classes[self.classMenu.index(
					Pmw.SELECT)].__name__)

import dialogs
dialogs.register(WriteSelDialog.name, WriteSelDialog)
예제 #9
0
			TextureDialog.defaultTexture = x
		tList.sort()
		self.menu.delete(0, Tkinter.END)
		for t in tList:
			self.menu.add_command(label=t,
						command=lambda s=self, t=t:
							s.__selectTexture(t))
		if cursel not in tList:
			cursel = None
		if not cursel:
			cursel = tList[0]
		self.__selectTexture(cursel)

	def updateTexture(self, image):
		if not self.texture:
			return
		w, h, depth, nc, nb = self.texture.sizes()
		if image.size[0] != w or image.size[1] != h:
			raise ValueError, 'image/texture size mismatch'
		self.texture.image = image

	def __textureHandler(self, trigger, closure, textures):
		if textures.created or textures.deleted:
			self.reloadTextures()
			return
		for t in textures.modified:
			if t == self.texture:
				self.editor.map.redrawIfNeeded()
import dialogs
dialogs.register(TextureDialog.name, TextureDialog)
예제 #10
0
	from CGLtk.color.ColorWell import _tkrgb2rgba
	w = Tkinter.Button(parent, text="Hello")
	bg = w.cget("bg")
	fg = w.cget("fg")
	disabledColor = w.cget("disabledforeground")
	b_r, b_g, b_b, b_a = _tkrgb2rgba(w.winfo_rgb(bg))
	f_r, f_g, f_b, f_a = _tkrgb2rgba(w.winfo_rgb(fg))
	w.destroy()
	r = b_r + (f_r - b_r) / 10.0
	g = b_g + (f_g - b_g) / 10.0
	b = b_b + (f_b - b_b) / 10.0
	alt_bg = rgba2tk((r, g, b, b_a))
	return (bg, alt_bg), disabledColor

import dialogs
dialogs.register(TaskPanel.name, TaskPanel)


#
# Code below are examples and not used by Chimera
#

class TestProcess:

	def __init__(self):
		self.checkCount = 0
		self.task = Task("test", self.cancelCB, self.statusCB)

	def cancelCB(self):
		self.finished()