Pythonのプログラムを配布可能なアプリケーションを作成する方法について扱います。
コンピュータが理解できるのは突き詰めると、0と1だけです。そのため、プログラムを実行するには「プログラミング言語で書かれたテキストのプログラム」を0と1に変換する必要があります。そのやり方には2つあり、ひとつはコンパイラを使うもので、もうひとつはインタプリタを使うものです。
以下に両者の違いについて記載します。
ObjC.import('Cocoa') | |
ObjC.import('WebKit') | |
MyWindow = WebViewWindow('http://www.youtube.com/') | |
MyWindow.makeKeyAndOrderFront(null) | |
//===================================================================== | |
function Window(x, y, width, height) { | |
let r = $.NSMakeRect(x, y, width, height) |
function MenuItem(title, action, target) { | |
if (!title && !action && !target) return $.NSMenuItem.separatorItem | |
let i = $.NSMenuItem.alloc.init | |
i.title = title | |
i.action = action | |
i.target = target | |
return i | |
} | |
function StatusItem() { |
import SwiftUI | |
import SafariServices | |
struct DemoView: View, Hostable { | |
@EnvironmentObject var hostedObject: HostingObject<DemoView> | |
var address: String = "https://example.com" | |
func present() { // UIKit code | |
let safari = SFSafariViewController(url: URL(string: address)!) |
ObjC.import('Cocoa') | |
App = Application.currentApplication() | |
App.includeStandardAdditions = true | |
const RESOURCE = $.NSBundle.mainBundle.resourcePath.js | |
const HOST = 'localhost' | |
const PORT = 8080 | |
const ADDR = `${HOST}:${PORT}` | |
const DIR = `${RESOURCE}/public_html/` |
#!/usr/bin/osascript -l JavaScript | |
ObjC.import('Cocoa') | |
app = Application.currentApplication() | |
app.includeStandardAdditions = true | |
ObjC.registerSubclass({ | |
name: 'MenuAction', | |
methods: { |
import SwiftUI | |
struct ContentView: View { | |
@ObservedObject var browser = { () -> DocumentBrowserObject in | |
let dbo = DocumentBrowserObject ( | |
forOpeningFilesWithContentTypes: [ | |
"public.png", | |
"public.jpeg" | |
] | |
) |
ObjC.import('Cocoa') | |
ObjC.import('WebKit') | |
App = Application.currentApplication() | |
App.includeStandardAdditions = true | |
MyAction = SimpleSubclass('Action', { | |
quit(sender) { | |
App.quit() | |
}, |