Skip to content

Instantly share code, notes, and snippets.

@jsbain
Created September 9, 2016 10:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsbain/84ab564cf1ae26ce4ad100b103502b17 to your computer and use it in GitHub Desktop.
Save jsbain/84ab564cf1ae26ce4ad100b103502b17 to your computer and use it in GitHub Desktop.
selectNextTab.py
from objc_util import *
@on_main_thread
def select(idx):
import editor
tvc=editor._get_editor_tab().parentViewController()
tbv=tvc.tabBarView()
tvs=tbv.tabViews()
if idx < len(tvs):
tvc.tabBarView().tabSelected_(tvs[idx])
tvc.switchToTabViewController_(tvc.tabViewControllers()[idx])
@on_main_thread
def nextTab():
import editor
tvc=editor._get_editor_tab().parentViewController()
tbv=tvc.tabBarView()
tvs=tbv.tabViews()
current=tbv.selectedTabIndex()
next=(current+1)%len(tvs)
tbv.tabSelected_(tvs[next])
tvc.switchToTabViewController_(tvc.tabViewControllers()[next])
@on_main_thread
def prevTab():
import editor
tvc=editor._get_editor_tab().parentViewController()
tbv=tvc.tabBarView()
tvs=tbv.tabViews()
current=tbv.selectedTabIndex()
next=(current-1)%len(tvs)
tbv.tabSelected_(tvs[next])
tvc.switchToTabViewController_(tvc.tabViewControllers()[next])
#select(0)
#nextTab()
#prevTab()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment