gtk

how to program window to close with escape key

纵然是瞬间 提交于 2019-12-23 02:00:56
问题 I've been searching all over the place to find out how to get my program to close using the escape key. Not that many people use GTK+ I assume. Also, if it's not asking too much, can some please show me how to use the Gnome developer website so I could find this stuff out on my own? Thanks. So, closing the window with escape key, here's my code: #include <stdio.h> #include <string.h> #include <gtk/gtk.h> #include <stdlib.h> #include <ctype.h> #include <curses.h> #define KEY_ESC '\033' static

Detect ctrl+click on button in pygtk

眉间皱痕 提交于 2019-12-22 18:29:28
问题 I want to detect if ctrl is held down when the user clicks a button. The 'clicked' signal doesn't seem to pass enough information to the callback to work this out. 回答1: If you can connect to either button-press-event or button-release-event instead of clicked , the event passed to the callback can be used to get the modifier state (using get_state) and check if control key is pressed. For ex. def button_release_callback(widget, event, data=None): if event.get_state() & gtk.gdk.CONTROL_MASK:

Problems importing GDK

南楼画角 提交于 2019-12-22 18:28:38
问题 I am trying to import GDK to my program however I continue to get an error No module named GDK Do you know how I can fix this? Since it was working before I already tried import gtk.GDK and import GDK . I have installed PyGTK and PyGDK is part of of it pyGTK. 回答1: Try: import gtk.gdk (note: small letters) 来源: https://stackoverflow.com/questions/5923746/problems-importing-gdk

Chain up to 'Gtk.Box.new' not supported

六眼飞鱼酱① 提交于 2019-12-22 17:56:26
问题 I'm new to Vala and so far I think it's pretty cool but I'm having trouble understanding inheritance. I read here that I should use base() to call the parents constructor. Alright, cool, seems understandable but It din't work for me. I kept getting the error on the title. Here is my snippet to show: public class MyBox : Gtk.Box { public MyBox(Gtk.Orientation orientation, int spacing) { // I have to this this.set_orientation(orientation); this.set_spacing(spacing); // I want to do this: base

Ruby GTK Pixbuf timed image change

折月煮酒 提交于 2019-12-22 14:04:13
问题 I am creating an image slideshow in ruby, using gtk pixbuf to load images. I am very new to ruby & GTK, this may be an stupid question. Currently image changes are linked to the GUI button_press_event, I would like them to change /refresh automatically based on a set time, like a slideshow or animation. I saw the gtk animation using a gif method, but I would like to use individual jpeg files inline sequence, so that I can set the time to show a slide. Once the loop has gone through all the

Glade3 and C programming

牧云@^-^@ 提交于 2019-12-22 12:37:29
问题 I am trying to create a simple app that accepts two integer and displays Sum of two on clicking "Sum" button And I am new to Glade3, so you can expect blunders /* * Compile me with: * gcc -o test test.c $(pkg-config --cflags --libs gtk+-2.0 gmodule-2.0) */ #include <gtk/gtk.h> #include <stdio.h> #include <stdlib.h> #include <string.h> GtkBuilder *builder; GtkWidget *window; GError *error = NULL; void on_button1_clicked(GtkButton *button1, GtkEntry *entry1, GtkEntry *entry2, GtkEntry *entry3 )

Load GTK-Glade translations in Windows using Python/PyGObject

走远了吗. 提交于 2019-12-22 12:19:19
问题 I have a Python script that loads a Glade-GUI that can be translated. Everything works fine under Linux, but I am having a lot of trouble understanding the necessary steps on Windows. All that seems necessary under Linux is: import locale [...] locale.setlocale(locale.LC_ALL, locale.getlocale()) locale.bindtextdomain(APP_NAME, LOCALE_DIR) [...] class SomeClass(): self.builder = Gtk.Builder() self.builder.set_translation_domain(APP_NAME) locale.getlocale() returns for example ('de_DE', 'UTF-8'

Python: Fastest way to take and save screenshots

你离开我真会死。 提交于 2019-12-22 11:27:19
问题 I've been struggling to come up with a script that allows me to take screenshots of my desktop more than once per every second. I'm using Win10. PIL: from PIL import ImageGrab import time while True: im = ImageGrab.grab() fname = "dropfolder/%s.png" %int(time.time()) im.save(fname,'PNG') Results 1.01 seconds per image. PyScreeze (https://github.com/asweigart/pyscreeze): import pyscreeze import time while True: fname = "dropfolder/%s.png" %int(time.time()) x = pyscreeze.screenshot(fname)

How to left align a Gtk Label when its width is set by GtkSizeGroup

◇◆丶佛笑我妖孽 提交于 2019-12-22 11:08:05
问题 I have labels that should be left aligned and should all have the same width. I'm using a GtkSizeGroup to achieve the sizing (because the labels don't all have the same parent). Unfortunately this seems to break alignment: With the below code the labels align horizontally in the middle even though I ask for GTK_ALIGN_START . If I remove the sizegroup the labels align to start as they should. /* gcc `pkg-config --libs --cflags gtk+-3.0` label-align-test.c */ #include <gtk/gtk.h> int main(int

GTK window motion animation?

安稳与你 提交于 2019-12-22 10:36:14
问题 I want to move my GTK_WINDOW across the screen automatically. Currently I have it in a draw/move loop, but that's terribly choppy. I'm very new to GTK programming (and gui programming in general). What am I missing? 回答1: You haven't said what sort of path you want the window to follow. If the path is some simple function of time -- that is, if you have a way to compute where you want the window to be at any given time -- you could try the method illustrated in following code. For the quite