[Pythonmac-SIG] Tkinter/Mac newbie query
Mac OSX 10.8.1, 2 x quad processor Intel MacPro, Python 2.7.3 from python.org. I've been programming in python for a couple of years (off and on), and I'm getting more and more comfortable with it. I'd like to start putting GUIs in front of some of my code, and have been looking at wx, Tkinter, and PyQt. Everything I read says that starting with Tkinter version 8.2 (or something like that) it is "themed" and Tkinter applications should look native on the various platforms. The version of Tkinter I have is 8.5, but when I code up some of the Tkinter demos, they all come out looking more like X11 applications than like native Mac apps. I assume the problem is because I'm not doing SOMETHING right in the initialization, but I'm scratching my head over what. Does anyone have any thoughts as to what I might be doing wrong? I've pasted a typical bit of code in below. #!/usr/bin/env python from Tkinter import * class App: def __init__(self, master): frame = Frame(master) frame.pack() self.button = Button(frame, text="QUIT", fg="red", command=frame.quit) self.button.pack(side=LEFT) self.hi_there = Button(frame, text="Hello", command=self.say_hi) self.hi_there.pack(side=LEFT) def say_hi(self): print "hi there, everyone!" root = Tk() app = App(root) root.mainloop() And yes, the version of python I get via !usr/bin/env is the same one I get at the terminal prompt. Thanks, Bill ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
[Pythonmac-SIG] Matplotlib-animation problem
I'm running Mac OS-X 10.8.1, with python 2.7.3, numpy 1.8.0, matplotlib 1.2, and wxPython 2.9.3.1 (although wx isn't involved here, at least I don't think so). I'm running on a dual-quad processor Xeon Mac Pro. I decided to learn something about animated matplotlib graphics, so started to look at the examples in http://matplotlib.sourceforge.net/examples/animation/... I consistently run into a problem, illustrated below. Starting from the animate_decay.py code, copied and pasted into an editor as here: #!/usr/bin/env python """ http://matplotlib.sourceforge.net/examples/animation/animate_decay.html """ import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation def data_gen(): t = data_gen.t cnt = 0 while cnt < 1000: cnt+=1 t += 0.05 yield t, np.sin(2*np.pi*t) * np.exp(-t/10.) data_gen.t = 0 fig = plt.figure() ax = fig.add_subplot(111) line, = ax.plot([], [], lw=2) ax.set_ylim(-1.1, 1.1) ax.set_xlim(0, 5) ax.grid() xdata, ydata = [], [] def run(data): # update the data t,y = data xdata.append(t) ydata.append(y) xmin, xmax = ax.get_xlim() if t >= xmax: ax.set_xlim(xmin, 2*xmax) ax.figure.canvas.draw() line.set_data(xdata, ydata) return line, ani = animation.FuncAnimation(fig, run, data_gen, blit=True, interval=10, repeat=False) plt.show() If I attempt to run this script (or any of several others), I get: StraylightPro:Matplotlib_stuff wrw$ ./animate_decay.py Traceback (most recent call last): File "/Library/Python/2.7/site-packages/matplotlib-1.2.x-py2.7-macosx-10.8-intel.egg/matplotlib/backend_bases.py", line 1117, in _on_timer ret = func(*args, **kwargs) File "/Library/Python/2.7/site-packages/matplotlib-1.2.x-py2.7-macosx-10.8-intel.egg/matplotlib/animation.py", line 763, in _step still_going = Animation._step(self, *args) File "/Library/Python/2.7/site-packages/matplotlib-1.2.x-py2.7-macosx-10.8-intel.egg/matplotlib/animation.py", line 625, in _step self._draw_next_frame(framedata, self._blit) File "/Library/Python/2.7/site-packages/matplotlib-1.2.x-py2.7-macosx-10.8-intel.egg/matplotlib/animation.py", line 645, in _draw_next_frame self._post_draw(framedata, blit) File "/Library/Python/2.7/site-packages/matplotlib-1.2.x-py2.7-macosx-10.8-intel.egg/matplotlib/animation.py", line 668, in _post_draw self._blit_draw(self._drawn_artists, self._blit_cache) File "/Library/Python/2.7/site-packages/matplotlib-1.2.x-py2.7-macosx-10.8-intel.egg/matplotlib/animation.py", line 682, in _blit_draw bg_cache[a.axes] = a.figure.canvas.copy_from_bbox(a.axes.bbox) AttributeError: 'FigureCanvasMac' object has no attribute 'copy_from_bbox' Traceback (most recent call last): File "/Library/Python/2.7/site-packages/matplotlib-1.2.x-py2.7-macosx-10.8-intel.egg/matplotlib/backend_bases.py", line 1117, in _on_timer ret = func(*args, **kwargs) File "/Library/Python/2.7/site-packages/matplotlib-1.2.x-py2.7-macosx-10.8-intel.egg/matplotlib/animation.py", line 763, in _step still_going = Animation._step(self, *args) File "/Library/Python/2.7/site-packages/matplotlib-1.2.x-py2.7-macosx-10.8-intel.egg/matplotlib/animation.py", line 625, in _step self._draw_next_frame(framedata, self._blit) File "/Library/Python/2.7/site-packages/matplotlib-1.2.x-py2.7-macosx-10.8-intel.egg/matplotlib/animation.py", line 643, in _draw_next_frame self._pre_draw(framedata, blit) File "/Library/Python/2.7/site-packages/matplotlib-1.2.x-py2.7-macosx-10.8-intel.egg/matplotlib/animation.py", line 656, in _pre_draw self._blit_clear(self._drawn_artists, self._blit_cache) File "/Library/Python/2.7/site-packages/matplotlib-1.2.x-py2.7-macosx-10.8-intel.egg/matplotlib/animation.py", line 696, in _blit_clear a.figure.canvas.restore_region(bg_cache[a]) AttributeError: 'FigureCanvasMac' object has no attribute 'restore_region' …and the 'restore-region' error sequence then repeats endlessly. I'm hoping this is all caused by my not quite having the right library installed someplace along the line. If anyone could point it out, I'd sure appreciate it. Thanks, Bill ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
[Pythonmac-SIG] Problem launching a py2app bundle from launchd on Mountain Lion
With apologies for cross-posting (I also asked about this on stackoverflow), but I'm getting REALLY frustrated. I have a python script called "Irrigate" that I've converted to a stand-alone application using py2app. It runs just fine when double-clicked in the Finder, or opened in a terminal session. However, when I try to have it launched by launched, it fails with the following message logged in the system log: Aug 8 07:15:02 StraylightPro.local Irrigate[79689]: Irrigate Error Aug 8 07:15:02 StraylightPro.local coreservicesd[77]: Application App:"Irrigate" [ 0x0/0x697596f] @ 0x0x7fe77240cec0 tried to be brought forward, but isn't in fPermittedFrontASNs ( ( ASN:0x0-0x1cb2cb1:) ), so denying. I discovered by trial and error that the .plist I submit to launchd apparently now has to contain a "SessionType" key, and the only key I can get launchd to accept is "Aqua" - which sort of seems consistent with the error message reference "tried to be brought forward". If I use SessionType keys of either "StandardIO" or "Background", launchd won't accept the plist. Googling for fPermittedFrontASNs (or pieces of this string), and searching Apple's developer docs hasn't produced anything. I assume this is all tied to Apple's new security features in Mountain Lion and further that, if I just knew what extended attributes to add to the app.bundle or a key to add to the info.plist inside it, I'd be good to go. Does anyone here know the answer? Thanks, Bill ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] question
On Jul 9, 2012, at 7:46 PM, Ed Pataky wrote: > i have a mac where i installed python, and tornado web server .. i used > py2app and created an executable which wraps my tornado kickoff script into > an executable .. works ok sometimes, but i am confused about a couple things: > > 1) when i run the app, since it is essentially a command line script with no > GUI, i see nothing, although i is running ... how can i create the app so > that it opens the terminal and shows the output? > Strictly speaking you can't without a lot of extra trouble - BUT any print statements in your script will be logged to the system log and is then easily viewable in the Console app in your Utilities folder. > 2) sometimes it gets blocked by the firewall and sometimes it does not .. i > have manually gone in and added it to he allowed list in the firewall, then > as soon as it tries to open a port, the firewall blocks it ... i am not sure > how i did it but i got it work a few times, then sometimes it is blocked .. > how can i make sure when i run the app, it has full permission without having > to mess with the firewall setting ... for example, is there an admin option > when making the executable? Could you be a little more specific here - are you opening a port to listen for incoming sessions or are you trying to open an outbound session? Also, exactly which version of the OS are you running? Apple has been locking things down more and more in the progression from 10.6 to 10.7. -Bill ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] Problems with /Library/ScriptingAdditions/Adobe Unit Types.osax
On Jun 6, 2012, at 9:56 AM, Kevin Walzer wrote: > On 6/5/12 10:36 PM, William R. Wing (Bill Wing) wrote: >> But, to be sure I understand… Is the reason I hadn't run into this problem >> earlier simply because Tk and wx need to check in with Apple Events so they >> can get things like mouse clicks, whereas more basic Python scripts don't? > > If you post a copy of your code, it would be easier to figure out what's > going on. > > -- > Kevin Walzer > Code by Kevin > http://www.codebykevin.com Probably not worth the bandwidth at this point, but here it is: #!/usr/bin/env python from Tkinter import * class Application(Frame): def say_hi(self): print "hi there, everyone!" def createWidgets(self): self.QUIT = Button(self) self.QUIT["text"] = "QUIT" self.QUIT["fg"] = "red" self.QUIT["command"] = self.quit self.QUIT.pack({"side": "left"}) self.hi_there = Button(self) self.hi_there["text"] = "Hello", self.hi_there["command"] = self.say_hi self.hi_there.pack({"side": "left"}) def __init__(self, master=None): Frame.__init__(self, master) self.pack() self.createWidgets() root = Tk() app = Application(master=root) app.mainloop() root.destroy() That code was copied straight out of the Tk documentation at: http://docs.python.org/library/tk.html and it triggered the error caused by the 32-bit Adobe file in /ScriptingAdditions/ that I'd never seen before. It turns out that Adobe has posted a 64-bit version of the file, although it takes a fair amount of work in a terminal session to get it, set its permissions, ownership, and ACL all properly. But, it still leaves me wondering - why do wxPython and Tkinter need to look at stuff in the ScriptingAdditions area of the OS at all? Thanks for your patience, Bill ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Re: [Pythonmac-SIG] Problems with /Library/ScriptingAdditions/Adobe Unit Types.osax
On Jun 5, 2012, at 9:57 PM, Kevin Walzer wrote: > On 6/5/12 8:43 PM, William R. Wing (Bill Wing) wrote: >> /Library/ScriptingAdditions/Adobe Unit Types.osax > > This osax is conflicting not with Python or Tk, but with the Apple Events > framework. It's probably PPC or 32-bit only. An updater is available from > Adobe. (I've run into this issue with my own apps, which crash when someone > has an outdated osax installed--there's no workaround other than to ask the > end user to remove or update the library.) > -- > Kevin Walzer > Code by Kevin > http://www.codebykevin.com Thanks, when your note showed up, I had just finished hiding the Adobe .osax file (I finally did find a clue on Google) and discovered that the error msg had gone away. But, to be sure I understand… Is the reason I hadn't run into this problem earlier simply because Tk and wx need to check in with Apple Events so they can get things like mouse clicks, whereas more basic Python scripts don't? That's terrible syntax, but maybe you can see what I'm asking. I've been writing Python scripts for a year or so, and this is the first I've seen of this problem. Thanks, Bill ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
[Pythonmac-SIG] Problems with /Library/ScriptingAdditions/Adobe Unit Types.osax
Hope someone here can help with a work-around. Context: OS-X 10.7.4 (Lion), Python 2.7.3 (downloaded from Python.org and installed in /Library/Frameworks... (not /System/Library), and seems to work just file. However, when I attempt to run any sort of GUI code (either a Tk demo from the Python docs page or a wxPython demo), I get the following error msg: StraylightPro:Python wrw$ python tk_test.py 2012-06-05 20:28:35.442 Python[51697:f07] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper Python: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers. When I first hit this, I was running wxPython2.8 which is based on the Carbon widgets and thus has to run in 32-bit mode. I assumed I was seeing an architecture collision, so downloaded wxPython2.9 Cocoa, which should be 64-bit compatible. Same error. After scratching my head and checking with Google (which knows about this error in conjunction with Adobe CS products but knows nothing about Python), I decided to try a Tk demo, assuming that since the Tk library is bundled with Python, it would be good to go. I got the same identical error again, and in fact (as you can see) the fragment of the terminal session pasted in above was from the Tk test. Color me frustrated. Any help appreciated. Thanks, -Bill ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG