Advertisement
here2share

tkinter options

Dec 16th, 2022 (edited)
1,001
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.20 KB | None | 0 0
  1. Button(root, text="Button Text", command=button_callback, bg="rgb(255,255,255)",fg="rgb(0,0,0)", font=("Arial",12))
  2. root: the parent widget where the button will be placed
  3. text: the text that will be displayed on the button
  4. command: the function that will be called when the button is clicked
  5. bg: the background color of the button, specified in RGB values ranging from 0 to 255
  6. fg: the text color of the button, specified in RGB values ranging from 0 to 255
  7. font: the font and font size of the text on the button
  8. label = Label(root, text="Label Text", bg="rgb(255,255,255)", fg="rgb(0,0,0)", font=("Arial",12))
  9. root: the parent widget where the label will be placed
  10. text: the text that will be displayed on the label
  11. bg: the background color of the label, specified in RGB values ranging from 0 to 255
  12. fg: the text color of the label, specified in RGB values ranging from 0 to 255
  13. font: the font and font size of the text on the label
  14. entry = Entry(root, show="*")
  15. root: the parent widget where the entry field will be placed
  16. show: the character that will be displayed in place of the user's input (e.g. "*" for password fields)
  17. canvas = Canvas(root, width=200, height=100, bg="rgb(255,255,255)", highlightthickness=0)
  18. root: the parent widget where the canvas will be placed
  19. width: the width of the canvas in pixels
  20. height: the height of the canvas in pixels
  21. bg: the background color of the canvas, specified in RGB values ranging from 0 to 255
  22. highlightthickness: the thickness of the border around the canvas (set to 0 to remove the border)
  23. listbox = Listbox(root, selectmode=SINGLE)
  24. root: the parent widget where the listbox will be placed
  25. selectmode: the selection mode for the listbox, can be SINGLE (only one item can be selected at a time), BROWSE (only one item can be selected and displayed as the "active" item), MULTIPLE (multiple items can be selected at once), or EXTENDED (multiple items can be selected using the Shift and Ctrl/Command keys)
  26. scrollbar = Scrollbar(root, orient=VERTICAL)
  27. root: the parent widget where the scrollbar will be placed
  28. orient: the orientation of the scrollbar, can be VERTICAL or HORIZONTAL
  29. radiobutton = Radiobutton(root, text="Radio Button Text", variable=radio_var, value=1)
  30. root: the parent widget where the radiobutton will be placed
  31. text: the text that will be displayed next to the radiobutton
  32. variable: a StringVar or IntVar that will hold the value of the selected radiobutton
  33. value: the value that will be assigned to the variable when this radiobutton is selected
  34. checkbutton = Checkbutton(root, text="Check Button Text", variable=check_var)
  35. root: the parent widget where the checkbutton will be placed
  36. text: the text that will be displayed next to the checkbutton
  37. variable: a BooleanVar that will hold the state of the checkbutton (True if checked, False if not checked)
  38. menu = Menu(root)
  39. root: the parent widget where the menu will be placed
  40. menu_item = Menu(menu, tearoff=0)
  41. menu: the parent menu where the menu item will be placed
  42. tearoff: a parameter that determines whether the menu item can be separated from the menu (set to 0 to disable tearoff)
  43. submenu = Menu(menu_item, tearoff=0)
  44. menu_item: the parent menu item where the submenu will be placed
  45. tearoff: a parameter that determines whether the submenu can be separated from the menu item (set to 0 to disable tearoff)
  46. menu_item.add_command(label="Menu Item Label", command=menu_callback)
  47. label: the text that will be displayed on the menu item
  48. command: the function that will be called when the menu item is clicked
  49. submenu.add_command(label="Submenu Item Label", command=submenu_callback)
  50. label: the text that will be displayed on the submenu item
  51. command: the function that will be called when the submenu item is clicked
  52. menu.add_cascade(label="Menu Label", menu=menu_item)
  53. label: the text that will be displayed on the menu
  54. menu: the menu item or submenu that will be displayed when the menu is clicked
  55. frame = Frame(root, bg="rgb(255,255,255)")
  56. root: the parent widget where the frame will be placed
  57. bg: the background color of the frame, specified in RGB values ranging from 0 to 255
  58. scale = Scale(root, orient=HORIZONTAL, length=200, from_=0, to=100, tickinterval=25, resolution=1)
  59. root: the parent widget where the scale will be placed
  60. orient: the orientation of the scale, can be VERTICAL or HORIZONTAL
  61. length: the length of the scale in pixels
  62. from_: the minimum value of the scale
  63. to: the maximum value of the scale
  64. tickinterval: the interval between tick marks on the scale
  65. resolution: the smallest increment that the scale will allow
  66. spinbox = Spinbox(root, from_=0, to=100)
  67. root: the parent widget where the spinbox will be placed
  68. from_: the minimum value that the spinbox will accept
  69. to: the maximum value that the spinbox will accept
  70. text = Text(root, width=30, height=10, wrap=WORD)
  71. root: the parent widget where the text widget will be placed
  72. width: the width of the text widget in characters
  73. height: the height of the text widget in lines
  74. wrap: the wrapping mode for the text widget, can be NONE (no wrapping), CHAR (wrap at character boundaries), or WORD (wrap at word boundaries)
  75. combobox = ttk.Combobox(root, values=["Option 1", "Option 2", "Option 3"])
  76. root: the parent widget where the combobox will be placed
  77. values: a list of values that will be displayed in the combobox
  78. frame = Frame(root, width=200, height=100, bg="rgb(255,255,255)", highlightthickness=0)
  79. root: the parent widget where the frame will be placed
  80. width: the width of the frame in pixels
  81. height: the height of the frame in pixels
  82. bg: the background color of the frame, specified in RGB values ranging from 0 to 255
  83. highlightthickness: the thickness of the border around the frame (set to 0 to remove the border)
  84. spinner = Spinbox(root, values=(1, 2, 3, 4, 5))
  85. root: the parent widget where the spinner will be placed
  86. values: a tuple or list of values that the spinner will allow the user to choose from
  87. combobox = ttk.Combobox(root, values=("Option 1", "Option 2", "Option 3"))
  88. root: the parent widget where the combobox will be placed
  89. values: a tuple or list of values that the combobox will allow the user to choose from
  90. separator = ttk.Separator(root, orient=HORIZONTAL)
  91. root: the parent widget where the separator will be placed
  92. orient: the orientation of the separator, can be VERTICAL or HORIZONTAL
  93. progressbar = ttk.Progressbar(root, orient=HORIZONTAL, length=200)
  94. root: the parent widget where the progressbar will be placed
  95. orient: the orientation of the progressbar, can be VERTICAL or HORIZONTAL
  96. length: the length of the progressbar in pixels
  97. slider = Scale(root, from_=0, to=100, orient=HORIZONTAL, resolution=1)
  98. root: the parent widget where the slider will be placed
  99. from_: the starting value of the slider
  100. to: the ending value of the slider
  101. orient: the orientation of the slider, can be HORIZONTAL or VERTICAL
  102. resolution: the incremental step value of the slider
  103. spinbox = Spinbox(root, from_=0, to=100)
  104. root: the parent widget where the spinbox will be placed
  105. from_: the starting value of the spinbox
  106. to: the ending value of the spinbox
  107. combobox = ttk.Combobox(root, values=["Option 1", "Option 2", "Option 3"])
  108. root: the parent widget where the combobox will be placed
  109. values: a list of options that will be displayed in the combobox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement