def scrollview_did_scroll(self, sender):
        ui.cancel_delays()
        d = sender.content_offset[0] - 5.0
        sender.content_offset = (5, 5)
        sender.dx = d + sender.dx

        def hq():
            sender.ready = False
            dx = sender.dx
            sender.dx = 0
            xl = plt.xlim()
            xl = [x + dx for x in xl]
            plt.xlim(xl)
            b = io.BytesIO()
            plt.savefig(b, format='jpeg', dpi=160)
            sender.subviews[0].image = ui.Image.from_data(b.getvalue())
            sender.ready = True

        if sender.ready:
            sender.ready = False
            dx = sender.dx
            sender.dx = 0
            xl = plt.xlim()
            xl = [x + dx for x in xl]
            plt.xlim(xl)
            b = io.BytesIO()
            plt.savefig(b, format='jpeg', dpi=16)
            sender.subviews[0].image = ui.Image.from_data(b.getvalue())
            sender.ready = True
        ui.delay(hq, 0.2)
Beispiel #2
0
 def will_close(self):
     # This will be called when a presented view is about to be dismissed.
     # You might want to save data here.
     if self.t:
         t.stop()
     ui.cancel_delays()
     pass
Beispiel #3
0
 def will_close(self):
     # This will be called when a presented view is about to be dismissed.
     # You might want to save data here.
     if self.t:
         t.stop()
     ui.cancel_delays()
     pass
Beispiel #4
0
 def textfield_should_change(self, textfield, rng, replacement):
     ui.cancel_delays()
     self.text=self.text[0:rng[0]]+replacement+self.text[rng[1]:]
     def replace_with_star() :
         #textfield.text=textfield.text[0:rng[0]]+'*'*len(replacement)+textfield.text[rng[1]:]
         textfield.text=len(self.text)*'*'
     ui.delay(replace_with_star,0.25)
     return True
Beispiel #5
0
    def quit(self, close=True):
        self.server.stop()
        self.server.join(timeout=3)
        if self.server.is_alive():
            log.warning("Server thread not terminated after 3 seconds!")

        ui.cancel_delays()
        if close:
            self.close()
 def toggle_timer1(self, sender):
     if not self.timer1_running:
         self.timer1_running = True
         self.timer1_btn.title = 'Stop'
         self.timer1_start_time = dt.datetime.now()
         ui.delay(self.update_timer1, 0)
     else:
         self.timer1_running = False
         ui.cancel_delays()
         self.timer1_btn.title = 'Start'
Beispiel #7
0
    def textfield_should_change(self, textfield, rng, replacement):
        ui.cancel_delays()
        self.text = self.text[0:rng[0]] + replacement + self.text[rng[1]:]

        def replace_with_star():
            # textfield.text=textfield.text[0:rng[0]]+'*'*len(replacement)+textfield.text[rng[1]:]
            textfield.text = len(self.text) * "*"

        ui.delay(replace_with_star, 0.25)
        return True
Beispiel #8
0
 def __bRAA(self, sender):
     ui.cancel_delays()
     self.__iQ = 5
     self.__ipR = ImageP.open('ionicons-ios7-reload-32')
     self.__bRA.image = ui.Image.named('ionicons-load-d-32')
     self.__bF2.enabled = False 
     self.__bF3.enabled = False 
     self.__bR1A(object)
     self.__bR2A(object)
     self.__bR3A(object)
     ui.delay(self.__AutoRefresh,3)
Beispiel #9
0
 def __bRAA(self, sender):
     ui.cancel_delays()
     self.__iQ = 5
     self.__ipR = ImageP.open('ionicons-ios7-reload-32')
     self.__bRA.image = ui.Image.named('ionicons-load-d-32')
     self.__bF2.enabled = False
     self.__bF3.enabled = False
     self.__bR1A(object)
     self.__bR2A(object)
     self.__bR3A(object)
     ui.delay(self.__AutoRefresh, 3)
Beispiel #10
0
 def __init__(self, obj, delay = .1):
     import console, time
     # trying for saftey
     ui.cancel_delays()
     # no sleeping...
     console.set_idle_timer_disabled(True)
     self.obj = obj
     self.delay = delay
     self.busy = False
     # record the start time
     self.start = time.time()
     ui.delay(self.auto_scroll, 2)
Beispiel #11
0
    def cancel(self, ignore_completion=False, finish_with=None):
        # for manual cancelling
        # finish_with just allows your func to be called a last time
        # with a value like 1.0 Could provide a more appealling effect

        ui.cancel_delays()
        if finish_with:
            self.func(finish_with)

        if self.on_completion:
            if not ignore_completion:
                self.on_completion(self)
Beispiel #12
0
    def do_updates(self):
        if not self.on_screen:
            ui.cancel_delays()
            return

        # the panel base class has a update() method that just passes.
        # so its safe to call the method. it needs to be overriden in the
        # child class for it to do anything.
        for panel in self.panels:
            panel.update()

        ui.delay(self.do_updates, 1)
	def do_updates(self):
		if not self.on_screen:
			ui.cancel_delays()
			return
			
		# the panel base class has a update() method that just passes.
		# so its safe to call the method. it needs to be overriden in the
		# child class for it to do anything.
		for panel in self.panels:
			panel.update()
		
		ui.delay(self.do_updates, 1)
 def layout(self, sender=None):
     ui.cancel_delays()
     if not self.navigation_view:
         return
     stations_dict = do_api_get(url, auth)
     self.navigation_view.name = 'Bike stations as of {} ago'.format(
         freshness(stations_dict['timeStamp']))
     stations = stations_dict['StationStatus']
     show_bikes_available = not self.seg_control.selected_index
     fmt = 'Station {id_} has {occ_} bikes available'
     self.table_view.data_source.items = [fmt.format(**x) for x
         in stations if bool(x['occ_']) == show_bikes_available]
     ui.delay(self.layout, 60)  # refresh at least once per minute
 def layout(self, sender=None):
     ui.cancel_delays()
     if not self.navigation_view:
         return
     stations_dict = do_api_get(url, auth)
     self.navigation_view.name = 'Bike stations as of {} ago'.format(
         freshness(stations_dict['timeStamp']))
     stations = stations_dict['StationStatus']
     show_bikes_available = not self.seg_control.selected_index
     fmt = 'Station {id_} has {occ_} bikes available'
     self.table_view.data_source.items = [
         fmt.format(**x) for x in stations
         if bool(x['occ_']) == show_bikes_available
     ]
     ui.delay(self.layout, 60)  # refresh at least once per minute
    def scrollview_did_scroll(self, sender):
        ui.cancel_delays()
        sender.dx += sender.content_offset[0] - 5.0
        sender.content_offset = (5, 5)

        def hq(dpi=160):
            sender.ready = False
            dx, sender.dx = sender.dx, 0
            plt.xlim([x + dx for x in plt.xlim()])
            b = io.BytesIO()
            plt.savefig(b, format='jpeg', dpi=dpi)
            sender.subviews[0].image = ui.Image.from_data(b.getvalue())
            sender.ready = True

        if sender.ready:
            hq(16)
        ui.delay(hq, 0)
Beispiel #17
0
 def touch_ended(self, touch):
     # Called when a touch ends.  if touch ended before timer, cancel it
     #self.t.cancel()
     ui.cancel_delays()
     if self.doing_longtouch:
         for  s in self.childHits(touch.location):
             s.action(s)
     if self.touched:
         #normal button action
         self.touched=False
         self.set_needs_display()
         self.action(self)
     #else:
     #    return
     self.doing_longtouch=False
     self.touched=False
     self.set_needs_display()
     self.longtouch_cleanup()
Beispiel #18
0
def complete_later(blk, _requestid):
    ui.cancel_delays()
    blkcopy = c._Block_copy(c_void_p(blk))
    logger.debug(blk, blkcopy)
    b = cast(blkcopy, POINTER(completion_block_literal)).contents

    s = Suggestion(matchedRanges=0, name='poop')
    s2 = Suggestion(matchedRanges=0, name='pooperiffic')

    @ui.in_background
    def invoke():
        time.sleep(2)
        completiondictlist = ns([s, s2])
        on_main_thread(b.invoke)(c_void_p(blkcopy), c_short(_requestid),
                                 completiondictlist)

    #ui.delay(invoke,0.05)
    invoke()
Beispiel #19
0
 def touch_ended(self, touch):
     # Called when a touch ends.  if touch ended before timer, cancel it
     #self.t.cancel()
     ui.cancel_delays()
     if self.doing_longtouch:
         for  s in self.childHits(touch.location):
             s.action(s)
     if self.touched:
         #normal button action
         self.touched=False
         self.set_needs_display()
         self.action(self)
     #else:
     #    return
     self.doing_longtouch=False
     self.touched=False
     self.set_needs_display()
     self.longtouch_cleanup()
Beispiel #20
0
 def __bF3A(self, sender):
     self.wv_3.bring_to_front()
     if self.wv_3.width < 1000:
         ui.cancel_delays()
         if getattr(self, 'bD3', None) is not None: self.bD3.hidden = True
         self.__bB.hidden = False
         self.__bF3.image = ui.Image.named('ionicons-arrow-shrink-32')
         self.__bF2.hidden = True
         self.wv_3.width = 1005
         self.wv_3.height = 651
     else:
         if getattr(self, 'bD3', None) is not None: self.bD3.hidden = False
         self.__bB.hidden = True
         self.__bF3.image = ui.Image.named('ionicons-arrow-expand-32')
         self.__bF2.hidden = False
         self.wv_3.width = 495
         self.wv_3.height = 352
         self.__bRAA(object)
     self.wv_3.evaluate_javascript(self.javascript_3)
Beispiel #21
0
 def __bF3A(self, sender):
     self.wv_3.bring_to_front()
     if self.wv_3.width < 1000:
         ui.cancel_delays()
         if getattr(self, 'bD3', None) is not None: self.bD3.hidden = True
         self.__bB.hidden = False
         self.__bF3.image = ui.Image.named('ionicons-arrow-shrink-32')
         self.__bF2.hidden = True 
         self.wv_3.width = 1005
         self.wv_3.height = 651
     else:
         if getattr(self, 'bD3', None) is not None: self.bD3.hidden = False
         self.__bB.hidden = True
         self.__bF3.image = ui.Image.named('ionicons-arrow-expand-32')
         self.__bF2.hidden = False 
         self.wv_3.width = 495
         self.wv_3.height = 352
         self.__bRAA(object)
     self.wv_3.evaluate_javascript(self.javascript_3)
Beispiel #22
0
	def auto_scroll(self):
		# this busy signal, probably not required.
		# but will keep it in anyway. its a small price
		# to pay for extra saftey.
		if self.busy:
			ui.cancel_delays()
			return 
		
		# thanks @JonB
		# if the view is not onscreen, we delete ourself
		# moments later our __del__ is called...
		if not self.obj.on_screen:
			print 'off screen'
			ui.cancel_delays()
			return
			
		self.busy = True
			
		# the scrollview
		sv = self.obj.sv
		
		# current offset of the scrollview
		v_offset = sv.content_offset[1]
		# calc new_offset, to be + one page 
		new_offset = v_offset + sv.height
		
		# wrap around if we reach the bottom if the list
		if new_offset > sv.content_size[1]:
			new_offset = 0
			
		sv.content_offset = (0, new_offset )
		
		ui.cancel_delays()
		ui.delay(self.auto_scroll, self.delay)
		self.busy = False
Beispiel #23
0
    def _work_linear(self):
        # the method that is called 100 times at evenlyish time intervals
        # which in turns calls the callers function with numbers 0.0 to 1.0

        # i know, this can be better. for now its ok to spell it out
        _expected_time = self.iterations * self.time_unit
        _real_time = time.time() - self.start_time
        _diff = _expected_time - _real_time

        if self.iterations == 100:
            # hmmm, call last time
            self.func(self, 1.0)

            # we are finished
            self.finish_time = time.time()
            ui.cancel_delays()
            print 'duration {}, total time {}, difference {}'.format(
                self.duration, self.finish_time - self.start_time,
                (self.finish_time - self.start_time) - self.duration)

            # if a completion routine has been defined, is called here
            if self.on_completion:
                self.on_completion(self)

            # reset some values, so calling multiple times work
            self.reset()
            self.working = False
            return

        # call the callers function with ref to this object and the current
        # value
        self._value = self.iterations / 100.
        self.func(self, self._value)
        self.iterations += 1

        # call ui.delay with .95% of the time unit we have.
        # this seems ok at the moment. if a lot of processing happens
        # in the callers function, it will start to fall behind
        # hofully _diff counteracts it
        ui.delay(self._work_linear, (self.time_unit) + _diff)
Beispiel #24
0
 def kblayout(self,kb):
     #allow kb to resizs, then resize editor
     ui.cancel_delays()
     KeyboardFrame.layout(kb)
Beispiel #25
0
 def stop_animation(self):
     ui.cancel_delays()
     self.frame_count = self.total_frames
Beispiel #26
0
	def btn_stop(self, sender):
		self.name = 'delay is stopped'
		ui.cancel_delays()
 def will_close(self):
     ui.cancel_delays()
Beispiel #28
0
# coding: utf-8
import ui
import time


@ui.in_background
def time_btn(self):
    #self.menu_button(...) just adding a button to
    #aView.right_button_items, returning the button.

    btn = self.menu_button('Time', False, None)
    #btn.enabled = False
    while (True):
        if not self.view.on_screen: break
        btn.title = time.strftime('%H:%M:%S')
        time.sleep(1)


def some_function():
    ## do stuff here...
    ui.delay(some_function, .5)  ## half-second delay


def button_pressed(sender):
    ## do whatever...
    ui.delay(some_function, .5)  ## half-second delay


## don't forget to cancel your delays...
ui.cancel_delays()
 def will_close(self):
     ui.cancel_delays()
Beispiel #30
0
 def will_close(self):
     ui.cancel_delays()
     self.wv_1.stop()
     self.wv_2.stop()
     self.wv_3.stop()
Beispiel #31
0
 def will_close(self):
     ui.cancel_delays()
     self.wv_1.stop()
     self.wv_2.stop()
     self.wv_3.stop()
Beispiel #32
0
 def __del__(self):
     print 'Stress died'
     ui.cancel_delays()
Beispiel #33
0
def end():
    label_results.text = str(totalQuestions) + " questions\ncomplete!"
    label_results.hidden = False
    ui.cancel_delays()
 def will_close(self):
     # window is going to close save anything you need to here
     # also stop ui.delay
     ui.cancel_delays()
Beispiel #35
0
            new_offset = 0

        sv.content_offset = (0, new_offset )

        ui.cancel_delays()
        ui.delay(self.auto_scroll, self.delay)
        self.busy = False

    # working now,
    def __del__(self):
        print 'Stress died'
        ui.cancel_delays()
        #print time.time() - self.time()

if __name__ == '__main__':
    ui.cancel_delays()  # just incase...the stress class sort of needs it
    if __ver__ == 1.6:
        console.set_font('Menlo', 22)
        # as our item size is 128,128 defined at the top
        # gives us a window size to view 4 rows x 4 cols
        vw = 128 * 4
        vh = 66 * 10
    else:
        vw, vh = 540, 576

    vv = VirtualView(vw, vh, _item_size, _buf_size, items = None , item_count = _item_count)
    vv.background_color = 'white'
    vv.present(_pres_style, hide_title_bar = False  )

    # this will continue to auto scroll the Virtual View until it the view is closed.
    if _STRESS_TEST: