Skip to content

Instantly share code, notes, and snippets.

@hdon
Created January 4, 2009 05:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hdon/43011 to your computer and use it in GitHub Desktop.
Save hdon/43011 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import gtk, gtk.glade as glade
class Application(object):
def __init__(self):
self.glade = glade.XML('spritecaster.glade')
self.glade.signal_autoconnect({
'on_window1_delete_event': self.delete_event,
'on_window1_destroy_event': self.destroy,
'on_auto_button_toggled': self.auto_tool_button,
'on_div_tool_button_toggled': self.div_tool_button,
'on_select_tool_button_toggled':self.select_tool_button,
'on_drawingarea1_expose_event': self.draw_area_draw,
'on_open_command': self.do_open,
})
pic = None
def draw_area_draw(self, widget, event, data=None):
if self.pic:
area = event.area
print "DRAWING666", area.x, area.y, area.width, area.height
widget.window.draw_pixbuf(widget.window.new_gc(), self.pic,
area.x, area.y, area.x, area.y, area.width, area.height)
print 'draw_pixbuf() returned!'
def main(self):
gtk.main()
def do_open(self, widget, *data):
dialog = self.glade.get_widget('filechooserdialog1')
response = dialog.run()
dialog.hide()
if response == gtk.RESPONSE_OK:
filename = dialog.get_filename()
self.pic = gtk.gdk.pixbuf_new_from_file(filename)
def div_tool_button(self, widget):
if widget.get_active():
print 'TODO assign div tool'
def auto_tool_button(self, widget):
if widget.get_active():
print 'TODO assign auto tool'
def select_tool_button(self, widget):
if widget.get_active():
print 'TODO assign select tool'
def delete_event(self, widget, event, data=None):
return False
def destroy(self, widget, data=None):
gtk.main_quit()
if __name__ == '__main__':
try:
app = Application()
app.main()
except KeyboardInterrupt:
print 'Bye'
donny@teamspace:~/spritecaster$ gdb python
GNU gdb 6.4.90-debian
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...(no debugging symbols found)
Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
(gdb) set args spritecaster.py
(gdb) run
Starting program: /usr/bin/python spritecaster.py
Failed to read a valid object file image from memory.
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread -1210218816 (LWP 24951)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[snip..........]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
DRAWING666 236 0 1 496
Program received signal SIGSEGV, Segmentation fault.
---Type <return> to continue, or q <return> to quit---
[Switching to Thread -1210218816 (LWP 24951)]
0xb7e46b3c in memcpy () from /lib/tls/i686/cmov/libc.so.6
(gdb) bt
#0 0xb7e46b3c in memcpy () from /lib/tls/i686/cmov/libc.so.6
#1 0xb76a167a in _gdk_x11_convert_to_format ()
from /usr/lib/libgdk-x11-2.0.so.0
#2 0xb76a25fb in gdk_x11_drawable_get_xdisplay ()
from /usr/lib/libgdk-x11-2.0.so.0
#3 0xb767ba98 in gdk_draw_pixbuf () from /usr/lib/libgdk-x11-2.0.so.0
#4 0xb76865c1 in gdk_pixbuf_render_pixmap_and_mask ()
from /usr/lib/libgdk-x11-2.0.so.0
#5 0xb767ba98 in gdk_draw_pixbuf () from /usr/lib/libgdk-x11-2.0.so.0
#6 0xb7693790 in gdk_window_get_window_type ()
from /usr/lib/libgdk-x11-2.0.so.0
#7 0xb767ba98 in gdk_draw_pixbuf () from /usr/lib/libgdk-x11-2.0.so.0
#8 0xb7aece6a in init_gtk ()
from /var/lib/python-support/python2.4/gtk-2.0/gtk/_gtk.so
#9 0x080b96b5 in PyEval_EvalFrame ()
#10 0x080ba975 in PyEval_EvalCodeEx ()
#11 0x08100eb8 in PyClassMethod_New ()
#12 0x08058a87 in PyObject_Call ()
#13 0x0805e33e in PyClass_IsSubclass ()
#14 0x08058a87 in PyObject_Call ()
#15 0x080b3f5d in PyEval_CallObjectWithKeywords ()
#16 0x08058f1e in PyObject_CallObject ()
#17 0xb7c26dae in initgobject ()
---Type <return> to continue, or q <return> to quit---
from /var/lib/python-support/python2.4/gtk-2.0/gobject.so
#18 0xb7bdc98b in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#19 0xb7becf2d in g_signal_chain_from_overridden ()
from /usr/lib/libgobject-2.0.so.0
#20 0xb7bee208 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#21 0xb7bee5d9 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#22 0xb78fcf64 in gtk_widget_get_default_style ()
from /usr/lib/libgtk-x11-2.0.so.0
#23 0xb780e00f in gtk_main_do_event () from /usr/lib/libgtk-x11-2.0.so.0
#24 0xb7691eb0 in gdk_window_is_viewable () from /usr/lib/libgdk-x11-2.0.so.0
#25 0xb769205f in gdk_window_process_all_updates ()
from /usr/lib/libgdk-x11-2.0.so.0
#26 0xb76920e5 in gdk_window_process_all_updates ()
from /usr/lib/libgdk-x11-2.0.so.0
#27 0xb7b6a9b1 in g_source_is_destroyed () from /usr/lib/libglib-2.0.so.0
#28 0xb7b6c731 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#29 0xb7b6f7a6 in g_main_context_check () from /usr/lib/libglib-2.0.so.0
#30 0xb7b6fb67 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
#31 0xb780e281 in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
#32 0xb7a9c7d3 in init_gtk ()
from /var/lib/python-support/python2.4/gtk-2.0/gtk/_gtk.so
#33 0x080b934e in PyEval_EvalFrame ()
#34 0x080b9444 in PyEval_EvalFrame ()
---Type <return> to continue, or q <return> to quit---
#35 0x080ba975 in PyEval_EvalCodeEx ()
#36 0x080ba9d9 in PyEval_EvalCode ()
#37 0x080dd447 in PyRun_FileExFlags ()
#38 0x080dd644 in PyRun_SimpleFileExFlags ()
#39 0x08055ba8 in Py_Main ()
#40 0x08055032 in main ()
(gdb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment