logo
down
shadow

is there a way to detect a press of a column header of a treeview?


is there a way to detect a press of a column header of a treeview?

By : 99 Stores Like
Date : October 17 2020, 06:10 PM
like below fixes the issue I actually already found a solution. When assigning the column headers there's a kwarg for a command so the code could look like this:
code :
import tkinter as tk      # Tk
import tkinter.ttk as tkk # treeview

root = tk.Tk()

# create the Treeview
tv = ttk.Treeview(root)
tv['columns'] = ('a', 'b', 'c')
tv['show'] = 'headings' #remove "#0" column

# Add column headers and Click commands
tv.heading('a', text='header a', command=lambda: print('a is pressed!')
tv.heading('b', text='header b', command=lambda: print('b is pressed!')
tv.heading('c', text='header c', command=lambda: print('c is pressed!')




Share : facebook icon twitter icon
Detect when column in gtk.treeview is resized

Detect when column in gtk.treeview is resized


By : user17463
Date : March 29 2020, 07:55 AM
Does that help gtk.TreeViewColumns aren't widgets so they unfortunately don't have a dedicated signal for size changes. But you can register a callback function that receives "width" change notifications:
code :
def onColWidthChange(col, width):
    # Note that "width" is a GParamInt object, not an integer
    ...

col.connect("notify::width", onColWidthChange)
Populating TreeView with column header and subheader

Populating TreeView with column header and subheader


By : scienceape
Date : March 29 2020, 07:55 AM
I hope this helps you . for the introducing the TreeView to my knowledge! With the help of this article, I have got it working with your conditions.
Design view | Executed of the userform:
code :
Option Explicit

Sub UserForm_Initialize()
    With Me.TreeView1
        .BorderStyle = ccFixedSingle
        .CheckBoxes = True
        .Style = tvwTreelinesPlusMinusText
        .LineStyle = tvwRootLines
    End With

    UpdateTreeView
End Sub

Private Sub UpdateTreeView()
    Dim WB As Workbook
    Dim WS As Worksheet
    Dim HeaderRng As Range
    Dim rng As Range
    Dim sCurrGroup As String
    Dim sChild As String
    Dim oNode As Node

    Set WB = ThisWorkbook
    Set WS = WB.Worksheets("Data")
    With WS ' Row A are Header/Groups
        Set HeaderRng = Intersect(.Rows(1), .UsedRange)
    End With

    With Me.TreeView1
        With .Nodes
            '.Clear
            sCurrGroup = ""
            For Each rng In HeaderRng
                'Debug.Print "rng: " & rng.Address & " | " & rng.Value
                sCurrGroup = rng.Value
                ' Add Node only if it does NOT exists
                Set oNode = Nothing
                On Error Resume Next
                Set oNode = .Item(sCurrGroup)
                If oNode Is Nothing Then
                    'Debug.Print "Adding Group: " & sCurrGroup
                    .Add Key:=sCurrGroup, Text:=sCurrGroup
                End If
                On Error GoTo 0

                ' Add the Child below the cell
                sChild = rng.Offset(1, 0).Value
                'Debug.Print "Adding [" & sChild & "] to [" & sCurrGroup & "]"
                .Add Relative:=sCurrGroup, Relationship:=tvwChild, Key:=sChild, Text:=sChild
            Next
        End With
        For Each oNode In .Nodes
            oNode.Expanded = True
        Next
    End With

    Set HeaderRng = Nothing
    Set WS = Nothing
    Set WB = Nothing
End Sub
Detect click on a table column header, hide the column, then display it again

Detect click on a table column header, hide the column, then display it again


By : Bruce
Date : March 29 2020, 07:55 AM
To fix the issue you can do I saw this response on how to hide a column. I need a little more complicated behavior. I have a react table like this , I would have a list of hidden table headers in state
code :
this.state = {hidden: []}
<th onClick={() => hideHeader('cost')}>
hidden.indexOf('cost') !=== -1 ? <someheader/> : null
How to detect resizing of ttk.Treeview column?

How to detect resizing of ttk.Treeview column?


By : Preksha Das
Date : March 29 2020, 07:55 AM
will help you Following CommonSense suggestions, I have made a binding on to check if a column has been resized. If tree.identify_region(event.x, event.y) is 'separator' then there was a resizing. Then I need to identify the columns on both sides of the separator. tree.identify_column(event.x) gives me the column on the left in the form '#' and from it I can get the id of the column on the right. Finally, I execute the function that resize the columns in all trees.
code :
import tkinter as tk
from tkinter import ttk

root = tk.Tk()


def on_click_release(event):
    tree = event.widget
    if tree.identify_region(event.x, event.y) == 'separator':
        left_column = tree.identify_column(event.x)
        right_column = '#%i' % (int(tree.identify_column(event.x)[1:]) + 1)
        width_l = tree.column(left_column, 'width')
        width_r = tree.column(right_column, 'width')
        for tree2 in trees:
            if tree2 != tree:
                tree2.column(left_column, width=width_l)
                tree2.column(right_column, width=width_r)


notebook = ttk.Notebook(root)
notebook.pack()

trees = [ttk.Treeview(notebook, columns=['a', 'b', 'c']) for i in range(4)]

for i, tree in enumerate(trees):
    tree.bind('<ButtonRelease-1>', on_click_release)
    notebook.add(tree, text='Tab %i' % i)

root.mainloop()
import tkinter as tk
from tkinter import ttk


def tab_changed(event):
    global current_tab
    tab = notebook.index('current')  # get newly visible tab number
    tree1 = trees[current_tab]  # get previously visible tree
    tree2 = trees[tab]   # get newly visible tree
    cols = ('#0', ) + tree1.cget('columns')  # tuple of all columns
    for column in cols:
        tree2.column(column, width=tree1.column(column, 'width'))
    current_tab = tab


root = tk.Tk()
notebook = ttk.Notebook(root)
notebook.pack()

trees = [ttk.Treeview(notebook, columns=['a', 'b', 'c']) for i in range(4)]
current_tab = 0  # store currently visible tab number

for i, tree in enumerate(trees):
    notebook.bind('<<NotebookTabChanged>>', tab_changed)
    notebook.add(tree, text='Tab %i' % i)

root.mainloop()
PyGtk3 - Creating a Gtk.TreeView column header with an icon?

PyGtk3 - Creating a Gtk.TreeView column header with an icon?


By : Vinay
Date : March 29 2020, 07:55 AM
Does that help
What I've done is create a horizontal Gtk.Box that contains a Gtk.Label and a Gtk.Button. I've placed this Box above the Gtk.TreeView. I've done this with Glade. You also should hide the columns of your Gtk.TreeView with Gtk.TreeView.set_headers_visible(False) so you only have your Widget as column.
code :
    # [2] The TreeView column 
    self.__w_treeview.set_headers_visible(False) 
    self.__w_samples_renderer_text = Gtk.CellRendererText()
    self.__w_samples_column = Gtk.TreeViewColumn("", self.__w_samples_renderer_text, text=1)
    self.__w_samples_column.set_sort_column_id(1)   
    self.__w_treeview.append_column(self.__w_samples_column)
Related Posts Related Posts :
  • Unit Test Won't Run Tests
  • Use two for loops simultaneously
  • can we display glass bar chart in python with google app engine
  • Scapy install issues. Nothing seems to actually be installed?
  • Why do people write the #!/usr/bin/env python shebang on the first line of a Python script?
  • What does s() mean?
  • ROC AUC value is 0
  • Why is this the value?
  • Best practices for logging in django project
  • Is there a python openid apps-discovery library to get appengine apps onto the apps marketplace
  • Cannot fetch a web site with python urllib.urlopen() or any web browser other than Shiretoko
  • Similar to ``tabnanny``, how can I check that all the python code is using 4 spaces as an indent?
  • Python: object identity question?
  • Multiple For loops, print else only once if condition is not met
  • Select one item from Series and keep the index
  • __repr__ method appears can't be invoked automatically for Exception class
  • Problem with list value (ValueError) in python 3
  • How to get TouchSensor nested under joint in Webots (Python API)
  • How to specify kernel while executing a Jupyter notebook using Papermill's Python client?
  • How to hide password in Database Connection?
  • How to get a list of dictionaries from the following code?
  • 'How to find out noun to which pronoun is referring to' in python
  • Removing a character (^) from each row of panda Dataframe and get unique words in each row
  • Changing a static variable of inherited classes
  • Django Query result comparison with if statement
  • Python: how to merge two dataframe based only on different columns?
  • Filter data by last 3 months and by ID
  • Inplace arithmetic operation versus normal arithmetic operation in PyTorch Tensors
  • How can I add custom signs to spaCy's punctuation functionality?
  • Ensure positive difference of two numbers
  • i keep getting an error that my list index is out of range
  • Is there a way to create gantt charts in python?
  • How to view network weights and bias during training
  • How can I force SAS to wait for a command to fully execute?
  • Remove all occurences of a value from a nested dictionary
  • How to ensure secure randomization for python password generator
  • Amazon SageMaker deploying from model artifacts - what object do we load from archive?
  • [] parameter or input used in sum() function - what is it doing?
  • Outlook email text formatting from Python application
  • Python 3 - comparing enums against hex value
  • Elegant way to check if a float is between two numbers in Python?
  • Understanding return [0,size-1][nums[0]<nums[size-1]] in Python
  • How do I make this script that heats up my CPU safe
  • RegEx for matching capital letters and numbers
  • What is differnces between array[0] and array[0:1] in Python?
  • How to run both items in scrapy function?
  • How to count the number of sequences of n numbers where no two adjacent numbers are the same?
  • Is there a more efficient way to re-write multi if-else statement
  • ValueError: Error when checking target: expected dense_3 to have shape (1000,) but got array with shape (1,)
  • SytanxError: Invalid Sytax
  • Setting debug = False makes the Django app crash with the following error, how to fix it?
  • How to get the average of many lists embedded within each other?
  • Paramiko with subprocess
  • 2D table conversion for example: y = f(x1,x2) => x1 = f(y, x2)
  • Return a literal string of a tuple in python
  • How to split a Column when you have same values?
  • How to perform str.strip in dataframe and save it with inplace=true?
  • why zip(*k) can't work when k is a iterator?
  • How to get list as an input from command line python?
  • Is Tensorflow Dataset.from_generator deprecated in tensorflow 2.0 ? It throws tf.py_func deprecation error
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk