简体   繁体   English

雪豹上的PyObjc和可可

[英]PyObjc and Cocoa on Snow Leopard

I am about to start my A-Level Computing project (High School Level) which will hopefully be a point-of-sale application for Mac OS. 我即将开始我的A-Level计算项目(高中水平),它有望成为Mac OS的销售点应用程序。 Unfortunately, Objective-C is a little out of my league at the moment and should I get stuck with it in the project I have no one to help out so I would fail the section of the course and not get into University. 不幸的是,Objective-C目前还不在我的联盟中,如果我在项目中遇到困难,我没有人帮忙,所以我会在课程部分失败而不能进入大学。 So this is quite important to me. 所以这对我来说非常重要。

I want to use Python to develop a Cocoa app. 我想用Python开发一个Cocoa应用程序。 I know that I need PyObjc, however all details on the net seem to assume it is pre-installed. 我知道我需要PyObjc,但是网上的所有细节似乎都假设它已预先安装。 Apparently this is the case with Leopard and Snow Leopard but I don't seem to have it on Snow Leopard and never noticed it on Leopard. 显然Leopard和Snow Leopard就是这种情况,但我似乎没有在Snow Leopard上使用它,也从未在Leopard上注意到它。 Also, I have tried installing the latest beta of PyObjc by following the instructions on the Sourceforge page, but with no luck. 此外,我已按照Sourceforge页面上的说明尝试安装最新的PyObjc测试版,但没有运气。

I would really appreciate it if anyone could shed some light on what needs to be installed, how, and links to any resources or tutorials that could help me. 如果有人能够了解需要安装的内容,如何以及可以帮助我的任何资源或教程的链接,我将非常感激。

Thanks in advance for the help! 在此先感谢您的帮助!

Update: I see that this is a popular question, I just got the 'Notable Question' badge for it so I thought I would update anyone coming to this page on what I did after getting the answers. 更新:我看到这是一个很受欢迎的问题,我刚刚得到了“值得注意的问题”徽章,所以我想我会在得到答案之后更新来到此页面的人。

Unfortunately, I wasn't able to use Python to create a Mac application. 不幸的是,我无法使用Python来创建Mac应用程序。 This was rather disappointing at the time, but probably a good thing. 这在当时相当令人失望,但可能是一件好事。 I made a Windows app in C# for my project, it was a tool for creating and running Assembly apps in a simulated environment. 我为我的项目在C#中创建了一个Windows应用程序,它是一个在模拟环境中创建和运行Assembly应用程序的工具。 My course teacher has now started to use my tool to teach the course instead of his own! 我的课程老师现在开始使用我的工具来教授课程而不是他自己的课程! I got a very high score on the computing project (over 90%) and this contributed to me getting an A* in my computing A-Level (the highest grade available) and I consequently got in to Southampton University to study Computer Science. 我在计算项目上获得了很高的分数(超过90%),这有助于我在计算机A-Level(最高级别)中获得A *,因此我进入南安普顿大学学习计算机科学。

This summer, I decided to make an iPad app (soon to be released) and I am glad to say that I know think I could make a Mac OS application in Objective-C as I feel I have learnt enough. 今年夏天,我决定制作一个iPad应用程序(即将发布),我很高兴地说我知道我可以在Objective-C中制作Mac OS应用程序,因为我觉得我已经学到了足够的东西。 I am glad that I took the time to learn it, it is a great language and really useful with iOS becoming so popular. 我很高兴我花时间学习它,它是一种很棒的语言,对于iOS变得如此受欢迎非常有用。

Sorry for all the boasting, but I am really happy about it. 抱歉所有的吹嘘,但我真的很高兴。 What I really want to say is, if you are coming to this page hoping to use PyObjc to create Mac apps easily, don't bother. 我真正想说的是,如果你来这个页面希望使用PyObjc轻松创建Mac应用程序,请不要打扰。 It takes some time and some effort, but once you have learnt Objective-C, it is really satisfying to create apps with it. 这需要一些时间和一些努力,但是一旦你学会了Objective-C,用它创建应用程序真的很令人满意。 Good Luck! 祝好运!

