pygobject

Gtk 3 position attribute on insert-text signal from Gtk.Entry is always 0

 ̄綄美尐妖づ 提交于 2019-12-01 18:09:43
I am having trouble in managing the insert-text signal emitted by the Gtk.Entry widget. Consider the following example: from gi.repository import Gtk def on_insert_text(entry, new_text, new_text_length, position): print(position) entry = Gtk.Entry() entry.connect('insert-text', on_insert_text) window = Gtk.Window() window.connect("destroy", lambda q: Gtk.main_quit()) window.add(entry) window.show_all() Gtk.main() The position attribute I am receiving on the signal handler is always 0. Unless I am misunderstanding this should it not be the position where the next text should be inserted? In the

How to send commands to pygobject virtual terminal?

拈花ヽ惹草 提交于 2019-12-01 14:30:02
Right now I can make a terminal but the output is not used as a command. It just prints a string to the virtual terminal. from gi.repository import Gtk, GObject, Vte class TheWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="inherited cell renderer") self.set_default_size(400, 200) box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) v = Vte.Terminal() #v.connect ("child-exited", lambda term: gtk.main_quit()) length = len("echo \"string\"\n") v.feed("echo \"string\"\n", length) box.pack_start(v, True, True, 0) self.add(box) I tried to use the docs here http://developer

Get the window handle in PyGI

眉间皱痕 提交于 2019-12-01 13:05:12
In my program 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 get that handle using: drawing_area.get_property('window').get_xid() But how do I get the handle on Windows? I searched on the internet but found only examples for PyGtk using window.handle which does not work using PyGI. The GStreamer documentation provides an example which uses the GDK_WINDOW_HWND macro to get the handle. This macro uses AFAIK gdk_win32_drawable_get_handle . But how to do

Remove widget from Gtk viewport / scrolled window in dynamic GUI

百般思念 提交于 2019-12-01 12:27:40
问题 I am building a GUI (Python binding of GTK3) where one Gtk Scrolled Window (from Glade) can contain different treeviews. The program launches with an empty window and the first time around everything works with: self.scrolled_window.add_with_viewport(treeview) self.main_window.show_all() Edit: Picture of the test program (see source below): The second time around I get the following error: (main.py:15905): Gtk-CRITICAL **: gtk_scrolled_window_add_with_viewport: assertion 'gtk_bin_get_child

How do I change the property of a GTK widget such as a stack?

三世轮回 提交于 2019-12-01 07:39:17
I've been taking a quick look at the GTK 3.10 documentation for a GtkStack. https://developer.gnome.org/gtk3/3.10/GtkStack.html It mentions that the child added to a GtkStack is given a property "icon-name". My question is - how can I change the value of this property. The reason - I want to change the GtkStackSwitcher button to be an icon not text but I want to code this - not use a GktBuilder UI. If you look at the gtk3-demo - Stack demo and the UI file you can see the GtkSwitcher has an icon. <?xml version="1.0" encoding="UTF-8"?> <interface> <!-- interface-requires gtk+ 3.6 --> <object

Python. Doing some work on background with Gtk GUI

别来无恙 提交于 2019-12-01 04:48:58
python 3.2.2 gtk3 3.2.2 python-gobject 3.0.2 I'm trying to display a GUI and do some work in the background. As I understand it should look something like this: #!/usr/bin/env python3 # -*- coding: utf-8 -*- import time from threading import Thread from gi.repository import Gtk, Gdk class Gui(): def run(self): self.Window = Gtk.Window() self.Window.set_border_width(8) self.Window.set_title("Некий GUI") self.Window.connect('destroy', lambda x: self.stop()) self.outBut = Gtk.Button.new_from_stock(Gtk.STOCK_OK) self.outBut.set_size_request(150, 35) self.outBut.connect('clicked', lambda x: self

How to create a complete menu using GIO Actions in PyGI GTK?

丶灬走出姿态 提交于 2019-12-01 04:05:38
I'm trying to convert the menubar in my Gtk app so it will use GActions (from the Gio) as opposed of GtkActions in Python3 using GObject Instrospection. I've been trying to figure it out on my own but so far it seems awfully complicated and I didn't have much luck with it. If someone could please post an example of how to create a simple menu GAction based with A submenu A menu item with a stock ID icon / hotkey A menu item with a non-stock icon / hotkey A checked menu item And radio menu item group A disabled(grayed out) menu item It would really help me a lot. EDIT : This is the menubar I

Python. Doing some work on background with Gtk GUI

假装没事ソ 提交于 2019-12-01 01:58:50
问题 python 3.2.2 gtk3 3.2.2 python-gobject 3.0.2 I'm trying to display a GUI and do some work in the background. As I understand it should look something like this: #!/usr/bin/env python3 # -*- coding: utf-8 -*- import time from threading import Thread from gi.repository import Gtk, Gdk class Gui(): def run(self): self.Window = Gtk.Window() self.Window.set_border_width(8) self.Window.set_title("Некий GUI") self.Window.connect('destroy', lambda x: self.stop()) self.outBut = Gtk.Button.new_from

Python program with Notification in Gnome Shell doesn't work

帅比萌擦擦* 提交于 2019-12-01 01:12:54
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_ips_state(ips_name, state): global IPS for key in IPS.iterkeys(): if key == ips_name: IPS[key] = state

Bundling GTK3+ with py2exe

随声附和 提交于 2019-11-30 21:31:07
Platform is Windows 7 64bit using python 2.7 and GTK3+ installed from http://sourceforge.net/projects/pygobjectwin32/files/?source=navbar The exe is compiled but fails to run, due to this The following modules appear to be missing ['gi.repository.Gdk', 'gi.repository.Gtk', 'overrides.registry'] How can i properly include these files? imports in my .py file from gi.repository import Gtk, Gdk my setup file #!/usr/bin/env python from distutils.core import setup import py2exe, sys sys.path.append("C:\Python27\Lib\site-packages\gnome") sys.path.append("C:\Python27\Lib\site-packages\repository")