Example #1
0
def initialize_font():
    if "Open Sans" in tkFont.families():
        default_font = tkFont.nametofont("TkDefaultFont")
        default_font.configure(family="Open Sans", size=11)
        
        default_font = tkFont.nametofont("TkTextFont")
        default_font.configure(family="Open Sans", size=11)
 def test_families(self):
     families = font.families(self.root)
     self.assertIsInstance(families, tuple)
     self.assertTrue(families)
     for family in families:
         self.assertIsInstance(family, (str, unicode))
         self.assertTrue(family)
Example #3
0
def initialize_font():
    if "Open Sans" in tkFont.families():
        default_font = tkFont.nametofont("TkDefaultFont")
        default_font.configure(family="Open Sans", size=11)

        default_font = tkFont.nametofont("TkTextFont")
        default_font.configure(family="Open Sans", size=11)
Example #4
0
    def title_page(self):
        global size

        title = Tkinter.StringVar()
        self.configure(bg="white")
        self.label = Tkinter.Label(self, textvariable=title,font=(list(tkFont.families())[random.randint(0,100)],32,"bold","underline"), fg=self.snake_color)
        self.label.grid(column=1,row=0)
        title.set("SNAKE");

        card = Tkinter.PhotoImage(file="/Users/aaronliberatore/Documents/snake/snake/turtle.gif")
        self.img = Tkinter.Label(self, image=card)
        self.img.image = card
        self.img.grid(column=1,row=2)

        self.columnconfigure(0,minsize=(size / 3))
        self.columnconfigure(1,minsize=(size / 3))
        self.columnconfigure(2,minsize=(size / 3))

        self.button = Tkinter.Button(self,text="Slow!", command=self.slow)
        self.button.grid(column=0,row=3)

        self.button1 = Tkinter.Button(self,text="Medium!", command=self.medium)
        self.button1.grid(column=1,row=3)

        self.button2 = Tkinter.Button(self,text="Fast!", command=self.fast)
        self.button2.grid(column=2,row=3)
Example #5
0
def set_mono(tkroot):
  global timer
  families = tkFont.families(tkroot)
  for font in families:
    if font.lower().find('mono')<>-1:
      timer = (font, int(float(height)*4./3.))
      return
 def fontAttributeToolbar( self, parent ):
    lst = list(tkFont.families( ))
    lst.sort()
    
    familyList    = [ name for name in lst if name[0] != '@' ]
    szList        = [ str(x) for x in range(6,31) ]
    stippleValues = [ '', 'gray12', 'gray25', 'gray50', 'gray75' ]
    reliefValues  = [ 'flat','sunken','raised','groove','ridge','solid']
    
    fontFrame = Toolset( parent )
    familyCombo = fontFrame.addCombo(  'families',   self._fontFamily, familyList, Font.DEFAULT_FONT['family'], width=15, command=self.onChooseAttribute('family', self._fontFamily))
    familyCombo.subwidget('listbox').config( width=30, height=20 )
    fontFrame.addCombo(  'sizes',      self._fontSize, szList,     Font.DEFAULT_FONT['size'],   width=3,  command=self.onChooseAttribute('size',   self._fontSize))
    fontFrame.addPushButton( 'bold',       self._bold,     text='B', font=Toolset.FONT + ' bold', command=self.onToggleAttribute('bold') )
    fontFrame.addPushButton( 'italic',     self._italic,      text='I', font=Toolset.FONT + ' italic', command=self.onToggleAttribute('italic') )
    fontFrame.addPushButton( 'underline',  self._underline,  text='U', font=Toolset.FONT + ' underline', command=self.onToggleAttribute('underline') )
    fontFrame.addPushButton( 'overstrike', self._overstrike, text='O', font=Toolset.FONT + ' overstrike', command=self.onToggleAttribute('overstrike') )
    fontFrame.addCombo(  'offset',     self._offset, ['normal','superscript','subscript'], 'normal', width=9, command=self.onChooseAttribute('offset',self._offset))
    self._fgColorButton = fontFrame.addButton( 'fgColor',    text='A', font=Toolset.FONT + ' bold', command=self.onChangeColor('foreground') )
    #self._bgColorButton = fontFrame.addButton( 'bgColor',    text='A', font=Toolset.FONT + ' bold', command=self.onChangeColor('background') )
    #fontFrame.addCombo(  'bgColor',    text='A', font=Toolset.FONT + ' bold', command=self.onChangeBG )
    #fontFrame.addCombo(  'fgStipple',  self._fgstipple, stippleValues, '', width=5, command=self.onChooseAttribute('fgstipple', self._fgstipple))
    #fontFrame.addCombo(  'bgStipple',  self._bgstipple, stippleValues, '', width=5, command=self.onChooseAttribute('bgstipple', self._bgstipple))
    fontFrame.addLabel(  'border',     text='border' )
    le = fontFrame.addEntry(  'bdwidth',    self._borderwidth, width=4 )
    le.bind( '<FocusOut>', self.onChooseAttribute('borderwidth',self._borderwidth) )
    fontFrame.addCombo(  'relief',     self._relief, reliefValues, 'flat', width=5, command=self.onChooseAttribute('relief',self._relief))
    
    return fontFrame
Example #7
0
 def test_families(self):
     families = font.families(self.root)
     self.assertIsInstance(families, tuple)
     self.assertTrue(families)
     for family in families:
         self.assertIsInstance(family, (str, unicode))
         self.assertTrue(family)
Example #8
0
    def title_page(self):
        global size

        title = Tkinter.StringVar()
        self.configure(bg="white")
        self.label = Tkinter.Label(
            self,
            textvariable=title,
            font=(list(tkFont.families())[random.randint(0, 100)], 32, "bold",
                  "underline"),
            fg=self.snake_color)
        self.label.grid(column=1, row=0)
        title.set("SNAKE")

        card = Tkinter.PhotoImage(
            file="/Users/aaronliberatore/Documents/snake/snake/turtle.gif")
        self.img = Tkinter.Label(self, image=card)
        self.img.image = card
        self.img.grid(column=1, row=2)

        self.columnconfigure(0, minsize=(size / 3))
        self.columnconfigure(1, minsize=(size / 3))
        self.columnconfigure(2, minsize=(size / 3))

        self.button = Tkinter.Button(self, text="Slow!", command=self.slow)
        self.button.grid(column=0, row=3)

        self.button1 = Tkinter.Button(self,
                                      text="Medium!",
                                      command=self.medium)
        self.button1.grid(column=1, row=3)

        self.button2 = Tkinter.Button(self, text="Fast!", command=self.fast)
        self.button2.grid(column=2, row=3)
Example #9
0
        def create_font_list_widget():
            frame = tk.Frame(self)
            frame.pack(fill=tk.BOTH)

            self.font_listbox = tk.Listbox(
                frame, takefocus=tk.FALSE, exportselection=tk.FALSE)

            font_scrollbar= tk.Scrollbar(frame)

            fonts = list(tkFont.families(self))
            fonts = list(set(fonts))
            fonts.sort()
            for font in fonts:
                self.font_listbox.insert(tk.END, font)
            if self.font_name in fonts:
                activate_index = fonts.index(self.font_name)
            else:
                activate_index = 0
            self.font_listbox.selection_set(activate_index)
            self.font_listbox.see(activate_index)

            font_scrollbar.config(command=self.font_listbox.yview)
            self.font_listbox.config(yscrollcommand=font_scrollbar.set)

            tk.Label(frame, text=u'字体:', anchor=tk.N).pack(
                side=tk.LEFT, fill=tk.Y)
            self.font_listbox.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
            font_scrollbar.pack(side=tk.LEFT, fill=tk.Y)
Example #10
0
    def LoadFontCfg(self):
        ##base editor font selection list
        fonts = list(tkFont.families(self))
        fonts.sort()
        for font in fonts:
            self.listFontName.insert(END, font)
        configuredFont = self.parent.cfg.get("FONT", "family")
        lc_configuredFont = configuredFont.lower()
        self.fontName = lc_configuredFont  # .set(lc_configuredFont)
        lc_fonts = [s.lower() for s in fonts]
        if lc_configuredFont in lc_fonts:
            currentFontIndex = lc_fonts.index(lc_configuredFont)
            self.listFontName.see(currentFontIndex)
            self.listFontName.select_set(currentFontIndex)
            self.listFontName.select_anchor(currentFontIndex)
        ##font size dropdown
        counter = 0
        selSize = 1
        self.fontSize = self.parent.cfg.get("FONT", "size")
        for size in range(7, 40):
            self.listFontSize.insert(END, size)
            if size == int(self.fontSize):
                selSize = counter
            counter = counter + 1

        self.listFontSize.see(selSize)
        self.listFontSize.select_set(selSize)
        self.listFontSize.select_anchor(selSize)
        ##fontWeight
        if self.parent.cfg.get("FONT", "weight") == "normal":
            self.fontBold.set(False)
        else:
            self.fontBold.set(True)
        ##font sample
        self.SetFontSample()
Example #11
0
 def gui_creator(self):
     # font family selector combobox
     Label(text="Font Family").grid(row=0, column=0)
     fontList = ttk.Combobox(textvariable=self.family)
     fontList.grid(row=1, column=0, columnspan=2, sticky=N + S + E + W, padx=10)
     fontList.bind("<<ComboboxSelected>>", self.on_value_change)
     allfonts = list(tkFont.families())
     allfonts.sort()
     fontList["values"] = allfonts
     # Font Sizes
     Label(text="Font Size").grid(row=0, column=2)
     sizeList = ttk.Combobox(textvariable=self.fontsize)
     sizeList.bind("<<ComboboxSelected>>", self.on_value_change)
     sizeList.grid(row=1, column=2, columnspan=2, sticky=N + S + E + W, padx=10)
     allfontsizes = range(6, 70)
     sizeList["values"] = allfontsizes
     # Font Styles
     Checkbutton(
         text="bold", variable=self.fontweight, command=self.on_value_change, onvalue="bold", offvalue="normal"
     ).grid(row=2, column=0)
     Checkbutton(
         text="italic", variable=self.slant, command=self.on_value_change, onvalue="italic", offvalue="roman"
     ).grid(row=2, column=1)
     Checkbutton(
         text="underline", variable=self.underlinevalue, command=self.on_value_change, onvalue=True, offvalue=False
     ).grid(row=2, column=2)
     Checkbutton(
         text="overstrike", variable=self.overstrikevalue, command=self.on_value_change, onvalue=True, offvalue=False
     ).grid(row=2, column=3)
     self.text = Text(height=5, width=50)
     self.text.grid(row=3, column=0, columnspan=4, padx=10, pady=10)
     sampletext = "The quick brown fox jumps over the lazy dog"
     self.text.insert(INSERT, "%s\n%s" % (sampletext, sampletext.upper()), "fontspecs")
     self.text.config(state=DISABLED)
 def gui_creator(self):
    #font family selector combobox
    Label(text='Font Family').grid(row=0, column=0)
    fontList = ttk.Combobox(textvariable=self.family)
    fontList.grid(row=1, column=0, columnspan=2, sticky=N+S+E+W, padx=10)
    fontList.bind('<<ComboboxSelected>>', self.on_value_change)
    allfonts = list(tkFont.families())
    allfonts.sort()
    fontList['values'] =  allfonts
    # Font Sizes
    Label(text='Font Size').grid(row=0, column=2)
    sizeList = ttk.Combobox(textvariable=self.fontsize)
    sizeList.bind('<<ComboboxSelected>>', self.on_value_change)
    sizeList.grid(row=1, column=2, columnspan=2, sticky=N+S+E+W, padx=10)
    allfontsizes = range(6,70)
    sizeList['values'] =  allfontsizes
    # Font Styles
    Checkbutton(text='bold',  variable=self.fontweight, command=self.on_value_change,onvalue='bold', offvalue='normal' ).grid(row=2, column=0)
    Checkbutton(text='italic', variable=self.slant, command=self.on_value_change, onvalue='italic', offvalue='roman' ).grid(row=2, column=1)
    Checkbutton(text='underline',variable=self.underlinevalue, command=self.on_value_change,onvalue=True, offvalue=False  ).grid(row=2, column=2)
    Checkbutton(text='overstrike', variable=self.overstrikevalue, command=self.on_value_change,  onvalue=True ,offvalue=False ).grid(row=2, column=3)
    self.text = Text(height=5, width=50)
    self.text.grid(row=3, column=0, columnspan=4, padx=10, pady=10)
    sampletext ='The quick brown fox jumps over the lazy dog'
    self.text.insert(INSERT, '%s\n%s'%(sampletext,sampletext.upper()), 'fontspecs')
    self.text.config(state=DISABLED)
Example #13
0
    def body( self, master ):
        theRow = 0

        Label( master, text="Font Family" ).grid( row=theRow, column=0 )
        Label( master, text="Font Size" ).grid( row=theRow, column=2 )

        theRow += 1

        # Font Families
        fontList = ttk.Combobox( master,  height=10, textvariable=self._family )
        fontList.grid( row=theRow, column=0, columnspan=2, sticky=N+S+E+W, padx=10 )
        first = None
        rawfamilyList = list(tkFont.families( ))
        rawfamilyList.sort()
        # print rawfamilyList
        familyList=[]
        for family in rawfamilyList:
            if family[0] == '@':
                continue
            familyList.append(family)
        fontList.configure( values=familyList )
        fontList.bind('<<ComboboxSelected>>', self.selectionChanged)

        # Font Sizes
        sizeList = ttk.Combobox( master,  height=10, width=5, textvariable=self._sizeString )
        sizeList.grid( row=theRow, column=2, columnspan=2, sticky=N+S+E+W, padx=10 )
        sizes=[]
        for size in xrange( 10,50 ):
            sizes.append( str(size) )
        sizeList.configure( values=sizes)
        sizeList.bind('<<ComboboxSelected>>', self.selectionChanged)

        # Styles
        if self._showStyles is not None:
            theRow += 1
            if self._showStyles in ( FontChooser.ALL, FontChooser.BASIC ):
                Label( master, text='Styles', anchor=W ).grid( row=theRow, column=0, pady=10, sticky=W )

                theRow += 1

                Checkbutton( master, text="bold", command=self.selectionChanged, offvalue='normal', onvalue='bold', variable=self._weight ).grid(row=theRow, column=0)
                Checkbutton( master, text="italic", command=self.selectionChanged, offvalue='roman', onvalue='italic', variable=self._slant ).grid(row=theRow, column=1)

        if self._showStyles == FontChooser.ALL:
            Checkbutton( master, text="underline", command=self.selectionChanged, offvalue=False, onvalue=True, variable=self._isUnderline ).grid(row=theRow, column=2)
            Checkbutton( master, text="overstrike", command=self.selectionChanged, offvalue=False, onvalue=True, variable=self._isOverstrike ).grid(row=theRow, column=3)

        # Sample Text
            theRow += 1

            Label( master, text='Sample Text', anchor=W ).grid( row=theRow, column=0, pady=10, sticky=W )

            theRow += 1

            self.sampleText = Text( master, height=11, width=70 )
            self.sampleText.insert( INSERT,'ABC...XYZ\nabc....xyz', 'fontStyle' )
            self.sampleText.config( state=DISABLED )
            self.sampleText.tag_config( 'fontStyle', font=self._currentFont )
            self.sampleText.grid( row=theRow, column=0, columnspan=4, padx=10 )
    def body( self, master ):
        theRow = 0

        Label( master, text="Font Family" ).grid( row=theRow, column=0 )
        Label( master, text="Font Size" ).grid( row=theRow, column=2 )

        theRow += 1

        # Font Families
        fontList = ttk.Combobox( master,  height=10, textvariable=self._family )
        fontList.grid( row=theRow, column=0, columnspan=2, sticky=N+S+E+W, padx=10 )
        rawfamilyList = list(tkFont.families( ))
        rawfamilyList.sort()
        # print rawfamilyList
        familyList=[]
        for family in rawfamilyList:
            if family[0] == '@':
                continue
            familyList.append(family)
        fontList.configure( values=familyList )
        fontList.bind('<<ComboboxSelected>>', self.selectionChanged)

        # Font Sizes
        sizeList = ttk.Combobox( master,  height=10, width=5, textvariable=self._sizeString )
        sizeList.grid( row=theRow, column=2, columnspan=2, sticky=N+S+E+W, padx=10 )
        sizes=[]
        for size in xrange( 10,50 ):
            sizes.append( str(size) )
        sizeList.configure( values=sizes)
        sizeList.bind('<<ComboboxSelected>>', self.selectionChanged)

        # Styles
        if self._showStyles is not None:
            theRow += 1
            if self._showStyles in ( FontChooser.ALL, FontChooser.BASIC ):
                Label( master, text='Styles', anchor=W ).grid( row=theRow, column=0, pady=10, sticky=W )

                theRow += 1

                Checkbutton( master, text="bold", command=self.selectionChanged, offvalue='normal', onvalue='bold', variable=self._weight ).grid(row=theRow, column=0)
                Checkbutton( master, text="italic", command=self.selectionChanged, offvalue='roman', onvalue='italic', variable=self._slant ).grid(row=theRow, column=1)

        if self._showStyles == FontChooser.ALL:
            Checkbutton( master, text="underline", command=self.selectionChanged, offvalue=False, onvalue=True, variable=self._isUnderline ).grid(row=theRow, column=2)
            Checkbutton( master, text="overstrike", command=self.selectionChanged, offvalue=False, onvalue=True, variable=self._isOverstrike ).grid(row=theRow, column=3)

        # Sample Text
            theRow += 1

            Label( master, text='Sample Text', anchor=W ).grid( row=theRow, column=0, pady=10, sticky=W )

            theRow += 1

            self.sampleText = Text( master, height=11, width=70 )
            self.sampleText.insert( INSERT,'ABC...XYZ\nabc....xyz', 'fontStyle' )
            self.sampleText.config( state=DISABLED )
            self.sampleText.tag_config( 'fontStyle', font=self._currentFont )
            self.sampleText.grid( row=theRow, column=0, columnspan=4, padx=10 )
Example #15
0
    def __init__(self, root, family, size, bold, italic, underline, anchor, eventHandler):
        self.root = root
        self.family = family
        self.size = size
        self.bold = bold
        self.italic = italic
        self.underline = underline
        self.anchor = anchor
        self.eventHandler = eventHandler

        self.familyScrollbar = Tkinter.Scrollbar(root, orient=Tkinter.VERTICAL)
        self.familyListbox = Tkinter.Listbox(root, yscrollcommand=self.familyScrollbar.set, selectmode=Tkinter.BROWSE, exportselection=0, height = 7)
        allFontsList = list(tkFont.families())
        allFontsList.sort()
        for font in allFontsList:
            self.familyListbox.insert(Tkinter.END, font)
        self.familyScrollbar.config(command=self.familyListbox.yview)

        self.familyListbox.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=1)
        self.familyListbox.bind("<ButtonRelease>",self.checkFamilyChange)
        self.familyScrollbar.pack(side=Tkinter.LEFT, fill=Tkinter.Y)

        self.sizeScrollbar = Tkinter.Scrollbar(root, orient=Tkinter.VERTICAL)
        self.sizeListbox = Tkinter.Listbox(root, yscrollcommand=self.sizeScrollbar.set, selectmode=Tkinter.BROWSE, width = 5, exportselection=0, height = 7)
        for size in [6,8,9,10,12,14,16,18,20,22,24,26,28,36,48,72]:
            self.sizeListbox.insert(Tkinter.END, size)
        self.sizeListbox.see(4)
        self.sizeScrollbar.config(command=self.sizeListbox.yview)

        self.sizeListbox.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=1)
        self.sizeListbox.bind("<ButtonRelease>",self.checkSizeChange)
        self.sizeScrollbar.pack(side=Tkinter.LEFT, fill=Tkinter.Y)

        self.optionFrame = Tkinter.Frame(root)
        h = 40
        w = 40
        
        boldxbm      = '@' + str( os.path.join( GRAPHIC_EDITOR_DATA, 'bold.xbm' ) )
        italicxbm    = '@' + str( os.path.join( GRAPHIC_EDITOR_DATA, 'italic.xbm' ) )
        underlinexbm = '@' + str( os.path.join( GRAPHIC_EDITOR_DATA, 'underline.xbm' ) )
        
        self.boldButton = Tkinter.Button(self.optionFrame, bitmap=boldxbm, height = h, width = w, command = self.onBold)
        self.italicButton = Tkinter.Button(self.optionFrame, bitmap=italicxbm, height = h, width = w, command = self.onItalic)
        self.underlineButton = Tkinter.Button(self.optionFrame, bitmap=underlinexbm, height = h, width = w, command = self.onUnderline)
        if self.bold:
            self.boldButton.config(relief=Tkinter.SUNKEN)
        if self.italic:
            self.italicButton.config(relief=Tkinter.SUNKEN)
        if self.underline:
            self.underlineButton.config(relief=Tkinter.SUNKEN)

        self.boldButton.pack(side=Tkinter.LEFT)
        self.italicButton.pack(side=Tkinter.LEFT)
        self.underlineButton.pack(side=Tkinter.LEFT)

        self.anchorChooser = AnchorChooser(root, self, self.anchor)

        self.optionFrame.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=1)
Example #16
0
 def body( self, master ):
    theRow = 0
    
    Tix.Label( master, text="Font Family" ).grid( row=theRow, column=0 )
    Tix.Label( master, text="Font Size" ).grid( row=theRow, column=2 )
    
    theRow += 1
    
    # Font Families
    fontList = Tix.ComboBox( master, command=self.selectionChanged, dropdown=False, editable=False, selectmode=Tix.IMMEDIATE, variable=self._family )
    fontList.grid( row=theRow, column=0, columnspan=2, sticky=Tix.N+Tix.S+Tix.E+Tix.W, padx=10 )
    first = None
    familyList = list(tkFont.families( ))
    familyList.sort()
    for family in familyList:
       if family[0] == '@':
          continue
       if first is None:
          first = family
       fontList.insert( Tix.END, family )
    fontList.configure( value=first )
    
    # Font Sizes
    sizeList = Tix.ComboBox( master, command=self.selectionChanged, dropdown=False, editable=False, selectmode=Tix.IMMEDIATE, variable=self._sizeString )
    sizeList.grid( row=theRow, column=2, columnspan=2, sticky=Tix.N+Tix.S+Tix.E+Tix.W, padx=10 )
    for size in xrange( 6,31 ):
       sizeList.insert( Tix.END, '%d' % size )
    sizeList.configure( value='9' )
    
    # Styles
    if self._showStyles is not None:
       theRow += 1
       
       if self._showStyles in ( FontChooser.ALL, FontChooser.BASIC ):
          Tix.Label( master, text='Styles', anchor=Tix.W ).grid( row=theRow, column=0, pady=10, sticky=Tix.W )
          
          theRow += 1
          
          Tix.Checkbutton( master, text="bold", command=self.selectionChanged, offvalue='normal', onvalue='bold', variable=self._weight ).grid(row=theRow, column=0)
          Tix.Checkbutton( master, text="italic", command=self.selectionChanged, offvalue='roman', onvalue='italic', variable=self._slant ).grid(row=theRow, column=1)
       
       if self._showStyles == FontChooser.ALL:
          Tix.Checkbutton( master, text="underline", command=self.selectionChanged, offvalue=False, onvalue=True, variable=self._isUnderline ).grid(row=theRow, column=2)
          Tix.Checkbutton( master, text="overstrike", command=self.selectionChanged, offvalue=False, onvalue=True, variable=self._isOverstrike ).grid(row=theRow, column=3)
    
    # Sample Text
    theRow += 1
    
    Tix.Label( master, text='Sample Text', anchor=Tix.W ).grid( row=theRow, column=0, pady=10, sticky=Tix.W )
    
    theRow += 1
    
    self.sampleText = Tix.Text( master, height=11, width=70 )
    self.sampleText.insert( Tix.INSERT,
                            'ABCDEFGHIJKLMNOPQRSTUVWXYZ\nabcdefghijklmnopqrstuvwxyz', 'fontStyle' )
    self.sampleText.config( state=Tix.DISABLED )
    self.sampleText.tag_config( 'fontStyle', font=self._currentFont )
    self.sampleText.grid( row=theRow, column=0, columnspan=4, padx=10 )
Example #17
0
 def findfont(self, names):
     "Return name of first font family derived from names."
     for name in names:
         if name.lower() in (x.lower() for x in tkfont.names(root=self)):
             font = tkfont.Font(name=name, exists=True, root=self)
             return font.actual()['family']
         elif name.lower() in (x.lower()
                               for x in tkfont.families(root=self)):
             return name
Example #18
0
 def findfont(self, names):
     "Return name of first font family derived from names."
     for name in names:
         if name.lower() in (x.lower() for x in tkfont.names(root=self)):
             font = tkfont.Font(name=name, exists=True, root=self)
             return font.actual()['family']
         elif name.lower() in (x.lower()
                               for x in tkfont.families(root=self)):
             return name
Example #19
0
    def __init__(self,master,error_sv,text,family="Helvetica",pointsize="12",weight="normal",group="subject",name=""):
        Frame.__init__(self,master)
        
        self.error_sv = error_sv
        
        rgb_label = Label(self,text=text,anchor=CENTER)
        rgb_label.grid(row=0,column=0,columnspan=2,pady=2)
    
        family_label = Label(self,text="Family",anchor=W)
        family_label.grid(row=1,column=0,sticky=E)
        self.family_entry_sv = StringVar()
        family_entry = Combobox(self,width=13,textvariable=self.family_entry_sv,
                                 values=tkFont.families())
        family_entry.grid(row=1,column=1,sticky=W,pady=2,padx=4)
        self.family_entry_sv.set(family)
        
        pointsize_label = Label(self,text="Pointsize")
        pointsize_label.grid(row=2,column=0,sticky=E)
        self.pointsize_entry_sv = StringVar()
        pointsize_entry = Entry(self,textvariable=self.pointsize_entry_sv,width=3)
        pointsize_entry.grid(row=2,column=1,sticky=W,pady=2,padx=4)
        self.pointsize_entry_sv.set(pointsize)
        
        weight_label = Label(self,text="Font",anchor=E,justify=RIGHT)
        weight_label.grid(row=3,column=0,sticky=E,pady=6)
        self.weight_entry_sv = StringVar()
        weight_entry = Combobox(self,width=13,textvariable=self.weight_entry_sv,values=["bold","italic","normal"])
        weight_entry.grid(row=3,column=1,sticky=W,padx=4)
        self.weight_entry_sv.set(weight)
        
        group_label = Label(self,text="Group",anchor=E,justify=RIGHT)
        group_label.grid(row=4,column=0,sticky=E,pady=6)
        self.group_entry_sv = StringVar()
    
        group_entry = Combobox(self,width=13,textvariable=self.group_entry_sv,values=["subject","recordType","teacher","status"])
        group_entry.grid(row=4,column=1,sticky=W,padx=4)
        self.group_entry_sv.set(group)
        
        name_label = Label(self,text="Name",anchor=E,justify=RIGHT)
        name_label.grid(row=5,column=0,sticky=E,pady=6)
        self.name_entry_sv = StringVar()
    
        name_entry = Entry(self,textvariable=self.name_entry_sv,width=13)
        name_entry.grid(row=5,column=1,sticky=W,padx=4)
        self.name_entry_sv.set(name)
        
        self.weight_entry_sv.trace("w",lambda name,index,mode,sv=self.weight_entry_sv:self.onchange())
        self.pointsize_entry_sv.trace("w",lambda name,index,mode,sv=self.pointsize_entry_sv:self.onchange())
        self.family_entry_sv.trace("w",lambda name,index,mode,sv=self.family_entry_sv:self.onchange())
        #self.group_entry_sv.trace("w",lambda name,index,mode,sv=self.fgroup_entry_sv:self.onchange())
        
        self.grid_columnconfigure(0,weight=1,uniform="foo")
        self.grid_columnconfigure(1,weight=2,uniform="foo")

        for i in range(5):
            self.grid_rowconfigure(i,weight=1,uniform="foo")
Example #20
0
 def header_font(self):
     if "header" in self.fonts:
         return self.fonts["header"]
     font_families = sorted(Tkf.families(self.master))
     if "Liberation Sans" in font_families:
         family = "Liberation Sans"
     else:
         family = "Tahoma"
     font = Tkf.Font(family=family, size=13, weight=Tkf.BOLD)
     self.fonts["header"] = font
     return font
Example #21
0
def nextFont(window, editor):
    window.font_num += 1
    font_name = tkFont.families()[window.font_num]
    sys.stdout.write(font_name + '\n')
    window.title(font_name)
    font = tkFont.Font(family=font_name, size=20, weight='bold')
    editor = tk.Text(window, font=font)
    editor.grid(column=0, row=0)
    for x in range(0, len(text), NB_COLS):
        editor.insert("end", text[x:x + NB_COLS])
        editor.insert("end", "\n")
    window.bt['command'] = lambda window=window, editor=editor: nextFont(
        window, editor)
Example #22
0
 def gui_creator(self):
     #font family selector combobox
     Label(text='Font Family').grid(row=0, column=0)
     fontList = ttk.Combobox(textvariable=self.family)
     fontList.grid(row=1,
                   column=0,
                   columnspan=2,
                   sticky=N + S + E + W,
                   padx=10)
     fontList.bind('<<ComboboxSelected>>', self.on_value_change)
     allfonts = list(tkFont.families())
     allfonts.sort()
     fontList['values'] = allfonts
     # Font Sizes
     Label(text='Font Size').grid(row=0, column=2)
     sizeList = ttk.Combobox(textvariable=self.fontsize)
     sizeList.bind('<<ComboboxSelected>>', self.on_value_change)
     sizeList.grid(row=1,
                   column=2,
                   columnspan=2,
                   sticky=N + S + E + W,
                   padx=10)
     allfontsizes = range(6, 70)
     sizeList['values'] = allfontsizes
     # Font Styles
     Checkbutton(text='bold',
                 variable=self.fontweight,
                 command=self.on_value_change,
                 onvalue='bold',
                 offvalue='normal').grid(row=2, column=0)
     Checkbutton(text='italic',
                 variable=self.slant,
                 command=self.on_value_change,
                 onvalue='italic',
                 offvalue='roman').grid(row=2, column=1)
     Checkbutton(text='underline',
                 variable=self.underlinevalue,
                 command=self.on_value_change,
                 onvalue=True,
                 offvalue=False).grid(row=2, column=2)
     Checkbutton(text='overstrike',
                 variable=self.overstrikevalue,
                 command=self.on_value_change,
                 onvalue=True,
                 offvalue=False).grid(row=2, column=3)
     self.text = Text(height=5, width=50)
     self.text.grid(row=3, column=0, columnspan=4, padx=10, pady=10)
     sampletext = 'The quick brown fox jumps over the lazy dog'
     self.text.insert(INSERT, '%s\n%s' % (sampletext, sampletext.upper()),
                      'fontspecs')
     self.text.config(state=DISABLED)
Example #23
0
	def body(self, master):
		self.fontEntry = Entry(master, width=20, textvariable=self.fontVar)
		self.fontEntry.delete(0, END)
		self.fontEntry.insert(INSERT, self.font)
		self.fontEntry.grid(row=0, column=0, sticky=E+W)
		self.fontComboMenu = ComboMenu(master, attachto=self.fontEntry, text=">")
		self.fontComboMenu.setList(sorted(tkFont.families()))
		self.fontComboMenu.grid(row=0, column=1, sticky=W)

		self.sizeEntry = Entry(master, width=3, textvariable=self.sizeVar)
		self.sizeEntry.delete(0, END)
		self.sizeEntry.insert(INSERT, self.size)
		self.sizeEntry.grid(row=0, column=2, sticky=W)
		self.sizeComboMenu = ComboMenu(master, attachto=self.sizeEntry, text=">")
		self.sizeComboMenu.setList(map(str, range(8,73)))
		self.sizeComboMenu.grid(row=0, column=3, sticky=W)

		global icondir
		self.boldIcon = default_icons.getIcon("text-bold")
		self.italicIcon = default_icons.getIcon("text-italic")

		Checkbutton(master, text=" B ", indicatoron=False, variable=self.boldVar, image=self.boldIcon).grid(row=0, column=4)
		if self.isBold:
			self.boldVar.set(True)
		Checkbutton(master, text=" I ", indicatoron=False, variable=self.italicVar, image=self.italicIcon).grid(row=0, column=5)
		if self.isItalic:
			self.italicVar.set(True)

		#self.update_idletasks()

		Label(master, text="Preview:").grid(row=1, column=0, sticky=W)

		self.previewCanvas = Canvas(master, height=120, width=50, bg="white")
		self.previewFont = Label(self.previewCanvas, text="ABCDEFGHIJKLM\nNOPQRSTUVWXYZ\nabcdefghijklm\nnopqrstuvwxyz\n0123456789", bg="white", justify=LEFT, font=(self.font, self.size, self.style))
		self.previewCanvas.create_window((0,0), window=self.previewFont, anchor=NW)
		self.previewCanvas.grid(row=2, column=0, columnspan=6, sticky=E+W)

		self.viewScrollY = AutoScrollbar(master, orient=VERTICAL, command=self.previewCanvas.yview)
		self.viewScrollY.grid(row=2, column=7, stick=NS+W)
		self.previewCanvas["yscrollcommand"] = self.viewScrollY.set

		self.viewScrollX = AutoScrollbar(master, orient=HORIZONTAL, command=self.previewCanvas.xview)
		self.viewScrollX.grid(row=3, column=0, stick=EW)
		self.previewCanvas["xscrollcommand"] = self.viewScrollX.set

		# The Tk variables to monitor for changes (for updating Preview)
		self.fontVar.trace_variable("w", self.setPreview)
		self.sizeVar.trace_variable("w", self.setPreview)
		self.boldVar.trace_variable("w", self.setPreview)
		self.italicVar.trace_variable("w", self.setPreview)
def main(root, text, menubar):
    objFormat = Format(text)

    fontoptions = families(root)
    font = Font(family="Verdana", size=10)

    formatMenu = Menu(menubar)

    fsubmenu = Menu(formatMenu, tearoff=0)
    ssubmenu = Menu(formatMenu, tearoff=0)

    for option in fontoptions:
        fsubmenu.add_command(label=option,
                             command=lambda: font.configure(family=option))
    for value in range(1, 31):
        ssubmenu.add_command(label=str(value),
                             command=lambda: font.configure(size=value))

    formatMenu.add_command(label="Change Background",
                           command=objFormat.changeBg)
    formatMenu.add_command(label="Change Font Color",
                           command=objFormat.changeFg)
    formatMenu.add_cascade(label="Font", underline=0, menu=fsubmenu)
    formatMenu.add_cascade(label="Size", underline=0, menu=ssubmenu)
    formatMenu.add_command(label="Bold",
                           command=objFormat.bold,
                           accelerator="Ctrl+B")
    formatMenu.add_command(label="Italic",
                           command=objFormat.italic,
                           accelerator="Ctrl+I")
    formatMenu.add_command(label="Underline",
                           command=objFormat.underline,
                           accelerator="Ctrl+U")
    formatMenu.add_command(label="Overstrike",
                           command=objFormat.overstrike,
                           accelerator="Ctrl+T")
    formatMenu.add_command(label="Add Date", command=objFormat.addDate)
    menubar.add_cascade(label="Format", menu=formatMenu)

    root.bind_all("<Control-b>", objFormat.bold)
    root.bind_all("<Control-i>", objFormat.italic)
    root.bind_all("<Control-u>", objFormat.underline)
    root.bind_all("<Control-T>", objFormat.overstrike)

    root.grid_columnconfigure(0, weight=1)
    root.resizable(True, True)

    root.config(menu=menubar)
Example #25
0
 def __init__(self, master=None, callback=None, **kwargs):
     """
     :param master: master widget
     :param callback: callable object with single argument: font family name
     :param kwargs: keyword arguments passed on to AutocompleteCombobox initializer
     """
     font_families = sorted([item for item in font.families()])
     self._fonts = font_families
     self._font = tk.StringVar(master)
     self.__callback = callback
     AutocompleteCombobox.__init__(self,
                                   master,
                                   textvariable=self._font,
                                   completevalues=font_families,
                                   **kwargs)
     self.bind("<<ComboboxSelected>>", self._on_select)
 def __init__(self, master=None, callback=None, **kwargs):
     """
     :param master: master widget
     :param callback: callable object with one argument: the font family name
     :param kwargs: keyword arguments passed to ScrolledListbox, in turn passed to Listbox
     """
     ScrolledListbox.__init__(self, master, compound=tk.RIGHT, **kwargs)
     self._callback = callback
     font_names = sorted(font.families())
     index = 0
     self.font_indexes = {}
     for name in font_names:
         self.listbox.insert(index, name)
         self.font_indexes[index] = name
         index += 1
     self.listbox.bind("<Button-1>", self._on_click)
Example #27
0
    def body(self, master):
        self.resizable(0, 0)
        theRow = 0
        Tkinter.Label(master, text="Font Family").grid(row=theRow, column=0)
        Tkinter.Label(master, text="Font Size").grid(row=theRow, column=2)
        theRow += 1
        # Font Families

        self.familyList = list(tkFont.families())
        self.familyList.sort()
        self.sizeList = []

        for i in range(6, 30):
            self.sizeList.append(i)
        self.fontBox = ttk.Combobox(master, values=self.familyList)
        self.sizeBox = ttk.Combobox(master, values=self.sizeList)


        if self._family.get() in self.familyList:
            self.fontBox.current(self.familyList.index(self._family.get()))
        elif _default_font in self.familyList:
            self.fontBox.current(self.familyList.index(_default_font))
        self.sizeBox.current(self.sizeList.index(int(self._size.get())))


        self.defaultFont = tkFont.Font(font=self.getFontTuple())

        self.fontBox.grid(row=theRow, column=0, columnspan=2, sticky=Tkinter.N + Tkinter.S + Tkinter.E + Tkinter.W, padx=10)
        self.fontBox.bind("<<ComboboxSelected>>", self.modifyFont)
        self.sizeBox.grid(row=theRow, column=2, columnspan=2, sticky=Tkinter.N + Tkinter.S + Tkinter.E + Tkinter.W, padx=10)
        self.sizeBox.bind("<<ComboboxSelected>>", self.modifyFont)
        theRow += 1

        Tkinter.Label(master, text='Styles', anchor=Tkinter.W).grid(row=theRow, column=0, pady=10, sticky=Tkinter.W)
        theRow += 1
        Tkinter.Checkbutton(master, command=self.modifyStyle, text="bold", offvalue='normal', onvalue='bold', variable=self._weight).grid(row=theRow, column=0)
        Tkinter.Checkbutton(master, command=self.modifyStyle, text="italic", offvalue='roman', onvalue='italic', variable=self._slant).grid(row=theRow, column=1)
        Tkinter.Checkbutton(master, command=self.modifyStyle, text="underline", offvalue=False, onvalue=True, variable=self._isUnderline).grid(row=theRow, column=2)
        theRow += 1
        Tkinter.Label(master, text='Sample Text', anchor=Tkinter.W).grid(row=theRow, column=0, pady=10, sticky=Tkinter.W)
        theRow += 1
        self.sampleText = Tkinter.Text(master, height=11, width=50, background="black")
        self.sampleText.insert(Tkinter.INSERT,
                                'ABCDEFGHIJKLMNOPQRSTUVWXYZ\nabcdefghijklmnopqrstuvwxyz\nA vile force of darkness has arrived!', 'fontStyle')
        self.sampleText.config(state=Tkinter.DISABLED)
        self.sampleText.tag_config('fontStyle', font=self.defaultFont, foreground="red")
        self.sampleText.grid(row=theRow, column=0, columnspan=4, padx=10)
Example #28
0
 def _mkfonts(self, fontmap=None):
     fontmap = fontmap or FONTS
     fonts = {}
     families = tkFont.families()
     for key, desc in fontmap.items():
         fs = desc.get('family')
         
         for f in fs:
             if f in families:
                 desc['family'] = f
                 break
             break
         else:
             del desc['family']
         fonts[key] = apply(tkFont.Font,(),desc)
         
     return fonts
Example #29
0
    def _mkfonts(self, fontmap=None):
        fontmap = fontmap or FONTS
        fonts = {}
        families = tkFont.families()
        for key, desc in fontmap.items():
            fs = desc.get('family')

            for f in fs:
                if f in families:
                    desc['family'] = f
                    break
                break
            else:
                del desc['family']
            fonts[key] = apply(tkFont.Font, (), desc)

        return fonts
Example #30
0
	def __init__(self, master = None):
		# call the frame constructor
		Frame.__init__(self, master)

		# give the calculator a 10 pixel border all around
		self.grid(padx=10, pady=10)

		# try Bitsteam Vera font first cause its a cool (and open-source)
		if "Bitstream Vera Sans Mono" in tkFont.families():
			self.font = tkFont.Font(family="Bitstream Vera Sans Mono", size="14")
		else:
			self.font = tkFont.Font(family="Courier", size="14")

		# populate the widgets
		self.__populate()

		# Call Calculator class constructor
		Calculator.__init__(self, display = self.display)


		# the functions of the calculator
		self.functions = {
			"add":[CFunctions.add, "+", 2, self.TYPE_OPERATOR],
			"subtract":[CFunctions.subtract, "-", 2, self.TYPE_OPERATOR],
			"multiply":[CFunctions.multiply, "*", 2, self.TYPE_OPERATOR],
			"divide":[CFunctions.divide, u"\u00F7", 2, self.TYPE_OPERATOR],
			"tan":[math.tan, "Tan", 1, self.TYPE_FUNCTION],
			"sin":[math.sin, "Sin", 1, self.TYPE_FUNCTION],
			"cos":[math.cos, "Cos", 1, self.TYPE_FUNCTION],
			"atan":[math.tan, "aTan", 1, self.TYPE_FUNCTION],
			"asin":[math.sin, "aSin", 1, self.TYPE_FUNCTION],
			"acos":[math.cos, "aCos", 1, self.TYPE_FUNCTION],
			"todegree":[math.degrees, ">Deg", 1, self.TYPE_FUNCTION],
			"toradian":[math.radians, ">Rad", 1, self.TYPE_FUNCTION],
			"pow":[CFunctions.pow, "^", 2, self.TYPE_OPERATOR],
			"mod":[CFunctions.fmod, "%", 2, self.TYPE_OPERATOR],
			"factorial":[CFunctions.factorial, "Factorial", 1, self.TYPE_FUNCTION],
			"log":[CFunctions.log, "log", 2, self.TYPE_FUNCTION],
			"ln":[math.log, "ln", 1, self.TYPE_FUNCTION],
			"sqrt":[decimal.Decimal.sqrt, u"\u221A", 1, self.TYPE_FUNCTION],
			"exp":[math.exp, "e^", 1, self.TYPE_FUNCTION],
		}
		# set the binds (virtual and keys)
		self.__setBinds()
Example #31
0
    def __init__(self, parent, parenttab, name, section, paramprefix):
        EditInput.__init__(self, parent, parenttab, name)
        self._section = section
        self._paramprefix = paramprefix
        
        fontlist = list(tkFont.families())
        fontlist.sort()
        self._bvb = tki.BooleanVar()
        self._bvi = tki.BooleanVar()
        self._bvs = tki.BooleanVar()
        self._bvu = tki.BooleanVar()
        
        l = tki.Label(self, text = lang[lng.txtFontsize])
        l.grid(row = 0, column = 0, padx = 5, pady = 2, sticky = tki.W)
        
        tcmd = (self.register(self._ehOnValidateEntry), '%d', '%P')
        e = tki.Entry(self, validate = 'key', validatecommand = tcmd, width = _sizechars)
        self._esize = e
        e.grid(row = 1, column = 0, padx = 5, pady = 2, sticky = tki.W)

        l = tki.Label(self, text = lang[lng.txtFontName])
        l.grid(row = 2, column = 0, padx = 5, pady = 2, sticky = tki.W)
        
        cb = Combobox(self, values = fontlist)
        self._cbfontname = cb
        cb.grid(row = 3, column = 0, padx = 5, pady = 2, sticky = tki.W)
        cb.bind('<<ComboboxSelected>>', self._setDirty)
        cb.current(0)

        cb = tki.Checkbutton(self, text = lang[lng.txtBold], onvalue = True, offvalue = False, variable = self._bvb, command = self._setDirty)
        self._cbb = cb
        cb.grid(row = 0, column = 1, padx = 5, pady = 2, sticky = tki.W)
        
        cb = tki.Checkbutton(self, text = lang[lng.txtItalics], onvalue = True, offvalue = False, variable = self._bvi, command = self._setDirty)
        self._cbi = cb
        cb.grid(row = 1, column = 1, padx = 5, pady = 2, sticky = tki.W)

        cb = tki.Checkbutton(self, text = lang[lng.txtStrikethrough], onvalue = True, offvalue = False, variable = self._bvs, command = self._setDirty)
        self._cbs = cb
        cb.grid(row = 2, column = 1, padx = 5, pady = 2, sticky = tki.W)

        cb = tki.Checkbutton(self, text = lang[lng.txtUnderline], onvalue = True, offvalue = False, variable = self._bvu, command = self._setDirty)
        self._cbu = cb
        cb.grid(row = 3, column = 1, padx = 5, pady = 2, sticky = tki.W)
Example #32
0
    def LoadFontCfg(self):
        fonts = list(tkFont.families(self))
        fonts.sort()
        for font in fonts:
            self.listFontName.insert(END, font)

        configuredFont = idleConf.GetOption('main', 'EditorWindow', 'font', default='courier')
        lc_configuredFont = configuredFont.lower()
        self.fontName.set(lc_configuredFont)
        lc_fonts = [ s.lower() for s in fonts ]
        if lc_configuredFont in lc_fonts:
            currentFontIndex = lc_fonts.index(lc_configuredFont)
            self.listFontName.see(currentFontIndex)
            self.listFontName.select_set(currentFontIndex)
            self.listFontName.select_anchor(currentFontIndex)
        fontSize = idleConf.GetOption('main', 'EditorWindow', 'font-size', type='int', default='10')
        self.optMenuFontSize.SetMenu(('7', '8', '9', '10', '11', '12', '13', '14', '16', '18', '20', '22'), fontSize)
        self.fontBold.set(idleConf.GetOption('main', 'EditorWindow', 'font-bold', default=0, type='bool'))
        self.SetFontSample()
Example #33
0
    def LoadFontCfg(self):
        fonts = list(tkFont.families(self))
        fonts.sort()
        for font in fonts:
            self.listFontName.insert(END, font)

        configuredFont = idleConf.GetOption('main', 'EditorWindow', 'font', default='courier')
        lc_configuredFont = configuredFont.lower()
        self.fontName.set(lc_configuredFont)
        lc_fonts = [ s.lower() for s in fonts ]
        if lc_configuredFont in lc_fonts:
            currentFontIndex = lc_fonts.index(lc_configuredFont)
            self.listFontName.see(currentFontIndex)
            self.listFontName.select_set(currentFontIndex)
            self.listFontName.select_anchor(currentFontIndex)
        fontSize = idleConf.GetOption('main', 'EditorWindow', 'font-size', type='int', default='10')
        self.optMenuFontSize.SetMenu(('7', '8', '9', '10', '11', '12', '13', '14', '16', '18', '20', '22'), fontSize)
        self.fontBold.set(idleConf.GetOption('main', 'EditorWindow', 'font-bold', default=0, type='bool'))
        self.SetFontSample()
Example #34
0
 def __init__( self, parent, value):
     available_families = list( tkFont.families())
     available_families.sort()
     available_families.insert(-1, '')
     for fnt in data.always_available_fonts:
       available_families.insert(1, fnt)
     if not value in available_families:
       v = ''
     else:
       v = value
     Pmw.ScrolledListBox.__init__( self,
                                   parent,
                                   labelpos = 'nw',
                                   label_text = _('Font family'),
                                   listbox_selectmode = 'single',
                                   items = available_families,
                                   hull_relief = 'ridge')
     self.select_set( available_families.index( v))
     self.see( available_families.index( v))
	def body(self, master):
		# get data 
		self.resizable(0,0)
		self.fonts = list(tkFont.families())
		self.fonts.sort()

		# prepare the widgets
		self.listbox_font_family = Listbox(master)
		self.entry_font_size = Entry(master)
		self.lbl_font_family = Label(master, text="Choose font: ")
		self.lbl_font_size = Label(master, text="Choose font size: ")

		for font in self.fonts:
			self.listbox_font_family.insert(END, font)

		# grid the widgets onto the window
		self.lbl_font_family.grid(row=0)
		self.lbl_font_size.grid(row=1)
		self.listbox_font_family.grid(row=0, column=1)
		self.entry_font_size.grid(row=1, column=1)
Example #36
0
 def body(self, master):
     self._npFrame = LabelFrame(master, text='Annotation window text')
     self._npFrame.pack(fill=X)
     self._fontFrame = Frame(self._npFrame, borderwidth=0)
     self._fontLabel = Label(self._fontFrame, text='Font:', width=5)
     self._fontLabel.pack(side=LEFT, padx=3)
     self._fontCombo = Combobox(self._fontFrame, values=sorted(families()),
                                state='readonly')
     self._fontCombo.pack(side=RIGHT, fill=X)
     self._sizeFrame = Frame(self._npFrame, borderwidth=0)
     self._sizeLabel = Label(self._sizeFrame, text='Size:', width=5)
     self._sizeLabel.pack(side=LEFT, padx=3)
     self._sizeCombo = Combobox(self._sizeFrame, values=range(8,15),
                                state='readonly')
     self._sizeCombo.pack(side=RIGHT, fill=X)
     self._fontFrame.pack()
     self._sizeFrame.pack()
     self._npFrame.pack(fill=X)
     self._fontCombo.set(self.font)
     self._sizeCombo.set(self.size)
Example #37
0
 def body(self, master):
     frm = tk.Frame(self)
     frm.pack(side=tk.TOP, fill=tk.X)
     tk.Label(frm, text='Font').pack(side=tk.LEFT)
     fonts = tkFont.families(self)
     self.font_family.set(ReciteWord.DEFAULT_FONT)
     tk.OptionMenu(frm, self.font_family, *fonts).pack(side=tk.LEFT)
     tk.Spinbox(frm,
                from_=10,
                to=36,
                increment=1,
                textvariable=self.font_size,
                width=3).pack(side=tk.LEFT)
     tk.Button(frm, text='Apply', command=self.use_font).pack(side=tk.LEFT)
     tk.Button(frm, text='Modify',
               command=self.edit_word).pack(side=tk.RIGHT)
     tk.Checkbutton(frm, variable=self.switch_hide, textvariable=self.switch_label, command=self.on_switch_changed).\
         pack(side=tk.RIGHT)
     ttk.Separator(master, orient=tk.HORIZONTAL).pack(side=tk.TOP,
                                                      fill=tk.X)
     frm = tk.Frame(master)
     frm.pack(side=tk.TOP, fill=tk.BOTH, expand=tk.YES)
     self.canvas = tk.Canvas(frm, confine=True)
     self.canvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=tk.YES)
     scroll = tk.Scrollbar(frm,
                           orient=tk.VERTICAL,
                           command=self.canvas.yview)
     scroll.pack(side=tk.RIGHT, fill=tk.Y)
     self.canvas.config(yscrollcommand=scroll.set)
     scroll = tk.Scrollbar(master,
                           orient=tk.HORIZONTAL,
                           command=self.canvas.xview)
     scroll.pack(side=tk.TOP, fill=tk.X)
     self.canvas.config(xscrollcommand=scroll.set)
     self.canvas.tag_bind('CLICK_AREA', '<Button-1>',
                          self.on_click_mask)  # left mouse button pressed
     self.canvas.tag_bind('CLICK_AREA', '<B1-Motion>',
                          self.on_move_mask)  # left mouse button moved
     self.canvas.bind('<MouseWheel>', self.on_canvas_scroll)  # up or down
     self.canvas.bind('<Shift-MouseWheel>',
                      self.on_canvas_scroll2)  # left or right
Example #38
0
def menu_font_family(gui):
    def set_to(fam):
        return lambda *args: gui.set_font_family_to('%s' % (fam, ), *args)

    menu = []
    submenu = []
    fams = filter(lambda x: 'a' <= x[0].lower() and x[0].lower() <= 'z',
                  tkFont.families())
    fams = utils.seq_sorted(fams, key=lambda n: n.lower())
    for i in range(len(fams)):
        fam = fams[i]
        submenu.append(fam)
        submenu.append((set_to(fam), '#'))
        if i > 0 and i % 20 == 0:
            menu.append(submenu)
            submenu = []
    if submenu != []:
        menu.append(submenu)
    for i in range(len(menu) - 1):
        menu[i].append('(&More...)')
        menu[i].append(menu[i + 1])
    return menu[0]
        def test_fontselectframe_family(self):
            frame = FontSelectFrame(self.window)
            frame.pack()
            self.window.update()
            frame._family_dropdown.set(font.families()[1])
            self.window.update()
            frame._on_family(frame._family_dropdown.get())
            results = frame.font
            self.assertIsInstance(results, tuple)
            self.assertEqual(len(results), 2)
            self.assertIsInstance(results[0], tuple)
            self.assertEqual(len(results[0]), 2)
            self.assertIsInstance(results[1], font.Font)

            frame._on_size(20)
            frame._on_family('Arial')
            frame._on_properties((True, True, True, True))
            self.window.update()
            results = frame.font
            self.assertEqual(
                results[0],
                ('Arial', 20, 'bold', 'italic', 'underline', 'overstrike'))
Example #40
0
 def body(self, master):
     self._npFrame = LabelFrame(master, text='Annotation window text')
     self._npFrame.pack(fill=X)
     self._fontFrame = Frame(self._npFrame, borderwidth=0)
     self._fontLabel = Label(self._fontFrame, text='Font:', width=5)
     self._fontLabel.pack(side=LEFT, padx=3)
     self._fontCombo = Combobox(self._fontFrame,
                                values=sorted(families()),
                                state='readonly')
     self._fontCombo.pack(side=RIGHT, fill=X)
     self._sizeFrame = Frame(self._npFrame, borderwidth=0)
     self._sizeLabel = Label(self._sizeFrame, text='Size:', width=5)
     self._sizeLabel.pack(side=LEFT, padx=3)
     self._sizeCombo = Combobox(self._sizeFrame,
                                values=range(8, 15),
                                state='readonly')
     self._sizeCombo.pack(side=RIGHT, fill=X)
     self._fontFrame.pack()
     self._sizeFrame.pack()
     self._npFrame.pack(fill=X)
     self._fontCombo.set(self.font)
     self._sizeCombo.set(self.size)
Example #41
0
 def __init__(self, master=None, **kw):
     Frame.__init__(self, master, **kw)
     
     # Font selector
     selectorFrame = LabelFrame(self, text='Font Selector')
     selectorFrame.pack(side=LEFT)
     # Font face
     faceFrame = LabelFrame(selectorFrame, text='Font Face')
     faceFrame.pack()
     faceList = ScrolledList(faceFrame)
     faceList.pack()
     fonts = list(tkFont.families(self))
     fonts.sort()
     for font in fonts:
         faceList.insert(END, font)
     faceList.listClick = self.onFaceSelect
     self.faceList = faceList
         
     # Font size
     sizeFrame = LabelFrame(selectorFrame, text='Font Size')
     sizeFrame.pack()
     sizeCombo = Combobox(sizeFrame, takefocus=1, stat='readonly')
     sizeCombo.pack()
     sizeCombo['value'] = range(7, 23)
     sizeCombo.current(0)
     sizeCombo.bind('<<ComboboxSelected>>', self.onSizeSelect)
     self.sizeCombo = sizeCombo
     
     # Font Sample
     defaultFont = ('Courier', 10, tkFont.NORMAL)
     sampleFrame = LabelFrame(self, text='Samples')
     sampleFrame.pack(side=RIGHT, expand=YES, fill=Y)
     sampleLabel = Label(sampleFrame, text='\tabcdefghij\t\n\tABCDEFGHIJ\t\n\t0123456789\t', font=defaultFont)
     sampleLabel.pack(expand=YES)
     self.sampleLabel = sampleLabel
     
     self.face = defaultFont[0]
     self.size = defaultFont[1]
     sizeCombo.current(self.size - 7)
Example #42
0
 def __init__(self, parent):
     self.parent = parent
     self.config = ConfigParser.ConfigParser()
     self.config.readfp(StringIO.StringIO(default_cfg))
     self.config.read(['gato.cfg', os.path.expanduser('~/.gato.cfg')])
     # Keys which have widgets for editing
     self.editkeys = [
         'blinkrate', 'blinkrepeat', 'algofont', 'algofontsize', 'algofg',
         'algobg', 'breakpointfg', 'breakpointbg', 'interactivefg',
         'interactivebg', 'activefg', 'activebg'
     ]
     # setup a list of legal config keys and remember what section
     # they are from
     self.keys = []
     self.section = {}
     for sec in self.config.sections():
         self.keys += self.config.options(sec)
         for opt in self.config.options(sec):
             self.section[opt] = sec
             #self.fonts = ['Courier', 'Helvetica']
     self.fonts = tkFont.families(self.parent)
     self.modified = 0
Example #43
0
 def __init__(self, parent):
     self.parent = parent
     self.config = ConfigParser.ConfigParser()
     self.config.readfp(StringIO.StringIO(default_cfg))
     self.config.read(['gato.cfg', os.path.expanduser('~/.gato.cfg')])
     # Keys which have widgets for editing
     self.editkeys = ['blinkrate', 'blinkrepeat', 
                      'algofont', 'algofontsize', 
                      'algofg', 'algobg',
                      'breakpointfg', 'breakpointbg',
                      'interactivefg', 'interactivebg',
                      'activefg', 'activebg']
     # setup a list of legal config keys and remember what section
     # they are from 
     self.keys = []
     self.section = {}
     for sec in self.config.sections():
         self.keys += self.config.options(sec)
         for opt in self.config.options(sec):
             self.section[opt] = sec
             #self.fonts = ['Courier', 'Helvetica']
     self.fonts = tkFont.families(self.parent)
     self.modified = 0
Example #44
0
    def setPreview(self, *dummy):
        self.font = self.fontVar.get()
        #print self.font
        if not self.font in tkFont.families():
            self.font = "Helvetica"
        self.size = self.sizeVar.get()
        if self.size == "":
            self.size = "10"

        self.isBold = self.boldVar.get()
        self.isItalic = self.italicVar.get()

        if self.isBold and self.isItalic:
            self.style = "bold italic"
        elif self.isBold:
            self.style = "bold"
        elif self.isItalic:
            self.style = "italic"
        else:
            self.style = "normal"

        self.previewFont.configure(font=(self.font, self.size, self.style))
        self.update_idletasks()
        self.previewCanvas.configure(scrollregion=self.previewCanvas.bbox(ALL))
Example #45
0
    def __init__ ( self, fontSelect, observer ):
        """Constructor for FamilyPicker
        """
        #-- 1 --
        # [ fontSelect  :=  fontSelect with a new Frame added
        #   self  :=  that Frame ]
        Frame.__init__ ( self, fontSelect )
        #-- 2 --
        self.fontSelect  =  fontSelect
        self.observer    =  observer

        #-- 3 --
        # [ self  :=   self with a new Label widget added
        #              and gridded
        #   self.topLabel  :=  that widget ]
        self.topLabel  =  Label ( self,
            font=fontSelect.regularFont,
            text="Click to select font family:" )
        self.topLabel.grid ( row=0, column=0, sticky=W )

        #-- 4 --
        # [ self  :=  self with a new ScrolledList widget added
        #             and gridded
        #   self.scrollList  :=  that widget ]
        self.scrollList  =  scrolledlist.ScrolledList ( self,
            width=LISTBOX_WIDTH, height=LISTBOX_HEIGHT,
            callback=self.__listboxHandler )
        self.scrollList.grid ( row=1, column=0 )
        self.scrollList.listbox["font"]  =  fontSelect.listFont
        #-- 5 --
        # [ self.scrollList  :=  self.scrollList with a list of
        #       the font families from tkFont added ]
        familySet  =  list ( tkFont.families() )
        familySet.sort()
        for  name in familySet:
            self.scrollList.append ( name )
Example #46
0
	def setPreview(self, *dummy):
		self.font = self.fontVar.get()
		#print self.font
		if not self.font in tkFont.families():
			self.font = "Helvetica"
		self.size = self.sizeVar.get()
		if self.size == "":
			self.size = "10"

		self.isBold = self.boldVar.get()
		self.isItalic = self.italicVar.get()

		if self.isBold and self.isItalic:
			self.style = "bold italic"
		elif self.isBold:
			self.style = "bold"
		elif self.isItalic:
			self.style = "italic"
		else:
			self.style = "normal"

		self.previewFont.configure(font=(self.font, self.size, self.style))
		self.update_idletasks()
		self.previewCanvas.configure(scrollregion=self.previewCanvas.bbox(ALL))
Example #47
0
    def __init__ ( self, fontSelect, observer ):
        """Constructor for FamilyPicker
        """
        #-- 1 --
        # [ fontSelect  :=  fontSelect with a new Frame added
        #   self  :=  that Frame ]
        Frame.__init__ ( self, fontSelect )
        #-- 2 --
        self.fontSelect  =  fontSelect
        self.observer    =  observer

        #-- 3 --
        # [ self  :=   self with a new Label widget added
        #              and gridded
        #   self.topLabel  :=  that widget ]
        self.topLabel  =  Label ( self,
            font=fontSelect.regularFont,
            text="Click to select font family:" )
        self.topLabel.grid ( row=0, column=0, sticky=W )

        #-- 4 --
        # [ self  :=  self with a new ScrolledList widget added
        #             and gridded
        #   self.scrollList  :=  that widget ]
        self.scrollList  =  scrolledlist.ScrolledList ( self,
            width=LISTBOX_WIDTH, height=LISTBOX_HEIGHT,
            callback=self.__listboxHandler )
        self.scrollList.grid ( row=1, column=0 )
        self.scrollList.listbox["font"]  =  fontSelect.listFont
        #-- 5 --
        # [ self.scrollList  :=  self.scrollList with a list of
        #       the font families from tkFont added ]
        familySet  =  list ( tkFont.families() )
        familySet.sort()
        for  name in familySet:
            self.scrollList.append ( name )
Example #48
0
Explanation: to specify fonts precisely you need to know what fonts are 
available and what they look like. The tkfont module is used here to
do that.

Author:          Mike Ohlson de Fine
"""
# fonts_available.py
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
from Tkinter import *
import tkFont
root = Tk()
root.title('Fonts available on this Computer')

canvas = Canvas(root, width=930, height=950, background='white')

fonts_available = list(tkFont.families())
fonts_available.sort()
text_sample = '  :  abcdefghij_HIJK_12340'
# list the font names on the system console first.
for this_family in fonts_available:
    print this_family
print '============================='

# Show first half on left half of screen .
for i in range(0, len(fonts_available) / 2):
    print fonts_available[i]
    texty = fonts_available[i]
    canvas.create_text(50,30 + i*20, text= texty + text_sample,\
                       fill='black', font=(texty, 12), anchor= "w")

# Show second half on right half of screen .
 def buildTextStylingFrame( self, parent ):
    textFrame = Tix.LabelFrame( parent, label='Text Styling', background='SystemButtonFace', labelside=Tix.ACROSSTOP, padx=5, pady=5 )
    
    row = 0
    
    # Font Selection
    Tix.Label( textFrame.frame, text='Font:', anchor=Tix.W ).grid( row=row, column=0, padx=5, pady=5, sticky=Tix.W )
    fontCombo = Tix.ComboBox( textFrame.frame, editable=False,
                  dropdown=True, fancy=False, variable=self._fontFamily,
                  history=False, command=self.onApplyEdits, selectmode=Tix.IMMEDIATE )
    fontCombo.entry.config( )
    fontCombo.grid( row=row, column=1, columnspan=2, padx=5, pady=5, sticky=Tix.W )
    sizeCombo = Tix.ComboBox( textFrame.frame, editable=True,
                  dropdown=True, fancy=False, variable=self._fontSize,
                  history=False, command=self.onApplyEdits, selectmode=Tix.IMMEDIATE )
    sizeCombo.entry.config( width=5 )
    sizeCombo.grid( row=row, column=3, padx=5, pady=5, sticky=Tix.W )
    
    row += 1
    
    # Style Selection
    Tix.Label( textFrame.frame, text='Styles:', anchor=Tix.W ).grid( row=row, column=0, padx=5, pady=5, sticky=Tix.W )
    Tix.Checkbutton( textFrame.frame, text='Bold', font=DIALOG_FONT + ' bold', variable=self._bold,
                    command=self.onApplyEdits ).grid( row=row, column=1, padx=5, pady=5, sticky=Tix.W )
    Tix.Checkbutton( textFrame.frame, text='Italic', font=DIALOG_FONT + ' italic', variable=self._italic,
                    command=self.onApplyEdits ).grid( row=row, column=2, padx=5, pady=5, sticky=Tix.W )
    Tix.Checkbutton( textFrame.frame, text='Under', font=DIALOG_FONT + ' underline', variable=self._underline,
                    command=self.onApplyEdits ).grid( row=row, column=3, padx=5, pady=5, sticky=Tix.W )
    Tix.Checkbutton( textFrame.frame, text='Over', font=DIALOG_FONT + ' overstrike', variable=self._overstrike,
                    command=self.onApplyEdits ).grid( row=row, column=4, padx=5, pady=5, sticky=Tix.W )
    
    row += 1
    
    # Offset
    Tix.Label( textFrame.frame, text='Offset:', anchor=Tix.W ).grid( row=row, column=0, padx=5, pady=5, sticky=Tix.W )
    Tix.Radiobutton( textFrame.frame, text='Normal', variable=self._offset, value='normal', command=self.onApplyEdits ).grid( row=row, column=1, padx=5, pady=5, sticky=Tix.W )
    Tix.Radiobutton( textFrame.frame, text='Superscript', variable=self._offset, value='superscript', command=self.onApplyEdits ).grid( row=row, column=2, padx=5, pady=5, sticky=Tix.W )
    Tix.Radiobutton( textFrame.frame, text='Subscript', variable=self._offset, value='subscript', command=self.onApplyEdits ).grid( row=row, column=3, padx=5, pady=5, sticky=Tix.W )
    
    row += 1
    
    # Pen
    Tix.Label( textFrame.frame, text='Pen:', anchor=Tix.W ).grid( row=row, column=0, padx=5, pady=5, sticky=Tix.W )
    colorFrame = Tix.Frame( textFrame.frame )
    Tix.Label( colorFrame, text='Foreground' ).grid( row=0, column=1, padx=5, pady=5 )
    Tix.Label( colorFrame, text='Background' ).grid( row=0, column=2, padx=5, pady=5 )
    
    Tix.Label( colorFrame, text='Color', anchor=Tix.W ).grid( row=1, column=0, padx=5, pady=5, sticky=Tix.W )
    self._fgColorButton = Tix.Button( colorFrame, text=' '*20,
                                background=self._foreground.get(),
                                command=self.chooseColor(self._foreground) )
    self._fgColorButton.grid( row=1, column=1, padx=5, pady=5 )
    #self._bgColorButton = Tix.Button( colorFrame,text=' '*20,
                                #background=self._background.get(),
                                #command=self.chooseColor(self._background) )
    #self._bgColorButton.grid( row=1, column=2, padx=5, pady=5 )
    
    Tix.Label( colorFrame, text='Stipple', anchor=Tix.W ).grid( row=2, column=0, padx=5, pady=5, sticky=Tix.W )
    fgStippleCombo = Tix.ComboBox( colorFrame, editable=True,
                  dropdown=True, fancy=False, variable=self._fgstipple,
                  history=False, command=self.onApplyEdits, selectmode=Tix.IMMEDIATE )
    fgStippleCombo.entry.config( width=10 )
    fgStippleCombo.grid( row=2, column=1, padx=5, pady=5 )
    bgStippleCombo = Tix.ComboBox( colorFrame, editable=True,
                  dropdown=True, fancy=False, variable=self._bgstipple,
                  history=False, command=self.onApplyEdits, selectmode=Tix.IMMEDIATE )
    bgStippleCombo.entry.config( width=10 )
    bgStippleCombo.grid( row=2, column=2, padx=5, pady=5 )
    colorFrame.grid( row=row, column=1, columnspan=4, padx=5, pady=5, sticky=Tix.W )
    
    row += 1
    
    # Border Options
    Tix.Label( textFrame.frame, text='Border:', anchor=Tix.W ).grid( row=row, column=0, padx=5, pady=5, sticky=Tix.W )
    bdwidthCombo = Tix.ComboBox( textFrame.frame, label='Width', editable=True,
                  dropdown=True, fancy=False, variable=self._borderwidth,
                  history=False, command=self.onApplyEdits, selectmode=Tix.IMMEDIATE )
    bdwidthCombo.entry.config( width=5 )
    bdwidthCombo.grid( row=row, column=1, columnspan=2, padx=5, pady=5, sticky=Tix.W )
    reliefCombo = Tix.ComboBox( textFrame.frame, label='Relief', editable=False,
                  dropdown=True, fancy=False, variable=self._relief,
                  history=False, command=self.onApplyEdits, selectmode=Tix.IMMEDIATE )
    reliefCombo.entry.config( width=10 )
    reliefCombo.grid(row=row, column=3, columnspan=2, padx=5, pady=5, sticky=Tix.W )
    
    #   Populate the font family combo box
    familyList = list(tkFont.families( ))
    familyList.sort()
    for family in familyList:
       if family[0] == '@':
          continue
       fontCombo.insert( Tix.END, family )
    
    #   Populate the font size combo box
    for size in xrange( 6,35 ):
       sizeCombo.insert( Tix.END, '%d' % size )
    
    #   Pack Stiple boxes
    for value in [ '', 'gray12', 'gray25', 'gray50', 'gray75' ]:
       fgStippleCombo.insert( Tix.END, value )
       bgStippleCombo.insert( Tix.END, value )
    
    #   Pack Borderwidth box
    for width in range( 0, 10 ):
       bdwidthCombo.insert( Tix.END, '%d' % width )
    
    #   Pack Border relief box
    for relief in [ 'flat', 'raised', 'sunken', 'groove', 'ridge', 'solid' ]:
       reliefCombo.insert( Tix.END, relief )
    
    return textFrame
Example #50
0
    global counter
    label1.config(text="button clicked %d times" % counter)
    counter += 1


counterList = [0]


def callback2():
    label2.config(text='button clicked %d times' % counterList[0])
    counterList[0] += 1


top = Tkinter.Tk()
# print tkFont.families()
for f in tkFont.families():
    print f
print
myFont = tkFont.Font(family='Verdana', size=30)
myCFont = tkFont.Font(family='Microsoft YaHei UI', size=30)
label1 = Tkinter.Label(top,
                       text="Hello world1",
                       pady=30,
                       bg='#C0FFEE',
                       font=myFont)
label2 = Tkinter.Label(top, text="welcome", padx=30, bg='#FFEEC0', font=myFont)
label3 = Tkinter.Label(top,
                       text='橫逸資訊',
                       font=myCFont,
                       fg='#990000',
                       bg='#EEFFC0',
Example #51
0
from Tkinter import *
import tkFont


root = Tk()

fonts=list(tkFont.families())
fonts.sort()



display = Listbox(root)
display.pack(fill=BOTH, expand=YES, side=LEFT)

scroll = Scrollbar(root)
scroll.pack(side=RIGHT, fill=Y, expand=NO)

scroll.configure(command=display.yview)
display.configure(yscrollcommand=scroll.set)


for item in fonts:
    display.insert(END, item)

root.mainloop()
Example #52
0
# encoding=UTF-8
import Tkinter
import tkFont

top = Tkinter.Tk()

myFont = tkFont.Font(family='Arial', size=30)
myFont2 = tkFont.Font(family='標楷體', size=30)
myFont3 = tkFont.Font(family='@標楷體', size=30)
for font in tkFont.families():
    print font

label1 = Tkinter.Label(top,
                       text='Hello TK!',
                       bg='#009900',
                       padx=20,
                       pady=10,
                       font=myFont)
label2 = Tkinter.Label(top,
                       text='Hello TKinter!',
                       bg='#000099',
                       fg='#FFFF99',
                       padx=10,
                       pady=20,
                       font=myFont)
label3 = Tkinter.Label(top, text='測試機台', font=myFont2)
label4 = Tkinter.Label(top, text='測試機台', font=myFont3)
label2.pack()
label1.pack()
label3.pack()
label4.pack()
Example #53
0
    def __init__(self, CodeClass):

        # Configure FoxDot's namespace to include the editor

        CodeClass.namespace['FoxDot'] = self
        CodeClass.namespace['Player'].widget = self

        this_version = CodeClass.namespace['__version__']
        pypi_version = get_pypi_version()

        def check_versions():

            if pypi_version is not None and VersionNumber(
                    pypi_version) > VersionNumber(this_version):

                tkMessageBox.showinfo(
                    "New version available",
                    "There is a new version of FoxDot available from PyPI. Upgrade by going to your command prompt and running:\n\npip install FoxDot --upgrade"
                )

            return

        # Used for docstring prompt

        self.namespace = CodeClass.namespace

        # Set up master widget

        self.root = Tk(className='FoxDot')
        self.root.title(
            "FoxDot v{} - Live Coding with Python and SuperCollider".format(
                this_version))
        self.root.rowconfigure(0, weight=1)  # Text box
        self.root.rowconfigure(1, weight=0)  # Separator
        self.root.rowconfigure(2, weight=0)  # Console
        self.root.grid_columnconfigure(0, weight=0)  # line numbers
        self.root.grid_columnconfigure(1, weight=1)  # Text boxes
        self.root.protocol("WM_DELETE_WINDOW", self.kill)

        # Track whether user wants transparent background

        self.transparent = BooleanVar()
        self.transparent.set(False)
        self.using_alpha = USE_ALPHA

        # Boolean for connection

        self.listening_for_connections = BooleanVar()
        self.listening_for_connections.set(False)

        # --- Set icon

        try:

            # Use .ico file by default
            self.root.iconbitmap(FOXDOT_ICON)

        except TclError:

            # Use .gif if necessary
            self.root.tk.call('wm', 'iconphoto', self.root._w,
                              PhotoImage(file=FOXDOT_ICON_GIF))

        # --- Setup font

        if self.default_font not in tkFont.families():

            if SYSTEM == WINDOWS:

                self.default_font = "Consolas"

            elif SYSTEM == MAC_OS:

                self.default_font = "Monaco"

            else:

                self.default_font = "Courier New"

        self.font = tkFont.Font(font=(self.default_font, 12), name="CodeFont")
        self.font.configure(family=self.default_font)

        self.help_key = "K" if SYSTEM == MAC_OS else "H"

        # --- start create menu

        self.menu = MenuBar(self, visible=MENU_ON_STARTUP)
        self.popup = PopupMenu(self)

        # Create y-axis scrollbar

        self.y_scroll = Scrollbar(self.root)
        self.y_scroll.grid(row=0, column=2, sticky='nsew')

        # Create text box for code

        self.text = ThreadedText(self.root,
                                 padx=5,
                                 pady=5,
                                 bg=colour_map['background'],
                                 fg=colour_map['plaintext'],
                                 insertbackground="White",
                                 font="CodeFont",
                                 yscrollcommand=self.y_scroll.set,
                                 width=100,
                                 height=20,
                                 bd=0,
                                 undo=True,
                                 autoseparators=True,
                                 maxundo=50)

        self.text.grid(row=0, column=1, sticky="nsew")
        self.y_scroll.config(command=self.text.yview)
        self.text.focus_set()

        self.text_as_string = ""

        # Create box for line numbers

        self.linenumbers = LineNumbers(self.text,
                                       width=50,
                                       bg=colour_map['background'],
                                       bd=0,
                                       highlightthickness=0)

        self.linenumbers.grid(row=0, column=0, sticky='nsew')

        # Docstring prompt label

        self.prompt = TextPrompt(self.text)

        # Key bindings (Use command key on Mac)

        ctrl = "Command" if SYSTEM == MAC_OS else "Control"
        alt = "Option" if SYSTEM == MAC_OS else "Alt"

        self.text.bind("<Return>", self.newline)
        self.text.bind("<BackSpace>", self.backspace)
        self.text.bind("<Delete>", self.delete)
        self.text.bind("<Tab>", self.tab)
        self.text.bind("<Key>", self.keypress)

        self.text.bind("<Button-{}>".format(2 if SYSTEM == MAC_OS else 3),
                       self.show_popup)

        self.text.bind("<{}-BackSpace>".format(ctrl), self.delete_word)
        self.text.bind("<{}-Delete>".format(ctrl), self.delete_next_word)

        self.text.bind("<{}-Return>".format(ctrl), self.exec_block)
        self.text.bind("<{}-Return>".format(alt), self.exec_line)

        # Directional movement

        self.text.bind("<{}-Left>".format(ctrl), self.move_word_left)
        self.text.bind("<{}-Right>".format(ctrl), self.move_word_right)

        self.text.bind("<{}-Shift-Right>".format(ctrl), self.select_word_right)
        self.text.bind("<{}-Shift-Left>".format(ctrl), self.select_word_left)

        self.text.bind("<Alt_L>", lambda event: "break")

        self.text.bind("<{}-a>".format(ctrl), self.select_all)
        self.text.bind("<{}-d>".format(ctrl), self.duplicate_line)

        self.text.bind("<{}-period>".format(ctrl), self.killall)
        self.text.bind("<Alt-period>".format(ctrl), self.releaseNodes)

        self.text.bind("<{}-c>".format(ctrl), self.edit_copy)
        self.text.bind("<{}-x>".format(ctrl), self.edit_cut)
        self.text.bind("<{}-v>".format(ctrl), self.edit_paste)

        self.text.bind("<{}-bracketright>".format(ctrl), self.indent)
        self.text.bind("<{}-bracketleft>".format(ctrl), self.unindent)

        self.text.bind("<{}-equal>".format(ctrl), self.zoom_in)
        self.text.bind("<{}-minus>".format(ctrl), self.zoom_out)

        self.text.bind("<{}-z>".format(ctrl), self.undo)
        self.text.bind("<{}-y>".format(ctrl), self.redo)

        self.text.bind("<{}-s>".format(ctrl), self.save)
        self.text.bind("<{}-o>".format(ctrl), self.openfile)
        self.text.bind("<{}-n>".format(ctrl), self.newfile)

        self.text.bind("<{}-m>".format(ctrl), self.toggle_menu)
        self.text.bind(
            "<{}-l>".format(ctrl),
            lambda event: self.insert_char(u"\u03BB"))  # insert lambda
        self.text.bind("<{}-t>".format(ctrl),
                       lambda event: self.insert_char("~"))

        self.text.bind("<{}-{}>".format(ctrl, self.help_key.lower()),
                       self.help)

        # Number pad

        for event in [
                "KP_Right", "KP_Left", "KP_Up", "KP_Down", "KP_Delete",
                "KP_Home", "KP_End", "KP_Next", "KP_Prior"
        ]:

            try:

                event1 = "<{}>".format(event)
                event2 = "<{}-{}>".format(ctrl, event)
                event3 = "<{}-{}>".format("Shift", event)
                event4 = "<{}-{}-{}>".format("Shift", ctrl, event)
                event5 = "<{}-{}-{}>".format(ctrl, "Shift", event)

                self.text.bind(
                    event1,
                    partial(lambda *args: self.text.event_generate(args[0]),
                            event1.replace("KP_", "")))
                self.text.bind(
                    event2,
                    partial(lambda *args: self.text.event_generate(args[0]),
                            event2.replace("KP_", "")))
                self.text.bind(
                    event3,
                    partial(lambda *args: self.text.event_generate(args[0]),
                            event3.replace("KP_", "")))
                self.text.bind(
                    event4,
                    partial(lambda *args: self.text.event_generate(args[0]),
                            event4.replace("KP_", "")))
                self.text.bind(
                    event5,
                    partial(lambda *args: self.text.event_generate(args[0]),
                            event5.replace("KP_", "")))

            except TclError:

                pass

        try:

            self.text.bind("<KP_Enter>", self.newline)

        except TclError:

            pass

        # Toggle console button keybind

        try:

            self.text.bind("<{}-#>".format(ctrl), self.toggle_console)
            self.toggle_key = "#"

        except:

            self.text.bind("<{}-G>".format(ctrl), self.toggle_console)
            self.toggle_key = "G"

        # Save feature variabes

        self.saved = False
        self.file = None
        self.filename = None

        # --- define bracket behaviour

        self.bracketHandler = BracketHandler(self)

        # Set tag names and config for specific colours

        for tier in tag_weights:

            for tag_name in tier:

                self.text.tag_config(tag_name, foreground=colour_map[tag_name])

        # --- Create console

        self.console = console(self, self.default_font)
        self.console_visible = True
        sys.stdout = self.console
        self.root.bind("<Button-1>", self.mouse_press)

        # Store original location of cursor
        self.origin = "origin"
        self.text.mark_set(self.origin, INSERT)
        self.text.mark_gravity(self.origin, LEFT)

        # Say Hello to the user

        def hello():

            if SYSTEM == MAC_OS:
                ctrl = "Cmd"
            else:
                ctrl = "Ctrl"

            hello = "Welcome to FoxDot! Press {}+{} for help.".format(
                ctrl, self.help_key)

            print(hello)
            print("-" * len(hello))

        # Ask after widget loaded

        self.root.after(50, hello)

        # Check temporary file

        def recover_work():

            with open(FOXDOT_TEMP_FILE) as f:

                text = f.read()

            if len(text):

                loading = tkMessageBox.askyesno(
                    "Load unsaved work?",
                    "Your code wasn't saved last time you used FoxDot, do you want to load any unsaved work?"
                )

                self.root.update()

                if loading:

                    self.set_all(text)

                else:

                    self.clear_temp_file()

                self.text_as_string = self.get_all()

        # Check online if a new version if available

        self.root.after(90, check_versions)

        # Ask after widget loaded
        if RECOVER_WORK:
            self.root.after(100, recover_work)

        # Check transparency on startup
        if TRANSPARENT_ON_STARTUP:
            self.transparent.set(True)
            self.root.after(100, self.toggle_transparency)
Example #54
0
    def __init__(self, root, family, size, bold, italic, underline, anchor,
                 eventHandler):
        self.root = root
        self.family = family
        self.size = size
        self.bold = bold
        self.italic = italic
        self.underline = underline
        self.anchor = anchor
        self.eventHandler = eventHandler

        self.familyScrollbar = Tkinter.Scrollbar(root, orient=Tkinter.VERTICAL)
        self.familyListbox = Tkinter.Listbox(
            root,
            yscrollcommand=self.familyScrollbar.set,
            selectmode=Tkinter.BROWSE,
            exportselection=0,
            height=7)
        allFontsList = list(tkFont.families())
        allFontsList.sort()
        for font in allFontsList:
            self.familyListbox.insert(Tkinter.END, font)
        self.familyScrollbar.config(command=self.familyListbox.yview)

        self.familyListbox.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=1)
        self.familyListbox.bind("<ButtonRelease>", self.checkFamilyChange)
        self.familyScrollbar.pack(side=Tkinter.LEFT, fill=Tkinter.Y)

        self.sizeScrollbar = Tkinter.Scrollbar(root, orient=Tkinter.VERTICAL)
        self.sizeListbox = Tkinter.Listbox(
            root,
            yscrollcommand=self.sizeScrollbar.set,
            selectmode=Tkinter.BROWSE,
            width=5,
            exportselection=0,
            height=7)
        for size in [
                6, 8, 9, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72
        ]:
            self.sizeListbox.insert(Tkinter.END, size)
        self.sizeListbox.see(4)
        self.sizeScrollbar.config(command=self.sizeListbox.yview)

        self.sizeListbox.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=1)
        self.sizeListbox.bind("<ButtonRelease>", self.checkSizeChange)
        self.sizeScrollbar.pack(side=Tkinter.LEFT, fill=Tkinter.Y)

        self.optionFrame = Tkinter.Frame(root)
        h = 40
        w = 40

        boldxbm = '@' + str(os.path.join(GRAPHIC_EDITOR_DATA, 'bold.xbm'))
        italicxbm = '@' + str(os.path.join(GRAPHIC_EDITOR_DATA, 'italic.xbm'))
        underlinexbm = '@' + str(
            os.path.join(GRAPHIC_EDITOR_DATA, 'underline.xbm'))

        self.boldButton = Tkinter.Button(self.optionFrame,
                                         bitmap=boldxbm,
                                         height=h,
                                         width=w,
                                         command=self.onBold)
        self.italicButton = Tkinter.Button(self.optionFrame,
                                           bitmap=italicxbm,
                                           height=h,
                                           width=w,
                                           command=self.onItalic)
        self.underlineButton = Tkinter.Button(self.optionFrame,
                                              bitmap=underlinexbm,
                                              height=h,
                                              width=w,
                                              command=self.onUnderline)
        if self.bold:
            self.boldButton.config(relief=Tkinter.SUNKEN)
        if self.italic:
            self.italicButton.config(relief=Tkinter.SUNKEN)
        if self.underline:
            self.underlineButton.config(relief=Tkinter.SUNKEN)

        self.boldButton.pack(side=Tkinter.LEFT)
        self.italicButton.pack(side=Tkinter.LEFT)
        self.underlineButton.pack(side=Tkinter.LEFT)

        self.anchorChooser = AnchorChooser(root, self, self.anchor)

        self.optionFrame.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=1)
numeric_entry_keys = ["message_duration", "min_spacing", "default_spacing", "framerate_limit", "size_multiplier"]
entries = {}
nextrow = 0
vcmd = (root.register(OnValidate),
        '%d', '%i', '%P', '%s', '%S', '%v', '%V', '%W')
for index, opt in enumerate(
        ["message_duration", "min_spacing", "default_spacing", "framerate_limit", "size_multiplier"]):
    Label(root, text=pretty_name(opt)).grid(row=nextrow)
    entries[opt] = Entry(root, validate="key", validatecommand=vcmd)
    entries[opt].grid(row=nextrow, column=1)
    entries[opt].insert(0, options.get(opt))
    nextrow += 1

for index, opt in enumerate(["show_font"]):
    Label(root, text=pretty_name(opt)).grid(row=nextrow)
    fonts = tkFont.families()
    initialvar = StringVar()
    initialvar.set(options.get(opt))
    entries[opt] = ttk.Combobox(root, values=sorted(fonts), textvariable=initialvar, state='readonly')
    entries[opt].pack()
    entries[opt].grid(row=nextrow, column=1)
    nextrow += 1

# generate text options by looping over option types
for index, opt in enumerate(["item_details_link", "custom_message"]):
    Label(root, text=pretty_name(opt)).grid(row=nextrow)
    entries[opt] = Entry(root)
    entries[opt].grid(row=nextrow, column=1)
    entries[opt].insert(0, options.get(opt))
    nextrow += 1
Example #56
0
    def __init__(self, session):

        self.specs_peaks = []

        self.session = session
        tkutil.Dialog.__init__(self, session.tk, 'Resonance Cross-Validation')

        # xcheck_label = tk.Label(self.top, text="X-Check Validation Filtering Module", font=20)
        # xcheck_label.pack(side='top', fill='both', expand=1, pady=15)

        # separator = tk.Frame(self.top, height=2, bd=1, relief="ridge")
        # separator.pack(fill="both", padx=5, pady=5, side ='top')

        # frames

        # listbox
        topfrm = tk.Frame(self.top)
        topfrm.pack(side='top', fill='both', expand=0, padx=8)

        # update, select all buttons
        midfrm = tk.Frame(self.top)
        midfrm.pack(fill='both', expand=1, padx=8)

        # settings
        btmfrm = tk.Frame(self.top)
        btmfrm.pack(fill='both', expand=1, padx=8)

        # run buttons 1st row
        buttonsfrm1 = tk.Frame(self.top)
        buttonsfrm1.pack(fill='both', expand=1, padx=(15, 0), pady=(10, 2))

        # run buttons 2nd row
        buttonsfrm2 = tk.Frame(self.top)
        buttonsfrm2.pack(fill='both', expand=1, padx=(15, 0))

        # status
        statusfrm = tk.Frame(self.top)
        statusfrm.pack(fill='both', expand=1, padx=8)

        #spectra list

        self.spectra_list = tkutil.scrolling_list(
            topfrm, 'Select the spectra for cross-validation:', 5, True)
        self.spectra_list.listbox['selectmode'] = 'extended'
        self.spectra_list.listbox.bind('<ButtonRelease-1>',
                                       self.spectra_selected)
        self.spectra_list.frame.pack(side='top',
                                     fill='both',
                                     expand=1,
                                     pady=(5, 5))
        tkutil.create_hint(
            self.spectra_list.frame,
            'You can select multiple experiments by holding down the Ctrl key and clicking on the experiments'
        )

        # buttons

        update_button = tk.Button(midfrm,
                                  text='Update List',
                                  command=self.update_list)
        update_button.pack(side='left', anchor='w', expand=0, pady=(0, 15))
        tkutil.create_hint(
            update_button,
            'This will refresh the list in case a new experiment is loaded')

        select_all_button = tk.Button(midfrm,
                                      text='Select All',
                                      command=self.select_all)
        select_all_button.pack(side='left',
                               anchor='w',
                               expand=0,
                               pady=(0, 15),
                               padx=1)
        tkutil.create_hint(
            select_all_button,
            'This will select all the loaded experiments for the cross validation'
        )

        # tolerance frame

        tolerance_font = tkFont.Font(size=11)
        tolerance_label = tk.Label(btmfrm,
                                   text="Tolerances:",
                                   font=tolerance_font)
        tolerance_label.pack(side='top', anchor='w')
        tkutil.create_hint(
            tolerance_label,
            'These tolerances are used in comparing peaks from different experiments'
        )

        tol_frm = tk.Frame(btmfrm)
        tol_frm.pack(side='top', fill='both', expand=1)

        self.tol_H = tkutil.entry_field(tol_frm,
                                        '1H: ',
                                        width=5,
                                        initial='0.05')
        self.tol_H.frame.pack(side='left', padx=(20, 10))
        tkutil.create_hint(
            self.tol_H.frame,
            'Maximum distance for H to be considered the same resonance')

        self.tol_N = tkutil.entry_field(tol_frm,
                                        '15N:',
                                        width=5,
                                        initial='0.3')
        self.tol_N.frame.pack(side='left', padx=(5, 10))
        tkutil.create_hint(
            self.tol_N.frame,
            'Maximum distance for N to be considered the same resonance')

        self.tol_C = tkutil.entry_field(tol_frm,
                                        '13C:',
                                        width=5,
                                        initial='0.35')
        self.tol_C.frame.pack(side='left', padx=(5, 10))
        tkutil.create_hint(
            self.tol_C.frame,
            'Maximum distance for C to be considered the same resonance')

        # exclude frame

        exclude_font = tkFont.Font(size=11)
        exclude_label = tk.Label(btmfrm,
                                 text="Exclude Range:",
                                 font=tolerance_font)
        exclude_label.pack(side='top', anchor='w', pady=(15, 0))
        tkutil.create_hint(
            exclude_label,
            'Any peak with their H resonance in this range will be excluded from the cross validation'
        )

        exclude_frm = tk.Frame(btmfrm)
        exclude_frm.pack(side='top', fill='both', expand=1, pady=(5, 0))

        self.exclude_from = tkutil.entry_field(exclude_frm,
                                               'From: ',
                                               width=5,
                                               initial='4.7')
        self.exclude_from.frame.pack(side='left', padx=(25, 0))
        tkutil.create_hint(
            self.exclude_from.frame,
            'Lower bound for the exclusion range. Any peak with their H resonance in this range will be excluded from the cross validation'
        )

        self.exclude_to = tkutil.entry_field(exclude_frm,
                                             'To: ',
                                             width=5,
                                             initial='4.9')
        self.exclude_to.frame.pack(side='left', padx=(5, 10))
        tkutil.create_hint(
            self.exclude_to.frame,
            'Upper bound for the exclusion range. Any peak with their H resonance in this range will be excluded from the cross validation'
        )

        # checkbox

        checkbox_frm = tk.Frame(btmfrm)
        checkbox_frm.pack(side='top', fill='both', expand=1, pady=(15, 0))

        self.note_append = tk.BooleanVar()
        self.note_append.set(True)
        checkbox_note_append = tk.Checkbutton(checkbox_frm,
                                              highlightthickness=0,
                                              text='Append to Note',
                                              variable=self.note_append)
        checkbox_note_append.pack(side='top', anchor='w', padx=(0, 0))
        tkutil.create_hint(
            checkbox_note_append,
            'If checked, the result will be appended to the Note property of each peak. If unchecked, the Note will be OVERWRITTEN!'
        )

        # separator
        sep = tk.Frame(btmfrm, height=2, bd=1, relief="ridge")
        sep.pack(fill="both", padx=5, pady=(10, 5), side='top')

        # histogram bins

        bin_font = tkFont.Font(size=11)
        bin_label = tk.Label(btmfrm, text="Histogram Bins:", font=bin_font)
        bin_label.pack(side='top', anchor='w', pady=(5, 3))
        tkutil.create_hint(bin_label,
                           'These bins are used in generating the histograms')

        bins_frm = tk.Frame(btmfrm)
        bins_frm.pack(side='top', fill='both', expand=1, pady=(0, 10))

        self.bin_H = tkutil.entry_field(bins_frm,
                                        '1H: ',
                                        width=5,
                                        initial='0.02')
        self.bin_H.frame.pack(side='left', padx=(18, 10))
        tkutil.create_hint(self.bin_H.frame, 'Bin steps for H histogram')

        self.bin_N = tkutil.entry_field(bins_frm,
                                        '15N:',
                                        width=5,
                                        initial='0.2')
        self.bin_N.frame.pack(side='left', padx=(3, 10))
        tkutil.create_hint(self.bin_N.frame, 'Bin steps for N histogram')

        self.bin_C = tkutil.entry_field(bins_frm,
                                        '13C:',
                                        width=5,
                                        initial='0.2')
        self.bin_C.frame.pack(side='left', padx=(3, 10))
        tkutil.create_hint(self.bin_C.frame, 'Bin steps for C histogram')

        # run button & status

        xcheck_button = tk.Button(buttonsfrm1,
                                  text='Run Cross-Validation',
                                  command=self.run_xcheck_button)
        xcheck_button.pack(side='left')
        tkutil.create_hint(
            xcheck_button,
            'Runs the cross validation using the settings above')

        peaklist_button = tk.Button(buttonsfrm1,
                                    text='Peak List',
                                    width=10,
                                    command=self.show_peak_list)
        peaklist_button.pack(side='left')
        tkutil.create_hint(peaklist_button, 'Shows the Peak list')

        hist_button = tk.Button(buttonsfrm2,
                                text='Peak Histogram',
                                width=16,
                                command=self.run_histogram)
        hist_button.pack(side='left')
        tkutil.create_hint(
            hist_button,
            'Generates and shows the histograms for the peak resonances.')

        stop_button = tk.Button(buttonsfrm2, text='Stop', command=self.stop_cb)
        stop_button.pack(side='left')
        tkutil.create_hint(stop_button, 'Stops the cross validations process')

        #TODO: Add the section for CrossValidation to the extensions.html file
        help_button = tk.Button(buttonsfrm2,
                                text='Help',
                                command=sputil.help_cb(session,
                                                       'CrossValidation'))
        help_button.pack(side='left')
        tkutil.create_hint(
            help_button,
            'Opens a help page with more information about this module.')

        self.status = tk.Label(statusfrm, text="Status: Ready!")
        self.status.pack(side='left', anchor='w', pady=(10, 5), padx=(5, 0))

        progress_label = tk.Label(statusfrm)
        progress_label.pack(side='left', anchor='w')

        tkutil.Stoppable.__init__(self, progress_label, stop_button)

        # fix the fonts

        suggested_fonts = [
            'Arial', 'NotoSans', 'Ubuntu', 'SegoeUI', 'Helvetica', 'Calibri',
            'Verdana', 'DejaVuSans', 'FreeSans'
        ]
        for fnt in suggested_fonts:
            if fnt in tkFont.families():
                self.spectra_list.listbox['font'] = (fnt, 9)
                self.spectra_list.heading['font'] = (fnt, 11)
                break

        self.update_list()
Example #57
0
    def _getEditWdg(self):
        currFontDict = self.prefVar.value
        fontFamilies = []
        for fam in tkFont.families():
            try:
                fam = str(fam)
                if fam.startswith("."):
                    continue
                fontFamilies.append(fam)
            except UnicodeEncodeError:
                continue
        fontFamilies.sort()
        fontSizes = [str(x) for x in range(6, 25)]

        # create a Font for the font editor widgets
        self.editFont = tkFont.Font(**currFontDict)

        fontNameVarSet = (
            ("family", Tkinter.StringVar()),
            ("size", Tkinter.StringVar()),
            ("weight", Tkinter.StringVar()),
            ("slant", Tkinter.StringVar()),
            ("underline", Tkinter.BooleanVar()),
            ("overstrike", Tkinter.BooleanVar()),
        )
        self.varDict = {}
        for varName, var in fontNameVarSet:
            # the default value in _internalDefFontDict is a last ditch default
            # in case the variable itself does not have a default value
            defValue = currFontDict.get(
                varName, self.prefVar._internalDefFontDict[varName])
            var.set(defValue)
            self.varDict[varName] = var

        frame = Tkinter.Frame(self.master)
        fontNameWdg = RO.Wdg.OptionMenu(
            master=frame,
            items=fontFamilies,
            var=self.varDict["family"],
            ignoreCase=True,
            helpText=self.prefVar.helpText,
            helpURL=self.prefVar.helpURL,
        )
        fontNameWdg.configure(font=self.editFont)
        fontNameWdg.ctxSetConfigFunc(self._configCtxMenu)

        fontSizeWdg = RO.Wdg.OptionMenu(
            master=frame,
            items=fontSizes,
            var=self.varDict["size"],
            helpText=self.prefVar.helpText,
            helpURL=self.prefVar.helpURL,
        )
        fontSizeWdg.configure(font=self.editFont)
        fontSizeWdg.ctxSetConfigFunc(self._configCtxMenu)

        fontOptionWdg = Tkinter.Menubutton(
            frame,
            text="Options",
            indicatoron=1,
            direction="below",
            borderwidth=2,
            relief="raised",
            highlightthickness=2,
        )
        mnu = Tkinter.Menu(fontOptionWdg, tearoff=0)
        mnu.add_checkbutton(label="Bold",
                            variable=self.varDict["weight"],
                            onvalue="bold",
                            offvalue="normal")
        mnu.add_checkbutton(label="Italic",
                            variable=self.varDict["slant"],
                            onvalue="italic",
                            offvalue="roman")
        mnu.add_checkbutton(label="Underline",
                            variable=self.varDict["underline"],
                            onvalue=True,
                            offvalue=False)
        mnu.add_checkbutton(label="Overstrike",
                            variable=self.varDict["overstrike"],
                            onvalue=True,
                            offvalue=False)
        fontOptionWdg["menu"] = mnu
        RO.Wdg.addCtxMenu(
            fontOptionWdg,
            helpURL=self.prefVar.helpURL,
            configFunc=self._configCtxMenu,
        )
        fontOptionWdg.helpText = self.prefVar.helpText

        fontNameWdg.pack(side="left")
        fontSizeWdg.pack(side="left")
        fontOptionWdg.pack(side="left")

        # set up a callback for each variable
        for var in self.varDict.itervalues():
            var.trace_variable("w", self._editCallback)

        return frame
    def createFrame(self):

        c = self.c
        gui = g.app.gui
        self.top = top = Tk.Toplevel(g.app.root)
        gui.attachLeoIcon(top)

        top.title("Fonts for " + c.frame.shortFileName())  # DS, 10/28/03
        top.protocol("WM_DELETE_WINDOW", self.onOk)

        #@    << create the Tk.IntVars >>
        #@+node:ekr.20031218072017.3913:<< create the Tk.IntVars >>
        # Variables to track values of style checkboxes.
        self.sizeVar = Tk.IntVar()
        self.boldVar = Tk.IntVar()
        self.italVar = Tk.IntVar()

        # Variables to track values of pane checkboxes.
        self.bodyVar = Tk.IntVar()
        self.logVar = Tk.IntVar()
        self.treeVar = Tk.IntVar()
        #@nonl
        #@-node:ekr.20031218072017.3913:<< create the Tk.IntVars >>
        #@nl
        #@    << Create the organizer frames >>
        #@+node:ekr.20031218072017.3914:<< create the organizer frames >>
        self.outer = outer = Tk.Frame(top, bd=2, relief="groove", width="8i")
        outer.pack(padx=2, pady=2, expand=1, fill="both")

        upper = Tk.Frame(outer)
        upper.pack(fill="both", expand=1)

        lt = Tk.Frame(upper)
        lt.pack(side="left", fill="both", expand=1)

        rt = Tk.Frame(upper)
        rt.pack(side="right", anchor="n",
                padx=4)  # Not filling or expanding centers contents.

        # Not filling or expanding centers contents.
        # padx=20 gives more room to the Listbox in the lt frame!
        lower = Tk.Frame(outer)
        lower.pack(side="top", anchor="w", padx=20)
        #@nonl
        #@-node:ekr.20031218072017.3914:<< create the organizer frames >>
        #@nl
        #@    << create the font pane >>
        #@+node:ekr.20031218072017.3915:<< create the font pane >>
        # Create the list box and its scrollbar.
        self.family_list_box = box = Tk.Listbox(lt, height=7)

        # Fill the listbox to set the width.
        names = tkFont.families()
        names = list(names)
        names.sort()
        for name in names:
            box.insert("end", name)

        box.pack(padx=4, pady=4, fill="both", expand=1)
        box.bind("<Double-Button-1>", self.update)

        bar = Tk.Scrollbar(box)
        bar.pack(side="right", fill="y")

        bar.config(command=box.yview)
        box.config(yscrollcommand=bar.set)
        #@nonl
        #@-node:ekr.20031218072017.3915:<< create the font pane >>
        #@nl
        #@    << create the checkboxes >>
        #@+node:ekr.20031218072017.3916:<< create the checkboxes >>
        # Create the style checkboxes.
        for text, var in (("Bold", self.boldVar), ("Italic", self.italVar)):

            b = Tk.Checkbutton(rt, text=text, variable=var)
            b.pack(side="top", anchor="w")

        # Create the size label and entry widget.
        row = Tk.Frame(rt)
        row.pack(side="top")

        lab = Tk.Label(row, text="Size:")
        lab.pack(side="left")

        self.size_entry = e = Tk.Entry(row, width=4)
        e.pack(side="left")
        e.bind("<Key>", self.onSizeEntryKey)

        # Create the pane checkboxes.
        for text, var in (("Body", self.bodyVar), (
                "Outline",
                self.treeVar,
        ), ("Log", self.logVar)):

            b = Tk.Checkbutton(rt, text=text, variable=var)
            b.pack(side="top", anchor="w")
        #@nonl
        #@-node:ekr.20031218072017.3916:<< create the checkboxes >>
        #@nl
        #@    << create the buttons >>
        #@+node:ekr.20031218072017.3917:<< create the buttons >>
        for name, command in (("Apply", self.onApply), ("OK", self.onOk),
                              ("Cancel", self.onCancel), ("Revert",
                                                          self.onRevert)):

            b = Tk.Button(lower, width=7, text=name, command=command)
            b.pack(side="left", anchor="w", pady=6, padx=4, expand=0)
        #@nonl
        #@-node:ekr.20031218072017.3917:<< create the buttons >>
        #@nl

        # This must be done _after_ the dialog has been built!
        w, h, x, y = gui.center_dialog(top)
        top.wm_minsize(height=h, width=w)