Hot answers tagged

6

The correct way to take an Screenshot using PyGobject (the Gtk version used by Quickly) is: from gi.repository import Gdk window = Gdk.get_default_root_window() x, y, width, height = window.get_geometry() print("The size of the root window is {} x {}".format(width, height)) # get_from_drawable() was deprecated. See: # https://developer.gnome.org/gtk3/...


6

Here are precisions added to bert's answer, about the fix that worked for me : sudo add-apt-repository ppa:jfi/test sudo apt-get update sudo apt-get dist-upgrade It should then work.


5

You must add a Related Action by clicking the "..." button. Once you have added an action, disable Use Action Appearance. Then you can clear the related action and set the button to whatever you wish. You can also continue using the action as sort of standardized actions in your program. For instance, most apps will have new buttons, so with actions you ...


4

When choosing the Center on Parent position, you must also let the dialog know which window is the parent ofcourse. This can either be done in Glade, but only if the parent window is inside the same Glade-file. Or by calling this method: gtk.Window.set_transient_for(parentwindow)


4

The command is quickly add dialog dialogname and needs ran from the app directory. Note, the word "Dialog" is automatically added to the dialog name.


4

It's a bug in the current version and is fixed in trunk as far as I know. So, 2 options: Compile Glade from trunk and use that. Use this workaround: first add a new Related action (right above the label option) and set Use action appearance to False. Remove the action again if needed.


4

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


4

The gi module you are importing isn't the one from Ubuntu's GI package python-gi but something you installed manually in /usr/local/. It's either a very old version or something different that just happened to be called gi, too. Remove it and make sure the package python-gi is installed.


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

See here: http://python-gtk-3-tutorial.readthedocs.org/en/latest/treeview.html You can get the selection on an event by connecting a selection object to an event: select = tree.get_selection() select.connect("changed", on_tree_selection_changed) def on_tree_selection_changed(selection): model, treeiter = selection.get_selected() if treeiter != ...


3

Try to disable Use Action Appearance.


3

Instead of specifying your image as step1.png, use this (relative) path in place of it: ../media/step1.png This should cause it to be accessed in the right place, since .. represents the parent directory of wherever the application is currently looking (in this case, apparently /home/jtp/projectnamme/data), and the actual file is located in /home/jtp/...


3

GTK+ uses box-based sizing, just like CSS and other modern tools. Also, a VBox will have all its children oriented vertically. You won't be able to add anything to the right. You can use the GtkLayout for absolute positioning, or a GtkGrid to create a grid-based layout (which is appropriate for calculator).


3

Removing \n from a string: newString = oldString.replace("\n", "");


3

Well, without your code, I can't be sure, but this is most likely caused by an incorrect import statement. It's possible and highly likely that the import statement for Gdk changed between Python 2 and Python 3. Try changing the from gi.repository.Gtk import gdk line to from gi.repository import Gdk. That's what I have in some of my code and it works fine. ...


2

The last time I programmed in Glade/GTK, it didn't require "gtk-builder-convert". The .glade file that glade provides is itself xml file you need. Just program your code as if you already have converted the file to .xml (btw, i'm using glade 3.12.1). As: #include <gtk/gtk.h> void on_window_destroy (GtkWidget *object, gpointer user_data) { ...


2

The problem lies with the Window. You should implement a callback for the 'delete-event' signal of the Window widget. def on_event_editor_delete_event(self, widget, event): self.event_editor.hide() return True This callback hides the Window and returns True so the event isn't propagated further (i.e. the Window isn't destroyed, including your ...


2

This appears to be a known issue with Glade on Ubuntu 13.10. See https://bugs.launchpad.net/ubuntu/+source/glade/+bug/1242865 The temporary fix as provided in comment #25 (https://bugs.launchpad.net/ubuntu/+source/glade/+bug/1242865/comments/25) works fine for me.


2

You have to have installed libgtksourceviewmm-3.0-dev to be able to use GtkSourceView (Gtk::SourceView) in gtkmm. To get the GtkSourceView widget in glade, you have to install libgtksourceview-3.0-dev, but it is in the depencies of the mm-package, so just do a sudo apt-get install libgtksourceviewmm-3.0-dev and it should work.


2

It is possible to build GUI dynamically from Glade file using PyGTK Gtk.Builder class The Gtk.Builder class offers you the opportunity to design user interfaces without writing a single line of code. This is possible through describing the interface by a XML file and then loading the XML description at runtime and create the objects automatically, which ...


2

I think flub = raw_input('Where would you like your save directory to be?') print flub Will get your variable, pass that to your GUI. Unless you change it later on in the program, it will remain until restarted / retriggered. To store that value permanently, you would need to write it somewhere lets say a text file, or set your program up to set a ...


2

The issue is that file.readlines() returns a list of strings - one for each line in the file - rather than a single string. The [' and '] characters are just python's way of indicating the containing list object. It doesn't know ahead of time that your file only contains a single line. You can print the individual strings (in this case there is only one) ...


2

I found what was wrong. I had previously tried to build from source the latest version of Glade 3.18.3. But that required my gtk to be be 3.12.0 . But my gtk was 3.10.0 and that seemed to be the latest version acquirable through apt-get install. So I downloaded the source of the actual latest version 3.12.2 and built that from source and executed a make ...


2

You need to use GTK3 to load a file created with Glade 3.x. As Glade 2.x isn't available in Ubuntu any more switching to GTK3 is your best option. To use GTK3 in Python you need to switch from PyGTK to to PyGObject. See The Python GTK+ 3 Tutorial for how to use it.


1

In addition to defining the functions to be called, you must connect the signal of the button. The easiest way to do this is to define a dict with a mapping from the names to the handlers and then pass it to the Gtk.Builder.connect_signals() method. Read here for more help.


1

You can use the set_opacity() method of GtkWindow object. It will expect a float, so you should do a type conversion before. try: self.set_opacity(float(title)) except ValueError: pass # Do something with the invalid value here.


1

This appears to be a known issue with Glade on Ubuntu 13.10. See https://bugs.launchpad.net/ubuntu/+source/glade/+bug/1242865 The temporary fix as provided in comment #25 (https://bugs.launchpad.net/ubuntu/+source/glade/+bug/1242865/comments/25) works fine for me.


1

The path you're giving set_from_file is relative to the glade file but not the python file. It's better to use full paths anyways as using relative paths often ends up having issues when you run the installed application. Quickly provides a nice helper function to give you the full path for a file found in the data/ folder. Try: from test_lib.testconfig ...


1

In Glade, select your entry and click the Common tab in the property editor on the right. Search for the Can focus property and make sure it's set to True.


1

You problem is that you're mixing a GTK3 interface with old PyGTK (GTK2) Python code. Here's the ported code: #!/usr/bin/env python from gi.repository import Gtk class TutorialApp(object): def __init__(self): builder = Gtk.Builder() builder.add_from_file("tutorial.xml") builder.connect_signals({ "on_window_delete_event" : Gtk....


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