Tkinter - Treeview Edit Cells Directly

  Рет қаралды 20,846

JobinPy

JobinPy

Күн бұрын

I'll show you how to edit individual cells in the Treeview widget.
You will be able to double-click a cell and edit the value directly.
This involves placing an entry widget over top of a Treeview cell at the right time, which then allows the user to edit the text.
The treeview widget provides the methods we need to make this happen.
A reference site which lists some of the methods we will be using in the Treeview widget:
tkdocs.com/shipman/ttk-Treevie...
0:00 Intro
0:57 Demo app
1:18 Starter code
2:00 Create a treeview class
4:35 Create columns
5:19 Add text to heading
6:42 Insert rows
9:28 Bind to double-click
12:03 Identify region double-clicked
16:43 Identify which item was double-clicked
20:16 Difference between text and values
21:57 Get selected text or values
23:50 Get cell text
27:04 Get cell bounding box
30:43 Create entry widget
35:02 Demo app with entry widget
35:38 Entry focus out binding
37:49 Update treeview data
44:21 Final demo app
45:16 Closure
#tkinter #treeview #pythongui #python3

Пікірлер: 90
@kristosy
@kristosy 2 ай бұрын
Best Tkinter channel I have found! Someone who actually explains real world intermediate/advanced scenarios instead of just "How to create a main window and place a button".
@antoniobuonomo6346
@antoniobuonomo6346 28 күн бұрын
Dall' italia sei un mito continua cosi, grazie 😀molte sto imparando molto (From Italy you are a legend, keep it up, thank you very much, I'm learning a lot)
@lukepemberton3555
@lukepemberton3555 Жыл бұрын
This was so helpful. Your tkinter videos are unrivalled on the internet. Thank you so much
@jobinpy
@jobinpy Жыл бұрын
Thanks for your kind words!
@ahmedragala3946
@ahmedragala3946 9 ай бұрын
I've finished the tutorial, and it works perfectly! Thank you for your generosity!
@vp1o2
@vp1o2 Жыл бұрын
Great tutorial. You are a very good teacher. Thank you.
@ahmedsaliem7041
@ahmedsaliem7041 Ай бұрын
Really excellent tutorial that I haven't seen like it before. Thanks. Thanks again
@RaymondAlman
@RaymondAlman Жыл бұрын
this was good, love to see a simple csv file opened and updated by this method
@mohammedabd-allah2257
@mohammedabd-allah2257 4 ай бұрын
excellent tutorial, straight to the point and addresses all needed. many thanks for sharing
@jobinpy
@jobinpy 3 ай бұрын
Thanks for watching!
@bithepower9081
@bithepower9081 Жыл бұрын
My word you are a genuine genius this was VERY impressive indeed! Thank you for sharing
@user-wn9es7xp2v
@user-wn9es7xp2v Жыл бұрын
I ve been searching this for a week. you are my savior. Thank you very much SIR!
@jobinpy
@jobinpy Жыл бұрын
Glad I could help!
@prwbluz
@prwbluz Жыл бұрын
Superb Tutorial, fabulous teacher. One of the most lucid demonstrations of TreeView.
@jobinpy
@jobinpy Жыл бұрын
Thanks!
@YOYOLUCK88
@YOYOLUCK88 2 жыл бұрын
Very detailed explanation, thanks a lot.
@barrykruyssen
@barrykruyssen Жыл бұрын
Excellent, great subject matter and well presented.
@pierreedelbruck1853
@pierreedelbruck1853 9 ай бұрын
Hi Jobin, and thank you for the nice tutorial. This was exactly what I needed. As I am french, I particularly appreciated the quality of the sound track and your crystal clear speech. About the topic, I would not have expected to have to dig in such details. I was hoping to find an editing feature out of the box in treeview. So, thank you again, Pierre.
@jobinpy
@jobinpy 8 ай бұрын
Thanks for your kind words!
@bolt3360
@bolt3360 3 ай бұрын
Great tutorial :) Only suggestion I have is to include the code from the video as a downloadable file to make adapting it for use in other projects easier. Thank you :D
@alipk2633
@alipk2633 2 жыл бұрын
this such a powerfull addition to tkinter thank you so much
@jobinpy
@jobinpy 2 жыл бұрын
Thanks for watching!
@curtis4u2
@curtis4u2 5 ай бұрын
Exactly what I needed, very well explained and easy to follow. If I can add a tip, the header height is determined by the first header column that tkinter creates. If you want to make the header taller you can add new line symbols to the beginning and end of the first column text like " Vehicle Type ". This would give you a three line header for all columns. Thanks again for this, I will be checking out your other videos as well.
@jobinpy
@jobinpy 5 ай бұрын
Great tip! Thanks for the info and thanks for watching!
@krystian6364
@krystian6364 Жыл бұрын
Amazing video brother, thanks for the help!
@victorhenrique3726
@victorhenrique3726 2 жыл бұрын
Thank you very much for the explanation, besides being a beginner, it helped me a lot because I hadn't found anything that would help with this.
@jobinpy
@jobinpy 2 жыл бұрын
Glad it helped! Thanks for watching.
@kevinrauer
@kevinrauer 2 ай бұрын
What an amazing tutorial.. Thank-you so much, I am looking forward to more of your videos..
@nightsky1979
@nightsky1979 Жыл бұрын
This tutorial is excellent!
@siyabonganxumalo4574
@siyabonganxumalo4574 Жыл бұрын
This is brilliant!
@4notheruser450
@4notheruser450 Жыл бұрын
Thats perfect and explained very detailed thank you
@jobinpy
@jobinpy Жыл бұрын
Glad it was helpful! Thanks for watching.
@sumitnair7499
@sumitnair7499 8 ай бұрын
thanks Jobin ,.. this is video is truly amazing.. keep up the good work and share such amazing and informative videos. 👍
@jobinpy
@jobinpy 8 ай бұрын
Thanks for your kind words!
@davendersingh114
@davendersingh114 2 жыл бұрын
Thanks for explain line by line
@higuys638
@higuys638 2 жыл бұрын
This is what I've been searching for a month. Thank you so much brother. Expecting more videos and support.
@jbt8903
@jbt8903 6 ай бұрын
Excellent Tutorial, the most advanced and Informative video I have seen. I personally learn best be example and this video taught me a lot and explained a lot of things I had questions about. Thank you for your effort. Hopefully there will be a follow up video to get into more details on developing an application. Thank You!
@jobinpy
@jobinpy 6 ай бұрын
Glad it was helpful!
@SamiVauhkonen
@SamiVauhkonen Жыл бұрын
Thanks, nice lesson!
@larrymarek9571
@larrymarek9571 2 ай бұрын
This is exactly what I need! Thank you for to this great video. It would be very helpful if you made the code available, its hard to type with the video
@alexeymatveev9031
@alexeymatveev9031 10 ай бұрын
this is just grand. Thank you very much
@jobinpy
@jobinpy 10 ай бұрын
Glad you liked it! Thanks for watching.
@AnyKeySkywalker
@AnyKeySkywalker Жыл бұрын
Спасибо, все четко и ясно.
@stevemarshall2358
@stevemarshall2358 2 жыл бұрын
Thank you
@elciocarlos3636
@elciocarlos3636 6 ай бұрын
Excelente !!!
@ahmedragala3946
@ahmedragala3946 9 ай бұрын
Thanks!!
@manfredschork299
@manfredschork299 11 ай бұрын
Great, Perfect
@shaliniemmanuel7585
@shaliniemmanuel7585 5 ай бұрын
Hello Jobin, thank you for this video, this was quite useful. I have a couple of questions, can we 1. wrap the text within the cell and automatically increase the size of the row, 2. adding verical and horizontal scrollbars, 3. highlight a column and a cell individually with different color, if yes can you pl. make a video on formatting the Treeview control. thank you
@godsonnudzor357
@godsonnudzor357 3 ай бұрын
Great tutorial, can i use say combo box widget than the entry widget and what about if I want the combo to replace where the sedan is only
@-sg.3665
@-sg.3665 Жыл бұрын
A couple of questions: Why do we record the column index and column iid? Is there a way to write pressed_on_enter without those recorded variables? I still don't understand how they work and why they should be under the entry_edit
@videosyarego
@videosyarego Жыл бұрын
this video is so useful teacher, so I have a question, how to save those entries to update database by selected the rows?
@Ant-up3iy
@Ant-up3iy Жыл бұрын
Jobin. I'm using a pandas dataframe as the source for my editable treeview. I'd like the pass any values changed in the treeview back to the dataframe. I think I need to somehow pass the dataframe (created outside the class) into the class so that it knows about it and can edit it as part of the class's 'on_enter_pressed' function, but not sure how to do it. Hoping you can help.
@krystian6364
@krystian6364 Жыл бұрын
I noticed that using "self.identify_row(event.y)" will basically do the same thing as "selected_iid = self.focus()" - both return row names like "I004", do you think using focus is better or not in this case? Why did you use focus?
@agentbanana1418
@agentbanana1418 3 ай бұрын
Great tutorial, but when I press enter or focus out of the entry widget, the contents of the cell disappear. Why is that?
@bentsionben-david2769
@bentsionben-david2769 Жыл бұрын
How to calculate automatic math method like accountability between different columns and rows?
@sungjecho552
@sungjecho552 2 жыл бұрын
Very helpful !!! One question: Can you advise how to handle if a cell requires multi-lines, such as comments data ?
@jobinpy
@jobinpy 2 жыл бұрын
Hello, Instead of using the Entry widget (which is limited to 1 line), you can use a different widget which supports multiple lines, such as tk.Text with a scrollbar. The text widget and scrollbar could be put into a Frame. Then set the height of the text widget to something that allows the user to type multiple lines. Then place the Frame on a treeview cell when the user wants to type something.
@nobertndiforazeh2191
@nobertndiforazeh2191 Жыл бұрын
Thanks very much for this tutorial Sir. It really helped me and works so well when I code same as you did. Please I have a little challenge Sir. When I create a treeview in a secondary dataframe the edit widget appears in another position from the actual cell I intend to edit, but when the new value is parsed and ‘Enter’ clicked the editing is done and the information gets in the right cell. This is also same when I change the position of the treeview in root Frame from .place(x=0, y=0) to another cordinate say .place(x=300, y=250). Please what can be done to correct this so that each time when I double-click the edit widget should appear just inside the cell I intend to edit as with the example you coded even in different sub-data frames having treeview. Thanks for your kind attention Sir.
@jobinpy
@jobinpy Жыл бұрын
Hello. Thanks for your comment. It appears to do the same thing for me when the treeview widget does not cover the whole window (for example, if it's only taking up a small portion of the window). I will look into this, thanks.
@alkareetesh8193
@alkareetesh8193 Жыл бұрын
How to generate grid lines in treeview sir... Please reply
@PANDURANG99
@PANDURANG99 Жыл бұрын
Getting problem while number starts from zero example 00001 , it takes as 1 in tkinter treeview
@1976arya
@1976arya 7 ай бұрын
Hello dear , I want to know how to change a single cell color (bg or fg) in treeview
@4notheruser450
@4notheruser450 Жыл бұрын
Can you make a video that contains searching elements without search bar and button. If user pressed any string key function will filter elements from rows and shows first matches as highligted on the middle of gui. For instances user typed "Nis" then function shows Nissan on the middle of gui as "Nis" is highlighted. Thanks for videos
@jobinpy
@jobinpy Жыл бұрын
I'll add that idea to my list of possible tutorial topics for future videos. Thanks!
@user-hl3xc3fe6d
@user-hl3xc3fe6d Жыл бұрын
Buenos días, Alguien de casualidad tiene el código que el implemento u otro que este funcionando, tengo un error y no logro solucionarlo, y lo necesito para un proyecto de la universidad, gracias de ante mano
@MMMEHTA99
@MMMEHTA99 5 ай бұрын
great sir,plz make a video of from date to end date search data filter row in python treeview with sqlite database, i try it but not made
@Ant-up3iy
@Ant-up3iy Жыл бұрын
Great video Jobin. What line(s) would I need to be changed when not wanting to use the "tree" column - i.e. not storing data in that column and using the following to hide it: treeview_vehicles['show'] = 'headings'
@jobinpy
@jobinpy Жыл бұрын
Hi @Ant, thanks for watching. The tree column uses the 'text' option to show text in cells for that column, so anything in the video example that uses the 'text' option may not be needed in your case (for example: treeview.insert(....text="tree column text"). When the tree column is hidden, only the 'values' option in the treeview is used for displaying text (example: treeview.insert(....values=("test", "value").
@Ant-up3iy
@Ant-up3iy Жыл бұрын
@@jobinpy Thanks Jobin. I'm populating my "editable" TreeView rows from a pandas dataframe. Would be great if you could do a video on how to expand the class to update a source pandas dataframe when you enter new values in the Treeview cell.
@frflo2476
@frflo2476 Жыл бұрын
t'a sauvé ma NSI, ehmercé la zone
@qddchu976
@qddchu976 6 ай бұрын
this is helpful. have a question, when the entry widget is pop up, then move the scrollbar, how to move the entry widget accordingly so that the treeview table looks intact? Thank you very much
@qddchu976
@qddchu976 6 ай бұрын
or how to just simply disable the scrolling action while a cell is double clicked for editing, then resume the scrolling capability afterwards?
@jobinpy
@jobinpy 6 ай бұрын
One way to deal with this situation is to hide the entry widget when the treeview widget is being scrolled or when the mouse wheel is used. In Linux, which is what I use, is used for wheel up (on the mouse) and is used for wheel down.
@qddchu976
@qddchu976 6 ай бұрын
Thank you so much@@jobinpy
@nitishsharma3038
@nitishsharma3038 Жыл бұрын
please share code also, thanks for this tutorial
@a1976husky
@a1976husky Жыл бұрын
That is a great tutorial! Are you offering the code for download?
@jobinpy
@jobinpy Жыл бұрын
Thanks for watching! I don't have the code available online except in this video.
@sadioba6104
@sadioba6104 Жыл бұрын
the program does not manage to work on my python console I have a python version 3.10 the latest version but when I run the program it tells me that ImportError: cannot import name 'InteractiveConsole' from 'code' and when I import InteractiveConsole it still doesn't work could you help me
@vp1o2
@vp1o2 Жыл бұрын
This is very informative. I wonder there is a Python widget like this to read/write property trees similar to the Eclipse property edit panel.
@TheDev3180
@TheDev3180 Жыл бұрын
Please make full python course, Please
@bentsionben-david2769
@bentsionben-david2769 Жыл бұрын
wow how to iterate (by for/while loop) between different cells in treeview a math method for example (maybe by numply/pandas): last rest = 10 (in column2 row1) new payment = 2 (in colum1 row 2) new rest = 8 (last rest - current payment) (in column2 row2) please consider to make video for this i think hondreads or thousands people will watch it
@jobinpy
@jobinpy Жыл бұрын
Hi, thanks for your comment. I think there are multiple ways to do this. The tutorial video shows the basics of getting and setting values in a treeview cell; you could perhaps use the ideas in the video and create a method in a custom treeview class to iterate rows/cells and calculate values.
@user-rr2vs8zl4u
@user-rr2vs8zl4u Жыл бұрын
Thank You~~As Always~~!!
@funnyclips2696
@funnyclips2696 Жыл бұрын
Wow! This if __name__== __main__ Of what relevant is that line pls?
@jobinpy
@jobinpy Жыл бұрын
if __name__ == "__main__" can be interpreted as "if this python script is the main startup script for the application and not being imported by another python script."
@funnyclips2696
@funnyclips2696 Жыл бұрын
@@jobinpy But must it be included for the codes to run? Can the same objective be achieved without including that line.... It's really confusing for me!
@blackshark4609
@blackshark4609 Жыл бұрын
please upload code to github Sir.
@mezdissa8388
@mezdissa8388 Жыл бұрын
Hello sir Btn.place(x=100,y=150) pycharm does not execute this code
Tkinter - Treeview Insert Images in Rows
24:53
JobinPy
Рет қаралды 5 М.
Tkinter - Multithreading
38:10
JobinPy
Рет қаралды 6 М.
小宇宙竟然尿裤子!#小丑#家庭#搞笑
00:26
家庭搞笑日记
Рет қаралды 17 МЛН
Survive 100 Days In Nuclear Bunker, Win $500,000
32:21
MrBeast
Рет қаралды 117 МЛН
Secret Experiment Toothpaste Pt.4 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 39 МЛН
Каха заблудился в горах
00:57
К-Media
Рет қаралды 10 МЛН
Object Oriented Tkinter
14:06
JobinPy
Рет қаралды 7 М.
Stop, Intel’s Already Dead! - AMD Ryzen 9600X & 9700X Review
13:47
Linus Tech Tips
Рет қаралды 948 М.
JPEG is Dying - And that's a bad thing
8:09
2kliksphilip
Рет қаралды 178 М.
Tkinter - Treeview Get Selected Items
11:43
JobinPy
Рет қаралды 9 М.
Tkinter - Treeview Configure Columns and Headers
18:44
JobinPy
Рет қаралды 6 М.
Convert GUI App to Real Program -  Python to exe to setup wizard
23:27
Python Simplified
Рет қаралды 506 М.
5 Useful Dunder Methods In Python
16:10
Indently
Рет қаралды 56 М.
Create Stunning Python GUIs in 10 Minutes With Drag & Drop
11:38
Coding Is Fun
Рет қаралды 42 М.
Hacker101 - JavaScript for Hackers (Created by @STOKfredrik)
24:17
Pack Vs Grid For Placement - Intro To Tkinter 3
13:20
Tkinter․com
Рет қаралды 2,1 М.
Klavye İle Trafik Işığını Yönetmek #shorts
0:18
Osman Kabadayı
Рет қаралды 9 МЛН
iPhone 15 Pro в реальной жизни
24:07
HUDAKOV
Рет қаралды 505 М.
Rate This Smartphone Cooler Set-up ⭐
0:10
Shakeuptech
Рет қаралды 7 МЛН
low battery 🪫
0:10
dednahype
Рет қаралды 1,8 МЛН
Проверил, как вам?
0:58
Коннор
Рет қаралды 413 М.