def CreatePageKeys(self):
     self.bindingTarget = StringVar(self)
     self.builtinKeys = StringVar(self)
     self.customKeys = StringVar(self)
     self.keysAreBuiltin = BooleanVar(self)
     self.keyBinding = StringVar(self)
     frame = self.tabPages.pages['Keys'].frame
     frameCustom = LabelFrame(frame, borderwidth=2, relief=GROOVE, text=' Custom Key Bindings ')
     frameKeySets = LabelFrame(frame, borderwidth=2, relief=GROOVE, text=' Key Set ')
     frameTarget = Frame(frameCustom)
     labelTargetTitle = Label(frameTarget, text='Action - Key(s)')
     scrollTargetY = Scrollbar(frameTarget)
     scrollTargetX = Scrollbar(frameTarget, orient=HORIZONTAL)
     self.listBindings = Listbox(frameTarget, takefocus=FALSE, exportselection=FALSE)
     self.listBindings.bind('<ButtonRelease-1>', self.KeyBindingSelected)
     scrollTargetY.config(command=self.listBindings.yview)
     scrollTargetX.config(command=self.listBindings.xview)
     self.listBindings.config(yscrollcommand=scrollTargetY.set)
     self.listBindings.config(xscrollcommand=scrollTargetX.set)
     self.buttonNewKeys = Button(frameCustom, text='Get New Keys for Selection', command=self.GetNewKeys, state=DISABLED)
     frames = [ Frame(frameKeySets, padx=2, pady=2, borderwidth=0) for i in range(2) ]
     self.radioKeysBuiltin = Radiobutton(frames[0], variable=self.keysAreBuiltin, value=1, command=self.SetKeysType, text='Use a Built-in Key Set')
     self.radioKeysCustom = Radiobutton(frames[0], variable=self.keysAreBuiltin, value=0, command=self.SetKeysType, text='Use a Custom Key Set')
     self.optMenuKeysBuiltin = DynOptionMenu(frames[0], self.builtinKeys, None, command=None)
     self.optMenuKeysCustom = DynOptionMenu(frames[0], self.customKeys, None, command=None)
     self.buttonDeleteCustomKeys = Button(frames[1], text='Delete Custom Key Set', command=self.DeleteCustomKeys)
     buttonSaveCustomKeys = Button(frames[1], text='Save as New Custom Key Set', command=self.SaveAsNewKeySet)
     frameCustom.pack(side=BOTTOM, padx=5, pady=5, expand=TRUE, fill=BOTH)
     frameKeySets.pack(side=BOTTOM, padx=5, pady=5, fill=BOTH)
     self.buttonNewKeys.pack(side=BOTTOM, fill=X, padx=5, pady=5)
     frameTarget.pack(side=LEFT, padx=5, pady=5, expand=TRUE, fill=BOTH)
     frameTarget.columnconfigure(0, weight=1)
     frameTarget.rowconfigure(1, weight=1)
     labelTargetTitle.grid(row=0, column=0, columnspan=2, sticky=W)
     self.listBindings.grid(row=1, column=0, sticky=NSEW)
     scrollTargetY.grid(row=1, column=1, sticky=NS)
     scrollTargetX.grid(row=2, column=0, sticky=EW)
     self.radioKeysBuiltin.grid(row=0, column=0, sticky=W + NS)
     self.radioKeysCustom.grid(row=1, column=0, sticky=W + NS)
     self.optMenuKeysBuiltin.grid(row=0, column=1, sticky=NSEW)
     self.optMenuKeysCustom.grid(row=1, column=1, sticky=NSEW)
     self.buttonDeleteCustomKeys.pack(side=LEFT, fill=X, expand=True, padx=2)
     buttonSaveCustomKeys.pack(side=LEFT, fill=X, expand=True, padx=2)
     frames[0].pack(side=TOP, fill=BOTH, expand=True)
     frames[1].pack(side=TOP, fill=X, expand=True, pady=2)
     return frame
 def CreatePageFontTab(self):
     self.fontSize = StringVar(self)
     self.fontBold = BooleanVar(self)
     self.fontName = StringVar(self)
     self.spaceNum = IntVar(self)
     self.editFont = tkFont.Font(self, ('courier', 10, 'normal'))
     frame = self.tabPages.pages['Fonts/Tabs'].frame
     frameFont = LabelFrame(frame, borderwidth=2, relief=GROOVE, text=' Base Editor Font ')
     frameIndent = LabelFrame(frame, borderwidth=2, relief=GROOVE, text=' Indentation Width ')
     frameFontName = Frame(frameFont)
     frameFontParam = Frame(frameFont)
     labelFontNameTitle = Label(frameFontName, justify=LEFT, text='Font Face :')
     self.listFontName = Listbox(frameFontName, height=5, takefocus=FALSE, exportselection=FALSE)
     self.listFontName.bind('<ButtonRelease-1>', self.OnListFontButtonRelease)
     scrollFont = Scrollbar(frameFontName)
     scrollFont.config(command=self.listFontName.yview)
     self.listFontName.config(yscrollcommand=scrollFont.set)
     labelFontSizeTitle = Label(frameFontParam, text='Size :')
     self.optMenuFontSize = DynOptionMenu(frameFontParam, self.fontSize, None, command=self.SetFontSample)
     checkFontBold = Checkbutton(frameFontParam, variable=self.fontBold, onvalue=1, offvalue=0, text='Bold', command=self.SetFontSample)
     frameFontSample = Frame(frameFont, relief=SOLID, borderwidth=1)
     self.labelFontSample = Label(frameFontSample, text='AaBbCcDdEe\nFfGgHhIiJjK\n1234567890\n#:+=(){}[]', justify=LEFT, font=self.editFont)
     frameIndentSize = Frame(frameIndent)
     labelSpaceNumTitle = Label(frameIndentSize, justify=LEFT, text='Python Standard: 4 Spaces!')
     self.scaleSpaceNum = Scale(frameIndentSize, variable=self.spaceNum, orient='horizontal', tickinterval=2, from_=2, to=16)
     frameFont.pack(side=LEFT, padx=5, pady=5, expand=TRUE, fill=BOTH)
     frameIndent.pack(side=LEFT, padx=5, pady=5, fill=Y)
     frameFontName.pack(side=TOP, padx=5, pady=5, fill=X)
     frameFontParam.pack(side=TOP, padx=5, pady=5, fill=X)
     labelFontNameTitle.pack(side=TOP, anchor=W)
     self.listFontName.pack(side=LEFT, expand=TRUE, fill=X)
     scrollFont.pack(side=LEFT, fill=Y)
     labelFontSizeTitle.pack(side=LEFT, anchor=W)
     self.optMenuFontSize.pack(side=LEFT, anchor=W)
     checkFontBold.pack(side=LEFT, anchor=W, padx=20)
     frameFontSample.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH)
     self.labelFontSample.pack(expand=TRUE, fill=BOTH)
     frameIndentSize.pack(side=TOP, fill=X)
     labelSpaceNumTitle.pack(side=TOP, anchor=W, padx=5)
     self.scaleSpaceNum.pack(side=TOP, padx=5, fill=X)
     return frame
Example #3
0
    def __init__(self, master, parent, defaultfont):
        super().__init__(master)
        self.master = master
        self.parent = parent
        self.result = None
        self.title('Font Chooser')
        self.protocol("WM_DELETE_WINDOW", self.cancel)
        self.transient(master)
        self.wait_visibility()
        self.grab_set()
        self.fontSize = tk.StringVar(self)
        self.fontBold = tk.BooleanVar(self)
        self.fontName = tk.StringVar(self)
        self.spaceNum = tk.IntVar(self)
        font_name = defaultfont[0]
        font_size = defaultfont[1]
        self.fontName.set(font_name)
        self.fontSize.set(font_size)
        self.editFont = tkinter.font.Font(self, (font_name,
                                                 int(font_size),
                                                 'normal'))
        frame = ttk.Frame(self)
        frame.pack(side=tk.TOP, expand=tk.TRUE, fill=tk.BOTH)

        frameFont = ttk.LabelFrame(
            frame, borderwidth=2, relief=tk.GROOVE, text=' Tutorial Font '
        )
        frameFontName = ttk.Frame(frameFont)
        frameFontParam = ttk.Frame(frameFont)
        self.labelFontNameTitle = ttk.Label(
            frameFontName, justify=tk.LEFT, text='Font Face : '+font_name
        )
        self.fontName.set(font_name)
        self.listFontName = tk.Listbox(
            frameFontName,
            height=5,
            takefocus=tk.FALSE,
            exportselection=tk.FALSE,
        )
        self.listFontName.bind('<ButtonRelease-1>',
                               self.OnListFontButtonRelease)
        scrollFont = ttk.Scrollbar(frameFontName)
        scrollFont.config(command=self.listFontName.yview)
        self.listFontName.config(yscrollcommand=scrollFont.set)
        labelFontSizeTitle = ttk.Label(frameFontParam, text='Size :')
        fonts = sorted(list(tkinter.font.families())+['Helvetica'])
        for font in fonts:
            self.listFontName.insert(tk.END, font)
        self.optMenuFontSize = DynOptionMenu(frameFontParam, self.fontSize,
                                             None, command=self.SetFontSample)
        frameFontSample = ttk.Frame(frameFont, relief=tk.SOLID, borderwidth=1)
        self.optMenuFontSize.SetMenu(('7', '8', '9', '10', '11', '12', '13',
                                      '14', '16', '18', '20', '22'), font_size)

        self.labelFontSample = ttk.Label(
            frameFontSample,
            text='AaBbCcDdEe\nFfGgHhIiJjK\n1234567890\n#:+=(){}[]',
            justify=tk.LEFT,
            font=self.editFont,
        )

        frameFont.pack(
            side=tk.LEFT,
            padx=5,
            pady=5,
            expand=tk.TRUE,
            fill=tk.BOTH,
        )
        frameFontName.pack(side=tk.TOP, padx=5, pady=5, fill=tk.X)
        frameFontParam.pack(side=tk.TOP, padx=5, pady=5, fill=tk.X)
        self.labelFontNameTitle.pack(side=tk.TOP, anchor=tk.W)
        self.listFontName.pack(side=tk.LEFT, expand=tk.TRUE, fill=tk.X)
        scrollFont.pack(side=tk.LEFT, fill=tk.Y)
        labelFontSizeTitle.pack(side=tk.LEFT, anchor=tk.W)
        self.optMenuFontSize.pack(side=tk.LEFT, anchor=tk.W)
        frameFontSample.pack(side=tk.TOP, padx=5, pady=5, expand=tk.TRUE, fill=tk.BOTH)
        self.labelFontSample.pack(expand=tk.TRUE, fill=tk.BOTH)
        buttonFrame = ttk.Frame(self)
        buttonFrame.pack(side=tk.TOP, expand=tk.TRUE, fill=tk.BOTH)
        okButton = ttk.Button(buttonFrame, text="OK", command=self.ok)
        applyButton = ttk.Button(buttonFrame, text="Apply", command=self.apply)
        cancelButton = ttk.Button(buttonFrame, text="Cancel", command=self.cancel)
        okButton.pack(side=tk.LEFT, expand=tk.TRUE)
        applyButton.pack(side=tk.LEFT, expand=tk.TRUE)
        cancelButton.pack(side=tk.LEFT, expand=tk.TRUE)
        self.wait_window(self)
    def CreatePageHighlight(self):
        self.builtinTheme = StringVar(self)
        self.customTheme = StringVar(self)
        self.fgHilite = BooleanVar(self)
        self.colour = StringVar(self)
        self.fontName = StringVar(self)
        self.themeIsBuiltin = BooleanVar(self)
        self.highlightTarget = StringVar(self)
        frame = self.tabPages.pages['Highlighting'].frame
        frameCustom = LabelFrame(frame, borderwidth=2, relief=GROOVE, text=' Custom Highlighting ')
        frameTheme = LabelFrame(frame, borderwidth=2, relief=GROOVE, text=' Highlighting Theme ')
        self.textHighlightSample = Text(frameCustom, relief=SOLID, borderwidth=1, font=('courier', 12, ''), cursor='hand2', width=21, height=11, takefocus=FALSE, highlightthickness=0, wrap=NONE)
        text = self.textHighlightSample
        text.bind('<Double-Button-1>', lambda e: 'break')
        text.bind('<B1-Motion>', lambda e: 'break')
        textAndTags = (('#you can click here', 'comment'),
         ('\n', 'normal'),
         ('#to choose items', 'comment'),
         ('\n', 'normal'),
         ('def', 'keyword'),
         (' ', 'normal'),
         ('func', 'definition'),
         ('(param):', 'normal'),
         ('\n  ', 'normal'),
         ('"""string"""', 'string'),
         ('\n  var0 = ', 'normal'),
         ("'string'", 'string'),
         ('\n  var1 = ', 'normal'),
         ("'selected'", 'hilite'),
         ('\n  var2 = ', 'normal'),
         ("'found'", 'hit'),
         ('\n  var3 = ', 'normal'),
         ('list', 'builtin'),
         ('(', 'normal'),
         ('None', 'builtin'),
         (')\n\n', 'normal'),
         (' error ', 'error'),
         (' ', 'normal'),
         ('cursor |', 'cursor'),
         ('\n ', 'normal'),
         ('shell', 'console'),
         (' ', 'normal'),
         ('stdout', 'stdout'),
         (' ', 'normal'),
         ('stderr', 'stderr'),
         ('\n', 'normal'))
        for txTa in textAndTags:
            text.insert(END, txTa[0], txTa[1])

        for element in self.themeElements.keys():
            text.tag_bind(self.themeElements[element][0], '<ButtonPress-1>', lambda event, elem = element: event.widget.winfo_toplevel().highlightTarget.set(elem))

        text.config(state=DISABLED)
        self.frameColourSet = Frame(frameCustom, relief=SOLID, borderwidth=1)
        frameFgBg = Frame(frameCustom)
        buttonSetColour = Button(self.frameColourSet, text='Choose Colour for :', command=self.GetColour, highlightthickness=0)
        self.optMenuHighlightTarget = DynOptionMenu(self.frameColourSet, self.highlightTarget, None, highlightthickness=0)
        self.radioFg = Radiobutton(frameFgBg, variable=self.fgHilite, value=1, text='Foreground', command=self.SetColourSampleBinding)
        self.radioBg = Radiobutton(frameFgBg, variable=self.fgHilite, value=0, text='Background', command=self.SetColourSampleBinding)
        self.fgHilite.set(1)
        buttonSaveCustomTheme = Button(frameCustom, text='Save as New Custom Theme', command=self.SaveAsNewTheme)
        labelTypeTitle = Label(frameTheme, text='Select : ')
        self.radioThemeBuiltin = Radiobutton(frameTheme, variable=self.themeIsBuiltin, value=1, command=self.SetThemeType, text='a Built-in Theme')
        self.radioThemeCustom = Radiobutton(frameTheme, variable=self.themeIsBuiltin, value=0, command=self.SetThemeType, text='a Custom Theme')
        self.optMenuThemeBuiltin = DynOptionMenu(frameTheme, self.builtinTheme, None, command=None)
        self.optMenuThemeCustom = DynOptionMenu(frameTheme, self.customTheme, None, command=None)
        self.buttonDeleteCustomTheme = Button(frameTheme, text='Delete Custom Theme', command=self.DeleteCustomTheme)
        frameCustom.pack(side=LEFT, padx=5, pady=5, expand=TRUE, fill=BOTH)
        frameTheme.pack(side=LEFT, padx=5, pady=5, fill=Y)
        self.frameColourSet.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=X)
        frameFgBg.pack(side=TOP, padx=5, pady=0)
        self.textHighlightSample.pack(side=TOP, padx=5, pady=5, expand=TRUE, fill=BOTH)
        buttonSetColour.pack(side=TOP, expand=TRUE, fill=X, padx=8, pady=4)
        self.optMenuHighlightTarget.pack(side=TOP, expand=TRUE, fill=X, padx=8, pady=3)
        self.radioFg.pack(side=LEFT, anchor=E)
        self.radioBg.pack(side=RIGHT, anchor=W)
        buttonSaveCustomTheme.pack(side=BOTTOM, fill=X, padx=5, pady=5)
        labelTypeTitle.pack(side=TOP, anchor=W, padx=5, pady=5)
        self.radioThemeBuiltin.pack(side=TOP, anchor=W, padx=5)
        self.radioThemeCustom.pack(side=TOP, anchor=W, padx=5, pady=2)
        self.optMenuThemeBuiltin.pack(side=TOP, fill=X, padx=5, pady=5)
        self.optMenuThemeCustom.pack(side=TOP, fill=X, anchor=W, padx=5, pady=5)
        self.buttonDeleteCustomTheme.pack(side=TOP, fill=X, padx=5, pady=5)
        return frame