예제 #1
0
def main():
	if not appex.is_widget():
		print('This script must be run in the Pythonista Today widget (in Notification Center). You can configure the widget script in the settings.')
		return
	console.clear()
	v = appex.get_widget_view()
	# If the shortcuts change, change the view name as well,
	# so it is reloaded.
	view_name = 'Launcher_' + str(shortcuts)
	# Check if the launcher view already exists, if not,
	# create it, and set it as the widget's view.
	if not v or v.name != view_name:
		h = math.ceil(len(shortcuts) / 3) * 44
		v = ui.View(frame=(0, 0, 300, h))
		# Create a button for each shortcut
		for i, s in enumerate(shortcuts):
			btn = ui.Button(title=s['title'])
			btn.image = ui.Image.named(s['icon'])
			btn.frame = ((i % 3) * 100, (i // 3) * 44, 100, 44)
			btn.flex = 'LRWH'
			btn.tint_color = 'white'
			# Just store the shortcut URL in the button's name attribute.
			# This makes it easy to retrieve it in the button_tapped action.
			btn.name = s['url']
			btn.action = button_tapped
			v.add_subview(btn)
		v.name = view_name
		appex.set_widget_view(v)
예제 #2
0
def main():
	v = appex.get_widget_view()
	global view
	view = ui.View(frame=(0, 0, 320, 64), name='StudyTimerWidget')
	
	sender = True
	viewHistory(sender)
	
	'''
	label = ui.Label(frame=(0, 0, 320-44, 64), flex='wh', font=('HelveticaNeue-Light', 64), alignment=ui.ALIGN_CENTER, text='')
	label.name = 'timerLabel'
	view.add_subview(label)
	
	global studyButton
	studyButton = ui.Button(name='studyButton', image=ui.Image('iow:ios7_heart_outline_256'), flex='hl', tint_color='#ff2765', action=button_tapped)
	studyButton.frame = (320-100, 0, 64, 64)
	view.add_subview(studyButton)
	

	reset_btn = ui.Button(name='viewHistory', image=ui.Image('iow:ios7_heart_32'), flex='h', tint_color='#ff2765', action=refreshHistory)
	reset_btn.frame = (320-40, 0, 64, 64)
	view.add_subview(reset_btn)
	'''
	
	appex.set_widget_view(view)
예제 #3
0
def main():
	# Optimization: Don't create a new view if the widget already shows the calculator.
	widget_name = __file__ + str(os.stat(__file__).st_mtime)
	widget_view = appex.get_widget_view()
	if widget_view is None or widget_view.name != widget_name:
		widget_view = CalcView()
		widget_view.name = widget_name
		appex.set_widget_view(widget_view)
예제 #4
0
def main():
    widget_name = __file__ + str(os.stat(__file__).st_mtime)
    v = appex.get_widget_view()
    # Optimization: Don't create a new view if the widget already shows the launcher.
    if v is None or v.name != widget_name:
        v = LauncherView(SHORTCUTS)
        v.name = widget_name
        appex.set_widget_view(v)
예제 #5
0
def main():
    widget_name = __file__ + str(os.stat(__file__).st_mtime)
    v = appex.get_widget_view()
    if v is None or v.name != widget_name:
        NOTICES = crawling_notice()
        v = LauncherView(NOTICES)
        v.name = widget_name
        appex.set_widget_view(v)
예제 #6
0
def main():
    widget_name = __file__ + str(os.stat(__file__).st_mtime)
    v = appex.get_widget_view()
    v = appex.get_widget_view()

    # Optimization: Don't create a new view if the widget already shows the launcher.
    if v is None or v.name != widget_name:
        from utils import py_utils
        from core.ui2.ui_widget import LauncherView

        # load global configs
        MAIN_CONFIG = py_utils.load_config()
        # getter index page buttons

        v = LauncherView(MAIN_CONFIG)
        v.name = widget_name
        appex.set_widget_view(v)
예제 #7
0
def main():
    # Get the current widget
    widget_name = __file__ + str(os.stat(__file__).st_mtime)
    v = appex.get_widget_view()
    # Only update the widget if the widget isn't displaying
    if v is None or v.name != widget_name:
        v = TimerView(COLS)
        v.name = widget_name
        appex.set_widget_view(v)
예제 #8
0
def main():
    widget_name = __file__ + str(os.stat(__file__).st_mtime)
    widget_view = appex.get_widget_view()
    if widget_view is None or widget_view.name != widget_name:
        widget_view = ClockView()
        widget_view.name = widget_name
        appex.set_widget_view(widget_view)
        while True:
            widget_view.reload()
            time.sleep(1)
예제 #9
0
def main():
	if appex.is_widget():
		console.clear()
		v = appex.get_widget_view()
		# Check if the counter view already exists, if not, create it,
		# and set it as the widget's view.
		if not v or v.name != 'TallyCounter':
			v = make_widget_view()
			appex.set_widget_view(v)
	else:
		v = make_widget_view()
		v.name = 'Widget Preview'
		v.background_color = '#333'
		v.present('sheet')
예제 #10
0
def main():
	if appex.is_widget():
		console.clear()
		v = appex.get_widget_view()
		# Check if the clipboard view already exists, if not, create it,
		# and set it as the widget's view.
		if not v or v.name != 'Clipboard':
			v = make_widget_view()
		appex.set_widget_view(v)
	else:
		v = make_widget_view()
		v.background_color = '#333'
		v.name = 'Widget Preview'
		v.present('sheet')
	v['text_label'].text = 'Clipboard: ' + (clipboard.get() or '(Empty)')
예제 #11
0
def main():
	if appex.is_widget():
		console.clear()
		label = appex.get_widget_view()
		# Check if the label already exists, if not, create it,
		# and set it as the widget's view.
		if not label or label.name != 'Dice':
			label = make_widget_view()
		appex.set_widget_view(label)
	else:
		label = make_widget_view()
		label.background_color = '#333'
		label.name = 'Widget Preview'
		label.present('sheet')
	# Roll two dice.
	a, b = randint(1, 6), randint(1, 6)
	# Update the label's text
	label.text = faces[a] + ' ' + faces[b]
예제 #12
0
def main():
	# Optimization: Don't create a new view if the widget already shows the tally counter.
	widget_name = __file__ + str(os.stat(__file__).st_mtime)
	v = appex.get_widget_view()
	if v is not None and v.name == widget_name:
		return
	v = ui.View(frame=(0, 0, 320, 64), name=widget_name)
	label = ui.Label(frame=(0, 0, 320-44, 64), flex='wh', font=('HelveticaNeue-Light', 64), alignment=ui.ALIGN_CENTER, text=str(counter))
	label.name = 'text_label'
	v.add_subview(label)
	minus_btn = ui.Button(name='-', image=ui.Image('iow:ios7_minus_outline_32'), flex='hl', tint_color='#666', action=button_tapped)
	minus_btn.frame = (320-128, 0, 64, 64)
	v.add_subview(minus_btn)
	plus_btn = ui.Button(name='+', image=ui.Image('iow:ios7_plus_outline_32'), flex='hl', tint_color='#666', action=button_tapped)
	plus_btn.frame = (320-64, 0, 64, 64)
	v.add_subview(plus_btn)
	reset_btn = ui.Button(name='reset', image=ui.Image('iow:ios7_skipbackward_outline_32'), flex='h', tint_color='#666', action=button_tapped)
	reset_btn.frame = (0, 0, 64, 64)
	v.add_subview(reset_btn)
	appex.set_widget_view(v)
예제 #13
0
def main():
    # Optimization: Don't create a new view if the widget already shows the tally dataset.
    widget_name = __file__ + str(os.stat(__file__).st_mtime)
    v = appex.get_widget_view()
    if v is not None and v.name == widget_name:
        return
    v = ui.View(frame=(0, 0, 320, 96), name=widget_name)
    label = ui.Label(frame=(0, 32, 320, 64),
                     flex='wh',
                     font=('HelveticaNeue-Light', 24),
                     alignment=ui.ALIGN_CENTER,
                     text='Median: ' + str(calc_median()),
                     line_break_mode=ui.LB_WORD_WRAP)
    label.name = 'text_label'
    v.add_subview(label)
    logout_btn = ui.Button(name='start',
                           image=ui.Image('iow:log_out_32'),
                           flex='hl',
                           tint_color='#666',
                           action=button_tapped)
    logout_btn.frame = (-32, 0, 32, 32)
    v.add_subview(logout_btn)
    home_btn = ui.Button(name='end',
                         image=ui.Image('iow:log_in_32'),
                         flex='hl',
                         tint_color='#666',
                         action=button_tapped)
    home_btn.frame = (320 - 64, 0, 32, 32)
    v.add_subview(home_btn)
    refresh_btn = ui.Button(name='refresh',
                            image=ui.Image('iow:ios7_refresh_outline_32'),
                            flex='hl',
                            tint_color='#666',
                            action=button_tapped)
    refresh_btn.frame = (320 - 112, 0, 32, 32)
    v.add_subview(refresh_btn)
    appex.set_widget_view(v)
예제 #14
0
def main():
    v = appex.get_widget_view()
    if v is not None and v.name == widget_name:
        return
    appex.set_widget_view(init_view())