SourceForge logo
SourceForge logo
Menu

matplotlib-devel — matplotlib developers

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
(1)
Nov
(33)
Dec
(20)
2004 Jan
(7)
Feb
(44)
Mar
(51)
Apr
(43)
May
(43)
Jun
(36)
Jul
(61)
Aug
(44)
Sep
(25)
Oct
(82)
Nov
(97)
Dec
(47)
2005 Jan
(77)
Feb
(143)
Mar
(42)
Apr
(31)
May
(93)
Jun
(93)
Jul
(35)
Aug
(78)
Sep
(56)
Oct
(44)
Nov
(72)
Dec
(75)
2006 Jan
(116)
Feb
(99)
Mar
(181)
Apr
(171)
May
(112)
Jun
(86)
Jul
(91)
Aug
(111)
Sep
(77)
Oct
(72)
Nov
(57)
Dec
(51)
2007 Jan
(64)
Feb
(116)
Mar
(70)
Apr
(74)
May
(53)
Jun
(40)
Jul
(519)
Aug
(151)
Sep
(132)
Oct
(74)
Nov
(282)
Dec
(190)
2008 Jan
(141)
Feb
(67)
Mar
(69)
Apr
(96)
May
(227)
Jun
(404)
Jul
(399)
Aug
(96)
Sep
(120)
Oct
(205)
Nov
(126)
Dec
(261)
2009 Jan
(136)
Feb
(136)
Mar
(119)
Apr
(124)
May
(155)
Jun
(98)
Jul
(136)
Aug
(292)
Sep
(174)
Oct
(126)
Nov
(126)
Dec
(79)
2010 Jan
(109)
Feb
(83)
Mar
(139)
Apr
(91)
May
(79)
Jun
(164)
Jul
(184)
Aug
(146)
Sep
(163)
Oct
(128)
Nov
(70)
Dec
(73)
2011 Jan
(235)
Feb
(165)
Mar
(147)
Apr
(86)
May
(74)
Jun
(118)
Jul
(65)
Aug
(75)
Sep
(162)
Oct
(94)
Nov
(48)
Dec
(44)
2012 Jan
(49)
Feb
(40)
Mar
(88)
Apr
(35)
May
(52)
Jun
(69)
Jul
(90)
Aug
(123)
Sep
(112)
Oct
(120)
Nov
(105)
Dec
(116)
2013 Jan
(76)
Feb
(26)
Mar
(78)
Apr
(43)
May
(61)
Jun
(53)
Jul
(147)
Aug
(85)
Sep
(83)
Oct
(122)
Nov
(18)
Dec
(27)
2014 Jan
(58)
Feb
(25)
Mar
(49)
Apr
(17)
May
(29)
Jun
(39)
Jul
(53)
Aug
(52)
Sep
(35)
Oct
(47)
Nov
(110)
Dec
(27)
2015 Jan
(50)
Feb
(93)
Mar
(96)
Apr
(30)
May
(55)
Jun
(83)
Jul
(44)
Aug
(8)
Sep
(5)
Oct
Nov
(1)
Dec
(1)
2016 Jan
Feb
Mar
(1)
Apr
May
Jun
(2)
Jul
Aug
(3)
Sep
(1)
Oct
(3)
Nov
Dec
2017 Jan
Feb
(5)
Mar
Apr
May
Jun
Jul
(3)
Aug
Sep
(7)
Oct
Nov
Dec
2018 Jan
Feb
Mar
Apr
May
Jun
Jul
(2)
Aug
Sep
Oct
Nov
Dec
S M T W T F S

1
(1)
2
(7)
3
(3)
4
5
6
7
8
9
10
(2)
11
12
(1)
13
(1)
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
(3)
30
(2)
31



Showing 2 results of 2

From: John H. <jdh...@ac...> - 2003年12月30日 17:55:24
>>>>> "Jeremy" == Jeremy O'Donoghue <je...@o-...> writes:
 Jeremy> Hi John, Thanks for your reply - and the patch! I am about
 Jeremy> to check in an updated backend_wx which basically contains
 Jeremy> your changes, with one difference: I have refactored the
 Jeremy> code:
 Jeremy> drawDC=wxClientDC(self) drawDC.BeginDrawing()
 Jeremy> drawDC.Clear() drawDC.DrawBitmap(self.bitmap, 0, 0)
 Jeremy> drawDC.EndDrawing()
Excellent, I was going to suggest the same.
I have rewritten the interactive interface so that you can call
import matplotlib
matplotlib.use('WX')
matplotlib.interactive(True)
(and I've removed the ShowOn abomination)
Perhaps you should just send me the latest version of you code in case
the mirror lags behind as usual and I'll then apply my patch to the
wx_backend for the new interface, and commit.
JDH
From: Jeremy O'D. <je...@o-...> - 2003年12月30日 17:16:27
Hi John,
Thanks for your reply - and the patch! I am about to check in an updated 
backend_wx which basically contains your changes, with one difference: I have 
refactored the code:
 drawDC=wxClientDC(self)
 drawDC.BeginDrawing()
 drawDC.Clear()
 drawDC.DrawBitmap(self.bitmap, 0, 0)
 drawDC.EndDrawing() 
into a new function in FigureWX: gui_repaint(). I have done this for several 
reasons, but mainly because the same code appears in several places 
(FigureWX._onSize() as well as draw_if_interactive(), and it turns out to be 
needed for the Wx variant of interactive_demo (which I am also about to check 
in)).
I have also made a change so that if _DEBUG is set to a value less than 5 
(i.e. you are interested in debugging), the system exception hook is replaced 
with one which performs a traceback and enters pdb. This seems to work 
correctly for me on Linux, and I'll verify Win32 when I get back to work next 
week. It's a bit of an ugly hack, and I may rethink it later, but it's very 
handy for now, and doesn't intrude when not needed.
On Monday 29 December 2003 4:15 pm, John Hunter wrote:
> >>>>> "Jeremy" == Jeremy O'Donoghue <je...@o-...> writes:
>
> Jeremy> A few questions for John Hunter: I think I need to do
> Jeremy> something like the following: - show() must now
> Jeremy> instantiate any figures already defined and enter the the
> Jeremy> main event loop. ShowOn needs to keep track of this. - I
> Jeremy> need to keep track of the number of figures
> Jeremy> instantiated. I assume that Gcf.destroy() does this. - I
> Jeremy> need to ensure that I do not exit when the last figure is
> Jeremy> destroyed, and therefore need to manage that I may need to
> Jeremy> create a new figure manager if there is none.
>
> Hi Jeremy,
>
> I think we should consider redoing this whole segment of the code from
> the ground up to make for a cleaner / cross GUI implementation. It
> may be that Pearu Peteson <pe...@ce...> gui_thread code is the
> way to go for this since that is what is was designed to do (enable
> interactive control of WX plots (chaco) from the shell). He has
> indicated a willingness to port it to pygtk provided we're willing to
> help test his code with the WX and GTK matplotlib backends. However,
> this would create a scipy dependency...
I followed the thread form Pearu a few weeks back, although have not gotten 
around to trying the gui_thread code. I think there is something similar in 
the Python Cookbook for PyGtk (chapter 9.12), which might assist in doing a 
Gtk port.
I'm not keen on adding a dependency on scipy, but perhaps Pearu would consider 
making gui_thread its own module (or allowing us to do so). Checking back 
over the mail you sent to me, there are only three files involved. One of the 
things which drew me to working on Matplotlib was the small set of 
dependencies, and it would be a shame to loose this.
I'm very willing to play with the code he has with the Wx backend - I doubt 
that it will require much work on my behalf.
[snip]
> I don't think the current architecture for show, draw_if_interactive,
> ShowOn etc, is very elegant or easily understandable, and would be
> happy to refactor it for the next release. Ideally we could handle
> these two cases across backends
>
> 1) defer all drawing until a call to show, which draws and realizes
> all pending figures. This should not hang the script, ie,
> further drawing commands should be possible.
You'll notice in the code that I checked in that I have been playing with this 
in the backend_wx code. While it is possible to exit the mainloop, it seems 
that it is not possible to re-enter. It may be that I can do something akin 
to the Python Cookbook recepie I mentioned above for wx - it doesn't look too 
hard.
I have attached the code from the book example below, if you're interested.
> 2) do drawing with each matplotlib.matlab command for interactive
> mode (current implementation in backend_gtk with ShowOn.set(1) at
> start of script)
As you noteed, this now works with your fix.
> For the most part, I think we have this with the GTK backend, but it
> may be necessary to refactor in order to get something that works with
> both. I'll think it over and take a look at the WX code to see if I
> get any ideas how to proceed.
>
> In the meantime, we should also see if we can get matplotlib to work
> with gui_thread -- I'll take a look at this too.
>
> JDH
Thanks again for the fix
Jeremy
====== interactive_gtk.py =====
import __builtin__, __main__
import codeop, keyword, gtk, os, re, readline, threading, traceback, signal, 
sys
def walk_class(klass):
 list = []
 for item in dir(klass):
 if item[0] != "_":
 list.append(item)
 for base in klass.__bases__:
 for item in walk_class(base):
 if item not in list: list.append(item)
 return list
class Completer:
 def __init__(self, lokals):
 self.locals = lokals
 self.completions = keyword.kwlist + \
 __builtins__.__dict__.keys() + \
 __main__.__dict__.keys()
 def complete(self, text, state):
 if state == 0:
 if "." in text:
 self.matches = self.attr_matches(text)
 else:
 self.matches = self.global_matches(text)
 try:
 return self.matches[state]
 except IndexError:
 return None
 def update(self, locs):
 self.locals = locs
 for key in self.locals.keys():
 if not key in self.completions:
 self.completions.append(key)
 def global_matches(self, text):
 matches = []
 n = len(text)
 for word in self.completions:
 if word[:n] == text:
 matches.append(word)
 return matches
 def attr_matches(self, text):
 m = re.match(r"(\w+(\.\w+)*)\.(\w*)", text)
 if not m:
 return
 expr, attr = m.group(1, 3)
 obj = eval(expr, self.locals)
 if str(obj)[1:4] == "gtk":
 words = walk_class(obj.__class__)
 else:
 words = dir(eval(expr, self.locals))
 matches = []
 n = len(attr)
 for word in words:
 if word[:n] == attr:
 matches.append("%s.%s" % (expr, word))
 return matches
class GtkInterpreter(threading.Thread):
 """ Run a GTK mainloop() in a separate thread. Python commands can be 
passed to the
 thread, where they will be executed. This is implemented by periodically 
checking for
 passed code using a GTK timeout callback. """
 TIMEOUT = 100 # interval in milliseconds between timeouts
 def __init__(self):
 threading.Thread.__init__ (self)
 self.ready = threading.Condition ()
 self.globs = globals ()
 self.locs = locals ()
 self._kill = 0
 self.cmd = '' # current code block
 self.new_cmd = None # waiting line of code, or None if none waiting
 self.completer = Completer(self.locs)
 readline.set_completer(self.completer.complete)
 readline.parse_and_bind('tab: complete')
 def run(self):
 gtk.timeout_add(self.TIMEOUT, self.code_exec)
 gtk.mainloop()
 def code_exec(self):
 """ Execute waiting code. Called every timeout period. """
 self.ready.acquire()
 if self._kill: gtk.mainquit()
 if self.new_cmd != None:
 self.ready.notify()
 self.cmd = self.cmd + self.new_cmd
 self.new_cmd = None
 try:
 code = codeop.compile_command(self.cmd[:-1])
 if code:
 self.cmd = ''
 exec code, self.globs, self.locs
 self.completer.update(self.locs)
 except:
 traceback.print_exc()
 self.cmd = ''
 self.ready.release()
 return 1
 def feed(self, code):
 """ Feed a line of code to the thread. This function will block until 
the code is
 checked by the GTK thread. Returns true if the thread has executed the 
code.
 Returns false if deferring execution until complete block is 
available. """
 if code[-1:]!='\n': code = code +'\n' # raw_input strips newline
 self.completer.update(self.locs)
 self.ready.acquire()
 self.new_cmd = code
 self.ready.wait() # Wait until processed in timeout interval
 self.ready.release()
 return not self.cmd
 def kill(self):
 """ Kill the thread, returning when it has been shut down. """
 self.ready.acquire()
 self._kill=1
 self.ready.release()
 self.join()
# Read user input in a loop and send each line to the interpreter thread
def signal_handler(*args):
 print "SIGNAL:", args
 sys.exit()
if __name__=="__main__":
 signal.signal(signal.SIGINT, signal_handler)
 signal.signal(signal.SIGSEGV, signal_handler)
 prompt = '>>> '
 interpreter = GtkInterpreter()
 interpreter.start()
 interpreter.feed("from gtk import *")
 interpreter.feed("sys.path.append('.')")
 if len (sys.argv) > 1:
 for file in open(sys.argv[1]).readlines():
 interpreter.feed(file)
 print 'Interactive GTK Shell'
 try:
 while 1:
 command = raw_input(prompt) + '\n' # raw_input strips newlines
 prompt = interpreter.feed(command) and '>>> ' or '... '
 except (EOFError, KeyboardInterrupt): pass
 interpreter.kill()
 print

Showing 2 results of 2

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /