Hot answers tagged

15

Development libraries usually don't show up very well in the software center. Usually using apt-cache search will help here. So for example: apt-cache search python gobject Will show you all the packages related to python and gobject introspection. Here is a snippet of the results: python-gi - Python 2.x bindings for gobject-introspection libraries python-...


15

This means the program you are running is looking for a particular python library called pygtk, which allows your program to have a gui. So, to let the program work, you need to install pygtk: sudo apt-get install python-gtk2-dev That should do it.


11

You can install python-gtk2 manually from 18.04 LTS repository: cd ~/Downloads wget http://archive.ubuntu.com/ubuntu/pool/universe/p/pygtk/python-gtk2_2.24.0-5.1ubuntu2_amd64.deb sudo apt-get install ./python-gtk2_2.24.0-5.1ubuntu2_amd64.deb and use it as usual :)


8

The problem is that you are looking at the PyGTK documentation, but are using PyGI/GTK3 in your script. The docs on gtk_widget_render_icon() says the following: gtk_widget_render_icon has been deprecated since version 3.0 and should not be used in newly-written code. Use gtk_widget_render_icon_pixbuf() instead. Then the docs on ...


7

You can do that stuff with devilspie. Install the devilspie package, and write the following configfile (save as ~/.devilspie/gnome-terminal.ds) (if (is (window_role) "borderless") (begin (geometry "+0+0") (maximize_vertically) (undecorate) ) ) Now you just run devilspie when you log in (e.g. by adding it to startup applications), then ...


7

try: from gi.repository import Gtk and replace gtk by Gtk in your code or from gi.repository import Gtk as gtk see also : Python GTK+ 3 Tutorial : Getting Started


6

This is a tricky one, I had a similar problem, when trying to have only a ncurses based interface on a time tracker pc, the problem for me was that when no window manager is present, normal X Window applications behave oddly. Here's my proposal: Install ratpoison window manager sudo apt-get install ratpoison Unbind keyboards that shows a menu or allows ...


5

Using the function list_icons(): icons=icon_theme.list_icons() for icon in icons: if 'usb' in icon: print icon and the output: drive-removable-media-usb usbpendrive_unmount gnome-dev-removable-usb usb-creator drive-harddisk-usb gnome-dev-harddisk-usb gnome-dev-unknown-usb usb-creator-gtk drive-harddisk-usb-symbolic Now take your pic


5

You can get the contents of a TextBuffer using get_text(): start_iter = self.textbuffer.get_start_iter() end_iter = self.textbuffer.get_end_iter() text = self.textbuffer.get_text(start_iter, end_iter, True) And save it like any other text file: with open(save_file, 'w') as f: f.write(text) I suggest that you ...


5

python packages installed system-wide may not be available for python versions installed in anaconda directories. Try instead to load your script using the full path to the system interpreter: $ /usr/bin/python3 Python 3.4.0 (default, Apr 11 2014, 13:05:11) [GCC 4.8.2] on linux Type "help", "copyright", "credits" or "license" for more information. >>...


5

Use the GObject introspection based Python3 bindings for Gtk and friends: from gi.repository import Gtk, GObject That needs the package python3-gi which is installed by default. Some names have changed since PyGTK. The Python GObject Introspection API Reference should help you to find the new names (and other changes).


4

Try to kill it via the process list: Or - if you want to be more nerdy - kill it via the console, using $>top


4

You need to tell xgettext that your file is a Glade file: xgettext -k_ -kN_ -L Glade -o messages.pot *.ui


4

Threads and GTK don't always play nice together. There are a few tricks that help, but don't be surprised to have weird bugs. I recently removed all threads from an application and it feels much better. So, the first thing you should think about is whether you can rewrite your application to take advantage of the GLib async methods. If you insist on having ...


4

I theme my popup windows like so: #Use Css themes css = Gtk.CssProvider() css.load_from_data(""" .popup {background-color: rgba(0,0,0,0); border: 0px rgba(255,255,255,0); border-radius: 14px; border-width: 0; } """ Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), css, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) #Get ...


4

The problem with this segmentation fault is in Kazam hotkeys bindings. Maybe the system cannot give some keybingings to Kazam, thus we get an exception. The rough solution is to remove Kazam’s global keybingings: Open the file: /usr/lib/python3/dist-packages/kazam/frontend/indicator.py Find these strings (about line 100 or so): Keybinder.bind("<Super&...


3

"on_preference_window_destroy":self.on_quit, This line is your problem. When the window is destroyed, you're calling a quit method. When you close the window, it gets destroyed, thus resulting in your quit method being called. Also, you don't want to call sys.exit(0) to exit a GTK+ application. You want to use Gtk.main_quit() instead. It would also be a ...


3

Using time.sleep() is not a good idea when you are using gtk. You could try use a timer event. (I don't use quickly anymore but this should work i think.) from gi.repository import GLib class Just_for_correct_coding(): self.per = int() def start(self): GLib.timeout_add_seconds(1, self.calc) def calc(self,treeiter): store=self....


3

EDIT Here's the correct function to use: Gtk.TextIter.forward_to_tag_toggle() here's an example that generates a list of all bolded words: start = self.textbuffer.get_start_iter() bolded=[] while start.forward_to_tag_toggle(self.tag_bold): begin=start.copy() start.forward_to_tag_toggle(self.tag_bold) bolded.append(self....


3

Yes it's possible. No it's probably not worth it for redistribution. If you did manually update your pygi+webkit you would have to shove that in a ppa and depend on your own packaged version of WebKit in order to "send" the functionality to other users. You would run the risk of breaking other things that depend on the current version in repo, which ...


3

Your /opt/gnome directory is not writable by you. either chmod 777 /opt/gnome/ -R or better yet, configure jhbuild to run from your home directory. If you followed those directions exactly jhbuild would be running as a normal user not as root.


3

Here you go, taken from the Seahorse source: from gi.repository import Gtk, Gio icon_theme = Gtk.IconTheme.get_default() def get_pixbuf_from_themed_icon(name, size): icon = Gio.ThemedIcon.new_with_default_fallbacks(name) icon_info = icon_theme.lookup_by_gicon(icon, size, 0) return icon_info.load_icon() pixbuf_lock = get_pixbuf_from_themed_icon(...


3

Here's a simple example: from gi.repository import Gtk class MyExample(Gtk.Window): def __init__(self): Gtk.Window.__init__(self) self.connect("delete-event", Gtk.main_quit) liststore = Gtk.ListStore(str) for match in ["test1", "test2", "test3", "spam", "foo", "eggs", "bar"]: liststore.append([match]) ...


3

The sound indicator in Ubuntu has sliders for the volume and I wondered how that is possible. After a look in the code it seems there are GtkMenus which can be filled via dbus meanwhile: https://developer.ubuntu.com/api/devel/ubuntu-12.04/c/dbusmenugtk/index.html But I don't know how to use them. Wanted to write a sound indicator where I can control the ...


3

Another way that I use personally is apt-file sudo apt-get install apt-file apt-file update Now you can search the packages for the missing files, eg: % apt-file search /usr/include/sasl/sasl.h libsasl2-dev: /usr/include/sasl/sasl.h therefore: sudo apt-get install libsasl2-dev Or another example % apt-file search /usr/bin/cups-config libcups2-dev: /...


3

Solved: I just needed to install python3-xlib: sudo apt-get update sudo apt-get install python3-xlib


2

How can i add an icon to the status bar using python ? like the skype icon ? It is called 'app indicator' not status bar icon, use the command quickly add indicator for it and is it possible to use the default notifications like those that appear when connecting or disconnecting to a wifi ? It is notify-osd,here is the guide for it


2

You need to read point 5 in https://wiki.ubuntu.com/UbuntuOne/Headless which is linked in the answer on that question.


2

If you know the name of your process, grep against ps to get the PID (process ID). Example: If I wanted to stop shotwell, I would do this (from a terminal session): $ ps -ef | grep shotwell xaap001 1779 1139 8 08:08 ? 00:00:01 shotwell xaap001 1792 1703 0 08:08 pts/1 00:00:00 grep --color=auto shotwell The first process listed is the one ...


2

Sure you can! Gtk3 allows for theming using CSS. Here's a quick example I threw together in Python: #!/usr/bin/python3 from gi.repository import Gtk, Gdk button = Gtk.Button("Click Me") grid = Gtk.Grid() grid.add(button) window = Gtk.Window() window.set_size_request(200, 50) window.add(grid) css_provider = Gtk.CssProvider() css = """ .button { ...


Only top voted, non community-wiki answers of a minimum length are eligible