Advanced Treeview Filtering Help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JUAN ERNESTO FLORES BELTRAN

    #1

    Advanced Treeview Filtering Help

    Hi you all,

    I am developping a python application which connects to a database
    (postresql) and displays the query results on a treeview. In adittion to
    displaying the info i do need to implement filtering facility for all the
    columns of the treestore/liststore model in order to allow the user an easy
    search method to find the desired information.

    The treestore is created with information related to cars, the columns are:

    car_model car_year car_color car_type car_price
    chevrolet 1998 white sedan 5.000 US$
    ford 1996 blue sedan 3.000 US$
    - - - - -
    - - - - -
    - - - - -

    I have been able to allow filtering to only one column, an extract of my
    code as follows:


    ------------------------------------------------------------------------------------------------------------------------
    #treestore creation
    self.treestore = gtk.TreeStore(s tr, str, str, str, str)
    self.modelfilte r = self.treestore. filter_new()
    self.treeview=g tk.TreeView()

    #append treestore columns
    self.treestore. append(None, [self.model, self.year, self.color,
    self.type, self.price]

    #set treestore model to allow filtering by car_model column
    self.modelfilte r.set_visible_f unc(self.visibl e_cd, self.car_model)

    #the function to filter the treestore
    def visible_cb(self , treestore, iter, x)
    return treestore.get_v alue(iter, 0) in x

    #self.car_model is a list of items wich change according to user needs and
    can be controlled by a #secundary treeview or a button this function is
    not explained.

    ------------------------------------------------------------------------------------------------------------------------

    The code mentioned above does work but i can only fllter by defining
    criterias in the first column. To allow filtering to all the columns i do
    need the following code to work:

    -------------------------------------------------------------------------------------------------------------------------
    treemodelfilter .set_modify_fun c(types, func, data=None)
    def func(model, iter, column, user_data)
    -------------------------------------------------------------------------------------------------------------------------

    where types should be:
    types = (str, str, str, str, str)

    the function to allow filtering:
    def visible_cb(self , treestore, column, iter, x)
    return treestore.get_v alue(iter, column) in x

    and the rest of the code never changes...howev er it is not woking. Any
    suggestion about the code mention?? am i making mistakes?? where?? do i have
    to pass the column number someway to the visible_cb function??? how??

    can any of you suggest a code example to follow and find out how the
    treeview must be coded in order to allow "multicolum n filtering"???

    thanks in advance for your support..
    Juan


  • Jarek Zgoda

    #2
    Re: Advanced Treeview Filtering Help

    JUAN ERNESTO FLORES BELTRAN napisa³(a):
    [color=blue]
    > can any of you suggest a code example to follow and find out how the
    > treeview must be coded in order to allow "multicolum n filtering"???
    >
    > thanks in advance for your support..[/color]

    Your question was answered on PyGTK mailing list. Please, don't crosspost.

    --
    Jarek Zgoda

    Comment

    • alisonken1

      #3
      Re: Advanced Treeview Filtering Help

      [color=blue]
      > Your question was answered on PyGTK mailing list. Please, don't crosspost.[/color]

      Where is the pygtk mailing list?

      Comment

      Working...