gtk3

Gtk.CssProvider.load_from_data TypeError: Item 0: Must be number, not str

别说谁变了你拦得住时间么 提交于 2019-12-24 05:02:48
问题 I was getting this error when running my gtk project from a terminal with python3 myapp.py , but not when launching my app via Sublime-Text-3's python build system! How weird. TypeError: Item 0: Must be number, not str The code at fault was essentially: color_scheme = {'fg_color':'#ffffff', 'bg_color': '#000000',} css = """ GtkLabel { color: %(fg_color)s; background: %(bg_color)s; } """ # ... cssprovider = Gtk.CssProvider() css_data = css % color_scheme cssprovider.load_from_data(css_data)

How to make a custom nonrectangular gtklayout in GTK+3

时光怂恿深爱的人放手 提交于 2019-12-24 03:56:07
问题 When using GTK+2, we can use gtk_widget_shape_combine_mask and gtk_widget_input_shape_combine_mask to make a custom nonrectangular gtklayout. For example, in the case of a GTKLayout with a circle hole, we can see the widget bottom of the custom gtklayout through the circle hole. With GTK+3, the gtk_widget_shape_combine_mask is replaced with gtk_widget_shape_combine_region . When using gtk_widget_shape_combine_region and gtk_widget_input_shape_combine_region , we can't see the widget bottom of

Programatically add new menu items to menu item PyGObject?

萝らか妹 提交于 2019-12-24 03:53:26
问题 I had this set up in wxPython, but now I'm rewriting it for GTK3/PyGObject, and I'm kind of lost here. Basically, my code scans through a directory, and adds the names of files to a menu item. I can't get it to work in PyGObject. Here is the current code: # Populate profiles menu profileMenu = self.builder.get_object("profilesMenu") profiles = os.listdir("/etc/netctl/") # Iterate through profiles directory, and add to "Profiles" Menu # for i in profiles: if os.path.isfile("/etc/netctl/" + i):

Cannot embed gnuplot x11 window into Gtk3 socket

风格不统一 提交于 2019-12-24 02:59:06
问题 I'm creating Gtk::Socket in my Gtk3 (actually, gtkmm) application and trying to embed gnuplot's window into it. But it does not work: the socket remains to stay as a black rectangle, while gnuplot window appears standalone elsewhere. Meanwhile, Gtk::Plug plugs into this socket perfectly. In Gtk2 this trick with gnuplot works well too. Here is socket.cpp #include <iostream> #include <fstream> #include <gtkmm.h> #include <gtkmm/socket.h> using namespace std; void plug_added(){ cout << "A plug

How to retrieve data from blocking read in another thread in Gtk3?

情到浓时终转凉″ 提交于 2019-12-23 22:11:34
问题 I have a lib that only expose a blocking theRead function on a streaming data. Now I need to theRead data and show in GTK3 GUI. So I used a transaction channel to pass data from a thread running theRead to GUI thread then read the var via g_idle_add. Apparently this is wrong. The application caused CPU busy. What is the proper way? Psudo code: idleAdd PRIORITY_DEFAULT_IDLE $ do readTChan chan >>= \case Nothing -> return SOURCE_CONTINUE Just data -> show_data_in_textview data forkIO $ loop $

Gtk ComboBox width based on contents

半腔热情 提交于 2019-12-23 21:00:31
问题 I'm dynamically populating the options to a GTK3 ComboBox that has an Entry. Some the options can be quite long, and I'd like to be able to make the ComboBox wider if there are wide items in my model. Is there a way to do this? (It would be especially nice if the combobox could be expanded automatically but with an upper limit that could be set.) 来源: https://stackoverflow.com/questions/11975230/gtk-combobox-width-based-on-contents

Gtk3 | Python: Namespace Gtk not available, Typelib file for namespace 'Gtk' (any version) not found (using macos)

怎甘沉沦 提交于 2019-12-23 19:35:09
问题 I'm trying to start making a little GTK program, and to test GTK installation and config I'm trying to execute a simple helloworld script. Just using a simple example given by pygobject documentation: import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk window = Gtk.Window(title="Hello World") window.show() window.connect("destroy", Gtk.main_quit) Gtk.main() First issue (resolved): from gi.repository import Gtk Gtk not found, but a new autoimport give me this import: from

How do you force a screen refresh in GTK 3.8?

非 Y 不嫁゛ 提交于 2019-12-23 18:26:14
问题 Found a solution. See below. I am using GTK 3.8 gtk_grid in a scrolled window. The C code works through a lot of data and displays some in the grid. GTK does not draw the grid until the program finishes processing all data. How do you force GTK 3 to refresh the screen when you add data? I tried gtk_widget_queue_draw but nothing happens. I also tested gtk_widget_show_now but nothing happened. The process might run for a few seconds or many minutes. The user can select the range of data to

Load and show an image from the web in Python with Gtk 3?

限于喜欢 提交于 2019-12-23 09:32:19
问题 I'm writing an app on Ubuntu 12.04 with Python and GTK 3. The problem I have is that I can't figure out how I should do to show a Gtk.Image in my app with an image file from the web. This is as far as I have come: from gi.repository import Gtk from gi.repository.GdkPixbuf import Pixbuf import urllib2 url = 'http://lolcat.com/images/lolcats/1338.jpg' response = urllib2.urlopen(url) image = Gtk.Image() image.set_from_pixbuf(Pixbuf.new_from_stream(response)) I think everything is correct except

python and gtk3 clipboard onChange

偶尔善良 提交于 2019-12-23 09:31:56
问题 With PyGTK 2 I could attach a function to be executed when the contents of the clipboard was changed. Browsing through the documentation of GTK3's python bindings I can not find any description of such an functionality. Can anyone tell me the 'best practice' for this? EDIT With gtk2 the following works: import gtk def test(*args): print "Clipboard changed" clip = gtk.Clipboard() clip.connect('owner-change',test) When adopting to Gtk3 from gi.repository import Gtk, Gdk def test(*args): print