public
Created

  • Download Gist
MultipleViews.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
"""
En una ventana muestra 7 vistas seleccionadas desde una barra de herramientas
"""
 
from Foundation import *
from AppKit import *
import objc
 
class DashboardController (NSViewController):
def show(self):
self.window = NSWindow.alloc().init()
self.DashboardViewController = NSViewController.alloc().initWithNibName_bundle_("Dashboard", None)
self.dashboardView = self.DashboardViewController.view()
show = classmethod(show)
def resetSubviews(self):
for i in range(1, len(self.dashboardView.subviews())):
self.dashboardView.subviews().removeObjectAtIndex_(i)
 
@objc.IBAction
def audio_(self, sender):
self.resetSubviews()
self.AudioViewController = NSViewController.alloc().initWithNibName_bundle_("Audio", None)
self.audioView = self.AudioViewController.view()
self.dashboardView.addSubview_(self.audioView)
@objc.IBAction
def chat_(self, sender):
self.resetSubviews()
self.ChatViewController = NSViewController.alloc().initWithNibName_bundle_("Chat", None)
self.chatView = self.ChatViewController.view()
self.dashboardView.addSubview_(self.chatView)
@objc.IBAction
def link_(self, sender):
self.resetSubviews()
self.LinkViewController = NSViewController.alloc().initWithNibName_bundle_("Link", None)
self.linkView = self.LinkViewController.view()
self.dashboardView.addSubview_(self.linkView)
@objc.IBAction
def logout_(self, sender):
NSApp().terminate_(self)
@objc.IBAction
def photo_(self, sender):
self.resetSubviews()
self.PhotoViewController = NSViewController.alloc().initWithNibName_bundle_("Photo", None)
self.photoView = self.PhotoViewController.view()
self.dashboardView.addSubview_(self.photoView)
@objc.IBAction
def quote_(self, sender):
self.resetSubviews()
self.QuoteViewController = NSViewController.alloc().initWithNibName_bundle_("Quote", None)
self.quoteView = self.QuoteViewController.view()
self.dashboardView.addSubview_(self.quoteView)
@objc.IBAction
def text_(self, sender):
self.resetSubviews()
self.TextViewController = NSViewController.alloc().initWithNibName_bundle_("Text", None)
self.textView = self.TextViewController.view()
self.dashboardView.addSubview_(self.textView)
 
@objc.IBAction
def video_(self, sender):
self.resetSubviews()
self.VideoViewController = NSViewController.alloc().initWithNibName_bundle_("Video", None)
self.videoView = self.VideoViewController.view()
self.dashboardView.addSubview_(self.videoView)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.