Ejemplo n.º 1
0
def _register_key_command(input, modifier_flags, function, title=None):
    if not UIApplication.sharedApplication().respondsToSelector_(
            sel('originalkeyCommands')):
        swizzle('UIApplication', 'keyCommands', _blackmamba_keyCommands)

    selector_name = _key_command_selector_name(input, modifier_flags)
    selector = sel(selector_name)
    obj = UIApplication.sharedApplication()

    info('Registering key command "{}" ({})'.format(
        _shortcut_name(input, modifier_flags), title
        or 'No discoverability title'))

    if not callable(function):
        error('Skipping, provided function is not callable')
        return False

    if obj.respondsToSelector_(selector):
        error('Skipping, method {} already registered'.format(selector_name))
        return False

    def key_command_action(_sel, _cmd, sender):
        function()

    IMPTYPE = CFUNCTYPE(None, c_void_p, c_void_p, c_void_p)
    imp = IMPTYPE(key_command_action)
    retain_global(imp)

    cls = c.object_getClass(obj.ptr)
    type_encoding = c_char_p('v@:@'.encode('utf-8'))
    did_add = c.class_addMethod(cls, selector, imp, type_encoding)
    if not did_add:
        error('Failed to add key command method {}'.format(selector_name))
        return False

    if isinstance(modifier_flags, UIKeyModifier):
        modifier_flags = modifier_flags.value

    if title:
        kc = UIKeyCommand.keyCommandWithInput_modifierFlags_action_discoverabilityTitle_(
            ns(input), modifier_flags, selector, ns(title))
    else:
        kc = UIKeyCommand.keyCommandWithInput_modifierFlags_action_(
            ns(input), modifier_flags, selector)

    _key_commands.append(kc)
    return True
Ejemplo n.º 2
0
def register_key_event_handler(key_code, fn, *, modifier_flags=0):
    if not UIApplication.sharedApplication().respondsToSelector_(
            sel('originalhandleKeyUIEvent:')):
        swizzle('UIApplication', 'handleKeyUIEvent:',
                _blackmamba_handleKeyUIEvent)

    handler = KeyEventHandler(key_code, modifier_flags, fn)
    _key_event_handlers.append(handler)
    return handler
Ejemplo n.º 3
0
def main():
	input = ' '.join(sys.argv[1:]) or dialogs.text_dialog()
	if input:
		referenceViewController = UIReferenceLibraryViewController.alloc().initWithTerm_(input)
		
		rootVC = UIApplication.sharedApplication().keyWindow().rootViewController()
		tabVC = rootVC.detailViewController()
		
		referenceViewController.setTitle_("Definition: '{}'".format(input))
		referenceViewController.setPreferredContentSize_(CGSize(540, 540))
		referenceViewController.setModalPresentationStyle_(2)
		
		#tabVC.addTabWithViewController_(referenceViewController)
		tabVC.presentViewController_animated_completion_(referenceViewController, True, None)
def main():
	input = ' '.join(sys.argv[1:]) or dialogs.text_dialog()
	if input:
		referenceViewController = UIReferenceLibraryViewController.alloc().initWithTerm_(input)
		
		rootVC = UIApplication.sharedApplication().keyWindow().rootViewController()
		tabVC = rootVC.detailViewController()
		
		referenceViewController.setTitle_("Definition: '{}'".format(input))
		referenceViewController.setPreferredContentSize_(CGSize(540, 540))
		referenceViewController.setModalPresentationStyle_(2)
		
		#tabVC.addTabWithViewController_(referenceViewController)
		tabVC.presentViewController_animated_completion_(referenceViewController, True, None)
Ejemplo n.º 5
0
def _register_key_event_handler(key_code,
                                func,
                                *,
                                modifier=UIKeyModifier.NONE):
    if not UIApplication.sharedApplication().respondsToSelector_(
            sel('originalhandleKeyUIEvent:')):
        swizzle('UIApplication', 'handleKeyUIEvent:',
                _blackmamba_handleKeyUIEvent)

    @system.catch_exceptions
    def invoke_func():
        func()

    handler = KeyEventHandler(key_code, modifier, invoke_func)
    _key_event_handlers.append(handler)
    return handler
Ejemplo n.º 6
0
def search_action(sender):
    #get swichs state
    global legbr, legpt, tor, title
    #, legendasdivxUrl, legendasdivxUrlLang, title, torrentUrl

    legpt = view['switchPt'].value
    legbr = view['switchBr'].value
    tor = view['switchTor'].value
    torSearchZ2 = view['switchTorZ2'].value
    torSearchPBay = view['switchTorzPBay'].value
    torSearchZooqle = view['switchTorZooqle'].value
    torSearchRarBg = view['switchTorRarBg'].value
    imdbSearch = view['switchImdb'].value
    dueSearch = view['switchDue'].value
    aftercredits = view['switchAfterCredits'].value
    if legbr and legpt:
        url = geturl(title, Lingua.ALL, Site.Legendas)
    elif legbr or legpt:
        if legbr:
            url = geturl(title, Lingua.BR, Site.Legendas)
        else:
            url = geturl(title, Lingua.PT, Site.Legendas)

    if tor:
        url = geturl(title, None, Site.Torrent)
    elif torSearchPBay:
        url = geturl(title, None, Site.TorSearchPBay)
    elif torSearchZ2:
        url = geturl(title, None, Site.TorSearchZ2)
    elif torSearchZooqle:
        url = geturl(title, None, Site.TorSearchZooqle)
    elif torSearchRarBg:
        url = geturl(title, None, Site.TorSearchRarBg)
    elif imdbSearch:
        url = geturl(title, None, Site.ImdbSearch)
    elif dueSearch:
        url = geturl(title, None, Site.DueRemember)
    elif aftercredits:
        url = geturl(title, None, Site.AfterCredits)

    log('url: '.format(url))
    app = UIApplication.sharedApplication()
    app.openURL_(nsurl(url))
Ejemplo n.º 7
0
	def __init__(self,width=55,*args,**kwargs):
		'''initialize the sidebar
		arguments:
		width (default = 55)
		'''
		app=UIApplication.sharedApplication()
		self.containerView=app.keyWindow().rootViewController().\
		detailContainerView()
		# we will add ourself as a subview of the container view, on the right edge, and also resize the other subviews to fit.
		self.background_color='white'
		self.alpha=0.5
		self.width=width
		self.y=20
		self.height=self.containerView.frame().size.height
		self.siblings=self.containerView.subviews()
		close=ui.Button(image=ui.Image('iob:close_round_24'))
		close.frame=[5,5,24,24]
		close.action=self._close
		self.add_subview(close)
		self.flex='LH'
		ObjCInstance(self).tag=hash('SideBar')
Ejemplo n.º 8
0
def main():
    input_dict = None
    if len(sys.argv) >= 2 and sys.argv[1] == 'quick':
        if appex.is_running_extension() and re.search('http*:\/\/[^\s]+', appex.get_attachments()[0]) is None:
            input_dict = appex.get_attachments()[0]
        else:
            clip = re.search('^(?!http)+', clipboard.get())
            if clip != None:
                input_dict = clipboard.get()
            
    input = input_dict or dialogs.text_dialog()
    if input:
        referenceViewController = UIReferenceLibraryViewController.alloc().initWithTerm_(input)

        rootVC = UIApplication.sharedApplication().keyWindow().rootViewController()
        tabVC = rootVC.detailViewController()

        referenceViewController.setTitle_("Definition: '{}'".format(input))
        referenceViewController.setPreferredContentSize_(CGSize(540, 540))
        referenceViewController.setModalPresentationStyle_(2)

        #tabVC.addTabWithViewController_(referenceViewController)
        tabVC.presentViewController_animated_completion_(referenceViewController, True, None)
Ejemplo n.º 9
0
    def present(self, title, content, frame=None, tag=None):
        overlay = OverlayView(title, content, self, tag)
        if frame:
            overlay.width = max(_OVERLAY_MIN_WIDTH, frame[2])
            overlay.height = max(_OVERLAY_MIN_HEIGHT, frame[3])
            overlay.x = frame[0]
            overlay.y = frame[1]
        else:
            overlay.width = _OVERLAY_MIN_WIDTH
            overlay.height = _OVERLAY_MIN_HEIGHT
            overlay.x = 50
            overlay.y = 110
        self.tag = tag

        for o in self._overlays:
            if o.is_active():
                o.become_inactive()

        self._overlays.append(overlay)

        window = UIApplication.sharedApplication().keyWindow()
        window.addSubview_(overlay)

        return overlay
Ejemplo n.º 10
0
__doc__ = '''A lib for working with the objc functions of the console view'''
from objc_util import ObjCClass, UIApplication, ns
from objc_tools.objc_json import objc_to_py

console = UIApplication.sharedApplication().\
                        keyWindow().rootViewController().\
                        accessoryViewController().\
                        consoleViewController()


class history(object):
    def __init__(self, objc):
        self._objc = console.history
        self._objc_set = console.setHistory_
        self._current_item = console.historyCurrentItem

    @property
    def items(self):
        return objc_to_py(self._objc())

    @items.setter
    def items(self, items):
        self._objc_set(ns(items))

    @property
    def current_item(self):
        return objc_to_py(self._current_item())


class Console(object):
    def __init__(self, objc = UIApplication.sharedApplication().\
Ejemplo n.º 11
0
the entire history in one table, rather than one line at a time.
Also adds the ability to save /load / and search history sessions.

Todo... copy multiple lines, to be able to copy a block of history to editor.

Warning: place in site-packages to avoid problems
'''
from objc_util import ObjCClass,ObjCInstance,UIApplication,NSRange,on_main_thread
import dialogs,ui,editor,os,json
HISTORY_FILE=os.path.join(os.path.dirname(__file__),'_history.json')
if not os.path.exists(HISTORY_FILE):
	with open(HISTORY_FILE,'w') as f:
		json.dump([],f)

cvc=UIApplication.sharedApplication().\
						keyWindow().rootViewController().\
						accessoryViewController().\
						consoleViewController()

def select_history(data):
	''' callback for longtap of history button.
	enumerate the console view controller's history, and present a list dialog to select.
	After the user selects a history item, write it to the console input
	'''
	if data.state==1:
		history = [str(h)[:-1] for h in cvc.history() or []]
	
		textField = cvc.promptEditorView().subviews()[0]
		
		txt = list_dialog('Select History',history)
		if txt:
			textField.text = txt
Ejemplo n.º 12
0
# https://forum.omz-software.com/topic/3306/disable-on-screen-printing-in-scene-

import scene, ui
from objc_util import UIApplication

def close_view():
	v.close()
	
class MyScene(scene.Scene):
	def setup(self):
		self.test_label = scene.LabelNode('Test hide title bar',
		position=self.size/2.0, parent=self)
		self.close_label = scene.LabelNode('Close view',
		position=(self.size[0]/2, self.size[1]/2-100),
		parent=self)
		
	def touch_began(self, touch):
		if touch.location in self.close_label.frame:
			close_view()
			
w, h = ui.get_window_size()
frame = (0, 0, w, h)
v = ui.View(frame=frame)
scene_view = scene.SceneView(frame=frame)
scene_view.flex= 'WH'
scene_view.scene = MyScene()
v.add_subview(scene_view)
v.present('fullscreen', hide_title_bar=True)
UIApplication.sharedApplication().statusBar().hidden = True

from objc_util import ObjCClass, UIApplication, CGSize, on_main_thread, ObjCInstance
import sys
import ui

UIReferenceLibraryViewController = ObjCClass(
    'UIReferenceLibraryViewController')

back = ui.View()
back.background_color = 'gray'
back.name = 'Dictionary'
back.present('full_screen', hide_title_bar=False)

input = 'word'
referenceViewController = UIReferenceLibraryViewController.alloc(
).initWithTerm_(input)

ObjCInstance(back).addSubview_(referenceViewController)

# ObjCInstance(back).addSubview_(referenceViewController.view())

rootVC = UIApplication.sharedApplication().keyWindow().rootViewController()
tabVC = rootVC.detailViewController()

referenceViewController.setTitle_('Definition: {0}{1}{0}'.format('\'', input))
referenceViewController.setPreferredContentSize_(CGSize(540, 540))
referenceViewController.setModalPresentationStyle_(2)
#tabVC.addTabWithViewController_(referenceViewController)
tabVC.presentViewController_animated_completion_(referenceViewController, True,
                                                 None)
Ejemplo n.º 14
0
        return str(self._objc.lightingModelName())

    @lightingModel.setter
    def lightingModel(self, value):
        if type(value) == str:
            self._objc.setLightingModelName_(value)
        else:
            print('not a valid type')
        
def load_scene(file):
    url = ns(file)
    s = SCNScene.sceneWithURL_options_(url, ns({}))
    return Scene(s)
                
if __name__ == '__main__':
    for i in UIApplication.sharedApplication().keyWindow().rootViewController().view().gestureRecognizers():
            if b'UIPanGestureRecognizer' == i._get_objc_classname():
                slide = i
    slide.setEnabled_(False)
    SCNLookAtConstraint = ObjCClass('SCNLookAtConstraint')
    
    v = SceneTab()
    v.allowsCameraControl=True
    SCNBox = ObjCClass('SCNBox')
    SCNFloor = ObjCClass('SCNFloor')
    SCNSphere = ObjCClass('SCNSphere')
    v.debugOptions = DebugOptions.showLightInfluences| DebugOptions.showLightExtents
    v.showsStatistics=True
    v.scene = Scene()
    floor = SCNFloor.floor()
    cnode = Node()
Ejemplo n.º 15
0
# https://gist.github.com/jsbain/045ec1b9a953e52778ca206bcc7c2898

# https://forum.omz-software.com/topic/3199/command-history

# here are some tools that can be used (e.g. from wrench menu) to save /load a command history session

from objc_util import UIApplication
with open('history.py', 'r') as f:
    UIApplication.sharedApplication().keyWindow().rootViewController(
    ).accessoryViewController().consoleViewController().history = f.readlines(
    )
Ejemplo n.º 16
0
def mail_compose(
        subject: str = "",
        recipients: Optional[List[str]] = None,
        body: str = "",
        filename: str = '',
        mime_type: str = '',
        dismiss_callback: Optional[Callable[[], None]] = None) -> None:
    """ Modal mail compose view.

    Display a modal mail compose view, with pre-populated contents, on top of
    the currently displayed view.

    The function returns immediately. Use argument `dismiss_callback` if your
    application needs to be notified when the compose view is dismissed.


    Arguments
    ---------

    subject: `str`, defaults to ``""``
        Mail subject.

    recipients: `Optional[List[str]]`, defaults to ``None``
        List of mail addresses for the recipients of the email.

    body: `str`, defaults to ``""``
        Mail body.

    filename: `str`, defaults to ``''``
        If non-empty, name of a file to be attached to the email.

    mime_type: `str`, defaults to ``''``
        If `filename` is not empty, indicates the mime type of its contents,
        for instance ``'image/gif'``

    dismiss_callback: `Optional[Callable[[], None]]`, defaults to ``None``
        When set to a callable, it is called (with no arguments) when the mail
        composition view is dismissed. """
    def mailComposeController_didFinishWithResult_error_(
            self, sel, controller, result, error):
        nonlocal dismiss_callback
        mail_vc = ObjCInstance(controller)
        mail_vc.setMailComposeDelegate_(None)
        mail_vc.dismissViewControllerAnimated_completion_(True, None)
        ObjCInstance(self).release()
        if dismiss_callback:
            dismiss_callback()

    try:
        MailDelegate = ObjCClass('MailDelegate')
    except ValueError:
        MailDelegate = create_objc_class(
            'MailDelegate',
            superclass=NSObject,
            methods=[mailComposeController_didFinishWithResult_error_],
            protocols=['MFMailComposeViewControllerDelegate'])
        objc_util.retain.append(
            mailComposeController_didFinishWithResult_error_)
    MFMailComposeViewController = ObjCClass('MFMailComposeViewController')
    mail_vc = MFMailComposeViewController.alloc().init().autorelease()
    delegate = MailDelegate.alloc().init().autorelease()
    objc_util.retain.append(delegate)
    mail_vc.setMailComposeDelegate_(delegate)
    # Find a view controller which is not already presenting, see
    # https://forum.omz-software.com/topic/2060/presenting-viewcontroller/2
    root_vc = UIApplication.sharedApplication().keyWindow().rootViewController(
    )
    while root_vc.presentedViewController():
        root_vc = root_vc.presentedViewController()
    mail_vc.setSubject_(subject)
    if recipients is not None:
        mail_vc.setToRecipients_(recipients)
    mail_vc.setMessageBody_isHTML_(body, body.startswith('<html>'))
    if filename and os.path.exists(filename):
        mail_vc.addAttachmentData_mimeType_fileName_(
            NSData.dataWithContentsOfFile_(os.path.abspath(filename)),
            mime_type, filename)
    root_vc.presentViewController_animated_completion_(mail_vc, True, None)
Ejemplo n.º 17
0
# https://gist.github.com/jsbain/045ec1b9a953e52778ca206bcc7c2898

# https://forum.omz-software.com/topic/3199/command-history

# here are some tools that can be used (e.g. from wrench menu) to save /load a command history session

from objc_util import UIApplication
with open('history.py','a') as f:	
		f.write(	'\n'.join([str(h) for h in UIApplication.sharedApplication().keyWindow().rootViewController().accessoryViewController().consoleViewController().history()])+'\n')
Ejemplo n.º 18
0
def recognizer_should_simultaneously_recognize(gr,ogr):
	g=ObjCInstance(gr)
	o=ObjCInstance(ogr)
	ispinch=g._get_objc_classname()==b'UIPinchGestureRecognizer'
	ispan=g._get_objc_classname()==b'UIPanGestureRecognizer'
	istap=g._get_objc_classname()==b'UITapGestureRecognizer'
	if (ispinch or ispan or istap) and (g.view()==o.view()) :
		return True
	else:
		return False
def gestureRecognizer_shouldRequireFailureOfGestureRecognizer_(
	_self,_sel,gr,othergr):
	console.hud_alert('aaa')
	return True
	
cls=ObjCClass(UIApplication.sharedApplication()._rootViewControllers()[0]._get_objc_classname())
swizzle.swizzle(cls,
								'gestureRecognizer:shouldRequireFailureOfGestureRecognizer:',gestureRecognizer_shouldRequireFailureOfGestureRecognizer_,'c@:@@')
								
def math_eval(expr):
	import math
	import re
	whitelist = '|'.join(
	# oprators, digits
	['-', '\+', '/', '\\', '\*', '\^', '\*\*', '\(', '\)', '\d+' ])

	if re.match(whitelist,expr):
		return eval(expr)
	else:
		return 1.0
																									
Ejemplo n.º 19
0
 def __init__(self, objc = UIApplication.sharedApplication().\
                     keyWindow().rootViewController().\
                     accessoryViewController().\
                     consoleViewController()):
     self.objc = objc
Ejemplo n.º 20
0
    @lightingModel.setter
    def lightingModel(self, value):
        if type(value) == str:
            self._objc.setLightingModelName_(value)
        else:
            print('not a valid type')


def load_scene(file):
    url = ns(file)
    s = SCNScene.sceneWithURL_options_(url, ns({}))
    return Scene(s)


if __name__ == '__main__':
    for i in UIApplication.sharedApplication().keyWindow().rootViewController(
    ).view().gestureRecognizers():
        if b'UIPanGestureRecognizer' == i._get_objc_classname():
            slide = i
    slide.setEnabled_(False)
    SCNLookAtConstraint = ObjCClass('SCNLookAtConstraint')

    v = SceneTab()
    v.allowsCameraControl = True
    SCNBox = ObjCClass('SCNBox')
    SCNFloor = ObjCClass('SCNFloor')
    SCNSphere = ObjCClass('SCNSphere')
    v.debugOptions = DebugOptions.showLightInfluences | DebugOptions.showLightExtents
    v.showsStatistics = True
    v.scene = Scene()
    floor = SCNFloor.floor()
    cnode = Node()
Ejemplo n.º 21
0
from objc_util import ObjCInstance, ObjCInstanceMethod, create_objc_class, nsurl, on_main_thread, sel, UIApplication, ObjCClass

# mostly from https://github.com/controversial/Pythonista-Tweaks/blob/master/pythonista/editor.py
UIViewController = ObjCClass('UIViewController')

app = UIApplication.sharedApplication()
rootVC = app.keyWindow().rootViewController()
tabVC = rootVC.detailViewController()

class TabView(object):
    @on_main_thread
    def __init__(self):
        self.name = ""
        self.right_button_items = []
        self.newVC = self.customVC()
        self.makeSelf()

    @on_main_thread
    def makeSelf(self):
        pass

    @on_main_thread
    def customVC(self):
        return None

    @on_main_thread
    def present(self):
        pass


class Tab(TabView):
Ejemplo n.º 22
0
def open_url(url):
  from objc_util import UIApplication, nsurl
  app=UIApplication.sharedApplication()
  app._openURL_(nsurl(url))
Ejemplo n.º 23
0
# coding: utf-8

# @omz twitter

import urllib
import appex
from objc_util import UIApplication, nsurl
import time

page_url = appex.get_url()
if page_url:
    overcast_url = 'overcast://x-callback-url/add?url=%s' % (urllib.quote(
        page_url, ''), )
    app = UIApplication.sharedApplication()
    app.openURL_(nsurl(overcast_url))
    time.sleep(0.5)
    appex.finish()
Ejemplo n.º 24
0
def showShareSheet(*params):
    vc = UIActivityViewController.alloc().initWithActivityItems_applicationActivities_(ns(list(params)), None)
    rootVC = UIApplication.sharedApplication().keyWindow().rootViewController()
    while rootVC.presentedViewController():
        rootVC = rootVC.presentedViewController()
    rootVC.presentViewController_animated_completion_(vc, True, None)
Ejemplo n.º 25
0
def togglestatusbar():
	objc_util.hideStatusBar=not objc_util.hideStatusBar
	UIApplication.sharedApplication().\
	_rootViewControllers()[0].setNeedsStatusBarAppearanceUpdate()
Ejemplo n.º 26
0
 def __init__(self, objc = UIApplication.sharedApplication().\
                     keyWindow().rootViewController().\
                     accessoryViewController().\
                     consoleViewController()):
     self.objc = objc
Ejemplo n.º 27
0
def root_view_controller():
    root = UIApplication.sharedApplication().keyWindow().rootViewController()
    if root.isKindOfClass_(PASlidingContainerViewController):
        return root
    return None
Ejemplo n.º 28
0
# https://forum.omz-software.com/topic/3902/sorry-if-this-is-obvious-but-is-there-an-easy-way-to-export-everything-in-the-shell-console-to-a-text-file/2

from objc_util import UIApplication
from time import ctime
# save history
with open('history.py', 'a') as f:
    f.write(ctime() + '\n')
    f.write('\n'.join([
        str(h) for
        h in UIApplication.sharedApplication().keyWindow().rootViewController(
        ).accessoryViewController().consoleViewController().history()
    ]) + '\n')
#save console output
with open('console_history.txt', 'w') as f:
    f.write(ctime() + '\n')
    f.write(
        str(UIApplication.sharedApplication().keyWindow(
        ).rootViewController().accessoryViewController().consoleViewController(
        ).consoleOutputTextView().text()))
Ejemplo n.º 29
0
 def open_in(self, app):
     ''' Display self's location in the app with the given moniker '''
     from objc_util import UIApplication, nsurl
     app_ = UIApplication.sharedApplication()
     xurl = nsurl(self.as_xurl(app))
     app_.openURL_(xurl)
Ejemplo n.º 30
0
def recognizer_should_simultaneously_recognize(gr,ogr):
	g=ObjCInstance(gr)
	o=ObjCInstance(ogr)
	ispinch=g._get_objc_classname()==b'UIPinchGestureRecognizer'
	ispan=g._get_objc_classname()==b'UIPanGestureRecognizer'
	istap=g._get_objc_classname()==b'UITapGestureRecognizer'
	if (ispinch or ispan or istap) and (g.view()==o.view()) :
		return True
	else:
		return False
def gestureRecognizer_shouldRequireFailureOfGestureRecognizer_(
	_self,_sel,gr,othergr):
	console.hud_alert('aaa')
	return True
	
cls=ObjCClass(UIApplication.sharedApplication()._rootViewControllers()[0]._get_objc_classname())
swizzle.swizzle(cls,
								'gestureRecognizer:shouldRequireFailureOfGestureRecognizer:',gestureRecognizer_shouldRequireFailureOfGestureRecognizer_,'c@:@@')
								
def math_eval(expr):
	import math
	import re
	whitelist = '|'.join(
	# oprators, digits
	['-', '\+', '/', '\\', '\*', '\^', '\*\*', '\(', '\)', '\d+' ])

	if re.match(whitelist,expr):
		return eval(expr)
	else:
		return 1.0
																									
Ejemplo n.º 31
0
# https://forum.omz-software.com/topic/3368/objc-setstatusbarhidden-possible

from objc_hacks import swizzle
from objc_util import ObjCClass, UIApplication
import objc_util # for hideStatusBar storage

try:
	objc_util.hideStatusBar
except AttributeError:
	objc_util.hideStatusBar=False
	
def togglestatusbar():
	objc_util.hideStatusBar=not objc_util.hideStatusBar
	UIApplication.sharedApplication().\
	_rootViewControllers()[0].setNeedsStatusBarAppearanceUpdate()
	
def prefersStatusBarHidden(obj,cmd):
	return objc_util.hideStatusBar
swizzle.swizzle(
    ObjCClass('PASlidingContainerViewController'),
    'prefersStatusBarHidden',
    prefersStatusBarHidden)
UIApplication.sharedApplication().\
            _rootViewControllers()[0].\
            setNeedsStatusBarAppearanceUpdate()

togglestatusbar()