Widgets Standard Attributes in Python


Tkinter GUI widgets's Standard Attributes 

Standard attributes are used to provide a design or look to the widgets, like size, colour, font etc

Dimensions
  • height : desired height of widget
  • width : desired width f the widget
  • underline : to underline the widget text
  • wraplength : maximum length set for single line, no of max characters in each line
  • padx : extra space left and right
  • pady : extra space above and below
  • borderwidth : to give a 3-D look to the Widget
  • selectborderwidth : border width of 3-D widget on selected item 
  • highlightthickness : width of highlighted part when on focus
all above option are assigned an integer value and by default it is in pixel, you have option to change the same followed by character as mentioned below
  • c : in centimeters 
  • i : in inches
  • m : millimeters
  • p : pixels


Colour
  • background ( bg ) : background colour of widget
  • activebackground : background colour of widget active state
  • highlightbackground : to set background colour of highlighted part in focus
  • selectbackground : background colour of the selected item of widget
  • foreground ( fg ) : to give text inside widget a colour
  • activeforeground : to give text a colour when its active
  • selectforeground : text colour of the selected part of widget
  • disableforeground : colour of text when it is disabled
  • highlightcolor : foreground colour of the highlighted section when in focus
can set colours in 2 ways
    locally defined standard colours : black, red, white, green, yellow, blue, cyan, magenta
    hexadecimal colour code : #ffffff, #000000 and more from #000000-#ffffff.



Fonts
this is to give fonts to the text part, it should go as tuple and need to be collected in font_object

Font (options,........)

options are
  • family : font family name as string
  • size : font height in integers
  • weight : bold and normal for text weight
  • slant : italic and roman to style text
  • underline : 1 to underline text, 0 to not underline
  • overstrike : 1 for overstruck text, 0 for normal one


Anchor
this is used to position the text w.r.t. reference point
  • NW : NoethWest
  • N : North
  • NE : North East
  • W : West
  • CENTER : CENTER
  • E : East
  • SW : South West
  • S : South
  • SE : South East


Relief
to give a 3-D effect around Widget. below is the list of relief styles
  • FLAT
  • RAISED
  • SUNKEN
  • GROOVE
  • RIDGE
Example :




Bitmap
to display a graphical symbol, bit map is used, set bitmap to below values as a string
  • "error"
  • "gray75"
  • "gray50"
  • "gray25"
  • "gray8"
  • "hourglass"
  • "info"
  • "questhead"
  • "question"
  • "warning"

Example :




Cursor
below is a list of shape can be set as cursor when hover on Widget
  • "arrow"
  • "circle"
  • "clock"
  • "cross"
  • "dotbox"
  • "exchange"
  • "fleur"
  • "heart"
  • "heart"
  • "man"
  • "mouse"
  • "pirate"
  • "plus"
  • "shuttle"
  • "sizing"
  • "spider"
  • "spraycan"
  • "star"
  • "target"
  • "tcross"
  • "trek"
  • "watch"





Comments

My photo
Techno Xpresss
Bangalore, Karnataka, India