Allow me to echo what has already been said. 请允许我回应已经说过的话。 I too am a student who just started a Cocoa development project, and at the beginning I thought "Well, I already know Python, I'll just use PyObjC and save myself from having to learn Objective-C, which looks beyond my grasp." 我也是刚刚开始Cocoa开发项目的学生,一开始我想:“好吧,我已经知道Python了,我只会使用PyObjC并且不必学习Objective-C,这看起来超出了我的想象。 “ I learned quickly that it can't be done. 我很快就知道它无法完成。 You can develop for OS X without learning Objective-C, but not without learning the Cocoa libraries, which constitute 99% of what you need to learn to write a Cocoa app in Objective-C. 您可以在不学习Objective-C的情况下为OS X开发,但不能不学习Cocoa库,这些库构成了在Objective-C中编写Cocoa应用程序所需要的99%。 Objective-C itself isn't that hard; Objective-C本身并不那么难; it's the Cocoa libraries that you need to invest in learning. 这是您需要投资学习的Cocoa库。

PyObjC basically uses Cocoa libraries and Python syntax. PyObjC基本上使用Cocoa库和Python语法。 I gave up with it quickly and decided that if I was going to have to learn Cocoa, I may as well use Objective-C. 我很快放弃了它,并决定如果我要学习Cocoa,我也可以使用Objective-C。

If you're looking to learn, Aaron Hillegass's book is a good place to start. 如果你想学习,Aaron Hillegass的书是一个很好的起点。 Good luck! 祝好运!

You mean like Checkout ? 你的意思是像Checkout :-) I only mention it because Checkout is gorgeous and written with PyObjC... :-)我只提到它,因为Checkout很华丽,用PyObjC编写......

Your concerns are valid, although probably not as much of a potential showstopper as you'd think. 您的担忧是有效的,尽管可能不如您想象的那么大。 Using PyObjC still requires you to learn some Objective-C, and definitely requires you to understand at least some of the Cocoa frameworks, since you need to call into the Cocoa frameworks whenever you need to do some sort of Cocoa-specific task. 使用PyObjC仍然需要你学习一些Objective-C,并且肯定要求你至少理解一些Cocoa框架,因为你需要在需要执行某种Cocoa特定任务时调用Cocoa框架。

I recommend you read and consider the SO question "Why is the PyObjC documentation so bad?" 我建议你阅读并考虑SO问题“为什么PyObjC文档如此糟糕?” and "PyObjc vs RubyCocoa for Mac development: Which is more mature?" “PyObjc vs RubyCocoa for Mac开发:哪个更成熟?” before you completely convince yourself that "just PyObjC" will make things much easier. 在你完全说服自己“只是PyObjC”会让事情变得更容易之前。 I refuse to disparage PyObjC because it is quite powerful and incredibly useful, but realize that nothing is a silver bullet, and no language or technology is best for all problems. 我拒绝贬低PyObjC,因为它非常强大且非常有用,但我意识到没有什么是灵丹妙药,没有任何语言或技术可以解决所有问题。

The Objective-C language is simple and pretty straightforward. Objective-C语言简单而且非常简单。 The Cocoa frameworks generally dominate the learning curve for new Cocoa programmers. Cocoa框架通常主导新Cocoa程序员的学习曲线。 Plus, you have StackOverflow and lots of other resources to help answer your questions. 此外,您还拥有StackOverflow和许多其他资源来帮助回答您的问题。 (Judging by the activity of the "pyobjc" tag , you also stand a better chance of getting good Objective-C help on SO.) (根据“pyobjc”标签的活动来判断,你也有更好的机会在SO上获得良好的Objective-C帮助 。)

And as one of the Checkout developers I'll weigh in too (hi Quinn!). 作为Checkout开发人员之一,我也会权衡一下(嗨Quinn!)。 From what we've seen PyObjC runs fairly well on Snow Leopard. 从我们看到的PyObjC在Snow Leopard上运行得相当好。 We've built one of the latest SVN revisions 2.2b with some customizations on Leopard and just moved over the site-packages folder. 我们已经在Leopard上构建了一个最新的SVN版本2.2b,其中包含一些自定义项,只是移动了site-packages文件夹。

Theoretically you should be able to use the built in Python/PyObjC (just do import objc, Foundation, AppKit) but as we ship/work with custom versions of both Python and PyObjC I'm not sure what the status exactly is. 从理论上讲,你应该能够使用内置的Python / PyObjC(只需要导入objc,Foundation,AppKit)但是当我们发布/使用Python和PyObjC的自定义版本时,我不确定状态究竟是什么。 The mailing list doesn't mention a lot of people having issues (just a few) so that could be a good sign. 邮件列表没有提到很多人有问题(只有少数),所以这可能是一个好兆头。

Good luck with the project, and if you have specific POS questions shoot me an email ;-) 祝这个项目好运,如果你有特定的POS问题请给我发电子邮件;-)

I hardly use PyObjC myself, but I believe you need to run the Xcode installer on the Snow Leopard DVD in order to use PyObjC. 我自己几乎不使用PyObjC,但我相信你需要在Snow Leopard DVD上运行Xcode安装程序才能使用PyObjC。

Also, as Quinn said, you will need to understand at least some Objective-C in order to use a Cocoa bridge like PyObjC without tearing your hair out. 此外,正如Quinn所说,你需要至少了解一些Objective-C才能使用像PyObjC这样的Cocoa桥而不会撕掉你的头发。 It just doesn't insulate you that completely. 它只是没有完全隔离你。

I'm going to agree with Quinn here. 我在这里同意奎因的意见。 Even if you're already proficient in Python, learning how to interface Python and Cocoa is not going to be any easier than learning Cocoa with Objective-C. 即使你已经精通Python,学习如何与Python和Cocoa接口也不会比使用Objective-C学习Cocoa更容易。

Objective-C is a simple, clean language that is quite easy to grok. Objective-C是一种简单,干净的语言,很容易理解。 Building the GUI and hooking it up to the back-end will be harder than learning the Objective-C to write the back-end, and building the GUI and hooking it up isn't that hard. 构建GUI并将其连接到后端将比学习Objective-C编写后端更难,并且构建GUI并将其挂起并不难。

Follow the Cocoa app tutorial (you should be able to get through it in a day, or maybe a weekend if you go slow) and you'll be well on your way. 按照Cocoa应用程序教程 (您应该能够在一天内完成它,或者如果你走得很慢,可能是一个周末)并且你将会很顺利。

I'm a long time python developer who's been doing iPhone apps for awhile now (and only using my python knowledge to package up build files for the apps in run scripts), then who started making some PyObjC apps. 我是一个很长时间的python开发人员,他现在已经做了一段时间的iPhone应用程序(并且只使用我的python知识来为运行脚本中的应用程序打包构建文件),然后谁开始制作一些PyObjC应用程序。

I'd have to say, PyObjC is pretty much STILL having to learn objective C (which I already know via iPhone dev), however you get several pretty cool benefits if you use it instead 我不得不说,PyObjC几乎还不得不学习目标C(我已经通过iPhone开发人员知道了),但如果你使用它,你可以获得几个很酷的好处

  • Easy use of python libraries you know (faster for you) 轻松使用您知道的python库(更快)
  • Option to drop it and go to wxPython if styimied by Cocoa 选择删除它,如果由Cocoa设置,则转到wxPython
  • Somewhat faster development time (you're writing less code, and the translation between the two languages is pretty darn easy to get used to). 更快的开发时间(你编写的代码更少,两种语言之间的翻译很容易习惯)。

Additionally, interface builder is a little tricky to get used to comparatively speaking, but if you're a python dev, it's not like you're exactly used to a functional gui builder anyhow :oP 另外,界面构建器相对来说比较习惯有点棘手,但是如果你是一个python开发者,那么你就不会完全习惯于功能性的gui构建器:oP

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM