8/3/2023 0 Comments Treeview tkinter![]() This code works : chat2.insert("", "end", iid=(idmensajeactual,), values=mensaje, tags=(messageid)) To enforce the fact that the message should be applied as a whole, just add a coma at the end : (idmensajeactual,) That's where the bug is : a string is also an iterable ! (it is literally a list of char) so when you try to call insert with the message "This is a message", ttk will apply "This" to the first column, "is" to the second, and so on. Ex: for (col, value) in zip( lumns(), values ) : That's the easiest question : the parameter -values expect an iterable for to apply to each columns. (more infos on the mailing list : ) Third Question : the truncature Windows completely ignores the -borderwidth parameter. However it will not work on Windows : it is a bug (or a feature :p ). Relief = 'flat', # flat ridge for separatorīorderwidth = 0, # zero width for the border Use the style configuration object ttk.Style().configure( '.', # every class of object Map ( lambda col : col.configure( yscrollcommand=vsb.set,xscrollcommand=hsb.set), columns ) ![]() # Link scrollbars activation to top-level object It's a bit more cumbersome than having the three columns in the same tree object, but it works : # Top level Treeview object The scrollbars activations are linked to the top-level tree view. Print(" - can't assign colour of " usuario ".")Ī solution consist of creating a top-level ttk.Treeview object, and another tree for every column. chat2 = ttk.Treeview(height="28", columns="Mensaje", selectmode="extended")Ĭhat2.heading('#1', text='Mensaje', anchor=CENTER)Ĭlumn('#1', stretch=NO, minwidth=400, width=620)Ĭlumn('#0', stretch=NO, minwidth=0, width=0)Īnd this goes on message: ("", "end", iid=(idmensajeactual), values=mensaje, tags=(messageid))ī_configure(messageid, foreground='#' colorfuente) #tfl No idea why neither :\ this is the new code about the first word issue. It's possible to bound to 3 treeviews? (If yes: how?, worth?, should i?)Īnd also another problem: all attempts to remove treeview border have failed in TTK python.Īnother problem is that now the Mensaje treeview only displays the first word. It's there a way to bound a scrollbar to 3 different treeviews? all my attemps had failed so far and i can move only one of the treeview with a scrollbar. ![]() Now I tried to do 3 different treeviews (1 column each) and it ends up this way:Īlthough that fix the colour issue, i have a new issue: The scrollbar. I tried for a long time now but it's 4 AM and I surrender ☹ Is there any way to do it? ![]() What I want is to change only the colour of the text of the #2 column (just the message) and not the entire row (not Nick or Time columns). Now, that works perfectly (here's a screenshot as an example): but that last line of code changes the colour of all 3 columns in that row. ![]() This is the code for the treeview: chat = ttk.Treeview(height="26", columns=("Nick","Mensaje","Hora"), selectmode="extended")Ĭhat.heading('#1', text='Nick', anchor=W)Ĭhat.heading('#2', text='Mensaje', anchor=W)Ĭhat.heading('#3', text='Hora', anchor=W)Ĭhat.column('#1', stretch=NO, minwidth=0, width=130)Ĭhat.column('#2', stretch=NO, minwidth=0, width=620)Ĭhat.column('#3', stretch=NO, minwidth=0, width=65)Ĭhat.column('#0', stretch=NO, minwidth=0, width=0) #width 0 to not display itĪnd I add items like this: chat.insert("", "end", "", values=((user, message, time)), tags=(messageid))Ĭhat.tag_configure(messageid, foreground='#ff0000') I am doing a chat client using a treeview with multiple columns in Python. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |