Search Results

Search found 6 results on 1 pages for 'pygi'.

Page 1/1 | 1 

  • Keybindings for individual letter keys (not modifier-combinations) on a GtkTextView widget (Gtk3 and PyGI)

    - by monotasker
    I've been able to set several keybord shortcuts for a GtkTextView and a GtkTextEntry using the new css provider system. I'm finding, though, that I only seem to be able to establish keybindings for combinations including a modifier key. The widget doesn't respond to any bindings I set up that use: the delete key the escape key individual letter or punctuation keys alone Here's the code where I set up the css provider for the keybindings: #set up style context keys = Gtk.CssProvider() keys.load_from_path(os.path.join(data_path, 'keybindings.css')) #set up style contexts and css providers widgets = {'window': self.window, 'vbox': self.vbox, 'toolbar': self.toolbar, 'search_entry': self.search_entry, 'paned': self.paned, 'notelist_treeview': self.notelist_treeview, 'notelist_window': self.notelist_window, 'notetext_window': self.notetext_window, 'editor': self.editor, 'statusbar': self.statusbar } for l, w in widgets.iteritems(): w.get_style_context().add_provider(keys, Gtk.STYLE_PROVIDER_PRIORITY_USER) Then in keybindings.css this is an example of what works: @binding-set gtk-vi-text-view { bind "<ctrl>b" { "move-cursor" (display-lines, -5, 0) }; /* 5 lines up */ bind "<ctrl>k" { "move-cursor" (display-lines, -1, 0) }; /* down */ bind "<ctrl>j" { "move-cursor" (display-lines, 1, 0) }; /* up */ } Part of what I'm trying to do is just add proper delete-key function to the text widgets (right now the delete key does nothing at all). So if I add a binding like one of these, nothing happens: bind "Delete" { "delete-selection" () }; bind "Delete" { "delete-from-cursor" (chars, 1) }; The other part of what I want to do is more elaborate. I want to set up something like Vim's command and visual modes. So at the moment I'm just playing around with (a) setting the widget to editable=false by hitting the esc key; and (b) using homerow letters to move the cursor (as a proof-of-concept exercise). So far there's no response from the escape key or from the letter keys, even though the bindings work when I apply them to modifier-key combinations. For example, I do this in the css for the text-widget: bind "j" { "move-cursor" (display-lines, 1, 0) }; /* down */ bind "k" { "move-cursor" (display-lines, -1, 0) }; /* up */ bind "l" { "move-cursor" (logical-positions, 1, 0) }; /* right */ bind "h" { "move-cursor" (logical-positions, -1, 0) }; /* left */ but none of these bindings does anything, even if other bindings in the same set are respected. What's especially odd is that the vim-like movement bindings above are respected when I attach them to a GtkTreeView widget for navigating the tree-view options: @binding-set gtk-vi-tree-view { bind "j" { "move-cursor" (display-lines, 1) }; /* selection down */ bind "k" { "move-cursor" (display-lines, -1) }; /* selection up */ } So it seems like there are limitations or overrides of some kind on keybindings for the TextView widget (and for the del key?), but I can't find documentation of anything like that. Are these just things that can't be done with the css providers? If so, what are my alternatives for non-modified keybindings? Thanks.

    Read the article

  • Change font programmatically for GTK3 TextView (quickly-widgets TextEditor)

    - by monotasker
    In an app using PyGI and GTK3, I'm trying to let the user set the font family and size in a TextView through my app's settings dialog. In PyGI the TextView object has "set" methods for several properties, but not for font properties. I can set the font family via CSS using a CSS style provider. But I can't change that CSS dynamically to respect the font selected by a user. So how can I do this? (Note that the widget in question is actually the TextEditor from the quickly-widgets package and I'm using Quickly to build the app.) Thanks, Ian

    Read the article

  • What package do I need to install to develop plugins for gedit?

    - by Wes
    I'm using Ubuntu 12.04 with python 2.7.3 and PyGObject and I'd like to develop plugins for Gedit in python. I found a simple looking tutorial for this sort of thing here. According to the tutorial, I need the Gedit module to interact with the plugin interface: from gi.repository import GObject, Gedit I keep getting an import error when trying to import the Gedit module. So, my question is: what package do I need to install to get this module? I've tried: gedit-dev , gedit-plugins Edit: Here is the full traceback for the above statement: ERROR:root:Could not find any typelib for Gedit Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name Gedit

    Read the article

  • How to get rid of the background gradient of the inline GtkToolbar?

    - by Dima
    When you run the below code, it will show an inline toolbar in a window. Notice how the inline toolbar has a stand-out backbround. Is there a way to apply CSS to get rid of it and make blend with regular window color? #!/usr/bin/python3 from gi.repository import Gtk button_names = [Gtk.STOCK_ABOUT, Gtk.STOCK_ADD, Gtk.STOCK_REMOVE, Gtk.STOCK_QUIT] buttons = [Gtk.ToolButton.new_from_stock(name) for name in button_names] toolbar = Gtk.Toolbar() toolbar.set_show_arrow(False) for button in buttons: toolbar.insert(button, -1) style_context = toolbar.get_style_context() style_context.add_class(Gtk.STYLE_CLASS_INLINE_TOOLBAR) grid = Gtk.Grid() grid.add(toolbar) label = Gtk.Label() grid.add(label) window = Gtk.Window() window.set_size_request(200, 50) window.add(grid) window.connect('delete-event', Gtk.main_quit) window.show_all() Gtk.main()

    Read the article

  • How to programmatically fetch a list of applications from the Software Center

    - by David Planella
    Im writing a PyGI app where I'd like to show a list of matching applications from the Ubuntu Software Centre in an auto-completion text entry or dropdwon. I haven't yet figured out the best way to present the information, I just want to make it easier for the user to type the name of an application. But before that, I'd like to figure out how to get the data. Is there an API to get a list of all applications from the Software Centre, or indirectly through the Applications Dash in Unity?

    Read the article

  • How to generate GIR files from the Vala compiler?

    - by celil
    I am trying to create python bindings to a vala library using pygi with gobject introspection. However, I am having trouble generating the GIR files (that I am planning to compile to typelib files subsequently). According to the documentation valac should support generating GIR files. Compiling the following helloworld.vala public struct Point { public double x; public double y; } public class Person { public int age = 32; public Person(int age) { this.age = age; } } public int main() { var p = Point() { x=0.0, y=0.1 }; stdout.printf("%f %f\n", p.x, p.y); var per = new Person(22); stdout.printf("%d\n", per.age); return 0; } with the command valac helloworld.vala --gir=Hello-1.0.gir doesn't create the Hello-1.0.gir file as one would expect. How can I generate the gir file?

    Read the article

1