mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	repair posix fonts fix
This commit is contained in:
		
							parent
							
								
									58682b7fe5
								
							
						
					
					
						commit
						c01e30f072
					
				
					 2 changed files with 66 additions and 38 deletions
				
			
		| 
						 | 
					@ -8,6 +8,7 @@
 | 
				
			||||||
about box for idle
 | 
					about box for idle
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
from Tkinter import *
 | 
					from Tkinter import *
 | 
				
			||||||
 | 
					import tkFont
 | 
				
			||||||
import string, os
 | 
					import string, os
 | 
				
			||||||
import textView
 | 
					import textView
 | 
				
			||||||
import idlever
 | 
					import idlever
 | 
				
			||||||
| 
						 | 
					@ -24,12 +25,8 @@ def __init__(self,parent,title):
 | 
				
			||||||
        self.bg="#555555"
 | 
					        self.bg="#555555"
 | 
				
			||||||
        self.fg="#ffffff"
 | 
					        self.fg="#ffffff"
 | 
				
			||||||
        #no ugly bold default font on *nix 
 | 
					        #no ugly bold default font on *nix 
 | 
				
			||||||
        font=Label().cget('font')
 | 
					        font=tkFont.Font(self,Label().cget('font'))
 | 
				
			||||||
        if os.name=='posix':
 | 
					        if os.name=='posix': font.config(weight=NORMAL)
 | 
				
			||||||
            lFont=font.split()
 | 
					 | 
				
			||||||
            if len(lFont) == 2: lFont=lFont+['normal']
 | 
					 | 
				
			||||||
            else: lFont[2]='normal'
 | 
					 | 
				
			||||||
            font=tuple(lFont)
 | 
					 | 
				
			||||||
        self.textFont=font
 | 
					        self.textFont=font
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        self.CreateWidgets()
 | 
					        self.CreateWidgets()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,7 +8,7 @@
 | 
				
			||||||
configuration dialog
 | 
					configuration dialog
 | 
				
			||||||
"""
 | 
					"""
 | 
				
			||||||
from Tkinter import *
 | 
					from Tkinter import *
 | 
				
			||||||
import tkMessageBox, tkColorChooser
 | 
					import tkMessageBox, tkColorChooser, tkFont
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import IdleConf
 | 
					import IdleConf
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,8 +28,6 @@ def __init__(self,parent,title,configDict):
 | 
				
			||||||
        #elguavas - config placeholders til config stuff completed
 | 
					        #elguavas - config placeholders til config stuff completed
 | 
				
			||||||
        self.bg=self.cget('bg')
 | 
					        self.bg=self.cget('bg')
 | 
				
			||||||
        self.fg=None
 | 
					        self.fg=None
 | 
				
			||||||
        #no ugly bold default text font on *nix
 | 
					 | 
				
			||||||
        self.textFont=tuple(Label().cget('font').split())[0:2]+('normal',) 
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.CreateWidgets()
 | 
					        self.CreateWidgets()
 | 
				
			||||||
        self.resizable(height=FALSE,width=FALSE)
 | 
					        self.resizable(height=FALSE,width=FALSE)
 | 
				
			||||||
| 
						 | 
					@ -41,7 +39,7 @@ def __init__(self,parent,title,configDict):
 | 
				
			||||||
        self.framePages.focus_set()
 | 
					        self.framePages.focus_set()
 | 
				
			||||||
        #key bindings for this dialog
 | 
					        #key bindings for this dialog
 | 
				
			||||||
        self.bind('<Escape>',self.CancelBinding) #dismiss dialog, no save
 | 
					        self.bind('<Escape>',self.CancelBinding) #dismiss dialog, no save
 | 
				
			||||||
        self.bind('<Alt-s>',self.SaveBinding) #dismiss dialog, save
 | 
					        self.bind('<Alt-a>',self.ApplyBinding) #apply changes, save
 | 
				
			||||||
        self.bind('<F1>',self.HelpBinding) #context help
 | 
					        self.bind('<F1>',self.HelpBinding) #context help
 | 
				
			||||||
        self.bind('<Alt-f>',self.ChangePageBinding)
 | 
					        self.bind('<Alt-f>',self.ChangePageBinding)
 | 
				
			||||||
        self.bind('<Alt-h>',self.ChangePageBinding)
 | 
					        self.bind('<Alt-h>',self.ChangePageBinding)
 | 
				
			||||||
| 
						 | 
					@ -63,7 +61,10 @@ def LoadConfig(self):
 | 
				
			||||||
    def Cancel(self):
 | 
					    def Cancel(self):
 | 
				
			||||||
        self.destroy()
 | 
					        self.destroy()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def Save(self):
 | 
					    def Ok(self):
 | 
				
			||||||
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def Apply(self):
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def Help(self):
 | 
					    def Help(self):
 | 
				
			||||||
| 
						 | 
					@ -72,8 +73,11 @@ def Help(self):
 | 
				
			||||||
    def CancelBinding(self,event):
 | 
					    def CancelBinding(self,event):
 | 
				
			||||||
        self.Cancel()
 | 
					        self.Cancel()
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def SaveBinding(self,event):
 | 
					    def OkBinding(self,event):
 | 
				
			||||||
        self.Save()
 | 
					        self.Ok()
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    def ApplyBinding(self,event):
 | 
				
			||||||
 | 
					        self.Apply()
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def HelpBinding(self,event):
 | 
					    def HelpBinding(self,event):
 | 
				
			||||||
        self.Help()
 | 
					        self.Help()
 | 
				
			||||||
| 
						 | 
					@ -126,6 +130,20 @@ def GetColour(self):
 | 
				
			||||||
            self.frameHighlightSample.update() #redraw after dialog
 | 
					            self.frameHighlightSample.update() #redraw after dialog
 | 
				
			||||||
            self.labelTestSample.update()
 | 
					            self.labelTestSample.update()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def __LoadFontList(self):
 | 
				
			||||||
 | 
					        fonts=list(tkFont.families(self))
 | 
				
			||||||
 | 
					        fonts.sort()
 | 
				
			||||||
 | 
					        for font in fonts:
 | 
				
			||||||
 | 
					            self.listFontName.insert(END,font)
 | 
				
			||||||
 | 
					        currentFontIndex=fonts.index('courier')
 | 
				
			||||||
 | 
					        self.listFontName.see(currentFontIndex)
 | 
				
			||||||
 | 
					        self.listFontName.select_set(currentFontIndex)
 | 
				
			||||||
 | 
					        self.fontSize.set('12')
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    def __SetFontSample(self,event):
 | 
				
			||||||
 | 
					        self.newFont.config(size=self.fontSize.get(),weight=NORMAL,
 | 
				
			||||||
 | 
					            family=self.listFontName.get(self.listFontName.curselection()[0]))
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    def CreateWidgets(self):
 | 
					    def CreateWidgets(self):
 | 
				
			||||||
        self.framePages = Frame(self)
 | 
					        self.framePages = Frame(self)
 | 
				
			||||||
        frameActionButtons = Frame(self)
 | 
					        frameActionButtons = Frame(self)
 | 
				
			||||||
| 
						 | 
					@ -133,8 +151,10 @@ def CreateWidgets(self):
 | 
				
			||||||
        #action buttons
 | 
					        #action buttons
 | 
				
			||||||
        self.buttonHelp = Button(frameActionButtons,text='Help',
 | 
					        self.buttonHelp = Button(frameActionButtons,text='Help',
 | 
				
			||||||
                command=self.Help,takefocus=FALSE)
 | 
					                command=self.Help,takefocus=FALSE)
 | 
				
			||||||
        self.buttonSave = Button(frameActionButtons,text='Save, Apply and Exit',
 | 
					        self.buttonOk = Button(frameActionButtons,text='Ok',
 | 
				
			||||||
                command=self.Save,underline=0,takefocus=FALSE)
 | 
					                command=self.Ok,takefocus=FALSE)
 | 
				
			||||||
 | 
					        self.buttonApply = Button(frameActionButtons,text='Apply',
 | 
				
			||||||
 | 
					                command=self.Apply,underline=0,takefocus=FALSE)
 | 
				
			||||||
        self.buttonCancel = Button(frameActionButtons,text='Cancel',
 | 
					        self.buttonCancel = Button(frameActionButtons,text='Cancel',
 | 
				
			||||||
                command=self.Cancel,takefocus=FALSE)
 | 
					                command=self.Cancel,takefocus=FALSE)
 | 
				
			||||||
        #page buttons
 | 
					        #page buttons
 | 
				
			||||||
| 
						 | 
					@ -165,19 +185,20 @@ def CreateWidgets(self):
 | 
				
			||||||
        framePageButtons.grid(row=0,column=0,sticky=W)
 | 
					        framePageButtons.grid(row=0,column=0,sticky=W)
 | 
				
			||||||
        for page in self.pages: page.grid(row=1,column=0,sticky=(N,S,E,W))
 | 
					        for page in self.pages: page.grid(row=1,column=0,sticky=(N,S,E,W))
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        self.buttonHelp.pack(side=RIGHT,padx=20,pady=5)
 | 
					        self.buttonHelp.pack(side=RIGHT,padx=5,pady=5)
 | 
				
			||||||
        self.buttonSave.pack(side=LEFT,padx=5,pady=5)
 | 
					        self.buttonOk.pack(side=LEFT,padx=5,pady=5)
 | 
				
			||||||
 | 
					        self.buttonApply.pack(side=LEFT,padx=5,pady=5)
 | 
				
			||||||
        self.buttonCancel.pack(side=LEFT,padx=5,pady=5)
 | 
					        self.buttonCancel.pack(side=LEFT,padx=5,pady=5)
 | 
				
			||||||
        frameActionButtons.pack(side=BOTTOM)
 | 
					        frameActionButtons.pack(side=BOTTOM)
 | 
				
			||||||
        self.framePages.pack(side=TOP,expand=TRUE,fill=BOTH)
 | 
					        self.framePages.pack(side=TOP,expand=TRUE,fill=BOTH)
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
    def CreatePageFontTab(self):
 | 
					    def CreatePageFontTab(self):
 | 
				
			||||||
        #tkVars
 | 
					        #tkVars
 | 
				
			||||||
        self.fontName=StringVar()
 | 
					 | 
				
			||||||
        self.fontSize=StringVar()
 | 
					        self.fontSize=StringVar()
 | 
				
			||||||
        self.spaceNum=IntVar()
 | 
					        self.spaceNum=IntVar()
 | 
				
			||||||
        self.tabCols=IntVar()
 | 
					        self.tabCols=IntVar()
 | 
				
			||||||
        self.indentType=IntVar() 
 | 
					        self.indentType=IntVar() 
 | 
				
			||||||
 | 
					        self.newFont=tkFont.Font(self,('courier',12,'normal'))
 | 
				
			||||||
        ##widget creation
 | 
					        ##widget creation
 | 
				
			||||||
        #body frame
 | 
					        #body frame
 | 
				
			||||||
        frame=Frame(self.framePages,borderwidth=2,relief=SUNKEN)
 | 
					        frame=Frame(self.framePages,borderwidth=2,relief=SUNKEN)
 | 
				
			||||||
| 
						 | 
					@ -187,21 +208,27 @@ def CreatePageFontTab(self):
 | 
				
			||||||
        #frameFont
 | 
					        #frameFont
 | 
				
			||||||
        labelFontTitle=Label(frameFont,text='Set Base Editor Font')
 | 
					        labelFontTitle=Label(frameFont,text='Set Base Editor Font')
 | 
				
			||||||
        frameFontName=Frame(frameFont)
 | 
					        frameFontName=Frame(frameFont)
 | 
				
			||||||
        frameFontSize=Frame(frameFont)
 | 
					        frameFontSize=Frame(frameFontName)
 | 
				
			||||||
        labelFontNameTitle=Label(frameFontName,justify=LEFT,
 | 
					        labelFontNameTitle=Label(frameFontName,justify=LEFT,
 | 
				
			||||||
                text='Choose from available\nmonospaced fonts :')
 | 
					                text='Font :')
 | 
				
			||||||
        optFontName=OptionMenu(frameFontName,
 | 
					        self.listFontName=Listbox(frameFontName,height=5,takefocus=FALSE,
 | 
				
			||||||
            self.fontName,'Courier','Font Name 2','Font Name 3')
 | 
					                exportselection=FALSE)
 | 
				
			||||||
        self.fontName.set('Courier')
 | 
					        self.listFontName.bind('<<ListboxSelect>>',self.__SetFontSample)
 | 
				
			||||||
        labelFontSizeTitle=Label(frameFontSize,text='Choose font size :')
 | 
					        scrollFont=Scrollbar(frameFontName)
 | 
				
			||||||
        optFontSize=OptionMenu(frameFontSize,
 | 
					        self.__LoadFontList()
 | 
				
			||||||
            self.fontSize,'8','10','12','14','16','18','20')
 | 
					        scrollFont.config(command=self.listFontName.yview)
 | 
				
			||||||
        self.fontSize.set('12')
 | 
					        self.listFontName.config(yscrollcommand=scrollFont.set)
 | 
				
			||||||
 | 
					        labelFontSizeTitle=Label(frameFontSize,text='Size :')
 | 
				
			||||||
 | 
					        sizes=('10','11','12','13','14','16','18','20','22')
 | 
				
			||||||
 | 
					        args=(frameFontSize,self.fontSize)+sizes
 | 
				
			||||||
 | 
					        keyArgs={'command':self.__SetFontSample}
 | 
				
			||||||
 | 
					        optFontSize=apply(OptionMenu,args,keyArgs)
 | 
				
			||||||
 | 
					        #optFontSize.bind('<<MenuSelect>>',self.__SetFontSample)
 | 
				
			||||||
        frameFontSample=Frame(frameFont,relief=SOLID,borderwidth=1,
 | 
					        frameFontSample=Frame(frameFont,relief=SOLID,borderwidth=1,
 | 
				
			||||||
                bg=self.workingTestColours['Foo-Bg'])
 | 
					                bg=self.workingTestColours['Foo-Bg'])
 | 
				
			||||||
        labelFontSample=Label(frameFontSample,bg=self.workingTestColours['Foo-Bg'], 
 | 
					        self.labelFontSample=Label(frameFontSample,bg=self.workingTestColours['Foo-Bg'], 
 | 
				
			||||||
                fg='#000000',text='Font\nSample',justify=LEFT,
 | 
					                fg='#000000',text='AaBbCcDdEe\nFfGgHhIiJjK\n1234567890\n#:+=(){}[]',
 | 
				
			||||||
                font=('courier',12,''))
 | 
					                justify=LEFT,font=self.newFont)
 | 
				
			||||||
        #frameIndent
 | 
					        #frameIndent
 | 
				
			||||||
        labelIndentTitle=Label(frameIndent,text='Set Indentation Defaults')
 | 
					        labelIndentTitle=Label(frameIndent,text='Set Indentation Defaults')
 | 
				
			||||||
        frameIndentType=Frame(frameIndent)
 | 
					        frameIndentType=Frame(frameIndent)
 | 
				
			||||||
| 
						 | 
					@ -225,18 +252,19 @@ def CreatePageFontTab(self):
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        #widget packing
 | 
					        #widget packing
 | 
				
			||||||
        #body
 | 
					        #body
 | 
				
			||||||
        frameFont.pack(side=LEFT,padx=5,pady=10,fill=Y)
 | 
					        frameFont.pack(side=LEFT,padx=5,pady=10,expand=TRUE,fill=BOTH)
 | 
				
			||||||
        frameIndent.pack(side=LEFT,padx=5,pady=10,expand=TRUE,fill=BOTH)
 | 
					        frameIndent.pack(side=LEFT,padx=5,pady=10,fill=Y)
 | 
				
			||||||
        #frameFont
 | 
					        #frameFont
 | 
				
			||||||
        labelFontTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
 | 
					        labelFontTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
 | 
				
			||||||
        frameFontName.pack(side=TOP,padx=5,pady=5,fill=X)
 | 
					        frameFontName.pack(side=TOP,padx=5,pady=5)
 | 
				
			||||||
        frameFontSize.pack(side=TOP,padx=5,pady=5,fill=BOTH)
 | 
					        frameFontSize.pack(side=RIGHT,anchor=N,fill=X)
 | 
				
			||||||
        labelFontNameTitle.pack(side=TOP,anchor=W)
 | 
					        labelFontNameTitle.pack(side=TOP,anchor=W)
 | 
				
			||||||
        optFontName.pack(side=TOP,pady=5,fill=X)
 | 
					        self.listFontName.pack(side=LEFT,fill=Y)
 | 
				
			||||||
 | 
					        scrollFont.pack(side=LEFT,fill=Y)
 | 
				
			||||||
        labelFontSizeTitle.pack(side=TOP,anchor=W)
 | 
					        labelFontSizeTitle.pack(side=TOP,anchor=W)
 | 
				
			||||||
        optFontSize.pack(side=TOP,pady=5,fill=X)
 | 
					        optFontSize.pack(side=TOP,anchor=W,fill=X)
 | 
				
			||||||
        frameFontSample.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH)
 | 
					        frameFontSample.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH)
 | 
				
			||||||
        labelFontSample.pack(expand=TRUE,fill=BOTH)
 | 
					        self.labelFontSample.pack(expand=TRUE,fill=BOTH)
 | 
				
			||||||
        #frameIndent
 | 
					        #frameIndent
 | 
				
			||||||
        labelIndentTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
 | 
					        labelIndentTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
 | 
				
			||||||
        frameIndentType.pack(side=TOP,padx=5,fill=X)
 | 
					        frameIndentType.pack(side=TOP,padx=5,fill=X)
 | 
				
			||||||
| 
						 | 
					@ -260,7 +288,6 @@ def CreatePageHighlight(self):
 | 
				
			||||||
        self.fontName=StringVar()
 | 
					        self.fontName=StringVar()
 | 
				
			||||||
        self.fontBold=StringVar()
 | 
					        self.fontBold=StringVar()
 | 
				
			||||||
        self.fontItalic=StringVar()
 | 
					        self.fontItalic=StringVar()
 | 
				
			||||||
        self.fontSize=IntVar()
 | 
					 | 
				
			||||||
        self.themeType=IntVar() 
 | 
					        self.themeType=IntVar() 
 | 
				
			||||||
        ##widget creation
 | 
					        ##widget creation
 | 
				
			||||||
        #body frame
 | 
					        #body frame
 | 
				
			||||||
| 
						 | 
					@ -367,6 +394,8 @@ def CreatePageKeys(self):
 | 
				
			||||||
        labelTargetTitle=Label(frameTarget,text='Action')
 | 
					        labelTargetTitle=Label(frameTarget,text='Action')
 | 
				
			||||||
        scrollTarget=Scrollbar(frameTarget)
 | 
					        scrollTarget=Scrollbar(frameTarget)
 | 
				
			||||||
        listTarget=Listbox(frameTarget)
 | 
					        listTarget=Listbox(frameTarget)
 | 
				
			||||||
 | 
					        scrollTarget.config(command=listTarget.yview)
 | 
				
			||||||
 | 
					        listTarget.config(yscrollcommand=scrollTarget.set)
 | 
				
			||||||
        labelKeyBindTitle=Label(frameSet,text='Binding')
 | 
					        labelKeyBindTitle=Label(frameSet,text='Binding')
 | 
				
			||||||
        labelModifierTitle=Label(frameSet,text='Modifier:')
 | 
					        labelModifierTitle=Label(frameSet,text='Modifier:')
 | 
				
			||||||
        checkCtrl=Checkbutton(frameSet,text='Ctrl')
 | 
					        checkCtrl=Checkbutton(frameSet,text='Ctrl')
 | 
				
			||||||
| 
						 | 
					@ -456,6 +485,8 @@ def CreatePageGeneral(self):
 | 
				
			||||||
        labelExtListTitle=Label(frameExtList,text='Extension')
 | 
					        labelExtListTitle=Label(frameExtList,text='Extension')
 | 
				
			||||||
        scrollExtList=Scrollbar(frameExtList)
 | 
					        scrollExtList=Scrollbar(frameExtList)
 | 
				
			||||||
        listExt=Listbox(frameExtList,height=5)
 | 
					        listExt=Listbox(frameExtList,height=5)
 | 
				
			||||||
 | 
					        scrollExtList.config(command=listExt.yview)
 | 
				
			||||||
 | 
					        listExt.config(yscrollcommand=scrollExtList.set)
 | 
				
			||||||
        labelExtSetTitle=Label(frameExtSet,text='Settings')
 | 
					        labelExtSetTitle=Label(frameExtSet,text='Settings')
 | 
				
			||||||
        radioEnableExt=Radiobutton(frameExtSet,variable=self.extState,
 | 
					        radioEnableExt=Radiobutton(frameExtSet,variable=self.extState,
 | 
				
			||||||
            value=1,text="enable")
 | 
					            value=1,text="enable")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue