gtk3

Python/Gtk3 : How to add a Gtk.Entry to a Gtk.MessageDialog?

痴心易碎 提交于 2019-12-01 22:03:35
Good morning, I'm trying to add a Gtk.Entry to a Gtk.MessageDialog . With the following code it seems that I added the Gtk.Entry but it's not visible on the dialog window (Python3/Gtk3) : #!/usr/bin/python3 from gi.repository import Gtk def get_user_pw(parent, message, default=''): dialogWindow = Gtk.MessageDialog(parent, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.QUESTION, Gtk.ButtonsType.OK_CANCEL, message) dialogBox = dialogWindow.get_content_area() userEntry = Gtk.Entry() userEntry.set_visibility(False) userEntry.set_invisible_char("*") userEntry.set_size

How do I connect a custom function to the clicked action of a GTK Button?

旧巷老猫 提交于 2019-12-01 21:29:28
I am working my way through the Vala GTK+3 tutorial provided by Elementary OS. I understand that this code: var button_hello = new Gtk.Button.with_label ("Click me!"); button_hello.clicked.connect (() => { button_hello.label = "Hello World!"; button_hello.set_sensitive (false); }); uses a Lambda function to change the button's label when it's clicked. What I want to do is call this function instead: void clicked_button(Gtk.Button sender) { sender.label = "Clicked. Yippee!"; sender.set_sensitive(false); } I've tried this: button.clicked.connect(clicked_button(button)); But I get this error from

How to get as many information as possible about an OpenGL context

时光怂恿深爱的人放手 提交于 2019-12-01 21:06:12
问题 Hello world and thanks for taking some time to read this ! I am writing a program in GTK2/3 + OpenGL, I got two versions of the program running: (a) GTK+2 + GtkGlext Extention -> works great ! (b) GTK+3 + LibX11 -> works just fine ! Everything looks fine, except that the rendering in (a) is significantly faster that the rendering in (b) ... and I got no clue why. Here are some example of the code parts used to create the OpenGL context: (a) // To create the context, and the associated

How to get as many information as possible about an OpenGL context

萝らか妹 提交于 2019-12-01 18:57:09
Hello world and thanks for taking some time to read this ! I am writing a program in GTK2/3 + OpenGL, I got two versions of the program running: (a) GTK+2 + GtkGlext Extention -> works great ! (b) GTK+3 + LibX11 -> works just fine ! Everything looks fine, except that the rendering in (a) is significantly faster that the rendering in (b) ... and I got no clue why. Here are some example of the code parts used to create the OpenGL context: (a) // To create the context, and the associated GtkWidget GdkGLConfig * glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGBA | GDK_GL_MODE_DEPTH | GDK_GL

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

℡╲_俬逩灬. 提交于 2019-12-01 18:19:40
问题 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

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

Gtk3 replace child widget with another widget

时间秒杀一切 提交于 2019-12-01 13:55:31
问题 I'm looking for a way to remove a widget from its parent (whatever that may be - a VBox, a Grid, ...) and add a substitute widget in its place. I found this answer, but I can't seem to make it work with Gtk3. Here's what I tried: from gi.repository import Gtk def replace_widget(old, new): parent= old.get_parent() props= {} for key in Gtk.ContainerClass.list_child_properties(type(parent)): props[key.name]= parent.child_get_property(old, key.name) parent.remove(old) parent.add_with_properties

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

How do I set the mouse cursor to cross hair over a GtkDrawingArea?

久未见 提交于 2019-12-01 12:50:46
In GTK3, How do I set the mouse cursor to cross hair when hovering over a GtkWidget , in this case a GtkDrawingArea ? First of all, you must tell the GtkDrawingArea widget to use a backing window , in order to receive events: gtk_widget_set_has_window (GTK_WIDGET (darea), TRUE); Then you must tell it which events you wish to subscribe to ; in this case, you want the crossing events, in order to receive notification of the pointer entering and leaving the widget: int crossing_mask = GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK; gtk_widget_add_events (GTK_WIDGET (darea), crossing_mask); At this