Package: tkmacosx
This module provides some modified widgets of Tkinter which fixes many issues with widgets not working properly on macOS platform. For example Button of tkmacosx which looks and feels exactly like a native Tkinter button can change itsbackgroundandforegroundcolor and has a lot more functionality, Issues with Radiobutton are also fixed with this library. The library also offers some more useful functionality.Read more about all the classes and methods in thetkmacosx documentation.Table of ContentsRequirementsInstallationDemonstrationDocumentation4.1. Button Widget4.2. CircleButton Widget4.3. SFrame Widget4.4. Colorscale Widget4.5. Marquee Widget4.6. Radiobutton Widget4.7. ColorVar Variable4.8. DictVar Variable4.9. SaveVar4.10. get_shade4.11. check_appearance4.12. check_light_dark4.13. gradientChangelogLicenseRequirementsPython 3Python packages:tkinter(included in the python distribution)colourInstallationUse the package managerpipto installtkmacosxwith the following command:pipinstalltkmacosxIf you would like to get the latest master or branch from github, you could also:pipinstallgit+https://github.com/Saadmairaj/tkmacosxOr even select a specific revision(branch/tag/commit):pipinstallgit+https://github.com/Saadmairaj/tkmacosx@masterSimilarly, for tag specifytagwith@v0.x.x. For example to download tag v0.1.0 from Git use:pipinstallgit+https://github.com/Saadmairaj/tkmacosx@v0.1.0If you useAnacondaenvironmentthen you could run:condainstall-csaad_7tkmacosxDemonstrationpython-mtkmacosxRun the above command in the terminal or command line after installing tkmacosx to see working and almost all the configurable options of different widgets of tkmacosx.Also if you want to style your button to stand out, scroll down to bottom of the window opened from the above command and randomise or configure button to different styles.DocumentationButton WidgetThe tkmacosxButtonwidget is alternative to tkinter's Button that supports all features on a macos that were not possible with tkinter Button like background, relief, overrelief, activebackground, and some other features can be set. There is a blue focus ring that tells if the button has the focus or not to disable or hide the focus ring, either settakefocus=0orfocuscolor=''.Configurable options for a button widget. Syntax:Button(root, options=value, ...)OptionsDescriptionactivebackgroundWhat background color to use when the button is active. The default is system specific. Give tuple of two colors for gradient effect in active background.activeforegroundWhat foreground color to use when the button is active. The default is system specific.activeimageWhat Image to display when the button is active. No image to display by default.Note: This option is exclusive to only this libraray, the option doesn't exist by default in tkinter.activebitmapWhat Bitmap to display when the button is active. No bitmap to display by default.Note: This option is exclusive to only this libraray, the option doesn't exist by default in tkinter.anchorWhere the text is positioned on the button. For example,anchor=tk.NEwould position the text at the top right corner of the button.bordercolorThe color to use for the highlight border when the button does not have focus. The default is system-specific. Same as highlightbackground.borderlessBlend the button with its parent's background results in a clean look with no square borders. It will change color automatically. The default is False.Note: This option is exclusive to only this libraray, the option doesn't exist by default in tkinter.bd or borderwidthWidth of the border around the outside of the button. The default is two pixels.bg or backgroundNormal background color.commandFunction or method to be called when the button is clicked.cursorSelects the cursor to be shown when the mouse is over the button.disabledforegroundThe color to use when the button is disabled. The default is system specific.focuscolorThe color to use for the focus border when the button have focus. The default is system specific.Note: This option is exclusive to only this libraray, the option doesn't exist by default in tkinter.focusthicknessThe width of the focus border(pixels). The default is system specific.Note: This option is exclusive to only this libraray, the option doesn't exist by default in tkinter.fg or foregroundNormal foreground (text) color.fontText font to be used for the button's label.heightThe height of the button. The size is given inpixels for both text and images.highlightbackgroundColor of the focus highlight when the widget does not have focus.highlightcolorThe color of the focus highlight when the widget has focus.highlightthicknessThickness of the focus highlight.imageImage to be displayed on the button (instead of text).justifyHow to show multiple text lines:tk.LEFTto left-justify each line;tk.CENTERto center them; ortk.RIGHTto right-justify.overbackgroundAlternative background to use when the mouse is moved over the widget.Note: This option is exclusive to only this libraray, the option doesn't exist by default in tkinter.overforegroundAlternative foreground to use when the mouse is moved over the widget.Note: This option is exclusive to only this libraray, the option doesn't exist by default in tkinter.overreliefThe relief style to be used while the mouse is on the button; the default relief istk.RAISED.padxAdditional padding left and right of the text.padyAdditional padding above and below the text.reliefSpecifies the relief type for the button. The default relief istk.RAISED.repeatdelaySeerepeatinterval, below.repeatintervalNormally, a button fires only once when the user releases the mouse button. If you want the button to fire at regular intervals as long as the mouse button is held down, set this option to a number of milliseconds to be used between repeats, and set therepeatdelayto the number of milliseconds to wait before starting to repeat.For example, if you specify “repeatdelay=500,repeatinterval=100” the button will fire after half a second, and every tenth of a second thereafter, until the user releases the mouse button. If the user does not hold the mouse button down at leastrepeatdelaymilliseconds, the button will fire normally.stateSet this option to"disabled"to gray out the button and make it unresponsive. Has the value"active"when the mouse is over it. Keep the button pressed with"pressed". Default is"normal".takefocusNormally, keyboard focus does visit buttons, and a space character acts as the same as a mouse click, “pushing” the button. You can set the takefocus option to zero to prevent focus from visiting the button.textText displayed on the button. Use internal newlines to display multiple text lines.textvariableAn instance ofStringVar()that is associated with the text on this button. If the variable is changed, the new value will be displayed on the button.widthThe width of the button. The size is given inpixels for both text and images.Methods onButtonobjects:MethodsDescription.invoke()Calls the button's command callback, and returns what that function returns. Has no effect if the button is disabled or there is no callback.Example:fromtkinterimportTkfromtkmacosximportButtonroot=Tk()root.geometry('200x150')B0=Button(root,text='Button')B0.pack(padx=20,pady=(20,0))B1=Button(root,text='Button',bg='#ADEFD1',fg='#00203F',borderless=1)B1.pack(padx=20,pady=10)B2=Button(root,text='Button',bg='#E69A8D',fg='#5F4B8B',borderless=1,activebackground=('#AE0E36','#D32E5E'),activeforeground='#E69A8D')B2.pack()root.mainloop()Few sample of different styles of button that can be configured.# Options to get button in the first image.b1=Button(root,text='Button',activeforeground='#EE3B3B',overrelief='flat',relief='flat',borderwidth=2,highlightthickness=1,font=font.Font(family='SignPainter',size=30,weight='bold',slant='roman'),focuscolor='#556B2F',highlightbackground='#CD5555',foreground='#1F1F1F',background='#7A7A7A',overbackground='#000000',overforeground='#00C78C',activebackground=('#BA55D3','#D4D4D4'),borderless=1)# Options to get button in the second image.b2=Button(root,text='Button',activeforeground='#B5B5B5',overrelief='raised',relief='sunken',borderwidth=2,highlightthickness=4,font=font.Font(family='Brush Script MT',size=30,weight='bold',slant='roman'),focuscolor='#CD3700',highlightbackground='#AAAAAA',foreground='#6B6B6B',background='#BDBDBD',overbackground='#7A67EE',overforeground='#404040',activebackground=('#FF34B3','#C1CDC1'),borderless=1)# Options to get button in the third image.b3=Button(root,text='Button',activeforeground='#FFDAB9',overrelief='flat',relief='raised',borderwidth=1,highlightthickness=3,font=font.Font(family='Helvetica',size=30,weight='bold',slant='roman',underline=1),focuscolor='#F5DEB3',highlightbackground='#8A360F',foreground='#FFC0CB',background='#708090',overbackground='#53868B',overforeground='#CCCCCC',activebackground=('#808069','#C67171'),borderless=1)CircleButton WidgetBETA-Disclaimer:Please note that this is a BETA version. Issues can be reportedhere.Circle shaped tkinter Button can contain text or images, and you can associate a Python function or method with each button. There is a blue focus ring that tells if the button has the focus or not to disable or hide the focus ring, either settakefocus=0orfocuscolor=''. The CircleButton widget supports all the configurable options of tkmacosxButton.Configurable options for a button widget. Syntax:CircleButton(root, options=value, ...)All the options are pretty much the same as tkmacosxButton. Other options:OptionsDescriptionradiusSet the size of the button using radius(in pixels). If width or height are given then radius value gets cancelled out.Methods onCircleButtonobjects:MethodsDescription.invoke()Calls the button's command callback, and returns what that function returns. Has no effect if the button is disabled or there is no callback.Example:fromtkinterimport*fromtkmacosximportCircleButtonroot=Tk()B0=CircleButton(root,text='Button')B0.grid(row=0)B1=CircleButton(root,text='Button',bg='#ADEFD1',fg='#00203F',borderless=1)B1.grid(row=0,column=1)B2=CircleButton(root,text='Button',bg='#E69A8D',fg='#5F4B8B',borderless=1,activebackground=('#AE0E36','#D32E5E'),activeforeground='#E69A8D')B2.grid(row=0,column=2)root.mainloop()SFrame WidgetThe tkmacosxSFramewidget is just like a tkinter Frame but can be vertically scrolled. The SFrame supports intelligent mousewheel scrolling where it let you use mousewheel with other children widgets also having mousewheel scrolling without interfering with other widgets scrolling, a list of widgets having mousewheel scrolling can be passed toavoidmousewheelargument(ex:avoidmousewheel=(text1, text2, sframe)or just oneavoidmousewheel=text2).Configurable options for a sframe widget. Syntax:SFrame(root, options=value, ...)OptionsDescriptionavoidmousewheelGive widgets that also having the mousewheel scrolling and is a child ofSFrame, this option will configure widgets to support their mousewheel scrolling as well and not interfere withSFramemousewheel scrolling.For example: Text widget inside SFrame can have mousewheel scrolling as well as SFrame.autohidescrollbarAuto hides the scrollbar when not in use or when the cursor is not around the scrollbar location. The scrollbar will reappear when mousewheel scrolling is used or the cursor is moved over the scrollbar location. Default is False.autohidescrollbardelayTime taken for the scrollbar to hide after reappearing.bg or backgroundThe frame's background color.bd or borderwidthWidth of the frame's border. The default is 0 (no border).cursorThe cursor used when the mouse is within the frame widget.heightThe vertical dimension of the new frame. This will be ignored unless you also call.grid_propagate(0)on the frame.highlightbackgroundColor of the focus highlight when the frame does not have focus.highlightcolorColor is shown in the focus highlight when the frame has the focus.highlightthicknessThe thickness of the focus highlight.mousewheelSet mousewheel scrolling. The default isFalsepadxNormally, a Frame fits tightly around its contents. To addNpixels of horizontal space inside the frame, setpadx=N.padyUsed to add vertical space inside a frame. Seepadxabove.reliefThe default relief for a frame istk.FLAT, which means the frame will blend in with its surroundings. To put a border around a frame, set its borderwidth to a positive value and set its relief to one of the standard relief types.scrollbarwidthSet the width of scrollbar.takefocusNormally, frame widgets are not visited by input focus. However, you can settakefocus=1if you want the frame to receive keyboard input. To handle such input, you will need to create bindings for keyboard events.widthThe horizontal dimension of the new frame. This value be ignored unless you also call.grid_propagate(0)on the frameExample:fromtkinterimport*fromtkmacosximportSFrame,Buttonroot=Tk()root.geometry('350x300')frame=SFrame(root,bg='#333')text=Text(frame,background='#5F4B8B',width=35,height=10,foreground='white')text.pack(pady=(0,20))frame2=SFrame(frame,bg='#E69A8D',scrollbarwidth=3)frame2.pack(pady=20)frame.config(avoidmousewheel=(text,frame2))frame.pack(expand=1,fill='both')foriinrange(50):Button(frame2,text='Button%s'%i).pack()text.insert('end','Text Line:%s\n'%i)root.mainloop()Colorscale WidgetColorscale is a new style color selector which is an alternate to tkinter's colorchooser.Configurable options for a Colorscale widget. Syntax:Colorscale(root, options=value, ...)OptionsDescriptionbd or borderwidthWidth of the border around the outside of theColorscale. The default is two pixels.commandA function or method with a parameter that is called when the slider is moved or scrolled and an argument is paased to the callback. The callback can be a function, bound method, or any other callable Python object. If this option is not used, nothing will happen when the slider is moved.cursorCursor used in theColorscale.gradientTakes tuple of two colors. Two colors are required to form a gradient (sequence[FROM, TO], For example: A tuple oftuple('white', 'black')will create aColorscalefromWHITEtoBLACKcolor). By default is complete color gradient.heightSize of theColorscalein the Y dimension.highlightbackgroundColor of the focus highlight when the widget does not have focus.highlightcolorColor is shown in the focus highlight.highlightthicknessThe thickness of the focus highlight. The default value is 1.mousewheelMove the slider with mousewheel withTrue.By default the option is setFalse.orientSet the orientation(VERTICAL, HORIZONTAL). By default is VERTICAL.reliefThe relief style of theColorscale. Default is tk.FLAT.showinfoShows hex or rbg while selecting color.showinfodelayDelay before the show info disappears(in ms).takefocusNormally, focus will cycle through this widget with the tab key only if there are keyboard bindings set for it (see Section 54, “Events”for an overview of keyboard bindings). If you set this option to 1, the focus will always visit this widget. Set it to '' to get the default behavior.valueGet either 'RGB' or 'HEX'. By deafult is hex.variableAssociates a Tkinter variable (usually atk.StringVar,tkm.ColorVar). If the slider is moved the value of the variable changes as well.widthSize of theColorscalein the X dimension.Example:fromtkinterimport*fromtkmacosximportColorscale,ColorVarroot=Tk()root['bg']='#333'bgvar=ColorVar(value='#333')fgvar=ColorVar(value='white')Label(root,text="I am a Label, Hello! :-)",bg=bgvar,fg=fgvar).pack(pady=10)Colorscale(root,value='hex',variable=bgvar,mousewheel=1).pack(padx=20)Colorscale(root,value='hex',variable=bgvar,mousewheel=1,gradient=('pink','purple')).pack(pady=10)Colorscale(root,value='hex',variable=fgvar,mousewheel=1,gradient=('lightgreen','orange')).pack()Colorscale(root,value='hex',variable=fgvar,mousewheel=1,gradient=('white','#89ABE3')).pack(pady=10)root.mainloop()Marquee WidgetUseMarqueefor creating scrolling text which moves from right to left only if the text does not fit completely on the window.Configurable options for a Marquee widget. Syntax:Marquee(root, options=value, ...)OptionsDescriptionbg or backgroundThe background color of the marquee area.bd or borderwidthWidth of the border around the marquee. The default value is two pixels.cursorCursor that appears when the mouse is over this marquee.disabledforegroundThe color to use when the button is disabled. The default is systemspecific.end_delayTime to wait before reseting at the end of movement. Default is 1000 ms.fontIf you are displaying text in this marquee with the text option, the font option specifies in what font that text will be displayed.fg or foregroundIf you are displaying text in this marquee, this option specifies the color of the text.fpsSet fps(frames per seconds) indirectly is the speed of text movement. Default is 30.heightThe height of theMarqueeis in pixels. If this option is not set, theMarqueewill be sized to fit its contents.highlightbackgroundColor of the focus highlight when the widget does not have focus.highlightcolorThe color of the focus highlight when the widget has focus.highlightthicknessThe thickness of the focus highlight.initial_delayTime to wait before starting the movement of the text. Default is 1000 ms.justifySpecifies how multiple lines of text will be aligned with respect to each other:tk.LEFTfor flush left,tk.CENTERfor centered (the default), ortk.RIGHTfor right-justified.left_marginText to keep moving to right after last character is displayed before reseting.smoothnessMillisecond delay in movement of each frame. Default is 1 ms.stateBy default, aMarqueewidget is in thetk.NORMALstate. Set this option totk.DISABLEDto make it unresponsive to mouse events.reliefSpecifies the appearance of a decorative border around theMarquee. The default istk.FLAT; for other values.takefocusNormally, focus does not cycle throughMarqueewidgets. If you want this widget to be visited by the focus, settakefocus=1.textTo display one or more lines of text in aMarqueewidget, set this option to a string containing the text. Internal newlines ('\n') will force a line break.widthThe width of theMarqueeis in pixels. If this option is not set, theMarqueewill be sized to fit its contents.Methods onMarqueewidget objects:MethodsDescription.reset()Resets the position of the text to default..stop(reset: bool)Stops the moving text to the current position. Set parameterreset=Trueto stop the movement and reset the position of the text to default..play(reset: bool)Plays the stopped text from the current position. Set parameterreset=Trueto play from the default position.Example:fromtkinterimport*fromtkmacosximportMarqueetext1="""This text will move from right to left\if does not fit the window."""text2="""Please hover over the text to move it.\This text will move only if the cursor hovers over\the text widget."""root=Tk()root['bg']='#333'Marquee(root,bg='#FEE715',fg='#101820',text=text1).pack(pady=10)m=Marquee(root,fg='#FEE715',bg='#101820',text=text2)m.pack(pady=(0,10),padx=10)m.stop(True)m.bind('<Enter>',lambda_:m.play())m.bind('<Leave>',lambda_:m.stop())root.mainloop()Radiobutton WidgetRadiobutton of tkmacosx are fixed from multiple issues i.e. background color not showing properly whenindicator=0,activebackground,activeforegroundoptions not working, few other issues are fixed in tkmacosx Radiobutton. Radiobuttons are sets of related widgets that allow the user to select only one of a set of choices. Each radiobutton consists of two parts, theindicatorand thelabel.Configurable options for a Colorscale widget. Syntax:Radiobutton(root, options=value, ...)OptionsDescriptionactivebackgroundThe background color when the mouse is over the radiobutton.activeforegroundThe foreground color when the mouse is over the radiobutton.anchorIf the widget inhabits a space larger than it needs, this option specifies where the radiobutton will sit in that space. The default isanchor=tk.CENTER. For other positioning options. For example, if you setanchor=tk.NE, the radiobutton will be placed in the top right corner of the available space.bg or backgroundThe normal background color behind the indicator and label.bitmapTo display a monochrome image on a radiobutton, set this option to a bitmap.bd or borderwidthThe size of the border around the indicator part itself. Default is two pixels.commandA procedure to be called every time the user changes the state of this radiobutton.compoundIf you specify both text and a graphic (either a bitmap or an image), this option specifies where the graphic appears relative to the text. Possible values aretk.NONE(the default value),tk.TOP,tk.BOTTOM,tk.LEFT,tk.RIGHT, andtk.CENTER. For example,compound=tk.BOTTOMwould position the graphic below the text. If you specifycompound=tk.NONE, the graphic is displayed but the text (if any) is not.cursorIf you set this option to a cursor name, the mouse cursor will change to that pattern when it is over the radiobutton.disabledforegroundThe foreground color used to render the text of a disabled radiobutton. The default is a stippled version of the default foreground color.fontThe font used for the text.fg or foregroundThe color used to render the text.heightThe number of lines (not pixels) of text on the radiobutton. Default is 1.highlightbackgroundThe color of the focus highlight when the radiobutton does not have focus.highlightcolorThe color of the focus highlight when the radiobutton has the focus.highlightthicknessThe thickness of the focus highlight. Default is 1. Sethighlightthickness=0to suppress the display of the focus highlight.imageTo display a graphic image instead of text for this radiobutton, set this option to an image object. The image appears when the radiobutton is not selected; compare selectimage, below.inidicatoronNormally a radiobutton displays its indicator. If you set this option to zero, the indicator disappears, and the entire widget becomes a “push-push” button that looks raised when it is cleared and sunken when it is set. You may want to increase the borderwidth value to make it easier to see the state of such a control.justifyIf the text contains multiple lines, this option controls how the text is justified:tk.CENTER(the default),tk.LEFT, ortk.RIGHT.offreliefIf you suppress the indicator by assertingindicatoron=False, the offrelief option specifies the relief style to be displayed when the radiobutton is not selected. The default values istk.RAISED.overreliefSpecifies the relief style to be displayed when the mouse is over the radiobutton.padxHow much space to leave to the left and right of the radiobutton and text. Default is 1.padyHow much space to leave above and below the radiobutton and text. Default is 1.reliefBy default, a radiobutton will havetk.FLATrelief, so it doesn't stand out from its background. You can also userelief=tk.SOLID, which displays a solid black frame around the radiobutton.selectcolorThe color of the radiobutton when it is set. Default is red.selectimageIf you are using the image option to display a graphic instead of text when the radiobutton is cleared, you can set the selectimage option to a different image that will be displayed when the radiobutton is set.stateThe default isstate=tk.NORMAL, but you can setstate=tk.DISABLEDto gray out the control and make it unresponsive. If the cursor is currently over the radiobutton, the state istk.ACTIVE.takefocusBy default, the input focus will pass through a radiobutton. If you settakefocus=0, focus will not visit this radiobutton.textThe label displayed next to the radiobutton. Use newlines ('\n') to display multiple lines of text.textvariableIf you need to change the label on a radiobutton during execution, create a StringVar to manage the current value, and set this option to that control variable. Whenever the control variable's value changes, the radiobutton's annotation will automatically change to that text as well.underlineWith the default value of -1, none of the characters of the text label are underlined. Set this option to the index of a character in the text (counting from zero) to underline that character.valueWhen a radiobutton is turned on by the user, its control variable is set to its current valueoption. If the control variable is an IntVar, give each radiobutton in the group a different integer value option. If the control variable is a StringVar, give each radiobutton a different string value option.variableThe control variable that this radiobutton shares with the other radiobuttons in the group. This can be either anIntVaror aStringVar.widthThe default width of a radiobutton is determined by the size of the displayed image or text. You can set this option to a number of characters ( not pixels) and the radiobutton will always have room for that many characters.wraplengthNormally, lines are not wrapped. You can set this option to a number of characters and all lines will be broken into pieces no longer than that number.Methods onRadiobuttonwidget objects:MethodsDescription.deselect()Clears (turns off) the radiobutton..flash()Flashes the radiobutton a few times between its active and normal colors, but leaves it the way it started..invoke()You can call this method to get the same actions that would occur if the user clicked on the radiobutton to change its state..select()Sets (turns on) the radiobutton.Example:importtkinterastkimporttkmacosxastkmroot=tk.Tk()var=tk.IntVar()r1=tkm.Radiobutton(root,text='Radiobutton1',value=1,variable=var,indicatoron=0,padx=20)r2=tkm.Radiobutton(root,text='Radiobutton2',value=2,variable=var,indicatoron=0,padx=20)r3=tkm.Radiobutton(root,text='Radiobutton3',value=3,variable=var,indicatoron=0,padx=20)r1.pack(pady=10)r2.pack(padx=10)r3.pack(pady=10)root.mainloop()ColorVar VariableColorVar of tkmacosx set same color to each widget it is assigned to. As ColorVar is a tkinter variable wrapper so it will change the color of widgets whenever the change is made to ColorVar instances. ColorVar takes HEX values and all the color names which tkinter supports but theget()method returns only the HEX value. It will work with all of the following keyword arguments of different widgets(eg:-Canvas,Frame,Button,Label, Canvas items, ...).'fg', 'foreground', 'bg', 'background', 'activebackground', 'activeforeground', 'disabledforeground', 'highlightbackground', 'highlightcolor', 'selectforeground', 'readonlybackground', 'selectbackground', 'insertbackground', 'disabledbackground', 'activefill', 'activeoutline', 'disabledfill','disabledoutline', 'fill', 'outline'(might work with more but have not tested).Configurable options for a ColorVar variable. Syntax:ColorVar(root, options=value, ...)OptionsDescriptionvalueThe value is an optional value (defaults to "").nameThe name is an optional Tcl name (defaults to PYVARnum). If _namematches an existing variable andvalueis omitted then the existing value is retained.Methods onColorVarvariable objects:MethodsDescription.get()Returns the current value of the variable..set(value: str)Changes the current value of the variable. If any widget options are slaved to this variable, those widgets will be updated when the main loop next idles.Example:fromtkinterimportTk,LabelfromtkmacosximportColorVar,Button,gradientroot=Tk()root['bg']='#333'root.geometry('200x200')defchange_color(c=0):ifc>=len(color_list):c=0color.set(color_list[c])root.after(50,change_color,c+1)color=ColorVar()color_list=gradient(200)L=Label(root,textvariable=color,bg='#333',fg=color)L.pack(fill='x',expand=1,padx=10,pady=10)B=Button(root,textvariable=color,bg=color,borderless=1,activeforeground=color)B.pack(fill='x',expand=1,padx=10,pady=10)change_color()root.mainloop()DictVar VariableDictVar of tkmacosx stores python dictionary. It is very similar to tkinterStringVarwith few modifications to it.DictVar.get()returns an instance ofdicttype whereas StringVar returnsstrtype also DictVar methodget()is a bit differentget(key=None, d=None)get a key fromget()method ifkey=Noneit will return the complete dictionary.Configurable options for a DictVar variable. Syntax:DictVar(root, options=value, ...)OptionsDescriptionvalueThe value is an optional value (defaults to {}).nameThe name is an optional Tcl name (defaults to PYVARnum). If _namematches an existing variable andvalueis omitted then the existing value is retained.Methods onDictVarvariable objects:MethodsDescription.get(key: any=None, d: any=None)Returns the current value of the variable. To get a specific value of dictionary usekey, give a default value todif thekeyis not available.set(value: str)Changes the current value of the variable. If any widget options are slaved to this variable, those widgets will be updated when the main loop next idles.Example:fromtkinterimport*fromtkmacosximportDictVarroot=Tk()dictionary=DictVar(value={'width':100,'height':200})print(type(dictionary.get()))print(dictionary.get())print(dictionary.get('width'))SaveVarSaveVar of tkmacosx will let you save and load values of tkinter variables (StringVar,IntVar, ..). SaveVar uses pickle module to save values of variables into a file and when the program is executed next time, it will load the same values as they were last time. If the content of the .py file changes, it might not load correct values to the assigned variables. To avoid this issue usenameargument to refer to the exact assigned values later.Configurable options for a SaveVar function. Syntax:SaveVar(var, master=None, value=None, name=None, filename='data.pkl')ParametersDescriptionvarGive thetkinter.Variableclass like (tk.StringVar,tk.IntVar)masterParent widget.valueThe value is an optional value (Given variable's default value).nameSet a name to group variables or to refer to assigned value when loaded.filenameSet the name of the save file. (To make the file invisible in the directory start the name of the file with "." like ".cache-savevar")Example:fromtkinterimport*fromtkmacosximportSaveVarroot=Tk()var1=SaveVar(StringVar,root,'Enter Username','Var1','.cache-savevar')var2=SaveVar(StringVar,root,'Enter Password','Var2','.cache-savevar')Entry(root,textvariable=var1).pack()Entry(root,textvariable=var2).pack()root.mainloop()get_shadeConfigurable options for a get_shade function. Syntax:get_shade(color, shade, mode='auto')ParametersDescriptioncolorGive a color as either HEX or name of the color.shadeThe amount of change required. Takes float between 0.0 to 1.0 eg:shade=0.225.modeUse mode for more control over the shade of the color. Usemode='-'for darker shade, usemode='+'for lighter shade, usemode='auto'to automatically decide the shade(the deafult). To change the intensity of shade checking usemode='auto-110where 110 is the intensity.check_appearanceChecks DARK/LIGHT mode of macOS and returns boolean value. Other settings can also be checked with this function just by passing a different command line argument to check a particular setting tocmdparameter ofcheck_appearance.Configurable options for a check_appearance function. Syntax:check_appearance(cmd='defaults read -g AppleInterfaceStyle').ParametersDescriptioncmdGive commands.For example: To check DARK/LIGHT mode the command is'defaults read -g AppleInterfaceStyle'.check_light_darkTells if the given RGB or HEX code is lighter or darker shade of color. Returns"black"for darker shade and"white"for lighter shade.Configurable options for a check_light_dark function. Syntax:check_light_dark(value, intensity=110).ParametersDescriptionvalueGive sequence of RBG values or hexcode.intensityThe measurable amount of a brightness. By deafult it is 110.gradientThis function returns sequences of rainbow colors hexcodes in order.Configurable options for a gradient function. Syntax:gradient(iteration).ParametersDescriptioniterationLength of the sequences.Changelogv1.0.5Fix Button disabled state (#39)Improved focus out appearance (#39)v1.0.4Fix button with image disappear on setting size (#37)Fix spacebar invoke on Button not working (#32)v1.0.3Fix Button face color and foreground color.Fix Button border line color changing to black when swtiching from dark to light mode.Fix washed out background color of button when window is not in focus (#28)Remove adapting highlightbackground for consistency (#27)Increase button border intensity by 0.15Minor improvements to the overall appearance of the button.v1.0.2Fix unknown color name "systemWindowBackgroundColor" (#20)Partial "borderless" button option support for ttk widgets (#19)Exclude test package in setup.pyv1.0.1Fix widgets not auto-switch light/dark mode. (#18)Fix Button not working with ttk widgets. (#19)v1.0.0Add Tests.Add "-selectcolor" option to ColorVar list.Reorganise tkmacosx package files into multiple packages.Reorganise button items to a separate class.FixMisc._configure()returning 'NoneType'. (#12)Fix text misalignment when changed dynamically under certain situations.Fix -activebackground" not accepting mac deafult system colors names.Fix button appearance when toplevel is out of focus.Fixfocusthickness=0glitch of button.Fix ColorVar not working with -focuscolor of button.Fix unknown option "-bitmap". errorFix "-width", "-height" have effect on 0 value.Fix Marqueecget()issues.Fix "-activebackground" not changing with Variable.Fix ColorVar not working with few Button options.Fix lag when Button is configured.Fix an error withButton.destroy(). (#17)v0.1.6Add new feature,set image as backgroundin Button widget.Add new functions (hex_to_rgb, check_light_dark).Add XView to Marquee widget.Add Radiobutton widget and fix selectcolor issue. (#11)Reorganize properties of BaseButton class.Fix broken links.Fix anchor of Button widget. (#7)Fix focusring appearing for all CircleButton.Fix activebackground and activeforeground of Radiobutton.Remove colors.py fileRemove support for python 2.x.Remove unnecessary code from multiple files.Remove Information.md file.Remove tkmacosx/README.md file.v0.1.5Add newCircleButton Widgetwidget.Fix["key"]to[key]in Marquee.Fix Colorvar not working with item of canvas in 0.1.4.Fix Marquee.play(reset=True) to reset and play the text from beginning.Fix focusthickness of button not working when set to 1.Fix Image not showing when button is active.Fix Text/Image/Bitmap bleed off the button widget.Fix width or height of button widget not working with compound argument.v0.1.4Add new feature"gradient"toColorscalewidget.Add new features toButtonwidget.Add newstop,playandresetmethods to Marquee.Add new featureavoidmousewheelto SFrame.Fix height not working with Button widget issue.Fixforegroundargument not working in Button widget.Fix SFrame not autosizing according to widgets.Redesign classes of widgets.Remove large images.Remove numpy and PIL dependencies.Some other fixes and improvements.v0.1.3Fixcan't invoke "bindtags" commanderror. (#3)v0.1.2Add python 2.x support.Fix half HEX issues. (#6)v0.1.1AddMarqueewidget.ColorVarnow works withCanvasitems as well.FixColorVarnot working with the foreground oftkmacosx.Button.Fix unnecessaryfocus_set()bytkmacosx.Button.Fix issues withmain.py file.Fix issues withSaveVar().v0.1.0AddSaveVar()function to save and load tkinter variable.Fix colors import issue.v0.0.9Fix installation issues.v0.0.8Fix installation issues.v0.0.7Changeeval()withast.literal_eval()in DictVar VariableFix colorscale issues.v0.0.6Add new style tkinter colorscale.v0.0.5Fix a bug whereborderlessfor multiple buttons does not work properly.Improveinit.py file.v0.0.4Fix an import error.v0.0.3Add docstring.v0.0.2Fix an error running commandpython -m tkmacosx.v0.0.1Initial release.ContributingWhen contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method of this repository before making a change.Please make sure to update tests as appropriate.LicenseApache