pygtk

catch close gtk.window

匆匆过客 提交于 2019-12-01 04:50:22
I have gtk.Window and I need to catch closure. I need to close the show the message dialog and click Yes if the window should be closed unless there is a show window Thank you. Handle the delete-event signal. Return False to close, True to cancel. Here is how I use it: # in constructor: self.connect('destroy', gtk.main_quit) self.connect('delete-event', self.on_destroy) def on_destroy(self, widget=None, *data): # return True --> no, don't close messagedialog = gtk.MessageDialog(parent=self, flags= gtk.DIALOG_MODAL & gtk.DIALOG_DESTROY_WITH_PARENT, type=gtk.MESSAGE_QUESTION, buttons=gtk.BUTTONS

pyGame within a pyGTK application

给你一囗甜甜゛ 提交于 2019-12-01 03:29:38
What is the best way to use PyGame (SDL) within a PyGTK application? I'm searching for a method that allows me to have a drawing area in the GTK window and at the same time being able to manage both GTK and SDL events. I've never attempted it myself, but hearing plenty about other people who've tried, it's not a road you want to go down. There is the alternative of putting the gui in pygame itself. There are plenty of gui toolkits built specifically for pygame that you could use. Most of them are rather unfinished, but there are 2 big, actively maintained ones: PGU and OcempGUI . The full list

GUI not updated from another thread when using PyGtk

旧街凉风 提交于 2019-12-01 02:31:16
问题 I am using PyGTK to build a GUI application. I want to update the textview widget from another thread but the widget is not getting updated everytime i try an update. What should i do to get a reliable GUI updating? 回答1: GTK+ is not thread-safe, so you should not simply call GUI update methods from other threads. glib.idle_add (or gobject.idle_add in older PyGTK versions) can be used for this purpose. Instead of writing: label.set_text("foo") you would write: glib.idle_add(label.set_text,

PyGTK: How do I make an image automatically scale to fit it's parent widget?

风格不统一 提交于 2019-12-01 01:40:17
问题 I have a PyGTK app that needs to load an image of unknown size, however I am having the problem that if the image is either very big or very small, the window layout becomes distorted and hard to use. I need some way of making the image automatically scale to fit its parent widget. Unfortunately, after doing some research, it seems there is no code, built in or otherwise, that does what I'm looking for. How could I go about writing something to do this? I would have thought that somebody

catch close gtk.window

可紊 提交于 2019-12-01 01:17:30
问题 I have gtk.Window and I need to catch closure. I need to close the show the message dialog and click Yes if the window should be closed unless there is a show window Thank you. 回答1: Handle the delete-event signal. Return False to close, True to cancel. 回答2: Here is how I use it: # in constructor: self.connect('destroy', gtk.main_quit) self.connect('delete-event', self.on_destroy) def on_destroy(self, widget=None, *data): # return True --> no, don't close messagedialog = gtk.MessageDialog

hide window from MS windows taskbar

99封情书 提交于 2019-12-01 00:36:39
Using pyGtk I created a window without decoration. The Window is hidden from task bar and top of all windows. On linux it works fine, but on MS Windows window sometimes it hides under some other window and always has "python.exe" the taskbar in windows. Image representing my problem: How can I hide this "python.exe" window from taskbar? My code: class Infowindow(gtk.Window): ''' Klasa okienka informacyjnego ''' def __init__(self, json, index, destroy_cb, device): gtk.Window.__init__(self) self.size_x = 260+48 self.size_y = 85 self.separator_size = 10 self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT

How do I get a list of all windows on my gnome2 desktop using pygtk?

核能气质少年 提交于 2019-11-30 20:58:20
I'm a bit confused with some gtk and gnome concepts. I'm trying to get list of non minimized windows on my gnome2 desktop, but after reading the pygtk documentation and inspecting the results, I can't understand the results. Neither of the two snippets below appears to work. First I tried this.. >>> gtk.gdk.window_get_toplevels() [<gtk.gdk.Window object at 0xb74339b4 (GdkWindow at 0x8a4c170)>] >>> gtk.gdk.window_get_toplevels()[0].get_children() [] then this >>> d = gtk.gdk.DisplayManager() >>> d.get_default_display().get_screen(0).get_root_window().get_children() [<gtk.gdk.Window object at

How to list directory hierarchy in GtkTreeView widget?

半世苍凉 提交于 2019-11-30 16:33:00
I am trying to generate a hierarchical directory listing in pyGTK. Currently, I have this following directory tree: /root folderA - subdirA - subA.py - a.py folderB - b.py I have written a function that -almost- seem to work: def go(root, piter=None): for filename in os.listdir(root): isdir = os.path.isdir(os.path.join(root, filename)) piter = self.treestore.append(piter, [filename]) if isdir == True: go(os.path.join(root, filename), piter) This is what i get when i run the app: I also think my function is inefficient and that i should be using os.walk(), since it already exists for such

How to click through gtk.Window?

浪尽此生 提交于 2019-11-30 16:30:17
Like on unity notifications. set_accept_focus() is not what I need, and I dont see something useful in gtk.gdk constants... Seems like my google-fu failed. So, the answer is: win.show_all() #win.window.input_shape_combine_mask(img,0,0) def set_mask(win): #b=gtk.gdk.bitmap_create_from_data(win.window,8,win.window.get_size()) size=win.window.get_size() print size bitmap=gtk.gdk.Pixmap(win.window,size[0],size[1],1) cr = bitmap.cairo_create() cr.set_operator(cairo.OPERATOR_SOURCE) cr.set_source_rgba(0.0,0.0,0.0,0.0) cr.rectangle((0,0)+size) cr.fill() win.window.input_shape_combine_mask(bitmap,0,0)

How to click through gtk.Window?

我们两清 提交于 2019-11-30 16:00:26
问题 Like on unity notifications. set_accept_focus() is not what I need, and I dont see something useful in gtk.gdk constants... Seems like my google-fu failed. 回答1: So, the answer is: win.show_all() #win.window.input_shape_combine_mask(img,0,0) def set_mask(win): #b=gtk.gdk.bitmap_create_from_data(win.window,8,win.window.get_size()) size=win.window.get_size() print size bitmap=gtk.gdk.Pixmap(win.window,size[0],size[1],1) cr = bitmap.cairo_create() cr.set_operator(cairo.OPERATOR_SOURCE) cr.set