def fillInUI(self, parent):
		label = Tk.Label(parent,
			text="Warning: clipping is turned on (see Side View"
			" tool) and will severely slow down POV-Ray raytracing.",
			justify='left', height=2)
		import tkFont
		font = tkFont.Font(root=parent, font=label.cget('font'))
		label.config(wraplength=(self.text_width * font.measure('n')))
		label.grid(row=0, columnspan=2, sticky=Tk.W, pady=5)

		off = Tk.Button(parent, text="Turn off clipping",
				command=self.__turnOff)
		off.grid(row=1, column=0, pady=1)

		if ClipWarning.__dsVar is None:
			ClipWarning.__dsVar = Tk.IntVar(chimera.tkgui.app)
			ClipWarning.__dsVar.set(False)
		ds = Tk.Checkbutton(parent, variable=ClipWarning.__dsVar,
			text="Don't show dialog again")
		from tkFont import Font
		font = Font(font=ds.cget('font'))
		font.config(size=int(0.75*float(font.cget('size'))+0.5),
					weight='normal')
		ds.config(font=font)
		ds.grid(row=1, column=1, sticky=Tk.SE, pady=1)

		parent.rowconfigure(0, weight=1)
		parent.columnconfigure(0, weight=1)
Esempio n. 2
0
class TkFont():
    def __init__(self,
                 family="Calibri",
                 weight=NORMAL,
                 slant=ROMAN,
                 overstrike=0,
                 underline=0,
                 size=12):
        '''
        family: 字符集
        size: 字体大小
        weight: "bold" for boldface, "normal" for regular weight.        
        slant: "italic" for italic, "roman" for unslanted.        
        underline: 1 for underlined text, 0 for normal.
        overstrike: 1 for overstruck text, 0 for normal.
        '''
        self.font = Font(family=family,
                         weight=weight,
                         slant=slant,
                         overstrike=overstrike,
                         underline=underline,
                         size=size)

    def get_actual_font_info(self):
        return self.font.actual()

    def config(self, **kw):
        self.font.config(**kw)
Esempio n. 3
0
 def bolditalic_command(self,*args):
     current_tags = self.textPad.tag_names()
     bold_italic = Font(self.textPad, self.textPad.cget("font"))
     bold_italic.config(weight="bold",slant="italic")
     self.textPad.tag_config("bldita", font=bold_italic)
     if "bldita" in current_tags:
             self.textPad.tag_delete("bldita", '1.0', 'end-1c')
     else:
             self.textPad.tag_add("bldita", '1.0', 'end-1c')
Esempio n. 4
0
 def italic_command(self,*args):
     current_tags = self.textPad.tag_names()
     italics = Font(self.textPad, self.textPad.cget("font"))
     italics.config(slant="italic")
     self.textPad.tag_config("ita", font=italics)
     if "ita" in current_tags:
             self.textPad.tag_delete("ita", '1.0', 'end-1c')
     else:
             self.textPad.tag_add("ita", '1.0', 'end-1c')
Esempio n. 5
0
 def underline_command(self,*args):
     current_tags = self.textPad.tag_names()
     underline = Font(self.textPad, self.textPad.cget("font"))
     underline.config(underline=True)
     self.textPad.tag_config("und", font=underline)
     if "und" in current_tags:
             self.textPad.tag_delete("und", '1.0', 'end-1c')
     else:
             self.textPad.tag_add("und", '1.0', 'end-1c')
Esempio n. 6
0
 def font_command(self,*args):
     try:
             font_specs = askstring("Font", "Font Style-Font Size")
             font_specs = font_specs.split('-')
             new_font = Font(self.textPad, self.textPad.cget("font"))
             new_font.config(family=font_specs[0], size=font_specs[1])
             self.textPad.tag_config("newfont", font=new_font)
             self.textPad.tag_add("newfont", '1.0', 'end-1c')
     except:
             pass
Esempio n. 7
0
	def __init__(self, parent):
		Tkinter.Frame.__init__(self, parent)
		self.menu = Pmw.OptionMenu(self, items=self.ambiguity,
			label_text="Ambiguity codes:", labelpos='w',
			command=self._configureInfo)
		self.menu.grid(row=0)

		self.label = Tkinter.Label(self, bd=0, padx=0, pady=0)
		from tkFont import Font
		font = Font(font=self.label.cget('font'))
		font.config(size=int(0.75*float(font.cget('size'))+0.5),
							weight="normal")
		self.label.config(font=font)
		self.label.grid(row=1)
    def __init__(self, parent):
        Tkinter.Frame.__init__(self, parent)
        self.menu = Pmw.OptionMenu(self,
                                   items=self.ambiguity,
                                   label_text="Ambiguity codes:",
                                   labelpos='w',
                                   command=self._configureInfo)
        self.menu.grid(row=0)

        self.label = Tkinter.Label(self, bd=0, padx=0, pady=0)
        from tkFont import Font
        font = Font(font=self.label.cget('font'))
        font.config(size=int(0.75 * float(font.cget('size')) + 0.5),
                    weight="normal")
        self.label.config(font=font)
        self.label.grid(row=1)
Esempio n. 9
0
class TkFont():
    
    def __init__(self, family = "Calibri", weight = NORMAL, slant = ROMAN, overstrike = 0, underline = 0, size = 12):
        '''
        family: 字符集
        size: 字体大小
        weight: "bold" for boldface, "normal" for regular weight.        
        slant: "italic" for italic, "roman" for unslanted.        
        underline: 1 for underlined text, 0 for normal.
        overstrike: 1 for overstruck text, 0 for normal.
        '''
        self.font = Font(family = family, weight = weight, slant = slant, overstrike = overstrike, underline = underline, size = size)
    
    def get_actual_font_info(self):
        return self.font.actual()
    
    def config(self,**kw):
        self.font.config(**kw)
Esempio n. 10
0
	def __init__(self, master=None, title=None, buttons=None, default=None,
			help=None, oneshot=None, highlight=None, 
			keepShown=None, resizable=True, *args, **kw):
		if master == None:
			from tkgui import app
			master = app
		else:
			self.overMaster = True
		self._master = master
		self._toplevel = Tk.Toplevel(master, *args, **kw)
		self._toplevel.wm_group(master)
		if not self.overMaster:
			self._idleWaits = 0
			#self._toplevel.bind("<Map>", self._initialPosition)
			self._toplevel.after_idle(self._initialPosition)

		if title:
			self.title = title
		if not self.title:
			self.title = self.name
		if self.title:
			self._toplevel.title(self.title)
		if buttons:
			self.buttons = buttons
		if highlight and not default:
			default = highlight
		if default:
			self.default = default
		if not help is None:
			self.help = help
		if oneshot:
			self.oneshot = oneshot
		if keepShown:
			self.keepShown = keepShown
		if not resizable:
			self._toplevel.wm_resizable(0, 0)
		# 'OK' needs to be able to delay 'oneshot' destruction
		# until after the user-callback returns...
		self.delayOneshot = False
		#sys.__stderr__.write('Create dialog: %s %s\n' %
		#	(self.title, str(self._toplevel)))
		#self._toplevel.bind("<Destroy>", self.Destroy)
		self._toplevel.protocol('WM_DELETE_WINDOW', self.Cancel)
		if isinstance(self.buttons, basestring):
			# compensate for common error of buttons
			# not being a sequence.
			self.buttons = (self.buttons,)
		if Cancel in self.buttons:
			self._toplevel.bind("<Escape>",
						lambda e, c=self.Cancel: c())
		elif Close in self.buttons:
			self._toplevel.bind("<Escape>",
						lambda e, c=self.Close: c())

		bot = Tk.Frame(self._toplevel)
		bot.pack(side=Tk.BOTTOM, fill=Tk.X)
		hr = Tk.Frame(self._toplevel, relief=Tk.GROOVE,
						borderwidth=1, height=2)
		hr.pack(side=Tk.BOTTOM, fill=Tk.X)

		if self.keepShown:
			self.__ksVar = Tkinter.IntVar(bot)
			self.__ksVar.set(False)
			ckbut = Tkinter.Checkbutton(bot, variable=self.__ksVar,
				text="Keep dialog up after %s" % self.keepShown,
				command=self.__keepShownCB)
			from tkFont import Font
			font = Font(font=ckbut.cget('font'))
			font.config(size=int(0.75*float(font.cget('size'))+0.5),
						weight='normal')
			ckbut.config(font=font)
			ckbut.pack(side=Tk.TOP, anchor=Tk.SE)
			self.__keepShownCB() # set up initial button assignment

		if hasattr(self, 'provideStatus') and self.provideStatus:
			slkw = { 'anchor': 'w', 'justify': 'left' }
			if self.statusWidth:
				slkw['width'] = self.statusWidth
			if self.statusPosition == "above":
				slMaster = self._toplevel
			else:
				slMaster = bot
			self.statusLine = Tk.Label(slMaster, **slkw)
			self._statusBlankHandle = None
			if not self.statusResizing:
				self.statusLine.bind('<Map>', self._statusMapCB)
			if self.statusPosition == "above":
				self.statusLine.pack(side=Tk.BOTTOM, fill=Tk.X,
					expand=Tk.NO)
			else:
				self.statusLine.pack(side=Tk.LEFT, fill=Tk.BOTH,
					expand=Tk.YES)
		if self.help:
			import help
			help.register(self._toplevel, self.help)

		self.buttonWidgets = {}
		if resizable:
			sg = Ttk.Sizegrip(bot)
			sg.pack(anchor=Tk.SE, side=Tk.RIGHT)
		self.addSpecialButtons(bot)

		buttons = list(self.buttons[:])	# don't destroy original buttons
		# if Cancel or Close is present, it should be next to Help
		if Cancel in buttons:
			buttons.remove(Cancel)
			self.buttonWidgets[Cancel] = self.__addButton(bot,
						Cancel, self.default is Cancel)
		if Close in buttons:
			buttons.remove(Close)
			self.buttonWidgets[Close] = self.__addButton(bot,
						Close, self.default is Close)
		buttons.reverse()
		for b in buttons:
			self.buttonWidgets[b] = self.__addButton(bot, b,
							self.default == b)
		if self.name:
			import dialogs
			dialogs.reregister(self.name, self)

		# pack last, so that resizing dialog will not occlude
		# action buttons
		self.__top = Tk.Frame(self._toplevel)
		self.__top.pack(side=Tk.TOP, anchor=Tk.W, expand=1,
								fill=Tk.BOTH)
		# do this after pack so that fillInUI can show progress if
		# necessary
		self.fillInUI(self.__top)
Esempio n. 11
0
    def fillInUI(self, parent):
        import Pmw, Tkinter
        self.buttonWidgets['OK']['state'] = 'disabled'
        self.buttonWidgets['Apply']['state'] = 'disabled'
        from chimera.widgets import ModelScrolledListBox
        self.surfListBox = ModelScrolledListBox(
            parent,
            labelpos='n',
            label_text='Surfaces to color by ESP:',
            listbox_selectmode="extended",
            filtFunc=lambda m: isinstance(m, chimera.MSMSModel),
            selectioncommand=self._selSurfCB)
        self.surfListBox.grid(row=0, column=0, sticky="nsew", columnspan=2)
        Pmw.OptionMenu(parent,
                       command=self._menuCB,
                       initialitem="3",
                       items=[str(x) for x in range(2, 12)],
                       labelpos='w',
                       label_text="Number of colors/values:").grid(
                           row=1, column=0, columnspan=2)
        f = self.interpFrame = Tkinter.Frame(parent)
        f.grid(row=2, column=0, columnspan=2)
        self.wells = []
        self.values = []
        self._entryOpts = {
            'validate': 'real',
            'entry_justify': 'center',
            'entry_width': 6
        }
        from CGLtk.color.ColorWell import ColorWell
        for color, value in [("red", -10), ("white", 0), ("blue", 10)]:
            well = ColorWell(f, color=color)
            well.grid(row=0, column=len(self.wells))
            self.wells.append(well)
            entry = Pmw.EntryField(f, value=str(value), **self._entryOpts)
            entry.grid(row=1, column=len(self.values))
            self.values.append(entry)

        from chimera.tkoptions import FloatOption, BooleanOption
        self.distDep = BooleanOption(
            parent,
            3,
            "Distance-dependent dielectric",
            True,
            None,
            balloon="If true, charge falls off with distance squared to\n"
            "simulate solvent screening effects")
        self.dielectric = FloatOption(parent, 4, "Dielectric constant", 4.0,
                                      None)
        self.surfDist = FloatOption(parent,
                                    5,
                                    "Distance from surface",
                                    1.4,
                                    None,
                                    balloon="Potential at this distance from\n"
                                    "the surface is used for coloring")

        self.hisGroup = Pmw.Group(parent,
                                  hull_padx=2,
                                  tag_text="Implicit Histidine Protonation")
        self.hisGroup.grid(row=6, column=0, columnspan=2, sticky="nsew")
        self.hisProtVar = Tkinter.StringVar(parent)
        self.hisProtVar.set("name")
        interior = self.hisGroup.interior()
        interior.columnconfigure(0, weight=1)
        lab = Tkinter.Label(
            interior,
            text="Assumed histidine "
            "protonation for\nstructures without explicit hydrogens")
        from tkFont import Font
        font = Font(font=lab.cget('font'))
        font.config(size=int(0.75 * float(font.cget('size'))), slant='italic')
        lab.config(font=font)
        lab.grid(row=0)
        Tkinter.Radiobutton(interior,
                            variable=self.hisProtVar,
                            value="name",
                            text="Residue name-based",
                            command=self._switchHisList).grid(row=1,
                                                              sticky='w')
        f = Tkinter.Frame(interior)
        f.grid(row=2)
        Tkinter.Label(f,
                      text="HID/HIE/HIP = delta/epsilon/both").grid(row=0,
                                                                    sticky='w')
        self.hisDefault = Pmw.OptionMenu(
            f,
            initialitem=self.HB,
            items=[self.HB, "delta", "epsilon", "both"],
            labelpos='w',
            label_text="HIS = ",
            command=lambda a, s=self: setattr(s, 'hisChanged', True))
        self.hisDefault.grid(row=1, sticky='w')
        self._pickText = Tkinter.StringVar(parent)
        self._pickText.set("Specified individually...")
        Tkinter.Radiobutton(interior,
                            variable=self.hisProtVar,
                            value="pick",
                            textvariable=self._pickText,
                            command=self._switchHisList).grid(row=3,
                                                              sticky='w')

        Tkinter.Button(parent,
                       pady=0,
                       command=self._colorKeyCB,
                       text="Create corresponding color key").grid(
                           row=7, column=0, columnspan=2)
        self.hisChanged = False
Esempio n. 12
0
	def updateParamFont (self, widget, mul = 2, weight = 'bold'):
		font = Font (widget, widget['font'])
		font.config (size = int (round (mul * font['size'])), weight = weight)
		widget.config (font = font)
Esempio n. 13
0
	def fillInUI(self, parent):
		import Pmw, Tkinter
		self.buttonWidgets['OK']['state'] = 'disabled'
		self.buttonWidgets['Apply']['state'] = 'disabled'
		from chimera.widgets import ModelScrolledListBox
		self.surfListBox = ModelScrolledListBox(parent, labelpos='n',
			label_text='Surfaces to color by ESP:',
			listbox_selectmode="extended",
			filtFunc=lambda m: isinstance(m, chimera.MSMSModel),
			selectioncommand=self._selSurfCB)
		self.surfListBox.grid(row=0, column=0, sticky="nsew",
							columnspan=2)
		Pmw.OptionMenu(parent, command=self._menuCB, initialitem="3",
			items=[str(x) for x in range(2, 12)], labelpos='w',
			label_text="Number of colors/values:").grid(row=1,
			column=0, columnspan=2)
		f = self.interpFrame = Tkinter.Frame(parent)
		f.grid(row=2, column=0, columnspan=2)
		self.wells = []
		self.values = []
		self._entryOpts = {
			'validate': 'real',
			'entry_justify': 'center',
			'entry_width': 6
		}
		from CGLtk.color.ColorWell import ColorWell
		for color, value in [("red", -10), ("white", 0), ("blue", 10)]:
			well = ColorWell(f, color=color)
			well.grid(row=0, column=len(self.wells))
			self.wells.append(well)
			entry = Pmw.EntryField(f, value=str(value),
							**self._entryOpts)
			entry.grid(row=1, column=len(self.values))
			self.values.append(entry)

		from chimera.tkoptions import FloatOption, BooleanOption
		self.distDep = BooleanOption(parent, 3,
			"Distance-dependent dielectric", True, None, balloon=
			"If true, charge falls off with distance squared to\n"
			"simulate solvent screening effects")
		self.dielectric = FloatOption(parent, 4, "Dielectric constant",
								4.0, None)
		self.surfDist = FloatOption(parent, 5, "Distance from surface",
			1.4, None, balloon="Potential at this distance from\n"
			"the surface is used for coloring")

		self.hisGroup = Pmw.Group(parent, hull_padx=2,
			tag_text="Implicit Histidine Protonation")
		self.hisGroup.grid(row=6, column=0, columnspan=2, sticky="nsew")
		self.hisProtVar = Tkinter.StringVar(parent)
		self.hisProtVar.set("name")
		interior = self.hisGroup.interior()
		interior.columnconfigure(0, weight=1)
		lab = Tkinter.Label(interior, text="Assumed histidine "
			"protonation for\nstructures without explicit hydrogens")
		from tkFont import Font
		font = Font(font=lab.cget('font'))
		font.config(size=int(0.75 * float(font.cget('size'))),
								slant='italic')
		lab.config(font=font)
		lab.grid(row=0)
		Tkinter.Radiobutton(interior, variable=self.hisProtVar,
			value="name", text="Residue name-based", command=
			self._switchHisList).grid(row=1, sticky='w')
		f = Tkinter.Frame(interior)
		f.grid(row=2)
		Tkinter.Label(f, text="HID/HIE/HIP = delta/epsilon/both").grid(
			row=0, sticky='w')
		self.hisDefault = Pmw.OptionMenu(f, initialitem=self.HB,
			items=[self.HB, "delta", "epsilon", "both"], labelpos='w',
			label_text="HIS = ", command=lambda a, s=self:
			setattr(s, 'hisChanged', True))
		self.hisDefault.grid(row=1, sticky='w')
		self._pickText = Tkinter.StringVar(parent)
		self._pickText.set("Specified individually...")
		Tkinter.Radiobutton(interior, variable=self.hisProtVar,
			value="pick", textvariable=self._pickText,
			command=self._switchHisList).grid(row=3, sticky='w')

		Tkinter.Button(parent, pady=0, command=self._colorKeyCB,
			text="Create corresponding color key").grid(row=7,
			column=0, columnspan=2)
		self.hisChanged = False
Esempio n. 14
0
import Tkinter
from tkFont import Font

# weight/slant
NORMAL = "normal"
BOLD   = "bold"
ITALIC = "italic"

root = Tkinter.Tk()

def families(root=None):
    "Get font families (as a tuple)"
    if not root:
        root = Tkinter._default_root
    return root.tk.splitlist(root.tk.call("font", "families"))
def names(root=None):
    "Get names of defined fonts (as a tuple)"
    if not root:
        root = Tkinter._default_root
    return root.tk.splitlist(root.tk.call("font", "names"))
# create a font
f = Font(family="times", size=30, weight=NORMAL)
print f.actual()
print f.actual("family")
print f.actual("weight")
print f.config()
print f.cget("family")
print f.cget("weight")
print names()
    def __init__(self,
                 master=None,
                 title=None,
                 buttons=None,
                 default=None,
                 help=None,
                 oneshot=None,
                 highlight=None,
                 keepShown=None,
                 resizable=True,
                 *args,
                 **kw):
        if master == None:
            from tkgui import app
            master = app
        else:
            self.overMaster = True
        self._master = master
        self._toplevel = Tk.Toplevel(master, *args, **kw)
        self._toplevel.wm_group(master)
        if not self.overMaster:
            self._idleWaits = 0
            #self._toplevel.bind("<Map>", self._initialPosition)
            self._toplevel.after_idle(self._initialPosition)

        if title:
            self.title = title
        if not self.title:
            self.title = self.name
        if self.title:
            self._toplevel.title(self.title)
        if buttons:
            self.buttons = buttons
        if highlight and not default:
            default = highlight
        if default:
            self.default = default
        if not help is None:
            self.help = help
        if oneshot:
            self.oneshot = oneshot
        if keepShown:
            self.keepShown = keepShown
        if not resizable:
            self._toplevel.wm_resizable(0, 0)
        # 'OK' needs to be able to delay 'oneshot' destruction
        # until after the user-callback returns...
        self.delayOneshot = False
        #sys.__stderr__.write('Create dialog: %s %s\n' %
        #	(self.title, str(self._toplevel)))
        #self._toplevel.bind("<Destroy>", self.Destroy)
        self._toplevel.protocol('WM_DELETE_WINDOW', self.Cancel)
        if isinstance(self.buttons, basestring):
            # compensate for common error of buttons
            # not being a sequence.
            self.buttons = (self.buttons, )
        if Cancel in self.buttons:
            self._toplevel.bind("<Escape>", lambda e, c=self.Cancel: c())
        elif Close in self.buttons:
            self._toplevel.bind("<Escape>", lambda e, c=self.Close: c())

        bot = Tk.Frame(self._toplevel)
        bot.pack(side=Tk.BOTTOM, fill=Tk.X)
        hr = Tk.Frame(self._toplevel,
                      relief=Tk.GROOVE,
                      borderwidth=1,
                      height=2)
        hr.pack(side=Tk.BOTTOM, fill=Tk.X)

        if self.keepShown:
            self.__ksVar = Tkinter.IntVar(bot)
            self.__ksVar.set(False)
            ckbut = Tkinter.Checkbutton(bot,
                                        variable=self.__ksVar,
                                        text="Keep dialog up after %s" %
                                        self.keepShown,
                                        command=self.__keepShownCB)
            from tkFont import Font
            font = Font(font=ckbut.cget('font'))
            font.config(size=int(0.75 * float(font.cget('size')) + 0.5),
                        weight='normal')
            ckbut.config(font=font)
            ckbut.pack(side=Tk.TOP, anchor=Tk.SE)
            self.__keepShownCB()  # set up initial button assignment

        if hasattr(self, 'provideStatus') and self.provideStatus:
            slkw = {'anchor': 'w', 'justify': 'left'}
            if self.statusWidth:
                slkw['width'] = self.statusWidth
            if self.statusPosition == "above":
                slMaster = self._toplevel
            else:
                slMaster = bot
            self.statusLine = Tk.Label(slMaster, **slkw)
            self._statusBlankHandle = None
            if not self.statusResizing:
                self.statusLine.bind('<Map>', self._statusMapCB)
            if self.statusPosition == "above":
                self.statusLine.pack(side=Tk.BOTTOM, fill=Tk.X, expand=Tk.NO)
            else:
                self.statusLine.pack(side=Tk.LEFT, fill=Tk.BOTH, expand=Tk.YES)
        if self.help:
            import help
            help.register(self._toplevel, self.help)

        self.buttonWidgets = {}
        if resizable:
            sg = Ttk.Sizegrip(bot)
            sg.pack(anchor=Tk.SE, side=Tk.RIGHT)
        self.addSpecialButtons(bot)

        buttons = list(self.buttons[:])  # don't destroy original buttons
        # if Cancel or Close is present, it should be next to Help
        if Cancel in buttons:
            buttons.remove(Cancel)
            self.buttonWidgets[Cancel] = self.__addButton(
                bot, Cancel, self.default is Cancel)
        if Close in buttons:
            buttons.remove(Close)
            self.buttonWidgets[Close] = self.__addButton(
                bot, Close, self.default is Close)
        buttons.reverse()
        for b in buttons:
            self.buttonWidgets[b] = self.__addButton(bot, b, self.default == b)
        if self.name:
            import dialogs
            dialogs.reregister(self.name, self)

        # pack last, so that resizing dialog will not occlude
        # action buttons
        self.__top = Tk.Frame(self._toplevel)
        self.__top.pack(side=Tk.TOP, anchor=Tk.W, expand=1, fill=Tk.BOTH)
        # do this after pack so that fillInUI can show progress if
        # necessary
        self.fillInUI(self.__top)
Esempio n. 16
0
    def fillInUI(self, parent):
        self._handlers = {}
        desigGroup = Pmw.Group(parent, tag_text="Atoms to Check", hull_padx=2)
        desigGroup.grid(row=0, sticky="ew")
        from chimera.tkgui import windowSystem
        Tkinter.Button(desigGroup.interior(),
                       command=self._desigCB,
                       text="Designate").grid(row=0, column=0, sticky='e')
        Tkinter.Label(desigGroup.interior(),
                      text="currently selected"
                      " atoms for checking").grid(row=0, column=1, sticky='w')
        self.desigStatus = Tkinter.Label(desigGroup.interior())
        from tkFont import Font
        font = Font(font=self.desigStatus.cget('font'))
        size = int(font.cget('size'))
        if size > 2:
            font.config(size=size - 2)
        font.config(weight='normal')
        self.desigStatus.config(font=font)
        from chimera.selection import ItemizedSelection
        self.designated = ItemizedSelection(
            selChangedCB=self._updateDesigStatus)
        self.desigStatus.grid(row=1, column=0, columnspan=2)
        self.designated2 = ItemizedSelection(selChangedCB=self._locButtonCB)
        if windowSystem == 'aqua':
            pady = None
        else:
            pady = 0
        Tkinter.Button(desigGroup.interior(),
                       command=self._desig2CB,
                       pady=pady,
                       text="Designate selection as second set").grid(row=3,
                                                                      column=1)
        self.desig2Status = Tkinter.Label(desigGroup.interior())
        if size > 4:
            font2 = Font(font=font)
            font2.config(size=size - 4)
        else:
            font2 = font
        self.desig2Status.config(font=font2)
        self.desig2Status.grid(row=4, column=1)
        self.checkLocButtons = Pmw.RadioSelect(
            desigGroup.interior(),
            pady=0,
            orient='vertical',
            buttontype='radiobutton',
            labelpos='w',
            label_text="Check designated\natoms"
            " against:",
            command=self._locButtonCB)
        self.checkLocButtons.grid(row=2, column=0, columnspan=2)
        self.checkLocButtons.add("themselves")
        self.checkLocButtons.add("all other atoms")
        self.checkLocButtons.add("other atoms in same model")
        self.checkLocButtons.add(self.CHECK_SET)
        self.checkLocButtons.invoke(1)

        defGroup = Pmw.Group(parent,
                             tag_text="Clash/Contact Parameters",
                             hull_padx=2)
        defGroup.grid(row=1, sticky='ew')
        self.clashDef = ClashDef(defGroup.interior(),
                                 command=self._checkContinuous,
                                 value=str(prefs[CLASH_THRESHOLD]))
        self.clashDef.grid(row=0, sticky='w')
        self.hbondAllow = HbondAllow(defGroup.interior(),
                                     command=self._checkContinuous,
                                     value=str(prefs[HBOND_ALLOWANCE]))
        self.hbondAllow.grid(row=1, sticky='w')
        defaultsFrame = Tkinter.Frame(defGroup.interior())
        defaultsFrame.grid(row=2)
        Tkinter.Label(defaultsFrame, text="Default").grid(row=0, column=0)
        Tkinter.Button(defaultsFrame,
                       text="clash",
                       pady=pady,
                       command=self._clashDefaultsCB).grid(row=0, column=1)
        Tkinter.Label(defaultsFrame, text="/").grid(row=0, column=2)
        Tkinter.Button(defaultsFrame,
                       text="contact",
                       pady=pady,
                       command=self._contactDefaultsCB).grid(row=0, column=3)
        Tkinter.Label(defaultsFrame, text="criteria").grid(row=0, column=4)
        bondsFrame = Tkinter.Frame(defGroup.interior())
        bondsFrame.grid(row=3, sticky='w')
        self.bondsApart = Pmw.OptionMenu(bondsFrame,
                                         labelpos='w',
                                         label_text="Ignore contacts of pairs",
                                         command=self._checkContinuous,
                                         initialitem=str(
                                             prefs[BOND_SEPARATION]),
                                         items=[str(i + 2) for i in range(4)])
        self.bondsApart.grid(row=0, column=0)
        Tkinter.Label(bondsFrame, text="or fewer bonds apart").grid(row=0,
                                                                    column=1)
        self.ignoreIntraResVar = Tkinter.IntVar(parent)
        self.ignoreIntraResVar.set(prefs[IGNORE_INTRA_RES])
        Tkinter.Checkbutton(defGroup.interior(),
                            text="Ignore intra-"
                            "residue contacts",
                            variable=self.ignoreIntraResVar,
                            command=self._checkContinuous).grid(row=4)

        actionGroup = Pmw.Group(parent,
                                tag_text="Treatment of Clash/Contact Atoms",
                                hull_padx=2)
        actionGroup.grid(row=2, sticky='ew')
        self.actionSelVar = Tkinter.IntVar(parent)
        self.actionSelVar.set(prefs[ACTION_SELECT])
        Tkinter.Checkbutton(actionGroup.interior(),
                            text="Select",
                            command=self._checkContinuous,
                            variable=self.actionSelVar).grid(row=0, sticky='w')
        self.actionColorVar = Tkinter.IntVar(parent)
        self.actionColorVar.set(prefs[ACTION_COLOR])
        f = Tkinter.Frame(actionGroup.interior())
        f.grid(row=1, sticky='w')
        Tkinter.Checkbutton(f,
                            text="Color",
                            command=self._checkContinuous,
                            variable=self.actionColorVar).grid(row=0, column=0)
        from CGLtk.color.ColorWell import ColorWell
        self.clashColorWell = ColorWell(f,
                                        noneOkay=True,
                                        callback=self._checkContinuous,
                                        color=prefs[CLASH_COLOR])
        self.clashColorWell.grid(row=0, column=1)
        Tkinter.Label(f, text=" (and color all other atoms").grid(row=0,
                                                                  column=2)
        self.nonclashColorWell = ColorWell(f,
                                           noneOkay=True,
                                           callback=self._checkContinuous,
                                           color=prefs[NONCLASH_COLOR])
        self.nonclashColorWell.grid(row=0, column=3)
        Tkinter.Label(f, text=")").grid(row=0, column=4)
        self.actionPBVar = Tkinter.IntVar(parent)
        self.actionPBVar.set(prefs[ACTION_PSEUDOBONDS])
        f = Tkinter.Frame(actionGroup.interior())
        f.grid(row=2, sticky='w')
        Tkinter.Checkbutton(f,
                            text="Draw pseudobonds of color",
                            command=self._checkContinuous,
                            variable=self.actionPBVar).grid(row=0, column=0)
        from CGLtk.color.ColorWell import ColorWell
        self.pbColorWell = ColorWell(f,
                                     noneOkay=False,
                                     callback=self._checkContinuous,
                                     color=prefs[PB_COLOR])
        self.pbColorWell.grid(row=0, column=1)
        self.pbWidthEntry = Pmw.EntryField(f,
                                           labelpos='w',
                                           label_text=" and width",
                                           validate={
                                               'validator': 'real',
                                               'min': 0.01
                                           },
                                           entry_width=4,
                                           entry_justify="center",
                                           command=self._checkContinuous,
                                           value=str(prefs[PB_WIDTH]))
        self.pbWidthEntry.grid(row=0, column=2)
        self.actionAttrVar = Tkinter.IntVar(parent)
        self.actionAttrVar.set(prefs[ACTION_ATTR])
        self.assignAttrButton = Tkinter.Checkbutton(
            actionGroup.interior(),
            text="Assign 'overlap' attribute",
            variable=self.actionAttrVar)
        self.assignAttrButton.grid(row=3, sticky='w')
        self.actionWriteInfoVar = Tkinter.IntVar(parent)
        self.actionWriteInfoVar.set(prefs[ACTION_WRITEINFO])
        self.writeInfoButton = Tkinter.Checkbutton(
            actionGroup.interior(),
            text="Write information to"
            " file",
            variable=self.actionWriteInfoVar)
        self.writeInfoButton.grid(row=4, sticky='w')
        self.actionLogInfoVar = Tkinter.IntVar(parent)
        self.actionLogInfoVar.set(prefs[ACTION_REPLYLOG])
        self.logInfoButton = Tkinter.Checkbutton(
            actionGroup.interior(),
            text="Write information to"
            " reply log",
            variable=self.actionLogInfoVar)
        self.logInfoButton.grid(row=5, sticky='w')

        freqGroup = Pmw.Group(parent,
                              tag_text="Frequency of Checking",
                              hull_padx=2)
        freqGroup.grid(row=3, sticky="ew")
        self.freqButtons = Pmw.RadioSelect(freqGroup.interior(),
                                           pady=0,
                                           orient='vertical',
                                           buttontype='radiobutton',
                                           labelpos='w',
                                           label_text="Check...",
                                           command=self._freqChangeCB)
        self.freqButtons.grid(sticky='w')
        self.freqButtons.add(self.FREQ_APPLY)
        self.freqButtons.add(self.FREQ_MOTION)
        self.freqButtons.add(self.FREQ_CONTINUOUS)

        self.freqButtons.invoke(0)
        self._updateDesigStatus()
Esempio n. 17
0
	def fillInUI(self, parent):
		self._handlers = {}
		desigGroup = Pmw.Group(parent, tag_text="Atoms to Check", hull_padx=2)
		desigGroup.grid(row=0, sticky="ew")
		from chimera.tkgui import windowSystem
		Tkinter.Button(desigGroup.interior(), command=self._desigCB,
				text="Designate").grid(row=0, column=0, sticky='e')
		Tkinter.Label(desigGroup.interior(), text="currently selected"
			" atoms for checking").grid(row=0, column=1, sticky='w')
		self.desigStatus = Tkinter.Label(desigGroup.interior())
		from tkFont import Font
		font = Font(font=self.desigStatus.cget('font'))
		size = int(font.cget('size'))
		if size > 2:
			font.config(size=size-2)
		font.config(weight='normal')
		self.desigStatus.config(font=font)
		from chimera.selection import ItemizedSelection
		self.designated = ItemizedSelection(
					selChangedCB=self._updateDesigStatus)
		self.desigStatus.grid(row=1, column=0, columnspan=2)
		self.designated2 = ItemizedSelection(selChangedCB=self._locButtonCB)
		if windowSystem == 'aqua':
			pady = None
		else:
			pady = 0
		Tkinter.Button(desigGroup.interior(), command=self._desig2CB,
				pady=pady, text="Designate selection as second set"
				).grid(row=3, column=1)
		self.desig2Status = Tkinter.Label(desigGroup.interior())
		if size > 4:
			font2 = Font(font=font)
			font2.config(size=size-4)
		else:
			font2 = font
		self.desig2Status.config(font=font2)
		self.desig2Status.grid(row=4, column=1)
		self.checkLocButtons = Pmw.RadioSelect(desigGroup.interior(),
			pady=0, orient='vertical', buttontype='radiobutton',
			labelpos='w', label_text="Check designated\natoms"
			" against:", command=self._locButtonCB)
		self.checkLocButtons.grid(row=2, column=0, columnspan=2)
		self.checkLocButtons.add("themselves")
		self.checkLocButtons.add("all other atoms")
		self.checkLocButtons.add("other atoms in same model")
		self.checkLocButtons.add(self.CHECK_SET)
		self.checkLocButtons.invoke(1)

		defGroup = Pmw.Group(parent,
			tag_text="Clash/Contact Parameters", hull_padx=2)
		defGroup.grid(row=1, sticky='ew')
		self.clashDef = ClashDef(defGroup.interior(),
					command=self._checkContinuous,
					value=str(prefs[CLASH_THRESHOLD]))
		self.clashDef.grid(row=0, sticky='w')
		self.hbondAllow = HbondAllow(defGroup.interior(),
					command=self._checkContinuous,
					value=str(prefs[HBOND_ALLOWANCE]))
		self.hbondAllow.grid(row=1, sticky='w')
		defaultsFrame = Tkinter.Frame(defGroup.interior())
		defaultsFrame.grid(row=2)
		Tkinter.Label(defaultsFrame, text="Default").grid(
							row=0, column=0)
		Tkinter.Button(defaultsFrame, text="clash", pady=pady,
			command=self._clashDefaultsCB).grid(row=0, column=1)
		Tkinter.Label(defaultsFrame, text="/").grid(row=0, column=2)
		Tkinter.Button(defaultsFrame, text="contact", pady=pady,
			command=self._contactDefaultsCB).grid(row=0, column=3)
		Tkinter.Label(defaultsFrame, text="criteria").grid(
							row=0, column=4)
		bondsFrame = Tkinter.Frame(defGroup.interior())
		bondsFrame.grid(row=3, sticky='w')
		self.bondsApart = Pmw.OptionMenu(bondsFrame, labelpos='w',
			label_text="Ignore contacts of pairs",
			command=self._checkContinuous,
			initialitem=str(prefs[BOND_SEPARATION]),
			items=[str(i+2) for i in range(4)])
		self.bondsApart.grid(row=0, column=0)
		Tkinter.Label(bondsFrame, text="or fewer bonds apart").grid(
							row=0, column=1)
		self.ignoreIntraResVar = Tkinter.IntVar(parent)
		self.ignoreIntraResVar.set(prefs[IGNORE_INTRA_RES])
		Tkinter.Checkbutton(defGroup.interior(), text="Ignore intra-"
			"residue contacts", variable=self.ignoreIntraResVar,
			command=self._checkContinuous
			).grid(row=4)
			
		actionGroup = Pmw.Group(parent, tag_text=
				"Treatment of Clash/Contact Atoms", hull_padx=2)
		actionGroup.grid(row=2, sticky='ew')
		self.actionSelVar = Tkinter.IntVar(parent)
		self.actionSelVar.set(prefs[ACTION_SELECT])
		Tkinter.Checkbutton(actionGroup.interior(), text="Select",
			command=self._checkContinuous,
			variable=self.actionSelVar).grid(row=0, sticky='w')
		self.actionColorVar = Tkinter.IntVar(parent)
		self.actionColorVar.set(prefs[ACTION_COLOR])
		f = Tkinter.Frame(actionGroup.interior())
		f.grid(row=1, sticky='w')
		Tkinter.Checkbutton(f, text="Color",
			command=self._checkContinuous,
			variable=self.actionColorVar).grid(row=0, column=0)
		from CGLtk.color.ColorWell import ColorWell
		self.clashColorWell = ColorWell(f, noneOkay=True,
						callback=self._checkContinuous,
						color=prefs[CLASH_COLOR])
		self.clashColorWell.grid(row=0, column=1)
		Tkinter.Label(f, text=" (and color all other atoms").grid(row=0,
								column=2)
		self.nonclashColorWell = ColorWell(f, noneOkay=True,
						callback=self._checkContinuous,
						color=prefs[NONCLASH_COLOR])
		self.nonclashColorWell.grid(row=0, column=3)
		Tkinter.Label(f, text=")").grid(row=0, column=4)
		self.actionPBVar = Tkinter.IntVar(parent)
		self.actionPBVar.set(prefs[ACTION_PSEUDOBONDS])
		f = Tkinter.Frame(actionGroup.interior())
		f.grid(row=2, sticky='w')
		Tkinter.Checkbutton(f, text="Draw pseudobonds of color",
			command=self._checkContinuous,
			variable=self.actionPBVar).grid(row=0, column=0)
		from CGLtk.color.ColorWell import ColorWell
		self.pbColorWell = ColorWell(f, noneOkay=False,
						callback=self._checkContinuous,
						color=prefs[PB_COLOR])
		self.pbColorWell.grid(row=0, column=1)
		self.pbWidthEntry = Pmw.EntryField(f, labelpos='w',
			label_text=" and width", validate={'validator': 'real',
			'min': 0.01}, entry_width=4, entry_justify="center",
			command=self._checkContinuous,
			value=str(prefs[PB_WIDTH]))
		self.pbWidthEntry.grid(row=0, column=2)
		self.actionAttrVar = Tkinter.IntVar(parent)
		self.actionAttrVar.set(prefs[ACTION_ATTR])
		self.assignAttrButton = Tkinter.Checkbutton(
					actionGroup.interior(),
					text="Assign 'overlap' attribute",
					variable=self.actionAttrVar)
		self.assignAttrButton.grid(row=3, sticky='w')
		self.actionWriteInfoVar = Tkinter.IntVar(parent)
		self.actionWriteInfoVar.set(prefs[ACTION_WRITEINFO])
		self.writeInfoButton = Tkinter.Checkbutton(
			actionGroup.interior(), text="Write information to"
			" file", variable=self.actionWriteInfoVar)
		self.writeInfoButton.grid(row=4, sticky='w')
		self.actionLogInfoVar = Tkinter.IntVar(parent)
		self.actionLogInfoVar.set(prefs[ACTION_REPLYLOG])
		self.logInfoButton = Tkinter.Checkbutton(
			actionGroup.interior(), text="Write information to"
			" reply log", variable=self.actionLogInfoVar)
		self.logInfoButton.grid(row=5, sticky='w')

		freqGroup = Pmw.Group(parent, tag_text="Frequency of Checking",
								hull_padx=2)
		freqGroup.grid(row=3, sticky="ew")
		self.freqButtons = Pmw.RadioSelect(freqGroup.interior(),
			pady=0, orient='vertical', buttontype='radiobutton',
			labelpos='w', label_text= "Check...",
			command=self._freqChangeCB)
		self.freqButtons.grid(sticky='w')
		self.freqButtons.add(self.FREQ_APPLY)
		self.freqButtons.add(self.FREQ_MOTION)
		self.freqButtons.add(self.FREQ_CONTINUOUS)

		self.freqButtons.invoke(0)
		self._updateDesigStatus()
Esempio n. 18
0
import Tkinter
from tkFont import Font
# weight/slant
NORMAL = "normal"
BOLD = "bold"
ITALIC = "italic"
root = Tkinter.Tk()

def families(root=None):
    "Get font families (as a tuple)"
    if not root:
        root = Tkinter._default_root
    return root.tk.splitlist(root.tk.call("font", "families"))

def names(root=None):
    "Get names of defined fonts (as a tuple)"
    if not root:
        root = Tkinter._default_root
    return root.tk.splitlist(root.tk.call("font", "names"))

# create a font
f = Font(family="times", size=30, weight=NORMAL)
print f.actual()
print f.actual("family")
print f.actual("weight")
print f.config()
print f.cget("family")
print f.cget("weight")
print names()
print f.measure("hello"), f.metrics("linespace")