exportselection = True, #selected text is automatically exported to the clipboard.
# highlightbackground =
# highlightcolor =
# highlightthickness =
insertbackground = "blue", # Color used for the insertion cursor.
insertborderwidth = 10,
insertofftime = 1000, # Together with insertontime, this option controls cursor blinking. Both values are given in milliseconds.
insertontime = 1000,
insertwidth = 20,
justify = "right", # right,left,center
# invalidcommand =
# invcmd =
readonlybackground = "orange", # The background color to use when the state is “readonly”.
relief = "groove", # flat,raised,ridge,sunken
selectbackground = "black",
selectborderwidth = 2,
selectforeground = "white",
show = "", # Controls how to display the contents of the widget.
state = "normal", # disabled,readonly
# takefocus =
validate = "none"# focusin,focusout,focus
# validatecommand =
# vcmd = # same as validatecommand
# xscrollcommand = # Used to connect an entry field to a horizontal scrollbar. This option should be set to the set method of the corresponding scrollbar.
)
value2 = value.get()
value.set("hello python ...")
entry.focus_set()
entry.delete(0,2)
entry.icursor(3) # Moves the insertion cursor to the given index.
index = entry,index(2) # Gets the numerical position corresponding to the given index.
entry.insert(0,"aaaaaa")
# scan_dragto(x), # Sets the scanning anchor for fast horizontal scrolling to the given mouse coordinate.
# scan_mark(x),# Scrolls the widget contents sideways according to the given mouse coordinate. The text is moved 10 times the distance between the scanning anchor and the new position.
#
# select_adjust(index) [#]
# Same as selection_adjust.
#
# select_clear() [#]
# Same as selection_clear.
#
# select_from(index) [#]
# Same as selection_from.
#
# select_present() [#]
# Same as selection_present.
#
# select_range(start, end) [#]
# Same as selection_range.
#
# select_to(index) [#]
# Same as selection_to.
#
# selection_adjust(index)
# Adjusts the selection to include also the given character. If index is already selected, do nothing.
#
# selection_clear()
# Clears the selection.
#
# selection_from(index)
# Starts a new selection. This also sets the ANCHOR index.
#
# selection_present()
# Checks if text is selected.
#
# lection_range(start, end)
# Explicitly sets the selection range. Start must be smaller than end. Use selection_range(0, END) to select all text in the widget.
#
# selection_to(index)
# Selects all text between ANCHOR and the given index.
#
# xview(index)
# Makes sure the given index is visible. The entry view is scrolled if necessary.
#
# xview_moveto(fraction)
# Adjusts the entry view so that the given offset is at the left edge of the canvas. Offset 0.0 is the beginning of the entry string, 1.0 the end.
#
# xview_scroll(number, what)
# Scrolls the entry view horizontally by the given amount.
# default = # If set, the button is a default button. Tkinter will indicate this by drawing a platform specific indicator (usually an extra border). The default is DISABLED (no default behavior).
# overrelief = # Alternative relief to use when the mouse is moved over the widget. If empty, always use the relief value.
)
button.flash() # Flash the button. This method redraws the button several times, alternating between active and normal appearance.
button.invoke() # Call the command associated with the button.
button.pack()
6. Checkbutton
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# config(**options)
val = tkinter.StringVar()
defcbcall():
val.set(val.get()+"...")
print (val.get())
checkButton = tkinter.Checkbutton(
root,
text = "color",
variable = val,
onvalue = "blue",
offvalue ="none",
command = cbcall
)
# deselect() # Deselects the checkbox; that is, sets the value to offvalue.
# flash() # Redraws the button several times, alternating between active and normal appearance.
# invoke() # Calls the command associated with the button.
# select() # Selects the button; that is, sets the value to onvalue.
# toggle() # Toggles the button.
checkButton.pack()
7. Rudiobutton
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# config(**options)
val = tkinter.StringVar()
defradcall():
print(val.get())
r1 = tkinter.Radiobutton(
root,
text = "one",
variable = val, # the value of the value
# textvariable = # the value of the text
value = "one1",
command = radcall
)
r1.pack()
r2 = tkinter.Radiobutton(
root,
text = "two",
variable = val,
value = "two2",
command = radcall
)
r2.pack()
# deselect() # Deselects the button.
# flash() # Redraws the button a couple of times, alternating between active and normal appearance. This can be useful when debugging, or to indicate when some other user action has activate the button.
# invoke() # Calls the command associated with the button.
# select() # Selects the button.
8. Listbox
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# config(**options)
listbox = tkinter.Listbox(
root,
selectmode = "extended", # browse
activestyle = "underline",
# exportselection =
# listvariable =
# xscrollcommand =
# yscrollcommand =
)
listbox.pack()
for x in [x*2for x in range(10)]:
listbox.insert("end",x)
# lb.bind("<Double-Button-1>", self.ok)
# activate(index)
# bbox(self, index)
# curselection()
# delete(first, last=None)
# get(first, last=None)
# index(index)
# insert(index, *elements)
# itemconfig(index, **options)
# selection_anchor(index) # Sets the selection anchor to the given index. The anchor can be refered to using the ANCHOR index.
# selection_clear(first, last=None) # Removes one or more items from the selection.
# selection_includes(index) # Checks if an item is selected.
# selection_set(first, last=None) # Adds one or more items to the selection.