An Interest In:
Web News this Week
- April 2, 2024
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
September 22, 2022 12:48 am GMT
Original Link: https://dev.to/moogoo78/tkinter-tk-resources-7i4
Tkinter & Tk resources
Documentation
- Tk Commands
- TkDocs Home
- Tkinter 8.5 reference: a GUI for Python
- Welcome to this Tk tutorial! Tk tutorial 2020 documentationTkinter Hello, World! many examples/snippets
Default Widgets
Quick references
Widgets useful methods
The following are some of the most useful methods: - winfo_class: a class identifying the type of widget, e.g. TButton for a themed button- winfo_children: a list of widgets that are the direct children of a widget in the hierarchy- winfo_parent: parent of the widget in the hierarchy- winfo_toplevel: the toplevel window containing this widget - winfo_width, winfo_height: current width and height of the widget; not accurate until appears onscreen - winfo_reqwidth, winfo_reqheight: the width and height the widget requests of the geometry manager (more on this shortly) - winfo_x, winfo_y: the position of the top-left corner of the widget relative to its parent - winfo_rootx, winfo_rooty: the position of the top-left corner of the widget relative to the entire screen the position of the top-left corner of the widget relative to its parent - winfo_rootx, winfo_rooty: the position of the top-left corner of the widget relative to the entire screen - winfo_vieweable: whether the widget is displayed or hidden (all its ancestors in the hierarchy must be viewable for it to be viewable)
def print_hierarchy(w, depth=0): print(' '*depth + w.winfo_class() + ' w=' + str(w.winfo_width()) + ' h=' + str(w.winfo_height()) + ' x=' + str(w.winfo_x()) + ' y=' + str(w.winfo_y())) for i in w.winfo_children(): print_hierarchy(i, depth+1)print_hierarchy(root)
Grid management
grid_forget & grid_remove
grid_slaves()w.grid_remove()destroy()grid_forgetw.grid()# destroyfor widget in frame.winfo_children(): widget.destroy()
life circle ?
update(), update_idletastks()
python - What's the difference between "update" and "update_idletasks"? - Stack Overflow
The important thing to remember is that update blocks until all events are processed. In effect, that means you have a mainloop nested inside a mainloop. It's never a good idea to have an infinite loop inside an infinite loop.
Event
Modifiers
ControlMod1, M1, CommandAltMod2, M2, OptionShiftMod3, M3LockMod4, M4ExtendedMod5, M5Button1, B1Meta, MButton2, B2DoubleButton3, B3TripleButton4, B4QuadrupleButton5, B5
Event types
ActivateDestroyMapButtonPress, ButtonEnterMapRequestButtonReleaseExposeMotionCirculateFocusInMouseWheelCirculateRequestFocusOutPropertyColormapGravityReparentConfigureKeyPress, KeyResizeRequestConfigureRequestKeyReleaseUnmapCreateLeaveVisibilityDeactivate
Some Examples
label.bind('<Button-1>', left_mouse_down) label.bind('<ButtonRelease-1>', left_mouse_up)label.bind('<Button-3>', right_mouse_down)label.bind('<ButtonRelease-3>', right_mouse_up)label.bind('<B1-Motion>', moving_mouse)label.bind('<Enter>', moving_into)label.bind('<Leave>', moving_out)label.bind('<FocusIn>', focus)label.bind('<FocusOut>', unfocus)<Double-Button-1><MouseWheel><Button-4><Button-5><Control-Button-1><space> # lower caseframe.bind('<Control-Shift-S>', key)
Styles
via: 5.6.Relief styles
# Create style Objectstyle = Style()style.configure('TButton', font = ('calibri', 20, 'bold'), borderwidth = '4')# Changes will be reflected# by the movement of mouse.style.map('TButton', foreground = [('active', '! disabled', 'green')], background = [('active', 'black')])
Packages/Widgets
Widgets
- Welcome to ttkwidgetss documentation! ttkwidgets 0.12.0 documentation
- Combobox Autocomplete Python recipes ActiveState Code
Video Player
- huskeee/tkvideo: Python module for playing videos (without sound) inside tkinter Label widget using Pillow and imageio imageio/imageio: Python library for reading and writing image data
- PaulleDemon/tkVideoPlayer: Video player for tkinter. av (ffmpeg4) build
Table/Excel/DataGrid
- ragardner/tksheet: Python 3.6+ tkinter table widget for displaying tabular data
- dmnfarrell/tkintertable: A pure Python library for adding tables to a Tkinter application
- nbro/tktable: Wrapper library for Python of the homonymous Tk library.
- jazzband/prettytable: Display tabular data in a visually appealing ASCII table format
Style/Theme
- COLORS wikiPython
- List of ttk Themes
- PaulleDemon/tkStyleSheet: stylesheet for TkinterHow to make Tkinter look modern? - How to use themes in Tkinter : Python
Books
Original Link: https://dev.to/moogoo78/tkinter-tk-resources-7i4
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To