summaryrefslogtreecommitdiff
path: root/examples/ide
diff options
context:
space:
mode:
Diffstat (limited to 'examples/ide')
-rw-r--r--examples/ide/README7
-rw-r--r--examples/ide/break.xpm29
-rwxr-xr-xexamples/ide/browse.py119
-rw-r--r--examples/ide/continue.xpm27
-rw-r--r--examples/ide/dialogs.py58
-rw-r--r--examples/ide/edit.py284
-rw-r--r--examples/ide/edit.xpm38
-rwxr-xr-xexamples/ide/gtkcons.py330
-rwxr-xr-xexamples/ide/gtkdb.py434
-rwxr-xr-xexamples/ide/gtkprof.py133
-rw-r--r--examples/ide/minibreak.xpm19
-rw-r--r--examples/ide/next.xpm32
-rwxr-xr-xexamples/ide/pyide.py260
-rw-r--r--examples/ide/quit.xpm36
-rw-r--r--examples/ide/return.xpm35
-rw-r--r--examples/ide/run.xpm28
-rw-r--r--examples/ide/step.xpm35
17 files changed, 0 insertions, 1904 deletions
diff --git a/examples/ide/README b/examples/ide/README
deleted file mode 100644
index 99568b0f..00000000
--- a/examples/ide/README
+++ /dev/null
@@ -1,7 +0,0 @@
-This directory contains some tools that can be used to help develop python
-applications. There is a graphical front end to the profiler and debugger,
-and a graphical python console, and a 'module browser'.
-
-I will probably link these together with an editor (just use emacs, or write
-one in python?).
-
diff --git a/examples/ide/break.xpm b/examples/ide/break.xpm
deleted file mode 100644
index f5221a30..00000000
--- a/examples/ide/break.xpm
+++ /dev/null
@@ -1,29 +0,0 @@
-/* XPM */
-static char * break_xpm[] = {
-"21 22 4 1",
-" c None",
-". c #000000",
-"X c #FFFFFF",
-"o c #FF0000",
-" ......... ",
-" .XXXXXXXXX. ",
-" .XXoooooooXX. ",
-" .XXoooooooooXX. ",
-" .XXoooooooooooXX. ",
-" .XXoooooooooooooXX. ",
-".XXoooooooooooooooXX.",
-".XoooooooooooooooooX.",
-".XooXXoXXXoXXooXXooX.",
-".XoXooXoXoXooXoXoXoX.",
-".XoXooooXoXooXoXoXoX.",
-".XooXXooXoXooXoXXooX.",
-".XooooXoXoXooXoXoooX.",
-".XoXooXoXoXooXoXoooX.",
-".XooXXooXooXXooXoooX.",
-".XXoooooooooooooooXX.",
-" .XXoooooooooooooXX. ",
-" .XXoooooooooooXX. ",
-" .XXoooooooooXX. ",
-" .XXoooooooXX. ",
-" .XXXXXXXXX. ",
-" ......... "};
diff --git a/examples/ide/browse.py b/examples/ide/browse.py
deleted file mode 100755
index 0cc85b0d..00000000
--- a/examples/ide/browse.py
+++ /dev/null
@@ -1,119 +0,0 @@
-#!/usr/bin/env python
-
-# This is an example of using dynamic trees (trees where nodes are only
-# calculated as they are needed) with pygtk. This particular example
-# allows for the browsing of the variables in a module, allowing the
-# descent into classes and modules and other objects with a __dict__
-# attribute.
-
-# If this file is run straight, it will let you browse the gtk module.
-
-import pygtk
-pygtk.require('2.0')
-import gtk
-
-class BrowseVariables(gtk.VBox):
- def __init__(self, name, obj):
- gtk.VBox.__init__(self)
- self.set_spacing(2)
- #
- self.sw = gtk.ScrolledWindow()
- self.sw.set_size_request(300, 200)
- self.sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
- self.pack_start(self.sw)
- self.sw.show()
- #
- self.disp = gtk.Entry()
- self.disp.set_editable(False)
- self.pack_start(self.disp, expand=False)
- self.disp.show()
- #
- self.treestore = gtk.TreeStore(str, object)
- self.tree = gtk.TreeView(self.treestore)
- treeviewcolumn = gtk.TreeViewColumn('Variable',
- gtk.CellRendererText(),
- text=0)
- self.tree.append_column(treeviewcolumn)
- self.sw.add(self.tree)
- self.tree.show()
- #
- riter = self.treestore.append(None, [name, obj])
- self.treestore.append(riter, ['', None])
- self.tree.connect('test-expand-row', self.expand_row_cb)
- self.tree.connect('test-collapse-row', self.collapse_row_cb)
- self.treeselection = self.tree.get_selection()
- self.treeselection.connect('changed', self.change_selection_cb)
- return
- def change_selection_cb(self, treeselection):
- model, iter = treeselection.get_selected()
- if not iter or not self.disp:
- return
- key = model[iter][0]
- if key == '__builtins__':
- value = key
- else:
- value = model[iter][1]
- self.disp.set_text(str(value))
- return
- def expand_row_cb(self, treeview, riter, path):
- model = treeview.get_model()
- dict = vars(model[riter][1])
- if not dict:
- return True
- citer = model.iter_children(riter)
- model.remove(citer)
- keylist = dict.keys()
- keylist.sort()
- for key in keylist:
- obj = dict[key]
- i = model.append(riter, [key, obj])
- try:
- d = vars(obj)
- if d:
- model.append(i, ['', d])
- except TypeError:
- pass
- return False
- def collapse_row_cb(self, treeview, riter, path):
- model = treeview.get_model()
- citer = model.iter_children(riter)
- if citer:
- while model.remove(citer):
- pass
- model.append(riter, ['', None])
- return True
-
-class BrowseWindow(gtk.Window):
- def __init__(self, name, dict):
- gtk.Window.__init__(self)
- self.set_title("Browse Window")
- box = gtk.VBox()
- self.add(box)
- box.show()
- browse = BrowseVariables(name, dict)
- browse.set_border_width(10)
- box.pack_start(browse)
- browse.show()
- separator = gtk.HSeparator()
- box.pack_start(separator, expand=False)
- separator.show()
- box2 = gtk.VBox(spacing=10)
- box2.set_border_width(10)
- box.pack_start(box2, expand=False)
- box2.show()
- button = gtk.Button(stock=gtk.STOCK_CLOSE)
- box2.pack_start(button)
- button.set_flags(gtk.CAN_DEFAULT)
- button.grab_default()
- button.show()
- self.close_button = button
- return
-
-if __name__ == '__main__':
- win = BrowseWindow('gtk', gtk)
- win.set_title("Browse gtk")
- win.connect("destroy", lambda w: gtk.main_quit())
- win.connect("delete_event", lambda w,e: gtk.main_quit())
- win.close_button.connect("clicked", lambda w: gtk.main_quit())
- win.show()
- gtk.main()
diff --git a/examples/ide/continue.xpm b/examples/ide/continue.xpm
deleted file mode 100644
index f44f61d7..00000000
--- a/examples/ide/continue.xpm
+++ /dev/null
@@ -1,27 +0,0 @@
-/* XPM */
-static char * continue_xpm[] = {
-"20 22 2 1",
-" c None",
-". c #000000",
-" ",
-" ",
-" . . ",
-" .. .. ",
-" ... ... ",
-" .... .... ",
-" ..... ..... ",
-" ...... ...... ",
-" ....... ....... ",
-" ........ ........ ",
-" .................. ",
-" .................. ",
-" ........ ........ ",
-" ....... ....... ",
-" ...... ...... ",
-" ..... ..... ",
-" .... .... ",
-" ... ... ",
-" .. .. ",
-" . . ",
-" ",
-" "};
diff --git a/examples/ide/dialogs.py b/examples/ide/dialogs.py
deleted file mode 100644
index ac009e44..00000000
--- a/examples/ide/dialogs.py
+++ /dev/null
@@ -1,58 +0,0 @@
-import pygtk
-pygtk.require('2.0')
-import gtk
-
-import os
-
-def InputBox(title, label, parent, text=''):
- dlg = gtk.Dialog(title, parent, gtk.DIALOG_DESTROY_WITH_PARENT,
- (gtk.STOCK_OK, gtk.RESPONSE_OK,
- gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
- lbl = gtk.Label(label)
- lbl.show()
- dlg.vbox.pack_start(lbl)
- entry = gtk.Entry()
- if text: entry.set_text(text)
- entry.show()
- dlg.vbox.pack_start(entry, False)
- resp = dlg.run()
- text = entry.get_text()
- dlg.hide()
- if resp == gtk.RESPONSE_CANCEL:
- return None
- return text
-
-def OpenFile(title, parent=None, dirname=None, fname=None):
- dlg = gtk.FileChooserDialog(title, parent,
- buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
- gtk.STOCK_CANCEL,
- gtk.RESPONSE_CANCEL))
- if fname:
- dlg.set_current_folder(os.path.dirname(fname))
- elif dirname:
- dlg.set_current_folder(dirname)
- dlg.set_local_only(True)
- resp = dlg.run()
- fname = dlg.get_filename()
- dlg.hide()
- if resp == gtk.RESPONSE_CANCEL:
- return None
- return fname
-
-def SaveFile(title, parent=None, dirname=None, fname=None):
- dlg = gtk.FileChooserDialog(title, parent,
- gtk.FILE_CHOOSER_ACTION_SAVE,
- buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
- gtk.STOCK_CANCEL,
- gtk.RESPONSE_CANCEL))
- if fname:
- dlg.set_filename(fname)
- elif dirname:
- dlg.set_current_folder(dirname)
- dlg.set_local_only(True)
- resp = dlg.run()
- fname = dlg.get_filename()
- dlg.hide()
- if resp == gtk.RESPONSE_CANCEL:
- return None
- return fname
diff --git a/examples/ide/edit.py b/examples/ide/edit.py
deleted file mode 100644
index 6e34e8b0..00000000
--- a/examples/ide/edit.py
+++ /dev/null
@@ -1,284 +0,0 @@
-#!/usr/bin/env python
-
-# This is a sample implementation of an editor.
-
-import os
-import dialogs
-
-import gtk
-
-BLOCK_SIZE = 2048
-RESPONSE_FORWARD = 1
-
-class EditWindow(gtk.Window):
- def __init__(self, quit_cb=None):
- gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
- self.set_size_request(470, 300)
- self.connect("delete_event", self.file_exit)
- self.quit_cb = quit_cb
- self.vbox = gtk.VBox()
- self.add(self.vbox)
- self.vbox.show()
- hdlbox = gtk.HandleBox()
- self.vbox.pack_start(hdlbox, expand=False)
- hdlbox.show()
- self.menubar, self.toolbar = self.create_menu()
- hdlbox.add(self.menubar)
- self.menubar.show()
- self.vbox.pack_start(self.toolbar, expand=False)
- self.scrolledwin = gtk.ScrolledWindow()
- self.scrolledwin.show()
- self.vbox.pack_start(self.scrolledwin)
- self.text = gtk.TextView()
- self.text.set_editable(True)
- self.scrolledwin.add(self.text)
- self.text.show()
- self.buffer = self.text.get_buffer()
- self.dirty = 0
- self.file_new()
- self.text.grab_focus()
- self.clipboard = gtk.Clipboard(selection='CLIPBOARD')
- self.dirname = None
- self.search_string = None
- self.last_search_iter = None
- return
- def load_file(self, fname):
- try:
- fd = open(fname)
- self.buffer.set_text('')
- buf = fd.read(BLOCK_SIZE)
- while buf != '':
- self.buffer.insert_at_cursor(buf)
- buf = fd.read(BLOCK_SIZE)
- self.text.queue_draw()
- self.set_title(os.path.basename(fname))
- self.fname = fname
- self.dirname = os.path.dirname(self.fname)
- self.buffer.set_modified(False)
- self.new = 0
- except:
- dlg = gtk.MessageDialog(self, gtk.DIALOG_DESTROY_WITH_PARENT,
- gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
- "Can't open " + fname)
- resp = dlg.run()
- dlg.hide()
- return
- def create_menu(self):
- ui_string = """<ui>
- <menubar>
- <menu name='FileMenu' action='FileMenu'>
- <menuitem action='FileNew'/>
- <menuitem action='FileOpen'/>
- <menuitem action='FileSave'/>
- <menuitem action='FileSaveAs'/>
- <separator/>
- <menuitem action='FileExit'/>
- </menu>
- <menu name='EditMenu' action='EditMenu'>
- <menuitem action='EditCut'/>
- <menuitem action='EditCopy'/>
- <menuitem action='EditPaste'/>
- <menuitem action='EditClear'/>
- <separator/>
- <menuitem action='EditFind'/>
- <menuitem action='EditFindNext'/>
- </menu>
- <placeholder name='OtherMenus'/>
- <menu name='HelpMenu' action='HelpMenu'>
- <menuitem action='HelpAbout'/>
- </menu>
- </menubar>
- <toolbar>
- <toolitem action='FileNew'/>
- <toolitem action='FileOpen'/>
- <toolitem action='FileSave'/>
- <toolitem action='FileSaveAs'/>
- <separator/>
- <toolitem action='EditCut'/>
- <toolitem action='EditCopy'/>
- <toolitem action='EditPaste'/>
- <toolitem action='EditClear'/>
- </toolbar>
- </ui>
- """
- actions = [
- ('FileMenu', None, '_File'),
- ('FileNew', gtk.STOCK_NEW, None, None, None, self.file_new),
- ('FileOpen', gtk.STOCK_OPEN, None, None, None, self.file_open),
- ('FileSave', gtk.STOCK_SAVE, None, None, None, self.file_save),
- ('FileSaveAs', gtk.STOCK_SAVE_AS, None, None, None,
- self.file_saveas),
- ('FileExit', gtk.STOCK_QUIT, None, None, None, self.file_exit),
- ('EditMenu', None, '_Edit'),
- ('EditCut', gtk.STOCK_CUT, None, None, None, self.edit_cut),
- ('EditCopy', gtk.STOCK_COPY, None, None, None, self.edit_copy),
- ('EditPaste', gtk.STOCK_PASTE, None, None, None, self.edit_paste),
- ('EditClear', gtk.STOCK_REMOVE, 'C_lear', None, None,
- self.edit_clear),
- ('EditFind', gtk.STOCK_FIND, None, None, None, self.edit_find),
- ('EditFindNext', None, 'Find _Next', "F3", None,
- self.edit_find_next),
- ('HelpMenu', gtk.STOCK_HELP),
- ('HelpAbout', None, 'A_bout', None, None, self.help_about),
- ]
- self.ag = gtk.ActionGroup('edit')
- self.ag.add_actions(actions)
- self.ui = gtk.UIManager()
- self.ui.insert_action_group(self.ag, 0)
- self.ui.add_ui_from_string(ui_string)
- self.add_accel_group(self.ui.get_accel_group())
- return (self.ui.get_widget('/menubar'), self.ui.get_widget('/toolbar'))
-
- def chk_save(self):
- if self.buffer.get_modified():
- dlg = gtk.Dialog('Unsaved File', self,
- gtk.DIALOG_DESTROY_WITH_PARENT,
- (gtk.STOCK_YES, gtk.RESPONSE_YES,
- gtk.STOCK_NO, gtk.RESPONSE_NO,
- gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
- lbl = gtk.Label((self.fname or "Untitled")+
- " has not been saved\n" +
- "Do you want to save it?")
- lbl.show()
- dlg.vbox.pack_start(lbl)
- ret = dlg.run()
- dlg.hide()
- if ret == gtk.RESPONSE_NO:
- return 0
- if ret == gtk.RESPONSE_YES:
- if self.file_save():
- return 0
- return 1
- return 0
-
- def file_new(self, mi=None):
- if self.chk_save(): return
- self.buffer.set_text('')
- self.buffer.set_modified(False)
- self.fname = None
- self.set_title("Untitled")
- self.new = 1
- return
- def file_open(self, mi=None):
- if self.chk_save(): return
- fname = dialogs.OpenFile('Open File', self, self.dirname, self.fname)
- if not fname: return
- self.load_file(fname)
- return
- def file_save(self, mi=None):
- if self.new:
- return self.file_saveas()
- ret = False
- try:
- start, end = self.buffer.get_bounds()
- blockend = start.copy()
- fd = open(self.fname, "w")
- while blockend.forward_chars(BLOCK_SIZE):
- buf = self.buffer.get_text(start, blockend)
- fd.write(buf)
- start = blockend.copy()
- buf = self.buffer.get_text(start, blockend)
- fd.write(buf)
- fd.close()
- self.buffer.set_modified(False)
- ret = True
- except:
- dlg = gtk.MessageDialog(self, gtk.DIALOG_DESTROY_WITH_PARENT,
- gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
- "Error saving file " + self.fname)
- resp = dlg.run()
- dlg.hide()
- return ret
- def file_saveas(self, mi=None):
- fname = dialogs.SaveFile('Save File As', self, self.dirname,
- self.fname)
- if not fname: return False
- self.fname = fname
- self.dirname = os.path.dirname(self.fname)
- self.set_title(os.path.basename(fname))
- self.new = 0
- return self.file_save()
- def file_exit(self, mi=None, event=None):
- if self.chk_save(): return True
- self.hide()
- self.destroy()
- if self.quit_cb: self.quit_cb(self)
- return False
- def edit_cut(self, mi):
- self.buffer.cut_clipboard(self.clipboard, True)
- return
- def edit_copy(self, mi):
- self.buffer.copy_clipboard(self.clipboard)
- return
- def edit_paste(self, mi):
- self.buffer.paste_clipboard(self.clipboard, None, True)
- return
- def edit_clear(self, mi):
- self.buffer.delete_selection(True, True)
- return
- def _search(self, search_string, iter = None):
- if iter is None:
- start = self.buffer.get_start_iter()
- else:
- start = iter
- i = 0
- if search_string:
- self.search_string = search_string
- res = start.forward_search(search_string, gtk.TEXT_SEARCH_TEXT_ONLY)
- if res:
- match_start, match_end = res
- self.buffer.place_cursor(match_start)
- self.buffer.select_range(match_start, match_end)
- self.text.scroll_to_iter(match_start, 0.0)
- self.last_search_iter = match_end
-
- else:
- self.search_string = None
- self.last_search_iter = None
-
- def edit_find(self, mi):
- def dialog_response_callback(dialog, response_id):
- if response_id == gtk.RESPONSE_CLOSE:
- dialog.destroy()
- return
- self._search(search_text.get_text(), self.last_search_iter)
- search_text = gtk.Entry()
- s = self.buffer.get_selection_bounds()
- if len(s) > 0:
- search_text.set_text(self.buffer.get_slice(s[0], s[1]))
- dialog = gtk.Dialog("Search", self,
- gtk.DIALOG_DESTROY_WITH_PARENT,
- (gtk.STOCK_FIND, RESPONSE_FORWARD,
- gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
- dialog.vbox.pack_end(search_text, True, True, 0)
- dialog.connect("response", dialog_response_callback)
- search_text.show()
- search_text.grab_focus()
- dialog.show_all()
- response_id = dialog.run()
- def edit_find_next(self, mi):
- self._search(self.search_string, self.last_search_iter)
- def help_about(self, mi):
- dlg = gtk.MessageDialog(self, gtk.DIALOG_DESTROY_WITH_PARENT,
- gtk.MESSAGE_INFO, gtk.BUTTONS_OK,
- "Copyright (C)\n"
- "1998 James Henstridge\n"
- "2004 John Finlay\n"
- "This program is covered by the GPL>=2")
- dlg.run()
- dlg.hide()
- return
-
-def edit(fname, mainwin=False):
- if mainwin: quit_cb = lambda w: gtk.main_quit()
- else: quit_cb = None
- w = EditWindow(quit_cb=quit_cb)
- w.load_file(fname)
- w.show()
- w.set_size_request(0,0)
- if mainwin: gtk.main()
- return
-
-if __name__ == '__main__':
- import sys
- edit(sys.argv[-1], mainwin=True)
diff --git a/examples/ide/edit.xpm b/examples/ide/edit.xpm
deleted file mode 100644
index a2291f36..00000000
--- a/examples/ide/edit.xpm
+++ /dev/null
@@ -1,38 +0,0 @@
-/* XPM */
-static char *edit[] = {
-/* width height num_colors chars_per_pixel */
-" 20 22 8 1",
-/* colors */
-". c #ffffff",
-"# c None",
-"a c #9999ff",
-"b c #999999",
-"c c #6666cc",
-"d c #663399",
-"e c #333333",
-"f c #000000",
-/* pixels */
-"eeeeeeeeeeeee#######",
-"e..........e.e######",
-"e..........e..eeffff",
-"e..........e.effadf#",
-"e..........effacdf##",
-"e.........ffaccdff##",
-"e........facccdfbf##",
-"e.......faccddfbbf##",
-"e......faccddf..bf##",
-"e.....faccddf...bf##",
-"e....faccddf....bf##",
-"e...eaccddf.....bf##",
-"e...facddf......bf##",
-"e..eacddf.......bf##",
-"e..faeff........bf##",
-"e.eaeb..........bf##",
-"e.feb...........bf##",
-"e.fb............bf##",
-"e.f.............bf##",
-"e...............bf##",
-"eebbbbbbbbbbbbbbef##",
-"##ffffffffffffffff##"
-};
-
diff --git a/examples/ide/gtkcons.py b/examples/ide/gtkcons.py
deleted file mode 100755
index 770d5859..00000000
--- a/examples/ide/gtkcons.py
+++ /dev/null
@@ -1,330 +0,0 @@
-#!/usr/bin/env python
-
-# Interactive Python-GTK Console
-# Copyright (C),
-# 1998 James Henstridge
-# 2004 John Finlay
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-# This module implements an interactive python session in a GTK window. To
-# start the session, use the gtk_console command. Its specification is:
-# gtk_console(namespace, title, copyright)
-# where namespace is a dictionary representing the namespace of the session,
-# title is the title on the window and
-# copyright is any additional copyright info to print.
-#
-# As well as the starting attributes in namespace, the session will also
-# have access to the list __history__, which is the command history.
-
-import sys, string, traceback
-import pygtk
-pygtk.require('2.0')
-import gobject
-import gtk
-
-stdout = sys.stdout
-
-if not hasattr(sys, 'ps1'): sys.ps1 = '>>> '
-if not hasattr(sys, 'ps2'): sys.ps2 = '... '
-
-# some functions to help recognise breaks between commands
-def remQuotStr(s):
- '''Returns s with any quoted strings removed (leaving quote marks)'''
- r = ''
- inq = 0
- qt = ''
- prev = '_'
- while len(s):
- s0, s = s[0], s[1:]
- if inq and (s0 != qt or prev == '\\'):
- prev = s0
- continue
- prev = s0
- if s0 in '\'"':
- if inq:
- inq = 0
- else:
- inq = 1
- qt = s0
- r = r + s0
- return r
-
-def bracketsBalanced(s):
- '''Returns true iff the brackets in s are balanced'''
- s = filter(lambda x: x in '()[]{}', s)
- stack = []
- brackets = {'(':')', '[':']', '{':'}'}
- while len(s) != 0:
- if s[0] in ")]}":
- if len(stack) != 0 and brackets[stack[-1]] == s[0]:
- del stack[-1]
- else:
- return 0
- else:
- stack.append(s[0])
- s = s[1:]
- return len(stack) == 0
-
-class gtkoutfile:
- '''A fake output file object. It sends output to a GTK TextView widget,
- and if asked for a file number, returns one set on instance creation'''
- def __init__(self, w, fn, font):
- self.__fn = fn
- self.__w = w
- self.__b = w.get_buffer()
- self.__ins = self.__b.get_mark('insert')
- self.__font = font
- def close(self): pass
- flush = close
- def fileno(self): return self.__fn
- def isatty(self): return 0
- def read(self, a): return ''
- def readline(self): return ''
- def readlines(self): return []
- def write(self, s):
- #stdout.write(str(self.__w.get_point()) + '\n')
- iter = self.__b.get_iter_at_mark(self.__ins)
- self.__b.insert_with_tags(iter, s, self.__font)
- self.__w.scroll_to_mark(self.__ins, 0.0)
- self.__w.queue_draw()
- def writelines(self, l):
- iter = self.__b.get_iter_at_mark(self.__ins)
- for s in l:
- self.__b.insert_with_tags(iter, s, self.__font)
- self.__w.scroll_to_mark(self.__ins, 0.0)
- self.__w.queue_draw()
- def seek(self, a): raise IOError, (29, 'Illegal seek')
- def tell(self): raise IOError, (29, 'Illegal seek')
- truncate = tell
-
-class Console(gtk.VBox):
- def __init__(self, namespace={}, copyright='', quit_cb=None):
- gtk.VBox.__init__(self, spacing=2)
- self.set_border_width(2)
- self.copyright = copyright
- #self.set_size_request(475, 300)
-
- self.quit_cb = quit_cb
-
- self.inp = gtk.HBox()
- self.pack_start(self.inp)
- self.inp.show()
-
- self.scrolledwin = gtk.ScrolledWindow()
- self.scrolledwin.show()
- self.inp.pack_start(self.scrolledwin, padding=1)
- self.text = gtk.TextView()
- self.text.set_editable(False)
- self.text.set_wrap_mode(gtk.WRAP_WORD)
- self.text.set_size_request(500, 400)
- self.scrolledwin.add(self.text)
- self.text.show()
- self.buffer = self.text.get_buffer()
- #create the tags we will use
- self.normal = self.buffer.create_tag('Normal', font='Helvetica 10',
- foreground='black')
- self.title = self.buffer.create_tag('Title', font='Helvetica Bold 10',
- foreground='darkgreen')
- self.error = self.buffer.create_tag('Error', font='Helvetica 12',
- foreground='red')
- self.command = self.buffer.create_tag('Command',
- font='Helvetica Bold 10',
- foreground='blue')
-
- self.inputbox = gtk.HBox(spacing=2)
- self.pack_end(self.inputbox, expand=False)
- self.inputbox.show()
-
- self.prompt = gtk.Label(sys.ps1)
- self.prompt.set_padding(xpad=2, ypad=0)
- self.prompt.set_size_request(26, -1)
- self.inputbox.pack_start(self.prompt, fill=False, expand=False)
- self.prompt.show()
-
- self.closer = gtk.Button(stock=gtk.STOCK_CLOSE)
- self.closer.connect("clicked", self.quit)
- self.inputbox.pack_end(self.closer, fill=False, expand=False)
- self.closer.show()
-
- self.line = gtk.Entry()
- self.line.set_size_request(400,-1)
- self.line.connect("key_press_event", self.key_function)
- self.inputbox.pack_start(self.line, padding=2)
- self.line.show()
-
- # now let the text box be resized
- self.text.set_size_request(0, 0)
- self.line.set_size_request(0, -1)
-
- self.namespace = namespace
-
- self.cmd = ''
- self.cmd2 = ''
-
- # set up hooks for standard output.
- self.stdout = gtkoutfile(self.text, sys.stdout.fileno(),
- self.normal)
- self.stderr = gtkoutfile(self.text, sys.stderr.fileno(),
- self.error)
-
- # set up command history
- self.history = ['']
- self.histpos = 0
- self.namespace['__history__'] = self.history
-
- def init(self):
- self.text.realize()
- self.insert = self.buffer.get_mark('insert')
- iter = self.buffer.get_iter_at_mark(self.insert)
- self.buffer.insert_with_tags(iter, 'Python %s\n%s\n\n' %
- (sys.version, sys.copyright) +
- 'Interactive Python-GTK Console - \n' +
- 'Copyright (C)\n' \
- '1998 James Henstridge\n' \
- '2004 John Finlay\n\n' +
- self.copyright + '\n', self.title)
- self.text.scroll_to_mark(self.insert, 0.0)
- self.line.grab_focus()
-
- def quit(self, *args):
- self.hide()
- self.destroy()
- if self.quit_cb: self.quit_cb()
-
- def key_function(self, entry, event):
- if event.keyval == gtk.keysyms.Return:
- self.line.emit_stop_by_name("key_press_event")
- self.eval()
- if event.keyval == gtk.keysyms.Tab:
- self.line.emit_stop_by_name("key_press_event")
- self.line.append_text('\t')
- gobject.idle_add(self.focus_text)
- elif event.keyval in (gtk.keysyms.KP_Up, gtk.keysyms.Up):
- self.line.emit_stop_by_name("key_press_event")
- self.historyUp()
- gobject.idle_add(self.focus_text)
- elif event.keyval in (gtk.keysyms.KP_Down, gtk.keysyms.Down):
- self.line.emit_stop_by_name("key_press_event")
- self.historyDown()
- gobject.idle_add(self.focus_text)
- elif event.keyval in (gtk.keysyms.D, gtk.keysyms.d) and \
- event.state & gtk.gdk.CONTROL_MASK:
- self.line.emit_stop_by_name("key_press_event")
- self.ctrld()
-
- def focus_text(self):
- self.line.grab_focus()
- return False # don't requeue this handler
-
- def ctrld(self):
- self.quit()
-
- def historyUp(self):
- if self.histpos > 0:
- l = self.line.get_text()
- if len(l) > 0 and l[0] == '\n': l = l[1:]
- if len(l) > 0 and l[-1] == '\n': l = l[:-1]
- self.history[self.histpos] = l
- self.histpos = self.histpos - 1
- self.line.set_text(self.history[self.histpos])
-
- def historyDown(self):
- if self.histpos < len(self.history) - 1:
- l = self.line.get_text()
- if len(l) > 0 and l[0] == '\n': l = l[1:]
- if len(l) > 0 and l[-1] == '\n': l = l[:-1]
- self.history[self.histpos] = l
- self.histpos = self.histpos + 1
- self.line.set_text(self.history[self.histpos])
-
- def eval(self):
- l = self.line.get_text() + '\n'
- if len(l) > 1 and l[0] == '\n': l = l[1:]
- self.histpos = len(self.history) - 1
- if len(l) > 0 and l[-1] == '\n':
- self.history[self.histpos] = l[:-1]
- else:
- self.history[self.histpos] = l
- self.line.set_text('')
- iter = self.buffer.get_iter_at_mark(self.insert)
- self.buffer.insert_with_tags(iter, self.prompt.get() + l, self.command)
- self.text.scroll_to_mark(self.insert, 0.0)
- if l == '\n':
- self.run(self.cmd)
- self.cmd = ''
- self.cmd2 = ''
- return
- self.histpos = self.histpos + 1
- self.history.append('')
- self.cmd = self.cmd + l
- self.cmd2 = self.cmd2 + remQuotStr(l)
- l = string.rstrip(l)
- if not bracketsBalanced(self.cmd2) or l[-1] == ':' or \
- l[-1] == '\\' or l[0] in ' \11':
- self.prompt.set_text(sys.ps2)
- self.prompt.queue_draw()
- return
- self.run(self.cmd)
- self.cmd = ''
- self.cmd2 = ''
-
- def run(self, cmd):
- sys.stdout, self.stdout = self.stdout, sys.stdout
- sys.stderr, self.stderr = self.stderr, sys.stderr
- try:
- try:
- r = eval(cmd, self.namespace, self.namespace)
- if r is not None:
- print `r`
- except SyntaxError:
- exec cmd in self.namespace
- except:
- if hasattr(sys, 'last_type') and \
- sys.last_type == SystemExit:
- self.quit()
- else:
- traceback.print_exc()
- self.prompt.set_text(sys.ps1)
- self.prompt.queue_draw()
- sys.stdout, self.stdout = self.stdout, sys.stdout
- sys.stderr, self.stderr = self.stderr, sys.stderr
-
-def gtk_console(ns, title='Python', copyright='', menu=None):
- win = gtk.Window()
- win.set_size_request(475, 300)
- win.connect("destroy", lambda w: gtk.main_quit())
- win.connect("delete_event", lambda w,e: gtk.main_quit())
- win.set_title(title)
- cons = Console(namespace=ns, copyright=copyright,
- quit_cb=lambda w: gtk.main_quit())
- if menu:
- box = gtk.VBox()
- win.add(box)
- box.show()
- box.pack_start(menu, expand=False)
- menu.show()
- box.pack_start(cons)
- else:
- win.add(cons)
- cons.show()
- win.show()
- win.set_size_request(0,0)
- cons.init()
- gtk.main()
-
-if __name__ == '__main__':
- gtk_console({'__builtins__': __builtins__, '__name__': '__main__',
- '__doc__': None})
diff --git a/examples/ide/gtkdb.py b/examples/ide/gtkdb.py
deleted file mode 100755
index cb33d150..00000000
--- a/examples/ide/gtkdb.py
+++ /dev/null
@@ -1,434 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-import bdb
-import repr
-import string
-import linecache # for linecache.getlines(filename)
-import pygtk
-pygtk.require('2.0')
-import gtk
-import dialogs
-
-class PyGTKDb(gtk.Window, bdb.Bdb):
- ui_string = """<ui>
- <toolbar name='Toolbar'>
- <toolitem action='Next'/>
- <toolitem action='Step'/>
- <separator/>
- <toolitem action='Return'/>
- <separator/>
- <toolitem action='Continue'/>
- <toolitem action='Break'/>
- <separator/>
- <toolitem action='Edit'/>
- <toolitem action='Run'/>
- <separator/>
- <toolitem action='Quit'/>
- </toolbar>
- </ui>"""
- def __init__(self):
- gtk.Window.__init__(self)
- bdb.Bdb.__init__(self)
- self.realize()
-
- self.set_title("PyGTKDb")
- self.connect("destroy", self.do_quit)
- self.connect("delete_event", self.do_quit)
-
- self.box = gtk.VBox()
- self.add(self.box)
- self.box.show()
-
- self.add_stock_ids()
-
- actions = [
- ('Next', 'pyide-next', None, None, "Next statement", self.do_next),
- ('Step', 'pyide-step', None, None, "Step into function",
- self.do_step),
- ('Return', 'pyide-return', None, None,
- "Continue execution to end of function", self.do_return),
- ('Continue', 'pyide-continue', None, None,
- "Continue execution to next break point", self.do_continue),
- ('Break', 'pyide-break', None, None,
- "Toggle break point at selected line", self.do_break),
- ('Edit', 'pyide-edit', None, None,
- "Edit the value of the selected variable", self.do_edit),
- ('Run', 'pyide-run', None, None,
- "Execute some code in the current stack context", self.do_run),
- ('Quit', 'pyide-quit', None, None, "Quit the debugger",
- self.do_quit),
- ]
-
- self.ag = gtk.ActionGroup('PyIDE Actions')
- self.ag.add_actions(actions)
- self.ui = gtk.UIManager()
- self.ui.insert_action_group(self.ag, 0)
- self.ui.add_ui_from_string(self.ui_string)
- self.add_accel_group(self.ui.get_accel_group())
-
- self.box.pack_start(self.ui.get_widget('/Toolbar'), expand=False)
- sep = gtk.HSeparator()
- self.box.pack_start(sep, expand=False)
- sep.show()
-
- vpane = gtk.VPaned()
- self.box.pack_start(vpane)
- vpane.show()
-
- hpane = gtk.HPaned()
- vpane.add1(hpane)
- hpane.show()
-
- swin = gtk.ScrolledWindow()
- swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
- hpane.add1(swin)
- swin.show()
-
- ls = gtk.ListStore(str)
- self.stackdisp = gtk.TreeView(ls)
- tvc = gtk.TreeViewColumn('Stack Frame', gtk.CellRendererText(),
- text=0)
- self.stackdisp.append_column(tvc)
- self.stackdisp.set_size_request(280, 125)
- selection = self.stackdisp.get_selection()
- selection.set_mode(gtk.SELECTION_BROWSE)
- selection.connect("changed", self.update_curstack)
-
- self.stackdisp.set_border_width(2)
- swin.add(self.stackdisp)
- self.stackdisp.show()
-
- swin = gtk.ScrolledWindow()
- swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
- hpane.add2(swin)
- swin.show()
-
- ls = gtk.ListStore(str, str, str)
- self.vardisp = gtk.TreeView(ls)
- titles = ['local var', 'type', 'value']
- for n in range(len(titles)):
- tvc = gtk.TreeViewColumn(titles[n], gtk.CellRendererText(),
- text=n)
- self.vardisp.append_column(tvc)
-
- selection = self.vardisp.get_selection()
- selection.set_mode(gtk.SELECTION_BROWSE)
- selection.connect("changed", self.update_selectedvar)
- self.vardisp.set_border_width(2)
-
- self.vardisp.set_border_width(2)
- swin.add(self.vardisp)
- self.vardisp.show()
- self.vardisp.selected = 0
- self.vardisp.varnames = []
-
- swin = gtk.ScrolledWindow()
- swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
- vpane.add2(swin)
- swin.show()
-
- self.minibreak = gtk.Image()
- self.minibreak.set_from_file("minibreak.xpm")
- self.minibreak.show()
- ls = gtk.ListStore(gtk.gdk.Pixbuf, str, str)
- self.filedisp = gtk.TreeView(ls)
- titles = ['break', 'lineno', 'line']
- cell = gtk.CellRendererPixbuf()
- tvc = gtk.TreeViewColumn(None, cell, pixbuf=0)
- tvc.set_min_width(14)
- tvc.set_widget(self.minibreak)
- self.filedisp.append_column(tvc)
- cell = gtk.CellRendererText()
- cell.set_property('xalign', 1.0)
- tvc = gtk.TreeViewColumn(titles[1], cell, text=1)
- self.filedisp.append_column(tvc)
- cell = gtk.CellRendererText()
- tvc = gtk.TreeViewColumn(titles[2], cell, text=2)
- self.filedisp.append_column(tvc)
- self.minibreak = self.minibreak.get_pixbuf()
- selection = self.filedisp.get_selection()
- selection.set_mode(gtk.SELECTION_BROWSE)
- selection.connect("changed", self.update_selection)
- self.filedisp.connect('row-activated', lambda t,p,c: self.do_break())
- self.filedisp.set_border_width(2)
- self.filedisp.set_size_request(600, 200)
- swin.add(self.filedisp)
- self.filedisp.show()
-
- separator = gtk.HSeparator()
- self.box.pack_start(separator, expand=False)
- separator.show()
-
- align = gtk.Alignment(0.0, 0.5, 0.0, 0.0)
- self.box.pack_start(align, expand=False)
- align.show()
- self.status = gtk.Label()
- self.status.set_padding(4, 1)
- align.add(self.status)
- self.status.show()
-
- self.filename = None
- self.selected = 0
- self.blockupdate = 0
- return
-
- def add_stock_ids(self):
- ids = [
- ('pyide-next', '_Next', gtk.gdk.CONTROL_MASK, gtk.keysyms.N,
- 'pyide'),
- ('pyide-step', '_Step', gtk.gdk.CONTROL_MASK, gtk.keysyms.S,
- 'pyide'),
- ('pyide-return', '_Return', gtk.gdk.CONTROL_MASK, gtk.keysyms.R,
- 'pyide'),
- ('pyide-continue', '_Continue', gtk.gdk.CONTROL_MASK,
- gtk.keysyms.C, 'pyide'),
- ('pyide-break', '_Break', gtk.gdk.CONTROL_MASK, gtk.keysyms.B,
- 'pyide'),
- ('pyide-edit', '_Edit', gtk.gdk.CONTROL_MASK, gtk.keysyms.E,
- 'pyide'),
- ('pyide-run', 'R_un', gtk.gdk.CONTROL_MASK, gtk.keysyms.U,
- 'pyide'),
- ('pyide-quit', '_Quit', gtk.gdk.CONTROL_MASK, gtk.keysyms.Q,
- 'pyide'),
- ]
- gtk.stock_add(ids)
- names = ['next', 'step', 'return', 'continue', 'break',
- 'edit', 'run', 'quit']
- self.iconfactory = gtk.IconFactory()
- for name in names:
- iconset = gtk.IconSet(gtk.gdk.pixbuf_new_from_file(name+'.xpm'))
- self.iconfactory.add('pyide-'+name, iconset)
- self.iconfactory.add_default()
- return
-
- def set_status(self, str):
- self.status.set_text(str)
- return
- def update_selection(self, sel):
- if self.blockupdate: return
- model, iter = sel.get_selected()
- r = model.get_path(iter)[0]
- self.selected = r + 1
- return
- def update_curstack(self, sel):
- if self.blockupdate: return
- model, iter = sel.get_selected()
- r = model.get_path(iter)[0]
- self.curindex = r
- self.curframe = self.stack[self.curindex][0]
- self.lineno = None
- self.update_code_listing()
- self.update_var_listing()
- return
- def update_selectedvar(self, sel):
- model, iter = sel.get_selected()
- if iter:
- r = model.get_path(iter)[0]
- self.vardisp.selected = r
- return
- def set_quit(self):
- self.hide()
- self.destroy()
- bdb.Bdb.set_quit(self)
-
- def reset(self):
- bdb.Bdb.reset(self)
- self.forget()
- def forget(self):
- self.lineno = None
- self.stack = []
- self.curindex = 0
- self.curframe = None
- def setup(self, f, t):
- self.forget()
- self.stack, self.curindex = self.get_stack(f, t)
- self.curframe = self.stack[self.curindex][0]
- return
- # interaction functions -- overriden from bdb
- def user_line(self, frame):
- # called when we stop or break at this line
- self.interaction(frame, None)
- def user_return(self, frame, return_value):
- # called when a return trap is set here
- frame.f_locals['__return__'] = return_value
- if frame.f_code.co_name:
- func = frame.f_code.co_name
- else:
- func = "<lambda>"
- self.set_status(func + " returned " + repr.repr(return_value))
- self.interaction(frame, None)
- def user_exception(self, frame, (exc_type, exc_value, exc_traceback)):
- frame.f_locals['__exception__'] = exc_type, exc_value
- if type(exc_type) == type(''):
- exc_type_name = exc_type
- else: exc_type_name = exc_type.__name__
- self.set_status(exc_type_name + ':' + repr.repr(exc_value))
- self.interaction(frame, exc_traceback)
-
- def interaction(self, frame, traceback):
- self.setup(frame, traceback)
- self.update_stack_listing(self.curindex)
- gtk.main()
- self.forget()
-
- def update_stack_listing(self, curindex):
- self.blockupdate = 1
- model = self.stackdisp.get_model()
- model.clear()
- for i in range(len(self.stack)):
- frame_lineno = self.stack[i]
- row = self.format_stack_entry(frame_lineno, "##!##")
- row = string.split(row, "##!##")[0]
- model.append([row])
- self.blockupdate = 0
- self.stackdisp.scroll_to_cell(curindex, None, True, 1.0, 0.0)
- self.stackdisp.get_selection().select_path(curindex)
- return
- def update_var_listing(self):
- model = self.vardisp.get_model()
- model.clear()
- locals = self.curframe.f_locals
- self.vardisp.varnames = locals.keys()
- self.vardisp.varnames.sort()
- for var in self.vardisp.varnames:
- row = [var, type(locals[var]).__name__, repr.repr(locals[var])]
- model.append(row)
- self.vardisp.get_selection().select_path(0)
- return
- def update_code_listing(self):
- frame = self.curframe
- newfile = frame.f_code.co_filename
- if newfile != self.filename:
- lines = linecache.getlines(newfile)
- self.filename = newfile
- self.blockupdate = 1
- model = self.filedisp.get_model()
- model.clear()
- breaks = self.get_file_breaks(newfile)
- for line in range(len(lines)):
- if line+1 in breaks:
- model.append([self.minibreak, line+1,
- lines[line].rstrip()])
- else:
- model.append([None, line+1, lines[line].rstrip()])
- self.blockupdate = 0
- self.selected = frame.f_lineno
- lineno = self.selected
- if newfile != '<string>':
- self.filedisp.scroll_to_cell(lineno - 1, None, True, 1.0, 0.0)
- self.filedisp.get_selection().select_path(lineno - 1)
- return
- def do_next(self, _b=None):
- self.set_next(self.curframe)
- gtk.main_quit()
- def do_step(self, _b=None):
- self.set_step()
- gtk.main_quit()
- def do_return(self, _b=None):
- self.set_return(self.curframe)
- gtk.main_quit()
- def do_continue(self, _b=None):
- self.set_continue()
- gtk.main_quit()
- def do_quit(self, _b=None, _e=None):
- self.set_quit()
- gtk.main_quit()
- def do_break(self, _b=None):
- breaks = self.get_file_breaks(self.filename)
- if self.selected in breaks:
- err = self.clear_break(self.filename, self.selected)
- if err:
- self.set_status(err)
- return
- self.filedisp.get_model()[self.selected-1][0] = None
- else:
- err = self.set_break(self.filename, self.selected)
- if err:
- self.set_status(err)
- return
- self.filedisp.get_model()[self.selected-1][0] = self.minibreak
- return
- def do_run(self, _b=None):
- line = dialogs.InputBox("Execute Code", "Enter code to execute:", self)
- if line == None: return
- locals = self.curframe.f_locals
- globals = self.curframe.f_globals
- globals['__privileged__'] = 1
- try:
- code = compile(line + '\n', '<stdin>', 'single')
- exec code in globals, locals
- except:
- if type(sys.exc_type) == type(''):
- exc_type_name = sys.exc_type
- else: exc_type_name = sys.exc_type.__name__
- self.set_status('*** ' + exc_type_name + ': ' +
- str(sys.exc_value))
- return
- self.update_var_listing()
- return
- def do_edit(self, _b=None):
- locals = self.curframe.f_locals
- varname = self.vardisp.varnames[self.vardisp.selected]
- val = repr.repr(locals[varname])
- value = dialogs.InputBox("Edit Variable",
- "Enter new value for " + varname + ":",
- self, val)
- if value == None: return
- globals = self.curframe.f_globals
- globals['__privileged__'] = 1
- try:
- val = eval(value, globals, locals)
- self.curframe.f_locals[varname] = val
- except:
- if type(sys.exc_type) == type(''):
- exc_type_name = sys.exc_type
- else: exc_type_name = sys.exc_type.__name__
- self.set_status('*** ' + exc_type_name + ': ' +
- str(sys.exc_value))
- return
- row = self.vardisp.selected
- model = self.vardisp.get_model()
- model[row][1] = type(val).__name__
- model[row][2] = repr.repr(val)
-
-# this makes up the interface that is compatible with pdb.
-def run(statement, globals=None, locals=None):
- win = PyGTKDb()
- win.show()
- win.run(statement, globals, locals)
-
-def runeval(expression, globals=None, locals=None):
- win = PyGTKDb()
- win.show()
- return win.runeval(expression, globals, locals)
-
-def runcall(*args):
- win = PyGTKDb()
- win.show()
- return apply(win.runcall, args)
-
-def set_trace():
- win = PyGTKDb()
- win.show()
- win.set_trace()
-
-def post_mortem(traceback):
- win = PyGTKDb()
- win.show()
- win.reset()
- win.interaction(None, traceback)
-
-def pm():
- post_mortem(sys.last_traceback)
-
-if __name__ == '__main__':
- import os
- if not sys.argv[1:]:
- print "usage: gtkdb.py scriptfile [args ...]"
- sys.exit(2)
- filename = sys.argv[1]
- del sys.argv[0] # delete gtkdb.py
- sys.path.insert(0, os.path.dirname(filename))
-
- run('execfile("' + filename + '")', {'__name__': '__main__'})
diff --git a/examples/ide/gtkprof.py b/examples/ide/gtkprof.py
deleted file mode 100755
index 649456f0..00000000
--- a/examples/ide/gtkprof.py
+++ /dev/null
@@ -1,133 +0,0 @@
-#!/usr/bin/env python
-
-import profile, pstats, fpformat
-
-import pygtk
-pygtk.require('2.0')
-import gtk
-
-class PStatWindow(gtk.Window):
- def __init__(self, stats):
- gtk.Window.__init__(self)
- self.connect("destroy", self.quit)
- self.connect("delete_event", self.quit)
- self.set_title("Profile Statistics")
-
- self.stats = stats
-
- box1 = gtk.VBox()
- self.add(box1)
- box1.show()
-
- text = `stats.total_calls` + " function calls "
- if stats.total_calls != stats.prim_calls:
- text = text + "( " + `stats.prim_calls` + " primitive calls) "
- text = text + "in " + fpformat.fix(stats.total_tt, 3) + " CPU seconds"
- label = gtk.Label(text)
- label.set_padding(2, 2)
- box1.pack_start(label, expand=False)
- label.show()
-
- swin = gtk.ScrolledWindow()
- swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
- box1.pack_start(swin)
- swin.show()
-
- titles = [('ncalls', 40), ('tottime', 50), ('percall', 50),
- ('cumtime', 50), ('percall', 50),
- ('filename:lineno(function)', 10)]
- ls = gtk.ListStore(*((str,)*len(titles)))
- list = gtk.TreeView(ls)
- for n in range(len(titles)):
- cell = gtk.CellRendererText()
- cell.set_property('xalign', 1.0)
- tvc = gtk.TreeViewColumn(titles[n][0], cell, text=n)
- tvc.set_min_width(titles[n][1])
- list.append_column(tvc)
- list.set_size_request(500, 200)
- self.list = list
- list.set_border_width(10)
- swin.add(list)
- list.show()
-
- self.insert_stats()
-
- separator = gtk.HSeparator()
- box1.pack_start(separator, expand=False)
- separator.show()
-
- box2 = gtk.VBox(spacing=10)
- box2.set_border_width(10)
- box1.pack_start(box2, expand=False)
- box2.show()
-
- button = gtk.Button("close")
- button.connect("clicked", self.quit)
- self.close_button = button
- box2.pack_start(button)
- button.set_flags(gtk.CAN_DEFAULT)
- button.grab_default()
- button.show()
-
- def quit(self, *args):
- self.hide()
- self.destroy()
- gtk.main_quit()
-
- def get_stats_list(self):
- if self.stats.fcn_list:
- return self.stats.fcn_list[:]
- else:
- return self.stats.stats.keys()
-
- def insert_stats(self):
- list = self.get_stats_list()
- if list:
- row = [None] * 6
- model = self.list.get_model()
- for func in list:
- cc,nc,tt,ct,callers = self.stats.stats[func]
- row[0] = `nc`
- if nc != cc:
- row[0] = row[0] + '/' + `cc`
- row[1] = fpformat.fix(tt, 3)
- if nc == 0:
- row[2] = ''
- else:
- row[2] = fpformat.fix(tt/nc, 3)
- row[3] = fpformat.fix(ct, 3)
- if cc == 0:
- row[4] = ''
- else:
- row[4] = fpformat.fix(ct/cc, 3)
- file,line,name = func
- row[5] = file + ":" + `line` + "(" + name + \
- ")"
- self.list.get_model().append(row)
- return
-
-def run(cmd):
- prof = profile.Profile()
- try:
- stats = pstats.Stats(prof.run(cmd))
- except SystemExit:
- pass
- stats.strip_dirs().sort_stats("time", "module", "name")
- win = PStatWindow(stats)
- win.show()
- gtk.main()
-
-def run_file(file):
- return run('execfile("' + file + '")')
-
-
-if __name__ == '__main__':
- import sys, os
- if not sys.argv[1:]:
- print "usage: gtkprof.py scriptfile [args ...]"
- sys.exit(2)
- filename = sys.argv[1]
- del sys.argv[0]
- sys.path.insert(0, os.path.dirname(filename))
-
- run_file(filename)
diff --git a/examples/ide/minibreak.xpm b/examples/ide/minibreak.xpm
deleted file mode 100644
index 6fd11e7c..00000000
--- a/examples/ide/minibreak.xpm
+++ /dev/null
@@ -1,19 +0,0 @@
-/* XPM */
-static char * minibreak_xpm[] = {
-"12 12 4 1",
-" c None",
-". c #000000",
-"X c #FF0000",
-"o c #FFFFFF",
-" ...... ",
-" .oooooo. ",
-" .ooXXXXoo. ",
-".ooXXXXXXoo.",
-".oXXXXXXXXo.",
-".oXXXXXXXXo.",
-".oXXXXXXXXo.",
-".oXXXXXXXXo.",
-".ooXXXXXXoo.",
-" .ooXXXXoo. ",
-" .oooooo. ",
-" ...... "};
diff --git a/examples/ide/next.xpm b/examples/ide/next.xpm
deleted file mode 100644
index 6c0cf361..00000000
--- a/examples/ide/next.xpm
+++ /dev/null
@@ -1,32 +0,0 @@
-/* XPM */
-static char *next[] = {
-/* width height num_colors chars_per_pixel */
-" 20 22 2 1",
-/* colors */
-". c None",
-"# c #000000",
-/* pixels */
-"....................",
-"....................",
-"......#.............",
-"......##............",
-"......###...........",
-"......####..........",
-"......#####.........",
-"......######........",
-"......#######.......",
-"......########......",
-"......#########.....",
-"......#########.....",
-"......########......",
-"......#######.......",
-"......######........",
-"......#####.........",
-"......####..........",
-"......###...........",
-"......##............",
-"......#.............",
-"....................",
-"...................."
-};
-
diff --git a/examples/ide/pyide.py b/examples/ide/pyide.py
deleted file mode 100755
index 9b6ea524..00000000
--- a/examples/ide/pyide.py
+++ /dev/null
@@ -1,260 +0,0 @@
-#!/usr/bin/env python
-
-import pygtk
-pygtk.require('2.0')
-import gtk
-import gtkcons, gtkdb, gtkprof, edit, dialogs
-import os, sys, string
-
-# select a good VT emulator
-for vt in 'Eterm', 'nxterm', 'xterm-color', 'xterm', 'rxvt':
- for dirname in string.split(os.environ['PATH'], os.pathsep):
- fullname = os.path.join(dirname, vt)
- if os.path.exists(fullname):
- VT_CMD = fullname + ' -geometry 80x6 -e '
- break
- else:
- continue
- break
-else:
- VT_CMD='' # this is not ideal
-
-ui_string = """<ui>
-<menubar>
- <menu action='FileMenu'>
- <menuitem action='FileNew'/>
- <menuitem action='FileOpen'/>
- <separator/>
- <menuitem action='FileExit'/>
- </menu>
- <menu action='EditMenu'>
- <menuitem action='EditCopy'/>
- <menuitem action='EditPaste'/>
- <menuitem action='EditClear'/>
- </menu>
- <placeholder name='OtherMenus'/>
- <menu action='HelpMenu' position='bot'>
- <menuitem action='HelpAbout'/>
- </menu>
-</menubar>
-</ui>
-"""
-pythonmenu_uistring = """<ui>
-<menubar>
- <placeholder name='OtherMenus'>
- <menu name='PythonMenu' action='PythonMenu'>
- <menuitem action='PythonReload'/>
- <menuitem action='PythonRun'/>
- <menuitem action='PythonDebug'/>
- <menuitem action='PythonProfile'/>
- </menu>
- </placeholder>
-</menubar>
-</ui>
-"""
-
-class Application(gtk.Window):
- def __init__(self):
- gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
- self.connect("destroy", self.quit)
- self.connect("delete_event", self.quit)
- self.set_title("Python")
- self.set_size_request(475, 325)
- self.main_box = gtk.VBox()
- self.add(self.main_box)
- self.main_box.show()
- hdlbox = gtk.HandleBox()
- self.main_box.pack_start(hdlbox, expand=False)
- hdlbox.show()
- actions = [
- ('FileMenu', None, '_File'),
- ('FileNew', gtk.STOCK_NEW, None, None, None, self.file_new),
- ('FileOpen', gtk.STOCK_OPEN, None, None, None, self.file_open),
- ('FileExit', gtk.STOCK_QUIT, None, None, None, self.file_exit),
- ('EditMenu', None, '_Edit'),
- ('EditCopy', gtk.STOCK_COPY, None, None, None, self.edit_copy),
- ('EditPaste', gtk.STOCK_PASTE, None, None, None, self.edit_paste),
- ('EditClear', gtk.STOCK_REMOVE, 'C_lear', None, None,
- self.edit_clear),
- ('HelpMenu', gtk.STOCK_HELP),
- ('HelpAbout', None, 'A_bout', None, None, self.help_about),
- ]
- python_actions = [
- ('PythonMenu', None, '_Python'),
- ('PythonReload', None, '_Reload Module...', None, None,
- self.python_reload),
- ('PythonRun', None, 'R_un...', None, None, self.python_run),
- ('PythonDebug', None, '_Debug...', None, None, self.python_debug),
- ('PythonProfile', None, 'Pro_file...', None, None,
- self.python_prof),
- ]
- self.ag = gtk.ActionGroup('ide')
- self.ag.add_actions(actions)
- self.ag.add_actions(python_actions)
- self.ui = gtk.UIManager()
- self.ui.insert_action_group(self.ag, 0)
- self.ui.add_ui_from_string(ui_string)
- self.ui.add_ui_from_string(pythonmenu_uistring)
- self.add_accel_group(self.ui.get_accel_group())
- hdlbox.add(self.ui.get_widget('/menubar'))
- #self.ui.get_widget('/menubar').show()
- self.interp = gtkcons.Console(
- namespace={'__builtins__': __builtins__,
- '__name__': '__main__',
- '__doc__': None}, quit_cb=self.quit)
- self.main_box.pack_start(self.interp)
- self.interp.show()
- self.interp.init()
- self.editwins = []
- return
-
- def quit(self, *args):
- for win in self.editwins:
- if win.chk_save(): return
- win.hide()
- win.destroy()
- gtk.main_quit()
- return
-
- def reload_file(self, fname):
- if not os.path.isfile(fname):
- gtk.MessageDialog(self, gtk.DIALOG_DESTROY_WITH_PARENT,
- gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
- fname + " was not found.")
- return
- dir = os.path.dirname(fname)
- base = os.path.basename(fname)
- if dir not in sys.path: sys.path.insert(0, dir)
- if string.lower(base[-3:]) == '.py': base = base[:-3]
- elif string.lower(base[-4:]) == '.pyc': base = base[:-4]
- if not sys.modules.has_key(base):
- self.interp.run('import ' + base)
- else:
- self.interp.run('import ' + base)
- self.interp.run('reload(' + base + ')')
- return
-
- # execute a python script normally or with the debugger or profiler
- def run_script(self, fname):
- if not fname or not os.path.exists(fname):
- dlg = gtk.MessageDialog(self, gtk.DIALOG_DESTROY_WITH_PARENT,
- gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
- "Invalid filename "+fname)
- dlg.run()
- return
- args = dialogs.InputBox("Arguments",
- "Enter any command line arguments", self)
- if args == None: return
- os.system(VT_CMD+'python "'+fname+'" ' + args + ' &')
- return
- def debug_script(self, fname):
- if not fname or not os.path.exists(fname):
- dlg = gtk.MessageDialog(self, gtk.DIALOG_DESTROY_WITH_PARENT,
- gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
- "Invalid filename "+fname)
- dlg.run()
- return
- args = dialogs.InputBox("Arguments",
- "Enter any command line arguments", self)
- if args == None: return
- os.system(VT_CMD+'python '+gtkdb.__file__+' "'+fname+'" ' +
- args + ' &')
- return
- def profile_script(self, fname):
- if not fname or not os.path.exists(fname):
- dlg = gtk.MessageDialog(self, gtk.DIALOG_DESTROY_WITH_PARENT,
- gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
- "Invalid filename "+fname)
- dlg.run()
- return
- args = dialogs.InputBox("Arguments",
- "Enter any command line arguments", self)
- if args == None: return
- os.system(VT_CMD+'python '+gtkprof.__file__+' "'+fname+'" ' +
- args + ' &')
- return
-
- def add_py_menu(self, ew):
- python_actions = [
- ('PythonMenu', None, '_Python'),
- ('PythonReload', None, '_Reload Module'),
- ('PythonRun', None, 'R_un...', None, None,
- lambda w, ew=ew: self.run_script(ew.fname)),
- ('PythonDebug', None, '_Debug...', None, None,
- lambda w, ew=ew: self.debug_script(ew.fname)),
- ('PythonProfile', None, 'Pro_file...', None, None,
- lambda w, ew=ew: self.profile_script(ew.fname)),
- ]
- ew.ag.add_actions(python_actions)
- ew.ui.add_ui_from_string(pythonmenu_uistring)
- return
-
- def file_new(self, mi=None):
- ew = edit.EditWindow(quit_cb=self.rem_editwin)
- self.editwins.append(ew)
- self.add_py_menu(ew)
- ew.show()
- ew.set_size_request(0,0)
- return
- def file_open(self, mi=None):
- fname = dialogs.OpenFile('Open', self)
- if fname:
- ew = edit.EditWindow(quit_cb=self.rem_editwin)
- ew.load_file(fname)
- self.editwins.append(ew)
- self.add_py_menu(ew)
- ew.show()
- ew.set_size_request(0,0)
- return
- def rem_editwin(self, win=None, event=None):
- for i in range(len(self.editwins)):
- if self.editwins[i] == win:
- del self.editwins[i]
- break
- return
- def file_exit(self, mi=None):
- self.quit()
- return
- def edit_copy(self, mi=None):
- self.interp.text.copy_clipboard(0)
- return
- def edit_paste(self, mi=None):
- self.interp.line.paste_clipboard(0)
- return
- def edit_clear(self, mi=None):
- self.interp.line.delete_selection()
- return
- def python_reload(self, mi=None):
- print "python_reload"
- return
- def python_run(self, mi=None):
- fname = dialogs.OpenFile("Run", self)
- if fname:
- self.run_script(fname)
- return
- def python_debug(self, mi=None):
- fname = dialogs.OpenFile("Debug", self)
- if fname:
- self.debug_script(fname)
- return
- def python_prof(self, mi=None):
- fname = dialogs.OpenFile("Profile", self)
- if fname:
- self.profile_script(fname)
- return
- def help_about(self, mi=None):
- dlg = gtk.MessageDialog(self, gtk.DIALOG_DESTROY_WITH_PARENT,
- gtk.MESSAGE_INFO, gtk.BUTTONS_OK,
- "Copyright (C)\n" \
- "1998 James Henstridge\n" \
- "2004 John Finlay\n" \
- "This program is covered by the GPL>=2")
- dlg.run()
- dlg.hide()
- return
-
-if __name__ == '__main__':
- app = Application()
- app.show()
- app.set_size_request(0,0)
- gtk.main()
diff --git a/examples/ide/quit.xpm b/examples/ide/quit.xpm
deleted file mode 100644
index 11d0bb01..00000000
--- a/examples/ide/quit.xpm
+++ /dev/null
@@ -1,36 +0,0 @@
-/* XPM */
-static char *quit[] = {
-/* width height num_colors chars_per_pixel */
-" 20 22 6 1",
-/* colors */
-". c #ffcc33",
-"# c None",
-"a c #996600",
-"b c #666666",
-"c c #333333",
-"d c #000000",
-/* pixels */
-"####################",
-"####################",
-"####################",
-"########d####d######",
-"#######dad##dd###dd#",
-"#######d.addaad#dad#",
-"######da......dda.d#",
-"#dddddd..........ad#",
-"da...............dc#",
-"cda..............dc#",
-"#cd..............ad#",
-"##d...............ad",
-"#da.............addc",
-"#d.............ddcc#",
-"da.............dc###",
-"dddd...........ad###",
-"#ccd........adaad###",
-"###d..da....dcddd###",
-"###dbdcda...c#ccc###",
-"###cdc#ccdadc#######",
-"####c###ccdc########",
-"##########c#########"
-};
-
diff --git a/examples/ide/return.xpm b/examples/ide/return.xpm
deleted file mode 100644
index a908f597..00000000
--- a/examples/ide/return.xpm
+++ /dev/null
@@ -1,35 +0,0 @@
-/* XPM */
-static char *return[] = {
-/* width height num_colors chars_per_pixel */
-" 20 22 5 1",
-/* colors */
-". c None",
-"# c #999999",
-"a c #666666",
-"b c #333333",
-"c c #000000",
-/* pixels */
-"....................",
-"..............c.....",
-"..............cc....",
-".........#bcccccc...",
-".....#bccccccccccc..",
-"..#bccccccccccccccc.",
-".acccccccccccccccccc",
-"#cccccccccccccccccc.",
-"bccccccccccccccccc..",
-"ccccccccccccccccc...",
-"cccccccccb#...cc....",
-"ccccccb#......c.....",
-"cccb#..b............",
-"cc..bbbbbb..........",
-"c.bbbbbbbb.a........",
-"bbbbbbbbbbb#........",
-".bbbbbbbbb.a........",
-"..bbbbbbbbb#........",
-"...bbbbbbb.a........",
-".....bbbbbb#........",
-"........bb.a........",
-"...................."
-};
-
diff --git a/examples/ide/run.xpm b/examples/ide/run.xpm
deleted file mode 100644
index fbfb4ed8..00000000
--- a/examples/ide/run.xpm
+++ /dev/null
@@ -1,28 +0,0 @@
-/* XPM */
-static char * run_xpm[] = {
-"20 22 3 1",
-" c None",
-". c #000000",
-"X c #C00080",
-" ",
-" ",
-" .... ",
-" .XXXX. ",
-" .XXXX. ",
-" .XXXX. ",
-" .XXXX. ",
-" .XX. ",
-" .XX. ",
-" .XX. ",
-" .XX. ",
-" .. ",
-" .. ",
-" .. ",
-" .. ",
-" ",
-" .. ",
-" .XX. ",
-" .XX. ",
-" .. ",
-" ",
-" "};
diff --git a/examples/ide/step.xpm b/examples/ide/step.xpm
deleted file mode 100644
index 4e5c7bb3..00000000
--- a/examples/ide/step.xpm
+++ /dev/null
@@ -1,35 +0,0 @@
-/* XPM */
-static char *forward[] = {
-/* width height num_colors chars_per_pixel */
-" 20 22 5 1",
-/* colors */
-". c None",
-"# c #999999",
-"a c #666666",
-"b c #333333",
-"c c #000000",
-/* pixels */
-"....................",
-"........bb.a........",
-".....bbbbbb#........",
-"...bbbbbbb.a........",
-"..bbbbbbbbb#........",
-".bbbbbbbbb.a........",
-"bbbbbbbbbbb#........",
-"c.bbbbbbbb.a........",
-"cc..bbbbbb..........",
-"cccb#..b............",
-"ccccccb#......c.....",
-"cccccccccb#...cc....",
-"ccccccccccccccccc...",
-"bccccccccccccccccc..",
-"#cccccccccccccccccc.",
-".acccccccccccccccccc",
-"..#bccccccccccccccc.",
-".....#bccccccccccc..",
-".........#bcccccc...",
-"..............cc....",
-"..............c.....",
-"...................."
-};
-