pygobject

Detecting when a GTK window is done moving/resizing by the user

£可爱£侵袭症+ 提交于 2019-12-10 15:46:18
问题 I want to detect when the user finished re-sizing or moving the GTK window. Basically an equivalent of WM_EXITSIZEMOVE in windows. I have looked at GTK detecting window resize from the user and am able to detect size/location changes using the configure-event; however because of how my other code is architect I want to know when the resizing is done. Almost like ValueChanged instead of ValueChanging event. I was thinking if i could find out is the mouse button is released or not and then try

Get the window handle in PyGI on MacOS

馋奶兔 提交于 2019-12-10 15:28:48
问题 I use PyGObject/PyGI and GStreamer to show a video in my GUI. The video is shown in a Gtk.DrawingArea and therefore I need to get it's window-handle in the realize-signal-handler. On Linux I can simply use drawing_area.get_property('window').get_xid() and on Windows I have to access the C-API (like described here): drawingarea_window = drawingarea.get_property('window') ctypes.pythonapi.PyCapsule_GetPointer.restype = ctypes.c_void_p ctypes.pythonapi.PyCapsule_GetPointer.argtypes = [ctypes.py

How to get the background color of a widget in GTK and Python?

放肆的年华 提交于 2019-12-10 14:47:07
问题 I want to get the normal background color of a widget (a GtkHeaderBar , in this case). I'm currently using style = self.get_titlebar().get_style_context() to get the style, and color = style.get_property("background-color", Gtk.StateFlags.NORMAL) to get the background color associated to that style. However it returns a Gkd.RGBA object with the following properties: Gdk.RGBA(red=0.000000, green=0.000000, blue=0.000000, alpha=0.000000) But if I open GTK Inspector, select the HeaderBar, and

Adding an icon to a ToolButton in Gtk 3

有些话、适合烂在心里 提交于 2019-12-10 10:59:54
问题 Is there a way to add an icon to a Gtk.ToolButton (Gtk3 using PyGi for Python) to add to the GTK+3 toolbar ? Below is my code: self.addfile = Gtk.ToolButton() self.addfile.set_label("Add File") self.addfileimg = Gtk.Image() self.addfileimg.show() self.addfileimg.set_from_file(self.get_resource("img/file.png")) self.addfile.set_icon_widget(self.addfileimg) self.addfile.connect("clicked", self.on_open_file) Note: The get_resource() method digs into the local working folder for the resource path

How to limit number of decimal places to be displayed in Gtk CellRendererText

前提是你 提交于 2019-12-09 23:14:14
问题 I am trying to limit the amount of decimal places shown in a Gtk.CellRendererText. Currently a float number field is shown with 6 decimal places, but I would like to have just 1. This test code should work on Linux: #!/usr/bin/python3 from gi.repository import Gtk class MyWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="Hello World") self.set_default_size(200, 200) self.liststore = Gtk.ListStore(float) treeview = Gtk.TreeView(model=self.liststore) self.liststore.append

Right Click Menu (context menu) using PyGTK

拜拜、爱过 提交于 2019-12-09 09:20:45
问题 So I'm still fairly new to Python, and have been learning for a couple months, but one thing I'm trying to figure out is say you have a basic window... #!/usr/bin/env python import sys, os import pygtk, gtk, gobject class app: def __init__(self): window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.set_title("TestApp") window.set_default_size(320, 240) window.connect("destroy", gtk.main_quit) window.show_all() app() gtk.main() I wanna right click inside this window, and have a menu pop up like

Python program with Notification in Gnome Shell doesn't work

独自空忆成欢 提交于 2019-12-09 01:43:46
问题 I'm writing a python program that takes info from a webpage and show it on Notification in Gnome Shell. I'm using Arch, so I want to start this program at startup and if there is any change on the webpage, it will notify me. Here is my code: import time import webbrowser import requests from bs4 import BeautifulSoup from gi.repository import Notify, GLib IPS = {'Mobifone': True, 'Viettel': False, 'Vinaphone': False} LINK = "https://id.vtc.vn/tin-tuc/chuyen-muc-49/tin-khuyen-mai.html" def set

Change the colour of pixels in a GdkPixbuf (GTK3)

我的梦境 提交于 2019-12-08 03:47:59
问题 I'm using Gtk.StatusIcon , and want to change the colour of some pixels; I have a working piece of code, this loads a 1x1 pixel PNG file with the colour I want to set, and then copies that to thhe icon Pixbuf. While this works, it has the obvious drawback of having to create a 1x1 pixel for every colour, so I can't use an arbitrary colour, only the predefined colours I created images for. How do I set a pixel to an arbitrary RGBA colour? The code I'm using now (simplified for demonstration

How to periodically update Gtk3 Label text?

一世执手 提交于 2019-12-08 03:30:12
问题 I am writing an app-indicator on Ubuntu 18.04. Getting started was the most difficult part. Docs don't help much. I found this blog and I have a POC that just shows a fixed text on my application bar like this - What I have not been able to figure out is how to update this text periodically or dynamically to display actual information that I need for example: CPU frequency, temperature etc. I have looked at the following places, however I think i am missing something. https://lazka.github.io

PyGTK+3 (PyGObject) to create screenshot?

做~自己de王妃 提交于 2019-12-07 18:01:43
问题 I've spend past 3 days searching in google, how can I create a screenshot with PyGTK+3 ? There are gallizion tutorials about pyqt,pygtk+2,wx and PIL. By the way, I don't need external programs like scrot, imlib2, imagemagick and so on. 回答1: Since nobody else posted the translation to GTK3, here you go: from gi.repository import Gdk win = Gdk.get_default_root_window() h = win.get_height() w = win.get_width() print ("The size of the window is %d x %d" % (w, h)) pb = Gdk.pixbuf_get_from_window