def registerPreferences():
    import tkoptions

    class ReplyDisplayOption(tkoptions.EnumOption):
        """Specialization of EnumOption Class for side"""
        values = (DisplayReplyLog, DisplayDialog)

    class StatusClearingOption(tkoptions.SymbolicEnumOption):
        values = [5, 10, 20, 30, 60, 0]
        labels = [
            "5 seconds", "10 seconds", "20 seconds", "30 seconds", "1 minute",
            "never"
        ]

    ReplyPreferences = {
        SHOW_STATUS_LINE: (tkoptions.BooleanOption, Tk.YES, _showStatusLine),
        STATUS_CLEARING: (StatusClearingOption, 30, None),
        COMMAND: (ReplyDisplayOption, DisplayReplyLog, None),
        WARNING: (ReplyDisplayOption, DisplayDialog, None),
        ERROR: (ReplyDisplayOption, DisplayDialog, None)
    }
    ReplyPreferencesOrder = [
        SHOW_STATUS_LINE, STATUS_CLEARING, COMMAND, WARNING, ERROR
    ]

    import preferences
    preferences.register(REPLY_PREFERENCES, ReplyPreferences)
    preferences.setOrder(REPLY_PREFERENCES, ReplyPreferencesOrder)

    chimera.triggers.addHandler('status line', _statusLineShownCB, None)
Example #2
0
def registerPreferences():
	import tkoptions
	class ReplyDisplayOption(tkoptions.EnumOption):
		"""Specialization of EnumOption Class for side"""
		values = (DisplayReplyLog, DisplayDialog)
	class StatusClearingOption(tkoptions.SymbolicEnumOption):
		values = [5, 10, 20, 30, 60, 0]
		labels = ["5 seconds", "10 seconds", "20 seconds",
			"30 seconds", "1 minute", "never"]
	ReplyPreferences = {
		SHOW_STATUS_LINE: (tkoptions.BooleanOption, Tk.YES,
				   _showStatusLine),
		STATUS_CLEARING:(StatusClearingOption, 30, None),
		COMMAND:	(ReplyDisplayOption, DisplayReplyLog, None),
		WARNING:	(ReplyDisplayOption, DisplayDialog, None),
		ERROR:		(ReplyDisplayOption, DisplayDialog, None)
	}
	ReplyPreferencesOrder = [
		SHOW_STATUS_LINE, STATUS_CLEARING,
		COMMAND, WARNING, ERROR
	]

	import preferences
	preferences.register(REPLY_PREFERENCES, ReplyPreferences)
	preferences.setOrder(REPLY_PREFERENCES, ReplyPreferencesOrder)

	chimera.triggers.addHandler('status line', _statusLineShownCB, None)
def initializeCreditPreferences():
	if os.environ.has_key('NAME'):
		artist = os.environ['NAME']
	elif os.environ.has_key('USERNAME'):
		artist = os.environ['USERNAME']
	elif os.environ.has_key('USER'):
		artist = os.environ['USER']
	elif os.environ.has_key('LOGNAME'):
		artist = os.environ['LOGNAME']
	else:
		artist = ""
	prefs = {
		ARTIST: (StringOption, artist, None),
		COPYRIGHT: (StringOption, "", None)
	}
	prefOrder = [
		ARTIST, COPYRIGHT
	]
	preferences.register(IMAGE_CREDITS, prefs)
	preferences.setOrder(IMAGE_CREDITS, prefOrder)
Example #4
0
def initialize():
    backgroundPreferences = {
        BG_COLOR: (tkoptions.RGBAOption, None, _backgroundColorCB),
        LABEL_FONT: (tkoptions.FontOption,
                     (tkoptions.FontOption.names[0],
                      tkoptions.FontOption.styles[0], 16), setLabelFont),
    }
    backgroundPreferencesOrder = [
        BG_COLOR,
        LABEL_FONT,
    ]
    if isinstance(chimera.viewer, chimera.LensViewer):
        backgroundPreferences.update({
            HMETHOD:
            (HighlightOption, chimera.viewer.highlight, _highlightMethodCB),
            HCOLOR: (tkoptions.RGBAOption,
                     chimera.viewer.highlightColor.rgba(), _highlightColorCB, {
                         "noneOkay": False
                     }),
            #LENS_PROFILE: (
            #	tkoptions.BooleanOption, chimera.viewer.lensBorder,
            #	_drawBorderCB
            #),
            #LENS_COLOR: (
            #	tkoptions.RGBAOption, chimera.viewer.lensBorderColor.rgba(),
            #	_borderColorCB, { "noneOkay": False }
            #)
        })
        backgroundPreferencesOrder.extend([
            HMETHOD,
            HCOLOR,
        ])
    preferences.register(BACKGROUND,
                         backgroundPreferences,
                         onDisplay=_bgPrefDisp,
                         onHide=_bgPrefHide)
    preferences.setOrder(BACKGROUND, backgroundPreferencesOrder)

    opt = preferences.getOption(BACKGROUND, LABEL_FONT)
    setLabelFont(opt)
Example #5
0
def initialize():
	backgroundPreferences = {
		BG_COLOR: (
			tkoptions.RGBAOption, None, _backgroundColorCB
		),
		LABEL_FONT:
			(tkoptions.FontOption,
				(tkoptions.FontOption.names[0],
				tkoptions.FontOption.styles[0], 16),
				setLabelFont),
	}
	backgroundPreferencesOrder = [ BG_COLOR, LABEL_FONT, ]
	if isinstance(chimera.viewer, chimera.LensViewer):
		backgroundPreferences.update({
			HMETHOD: (
				HighlightOption, chimera.viewer.highlight,
				_highlightMethodCB
			),
			HCOLOR: (
				tkoptions.RGBAOption, chimera.viewer.highlightColor.rgba(),
				_highlightColorCB, { "noneOkay": False }
			),
			#LENS_PROFILE: (
			#	tkoptions.BooleanOption, chimera.viewer.lensBorder,
			#	_drawBorderCB
			#),
			#LENS_COLOR: (
			#	tkoptions.RGBAOption, chimera.viewer.lensBorderColor.rgba(),
			#	_borderColorCB, { "noneOkay": False }
			#)
		})
		backgroundPreferencesOrder.extend([
			HMETHOD, HCOLOR,
		])
	preferences.register(BACKGROUND, backgroundPreferences,
				onDisplay=_bgPrefDisp, onHide=_bgPrefHide)
	preferences.setOrder(BACKGROUND, backgroundPreferencesOrder)

	opt = preferences.getOption(BACKGROUND, LABEL_FONT)
	setLabelFont(opt)
class DirectoryOption(OutputFileOption):
    def __init__(self, *args, **kw):
        kw['title'] = 'Fetch by Id Download Directory'
        kw['dirsOnly'] = True
        OutputFileOption.__init__(self, *args, **kw)


fetchPreferences = {
    FETCH_SAVE: (BooleanOption, True, None),
    FETCH_LOCAL: (BooleanOption, True, None),
    FETCH_DIRECTORY: (DirectoryOption, '', None),
}
fetchPreferencesOrder = [FETCH_SAVE, FETCH_LOCAL, FETCH_DIRECTORY]
import preferences
preferences.register(FETCH_PREFERENCES, fetchPreferences)
preferences.setOrder(FETCH_PREFERENCES, fetchPreferencesOrder)


# -----------------------------------------------------------------------------
#
def fetch_local_file(save_dir, save_name):

    import preferences
    if not preferences.get(FETCH_PREFERENCES, FETCH_LOCAL):
        return None
    dir = preferences.get(FETCH_PREFERENCES, FETCH_DIRECTORY)
    if not dir:
        return None
    from os.path import join, isfile
    path = join(dir, save_dir, save_name)
Example #7
0
FETCH_LOCAL = 'Use local files'
FETCH_DIRECTORY = 'Download directory'
from tkoptions import BooleanOption, OutputFileOption
class DirectoryOption(OutputFileOption):
	def __init__(self, *args, **kw):
		kw['title'] = 'Fetch by Id Download Directory'
		kw['dirsOnly'] = True
		OutputFileOption.__init__(self, *args, **kw)
fetchPreferences = {
	FETCH_SAVE: (BooleanOption, True, None),
	FETCH_LOCAL: (BooleanOption, True, None),
	FETCH_DIRECTORY: (DirectoryOption, '', None),
}
fetchPreferencesOrder = [FETCH_SAVE, FETCH_LOCAL, FETCH_DIRECTORY]
import preferences
preferences.register(FETCH_PREFERENCES, fetchPreferences)
preferences.setOrder(FETCH_PREFERENCES, fetchPreferencesOrder)

# -----------------------------------------------------------------------------
#
def fetch_local_file(save_dir, save_name):

	import preferences
	if not preferences.get(FETCH_PREFERENCES, FETCH_LOCAL):
		return None
	dir = preferences.get(FETCH_PREFERENCES, FETCH_DIRECTORY)
	if not dir:
		return None
	from os.path import join, isfile
	path = join(dir, save_dir, save_name)
	if not isfile(path):
Example #8
0
PREF_PDB = "PDB"
PREF_PDB_FETCH = "Fetch from web\nas necessary"
PREF_PDB_DIRS = "Personal PDB\ndirectories"

# register prefs one-by-one in category
_pdbPreferences = {
	PREF_PDB_FETCH:
		(tkoptions.BooleanOption, 1, None),
	PREF_PDB_DIRS:
		(tkoptions.OrderedDirListOption, [], None),
}

_pdbPreferencesOrder = [
	PREF_PDB_FETCH, PREF_PDB_DIRS
]
preferences.register(PREF_PDB, _pdbPreferences)

preferences.setOrder(PREF_PDB, _pdbPreferencesOrder)


# preferences for newly-opened models
MOLECULE_DEFAULT = "New Molecules"
MOL_AUTOCOLOR = "use new color for each model"
MOL_SMART = "smart initial display"
MOL_COLOR = "otherwise, use color"
MOL_LINEWIDTH = LineWidthOption.name
MOL_RIBBONDISP = RibbonDisplayOption.name
MOL_RIBBONMODE = RibbonXSectionOption.name
MOL_RIBBONSCALE = RibbonScalingOption.name
MOL_HIDE_BACKBONE = RibbonHideBackboneOption.name
MOL_ATOMDRAW = AtomDrawModeOption.name
		chimera.viewer.clipping = False

	def run(self, master):
		if self.__dsVar.get():
			return True
		return ModalDialog.run(self, master)

	def Continue(self):
		self.Cancel(value=True)

def Continue(self):
		self.Cancel(value=True)

if chimera.nogui:
	#preferences.addCategory(IMAGE_SETUP, ImageSetupCategory)
	preferences.register(POVRAY_SETUP, povrayPreferences)
	preferences.setOrder(POVRAY_SETUP, povrayPreferencesOrder)
	initializeCreditPreferences()

povray_options = {
	LICENSE_AGREE: False
}
preferences.addCategory(POVRAY_AGREE, preferences.HiddenCategory,
							optDict=povray_options)
del povray_options

image_setup_options = {
	UNITS: "pixels",
	USE_PRINT_UNITS: False,
	DPI: 100,
	ADJUST_FOV: ONLY_STEREO_CAMERAS,