How to add a continuous keypress ?

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

Posts: 1
Joined: Thu Jan 28, 2016 4:01 am UTC

How to add a continuous keypress ?

Postby anespa » Thu Jan 28, 2016 4:03 am UTC

Dear Friends,
In my pygtk application I need the continuous event of keypress for an entry in GtkTreeView. I need the key must be forward navigation ..

I write a sample code here . It work for right click of mouse . But in my case I need continous event on pressing the button continuosly...

please refer the following code and advise a solution ...

Code: Select all

# example

import pygtk
import gtk

class BasicTreeViewExample:

    # close the window and quit
    def delete_event(self, widget, event, data=None):
        return False

    def button_press_event(self, treeview, event):
      if event.button == 3: # right click
        #model, path = treeview.get_path_at_pos(int(event.x), int(event.y))
        print "ya allah"

    def __init__(self):
        # Create a new window
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)

        self.window.set_title("Basic TreeView Example")

        self.window.set_size_request(200, 200)

        self.window.connect("delete_event", self.delete_event)

        # create a TreeStore with one string column to use as the model
        self.treestore = gtk.TreeStore(str)

        # we'll add some data now - 4 rows with 3 child rows each
        for parent in range(4):
            piter = self.treestore.append(None, ['parent %i' % parent])
            for child in range(3):
                self.treestore.append(piter, ['child %i of parent %i' %
                                              (child, parent)])

        # create the TreeView using treestore
        self.treeview = gtk.TreeView(self.treestore)

        # create the TreeViewColumn to display the data
        self.tvcolumn = gtk.TreeViewColumn('Column 0')

        # add tvcolumn to treeview

        # create a CellRendererText to render the data
        self.cell = gtk.CellRendererText()

        # add the cell to the tvcolumn and allow it to expand
        self.tvcolumn.pack_start(self.cell, True)

        # set the cell "text" attribute to column 0 - retrieve text
        # from that column in treestore
        self.tvcolumn.add_attribute(self.cell, 'text', 0)

        # make it searchable

        self.treeview.connect('button-press-event' , self.button_press_event)

        # Allow sorting on the column

        # Allow drag and drop reordering of rows



def main():

if __name__ == "__main__":
    tvexample = BasicTreeViewExample()


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 10 guests