Beispiel #1
0
 def toggle_(self, notification):
     # toggle between Pause and Play
     if self.player.is_playing():
         # note, .pause() pauses and un-pauses the video,
         # .stop() stops the video and blanks the window
         self.player.pause()
         t = 'Play'
     else:
         self.player.play()
         t = 'Pause'
     self.NSitem.setTitle_(NSStr(t))
Beispiel #2
0
def open_panel():
    panel = NSOpenPanel.openPanel()

    panel.setPrompt_(NSStr('Set prompt...'))
#   panel.setResolvesAliases_(True)
    panel.setCanChooseDirectories_(True)
    panel.setCanChooseFiles_(True)
#   panel.allowedFileTypes(?)

    if panel.runModal():
        return nsString2str(panel.URL().path())
    return None
Beispiel #3
0
 def init(self, app, player, title, video):
     self = ObjCInstance(send_super(self, 'init'))
     #       self = ObjCInstance(send_message('NSObject', 'alloc'))
     self.app = app
     self.NSitem = None  # Play/Pause toggle
     self.player = player
     self.ratio = 2
     self.title = title  # app name, top-level menu title
     self.video = video  # window banner
     self.window = None
     nsBundleRename(NSStr(title))  # top-level menu title
     return self
Beispiel #4
0
def create_window():
    window = send_message('NSWindow', 'alloc')
    window = send_message(
        window,
        'initWithContentRect:styleMask:backing:defer:',
        NSMakeRect(10, 500, 600, 300),  # frame
        NSWindowStyleMaskUsual,
        NSBackingStoreBuffered,
        0)  # or False
    send_message(window, 'setTitle:',
                 NSStr("Window - Select Quit from Dock menu"))
    send_message(window, 'makeKeyAndOrderFront:', None)
    return window
Beispiel #5
0
def run_window():

    app = NSApplication.sharedApplication()
    #   pool = NSAutoreleasePool.alloc().init()  # PYCHOK expected

    window = NSWindow.alloc()
    window.initWithContentRect_styleMask_backing_defer_(
        NSRect4_t(100, 100, 300, 300), NSWindowStyleMaskUsual,
        NSBackingStoreBuffered, False)
    window.setTitle_(NSStr("Class Window"))
    window.makeKeyAndOrderFront_(None)

    app.run()
Beispiel #6
0
def create_menu(name='', app=None):
    menubar = NSMenu.alloc().init()
    appMenuItem = NSMenuItem.alloc().init()
    menubar.addItem_(appMenuItem)
    appMenu = NSMenu.alloc().init()

    fullItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
        NSStr('Full Screen'), get_selector('enterFullScreenMode:'), NSStr('f'))
    fullItem.setKeyEquivalentModifierMask_(NSControlKeyMask)  # Ctrl-Cmd-F
    appMenu.addItem_(fullItem)

    appMenu.addItem_(NSMenuItem.separatorItem())

    hideItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
        NSStr('Hide ' + name), get_selector('hide:'), NSStr('h'))
    appMenu.addItem_(hideItem)

    otherItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
        NSStr('Hide Others'), get_selector('hideOtherApplications:'),
        NSStr('h'))
    otherItem.setKeyEquivalentModifierMask_(NSAlternateKeyMask)  # Alt-Cmd-H
    appMenu.addItem_(otherItem)

    showItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
        NSStr('Show All'), get_selector('unhideAllApplications:'), NSStr(''))
    appMenu.addItem_(showItem)

    appMenu.addItem_(NSMenuItem.separatorItem())

    quitItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
        NSStr('Quit ' + name), get_selector('terminate:'), NSStr('q'))
    appMenu.addItem_(quitItem)

    appMenuItem.setSubmenu_(appMenu)

    if app:
        app.setMainMenu_(menubar)
    return menubar
Beispiel #7
0
def main(timeout=None):

    app = NSApplication.sharedApplication()

    frame = NSMakeRect(10, 10, 500, 400)
    window = NSWindow.alloc().initWithContentRect_styleMask_backing_defer_(
        frame, NSWindowStyleMaskUsual, NSBackingStoreBuffered, False)
    window.setTitle_(NSStr('Drawing - Close window to Quit'))

    view = _View.alloc().initWithFrame_(frame, 10)
    window.setContentView_(view)

    delegate = _Delegate.alloc().init(app)
    window.setDelegate_(delegate)

    window.display()
    window.orderFrontRegardless()

    # set up the timeout
    terminating(app, timeout)
    app.run()
Beispiel #8
0
 def writer(self, s):
     self.badge.setBadgeLabel_(NSStr(str(s)))