Esempio n. 1
0
    def dismiss_datepicker(self, sender):
        value = self.date_picker.date

        if self.selected_date_type == 'date':
            self.selected_date_cell.detail_text_label.text = value.strftime(
                self.selected_date_format)
        elif self.selected_date_type == 'time':
            self.selected_date_cell.detail_text_label.text = value.strftime(
                self.selected_date_format)
        else:
            self.selected_date_cell.detail_text_label.text = value.strftime(
                self.selected_date_format)
        self.values[self.selected_date_key] = value

        def fade_out():
            self.dismiss_datepicker_button.alpha = 0.0
            self.date_picker.transform = ui.Transform.translation(
                0, self.date_picker.height)

        def remove():
            self.container_view.remove_subview(self.shield_view)
            self.shield_view = None

            year = self.values[self.selected_date_key].strftime('%y')
            month = self.values[self.selected_date_key].strftime('%m')
            day = self.values[self.selected_date_key].strftime('%d')
            #self.ramq_dob = self.values[self.selected_date_key].strftime('%y%m%d')
            if self.values['is_female']:
                month = str(50 + int(month))
            self.ramq_dob = year + month + day
            self.set_ramq_number()

        ui.animate(fade_out, 0.3, completion=remove)
Esempio n. 2
0
 def animate_bar():
     for i in range(0, 200):
         if process_done:
             break
         ui.animate(self.blink, 0.1)
         if DEBUG: print(i)
         time.sleep(0.2)
Esempio n. 3
0
def change_text(sender):
    global i
    i += 1
    message_box2.text = entry_message.text

    def expand():
        message_box_container.width = message_box_container.width + 64
        message2.y -= 64
        message.y -= 64

    def shrink():
        def shrink_width():
            message_box_container.width = message_box_container.width - 64

        ui.animate(shrink_width, 1, 0)

    sound.play_effect('digital:HighDown')
    # If the message entry button counter is <= 3 (presses)...
    if i <= 4:
        # animate the width of the message2 box(expand) with a duration of 1 and a delay of 0, and then shrink it.
        # Also, move both message views 64 pixels up (negative)
        ui.animate(expand, 1, 0, shrink)
    else:
        message.y = message.location
        message2.y = message2.location
        i = 0
Esempio n. 4
0
    def button_tapped(self, sender):
        '''Checks if sender is the winning bit'''

        if str(sender.name) == self.winTex:
            self.touch_enabled = False
            self.count_points(sender.y)
            sender.image = ui.Image.named(
                'emj:Checkmark_3').with_rendering_mode(
                    ui.RENDERING_MODE_ORIGINAL)
            sound.play_effect('game:Ding_3', 0.2)

            if self.winTap == False:
                self.winTap = True

                def animation():
                    button.alpha = 0.0  # fade out

                for button in self.buttons:
                    ui.animate(animation, duration=1.5)
                for button in self.buttons2:
                    ui.animate(animation, duration=1.5)
                ui.delay(self.restart, 2)

        else:
            sender.image = ui.Image.named(
                'emj:Cross_Mark').with_rendering_mode(
                    ui.RENDERING_MODE_ORIGINAL)
            sound.play_effect('game:Error', 0.2)
Esempio n. 5
0
    def layout(self):
        (screenX, screenY) = ui.get_screen_size()
        i = 0

        for button in self.buttons:
            i += 1
            button.bounds = (0, 0, screenX / 5, screenX / 5)
            button.center = ((screenX / 4) * (i), (screenY / 4) * 3.05)

        self.red_points.frame = (0, 0, 600, 100)
        self.red_points.center = screenX / 2, ((screenY / 4) * 2.3)
        self.red_points.alignment = 1

        i = 0
        for button in self.buttons2:
            i += 1
            button.bounds = (0, 0, screenX / 5, screenX / 5)
            button.center = ((screenX / 4) * (i), (screenY / 4) * .6)

            def animation():
                button.transform = ui.Transform.rotation(pi)

            ui.animate(animation, duration=0.0)

        self.blue_points.frame = (0, 0, 600, 100)
        self.blue_points.center = screenX / 2, ((screenY / 4) * 1.4)

        def label_flip():
            self.blue_points.transform = ui.Transform.rotation(pi)

        ui.animate(label_flip, duration=0.0)
        self.blue_points.alignment = 1
Esempio n. 6
0
    def update(self):
        _setattr = lambda d={}: [setattr(self, n, v) for n, v in d.items()]
        if not self.alpha:
            self.y += 10
            self.x += 10
            ui.animate(lambda: _setattr({
                'alpha': 1,
                'y': self.y - 10,
                'x': self.x - 10
            }))

            html = '<form name="f"><select name="s" style="width:400px;font-size:63px">' + ''.join(
                f'<option>{i.name}</option>'
                for i in self.superview.get_all_views()) + '</select></form>'
            self['info_view'].load_html(html)

        else:
            ui.animate(lambda: _setattr({
                'alpha': 0,
                'y': self.y + 10,
                'x': self.x + 10
            }),
                       completion=lambda: _setattr({
                           'y': self.y - 10,
                           'x': self.x - 10
                       }))
Esempio n. 7
0
    def show_datepicker(self, mode):
        ui.end_editing()
        self.shield_view = ui.View()
        self.shield_view.flex = 'WH'
        self.shield_view.frame = (0, 0, self.view.width, self.view.height)

        self.dismiss_datepicker_button = ui.Button()
        self.dismiss_datepicker_button.flex = 'WH'
        self.dismiss_datepicker_button.frame = (0, 0, self.view.width,
                                                self.view.height)
        self.dismiss_datepicker_button.background_color = (0, 0, 0, 0.5)
        self.dismiss_datepicker_button.action = self.dismiss_datepicker
        self.dismiss_datepicker_button.alpha = 0.0
        self.shield_view.add_subview(self.dismiss_datepicker_button)

        self.date_picker = ui.DatePicker()
        self.date_picker.date = self.selected_date_value
        self.date_picker.background_color = 'white'
        self.date_picker.mode = mode
        self.date_picker.frame = (0, self.shield_view.height -
                                  self.date_picker.height,
                                  self.shield_view.width,
                                  self.date_picker.height)
        self.date_picker.flex = 'TW'
        self.date_picker.transform = ui.Transform.translation(
            0, self.date_picker.height)
        self.shield_view.add_subview(self.date_picker)

        self.container_view.add_subview(self.shield_view)

        def fade_in():
            self.dismiss_datepicker_button.alpha = 1.0
            self.date_picker.transform = ui.Transform.translation(0, 0)

        ui.animate(fade_in, 0.3)
Esempio n. 8
0
    def slide_up(self, timer=0.25):
        """
        Modify the views position by taking its y coordinate
        and adding the full length of the window, then using
        the ui.Animate to bring it up.
        """
        assert isinstance(self.view, ui.View)
        assert isinstance(self.superview, ui.View)

        # Keeping this for a kater thought
        self._siblings_cp()

        self.view.y += self.superview.height

        self.superview.add_subview(self.view)

        def animation():
            self.view.y -= self.superview.height

        ui.animate(animation, timer)

        if self.remove_siblings:
            for sv in self.superview.subviews:
                if sv != self.view:
                    self.superview.remove_subview(sv)
    def toggle_menu(self, slide_duration=0.7):
        '''Can be called with one argument 'slide_duration'.
		Example: a.toggle_menu(slide_duration=0.3) Note: the value is in seconds.
		Use Case: hiding the menu after selecting an item in master for display in detail'''
        ui.animate(self.slide_left, duration=slide_duration) if self.master_is_visible\
        else ui.animate(self.slide_right, duration=slide_duration)
        self.master_is_visible = True if not self.master_is_visible else False
Esempio n. 10
0
 def populate_table(self):
     console.show_activity()
     if callable(self.items):
         items=self.items()
     else:
         items=self.items
         
     dropdownlist=[]
     self.listsource.items=dropdownlist
     self.tbl.reload()        
     for item in items:
       def ani():
         dropdownlist.append(item)
         offset=self.tbl.content_offset
         self.listsource.items=dropdownlist
         self.tbl.reload()
         try:
             self.listsource.selected_row = self.listsource.items.index(self.textfield.text)
             self.listsource.tableview.selected_row = (0,self.listsource.selected_row)
         except ValueError:
             #self.listsource.selected_row=-1
             self.listsource.tableview.selected_row=(0,-1)
         self.tbl.content_offset=tuple(offset)
       ui.animate(ani,0.1)
     console.hide_activity()
Esempio n. 11
0
	def animate(self):
		len_subviews = len(self.subviews)
		
		for i, sub in enumerate(self.subviews):
			if sub.frame == self.frames[-	1]:
				sub.alpha = 0
			elif sub.frame == self.frames[0]:
				sub.alpha = 1
		
		def anim():
			#Change frames
			for i, sub in enumerate(self.subviews):
				next = (i + (1 if self.touch_direction else -1)) % len_subviews
				sub.frame = self.prev_frames[next]

		#Animate
		ui.animate(anim, 0.25)
		#Re-sort self.images
		if self.touch_direction:
			self.images = [self.images[-1]]+self.images
			self.images.pop(-1)
		else:
			self.images = self.images + [self.images[0]]
			self.images.pop(0)
		
		#Reorder layers based on the fact that biggest images are in front,
		#Bring smallest images to front first
		for s in sorted(self.subviews, key=lambda x: x.frame[3]): s.bring_to_front()
		
		#Reassign prev_frame
		for index, sub in enumerate(self.subviews):
			self.prev_frames[index] = sub.frame
Esempio n. 12
0
def move_right(sender):
    def right():
        r[0].action = move_left
        view2.x = window.width

    r[0].title = '+'
    ui.animate(right, .5)
Esempio n. 13
0
File: demo.py Progetto: cclauss/ui2
def demo_PathView():
    # SETUP
    p = ui2.get_regular_polygon_path(6, center=(50, 50), radius=50)
    pv = ui2.PathView(p)
    pv.x = 150
    pv.y = 150
    # ANIMATION FUNCTIONS
    def scaleWidth():
        pv.width = 200
    def scaleHeight():
        pv.height = 200
    def scaleBoth():
        pv.width = 300
        pv.height = 300
    def scaleBack():
        pv.x, pv.y = 0, 0
        pv.width, pv.height = 50, 50
    # BASIC USAGE
    v = ui.View(background_color="white")
    v.width = v.height = 500
    v.add_subview(pv)
    v.present("sheet", hide_title_bar=True)
    # PERFORM THE ANIMATIONS
    ui.animate(scaleWidth, 1)
    ui.delay(lambda: ui.animate(scaleHeight, 1), 1)
    ui.delay(lambda: ui.animate(scaleBoth, 1), 2)
    ui.delay(lambda: ui.animate(scaleBack, 1), 3)
Esempio n. 14
0
def main(im):
	global out
	out = image2ASCII(im)
	global outim
	outim = RenderASCII(out)
	
	rootView.background_color = 0.92
	
	global i
	i = ui.ImageView()
	
	i.frame = (0, 10, 1024, 768)
	i.content_mode = ui.CONTENT_SCALE_ASPECT_FIT
	
	i.image = pil_to_ui(outim)
	rootView.add_subview(i)
	
	
	view2.remove_subview(ishare)
	view2.x = 247
	view2.y = -285
	rootView.add_subview(view2)
	
	time.sleep(1.5)
	ui.animate(pulldown, 1)
Esempio n. 15
0
def demo_PathView():
    # SETUP
    p = ui2.get_regular_polygon_path(6, center=(50, 50), radius=50)
    pv = ui2.PathView(p)
    pv.x = 150
    pv.y = 150

    # ANIMATION FUNCTIONS
    def scaleWidth():
        pv.width = 200

    def scaleHeight():
        pv.height = 200

    def scaleBoth():
        pv.width = 300
        pv.height = 300

    def scaleBack():
        pv.x, pv.y = 0, 0
        pv.width, pv.height = 50, 50

    # BASIC USAGE
    v = ui.View(background_color="white")
    v.width = v.height = 500
    v.add_subview(pv)
    v.present("sheet", hide_title_bar=True)
    # PERFORM THE ANIMATIONS
    ui.animate(scaleWidth, 1)
    ui.delay(lambda: ui.animate(scaleHeight, 1), 1)
    ui.delay(lambda: ui.animate(scaleBoth, 1), 2)
    ui.delay(lambda: ui.animate(scaleBack, 1), 3)
Esempio n. 16
0
    def do_long_touch(self):
        if self.touched:
            self.doing_longtouch=True
            root=self.get_top_view()
            flow=self.flow
            #set popup flow as child to root, in proper location
            # root needs to be a plain view without layout manager
            myposinroot=ui.convert_point((0,0),self,root)
            flow.x=myposinroot[0]
            flow.y=myposinroot[1]
            root.add_subview(flow)
            flow.layout()
            flow.bg_color=self.bg_color
            flow.border_color=self.border_color
            flow.tint_color=self.tint_color
            flow.hidden=False
            def pop():
                flow.y=flow.y-flow.height-20
                flow.x=flow.x
            ui.animate(pop,0.05)
            self.set_needs_display()
            # add delayed cleanup of the popup, for panel mode where this deosnt behave

            self.longtouchcleanuptimer=Timer(3.0,self.longtouch_cleanup)
            self.longtouchcleanuptimer.start()
def slide_up(p, v, reverse = False, delay = 1.0 ):
	v.y = p.height if not reverse else -p.height
	
	def animation():
		v.y = 0
		
	ui.animate(animation, delay)
Esempio n. 18
0
def indicateSpawn(view):
        def restoreColor():
                view.background_color=(1,1,1,1)
                view.alpha=1.0
        view.background_color=(1,0,0,1)
        view.alpha=0.2
        ui.animate(restoreColor, duration=0.5)
Esempio n. 19
0
def display_toast(view, help_text, width = 220, height = 110, show_duration=2, fade_duration=0.5, background_colour=(.42, .42, .42), text_colour= (.96, .96, .96), corner_radius=10):

	w, h = ui.get_screen_size()

	help_view = ui.View(frame=((w/2)-(width/2),(h/2)-height, width, height))
	help_view.background_color = background_colour
	help_view.corner_radius = corner_radius

	label = ui.Label()
	label.text = help_text
	label.flex = 'H'
	label.width = help_view.width * 0.9
	label.alignment = ui.ALIGN_CENTER
	label.x = (help_view.width / 2) - (label.width / 2)
	label.y = (help_view.height / 2) - (label.height / 2)
	label.number_of_lines = 3

	label.text_color = text_colour

	help_view.add_subview(label)

	def animation_fade_in():
		help_view.alpha = 1.0
	def animation_fade_out():
		help_view.alpha = 0.0

	help_view.alpha = 0.0
	view.add_subview(help_view)
	ui.animate(animation_fade_in, duration=fade_duration)
	time.sleep(show_duration+fade_duration)
	ui.animate(animation_fade_out, duration=fade_duration)
	time.sleep(fade_duration)
	view.remove_subview(help_view)
Esempio n. 20
0
    def dismiss_datepicker(self, sender):
        value = self.date_picker.date

        if self.selected_date_type == 'date':
            self.selected_date_cell.detail_text_label.text = value.strftime(
                self.selected_date_format)
        elif self.selected_date_type == 'time':
            self.selected_date_cell.detail_text_label.text = value.strftime(
                self.selected_date_format)
        else:
            self.selected_date_cell.detail_text_label.text = value.strftime(
                self.selected_date_format)

        self.values[self.selected_date_key] = value

        def fade_out():
            self.dismiss_datepicker_button.alpha = 0.0
            self.date_picker.transform = ui.Transform.translation(
                0, self.date_picker.height)

        def remove():
            self.container_view.remove_subview(self.shield_view)
            self.shield_view = None

        ui.animate(fade_out, 0.3, completion=remove)
Esempio n. 21
0
def main(im):
    # Create the ASCII
    global out
    console.show_activity("Processing...")
    out = image2ASCII(im)
    console.hide_activity()
    # Render onto an image
    global outim
    console.show_activity("Rendering...")
    outim = RenderASCII(out)
    console.hide_activity()

    rootView.background_color = 0.92

    global i
    i = ui.ImageView()

    i.frame = (0, 10, 1024, 768)
    i.content_mode = ui.CONTENT_SCALE_ASPECT_FIT

    i.image = pil_to_ui(outim)
    rootView.add_subview(i)

    close.bring_to_front()

    view2.remove_subview(ishare)
    view2.x = 247
    view2.y = -285
    rootView.add_subview(view2)

    time.sleep(1.5)
    ui.animate(pulldown, 1)
Esempio n. 22
0
	def show_datepicker(self, mode):
		ui.end_editing()
		self.shield_view = ui.View()
		self.shield_view.flex = 'WH'
		self.shield_view.frame = (0, 0, self.view.width, self.view.height)
		
		self.dismiss_datepicker_button = ui.Button()
		self.dismiss_datepicker_button.flex = 'WH'
		self.dismiss_datepicker_button.frame = (0, 0, self.view.width, self.view.height)
		self.dismiss_datepicker_button.background_color = (0, 0, 0, 0.5)
		self.dismiss_datepicker_button.action = self.dismiss_datepicker
		self.dismiss_datepicker_button.alpha = 0.0
		self.shield_view.add_subview(self.dismiss_datepicker_button)

		self.date_picker = ui.DatePicker()
		self.date_picker.date = self.selected_date_value
		self.date_picker.background_color = 'white'
		self.date_picker.mode = mode
		self.date_picker.frame = (0, self.shield_view.height - self.date_picker.height, self.shield_view.width, self.date_picker.height)
		self.date_picker.flex = 'TW'
		self.date_picker.transform = ui.Transform.translation(0, self.date_picker.height)
		self.shield_view.add_subview(self.date_picker)

		self.container_view.add_subview(self.shield_view)
		
		def fade_in():
			self.dismiss_datepicker_button.alpha = 1.0
			self.date_picker.transform = ui.Transform.translation(0, 0)
		ui.animate(fade_in, 0.3)
Esempio n. 23
0
    def open_finder(self, sender):
        # expand out a view/dialog from sender
        root = self.find_root()
        overlay = ui.Button(frame=(0, 0) + tuple(root.frame)[2:],
                            bg_color=(0, 0, 0, 0.25),
                            name='overlay')
        dialog = ui.View(frame=sender.frame, bg_color='white', name='dialog')
        self.tbl = ui.TableView()
        self.tbl.width = dialog.width
        self.tbl.height = dialog.height
        self.listsource = ui.ListDataSource(items=[])
        self.tbl.data_source = self.listsource
        self.tbl.delegate = self.listsource
        self.listsource.action = self.stop_populating
        self.tbl.flex = 'wh'
        dialog.add_subview(self.tbl)
        overlay.add_subview(dialog)
        overlay.action = self.stop_populating
        root.add_subview(overlay)
        self.dialog = dialog

        def ani():
            dialog.x, dialog.y = ui.convert_point(
                (self.textfield.x, self.textfield.y + self.textfield.height),
                self, root)
            dialog.width = self.textfield.width
            dialog.height = min(
                400, root.height - ui.convert_point(
                    (0, dialog.y), self, root)[1])

        ui.delay(self.start_populating, 0.16)
        ui.animate(ani, 0.15)
Esempio n. 24
0
    def populate_table(self):
        console.show_activity()
        if callable(self.items):
            items = self.items()
        else:
            items = self.items

        dropdownlist = []
        self.listsource.items = dropdownlist
        self.tbl.reload()
        for item in items:

            def ani():
                dropdownlist.append(item)
                offset = self.tbl.content_offset
                self.listsource.items = dropdownlist
                self.tbl.reload()
                try:
                    self.listsource.selected_row = self.listsource.items.index(
                        self.textfield.text)
                    self.listsource.tableview.selected_row = (
                        0, self.listsource.selected_row)
                except ValueError:
                    #self.listsource.selected_row=-1
                    self.listsource.tableview.selected_row = (0, -1)
                self.tbl.content_offset = tuple(offset)

            ui.animate(ani, 0.1)
        console.hide_activity()
Esempio n. 25
0
	def reveal(self):
		self.hiding = False
		if self.left:
			self.width = self.superview.width
		def animation():
			self.x = self.visible_x()
		ui.animate(animation, self.speed)
def slide_in(p, v, reverse = False, delay = 1.0 ):
	v.x = p.width if not reverse else -p.width
	
	def animation():
		v.x = 0
		
	ui.animate(animation, delay)
Esempio n. 27
0
def b5():
	def d():
		checkThread('animated')
		s.y=s.y+1
	def c():
		checkThread('animatcompletion')
	ui.animate(d,0.1,completion=c)
Esempio n. 28
0
    def do_long_touch(self):
        if self.touched:
            self.doing_longtouch=True
            root=self.get_top_view()
            flow=self.flow
            #set popup flow as child to root, in proper location
            # root needs to be a plain view without layout manager
            myposinroot=ui.convert_point((0,0),self,root)
            flow.x=myposinroot[0]
            flow.y=myposinroot[1]
            root.add_subview(flow)
            flow.layout()
            flow.bg_color=self.bg_color
            flow.border_color=self.border_color
            flow.tint_color=self.tint_color
            flow.hidden=False
            def pop():
                flow.y=flow.y-flow.height-20
                flow.x=flow.x
            ui.animate(pop,0.05)
            self.set_needs_display()
            # add delayed cleanup of the popup, for panel mode where this deosnt behave

            self.longtouchcleanuptimer=Timer(3.0,self.longtouch_cleanup)
            self.longtouchcleanuptimer.start()
Esempio n. 29
0
    def rotate(self, sender):
        self.angle += 1

        def anim():
            self.buttonView.transform = ui.Transform().rotation(
                (pi / 2 * self.angle))

        ui.animate(anim, duration=0.5)
def move_left(sender):
	def left():
		view2.x = 0
		#view2 is a custom view located to the right of the main view
		# add suviews to this view if you please.
		r[0].action = move_right
	r[0].title = '>'
	ui.animate(left, .5)
Esempio n. 31
0
 def layout(self):
     self.frame = (0,0, 320, 50)
     self.__tvP.frame = (10, 5, 200, 30)
     self.__bC.frame = (220, 10, 100, 30)
     self.__tvP.alpha = 0.0
     def f():
         self.__tvP.alpha = 1.0
     ui.animate(f, duration=1.0)
Esempio n. 32
0
def auto_scroll():
    def do_scroll():
        tx = txMain.content_offset[1]
        sz = txMain.content_size[1]
        hg = txMain.height
        txMain.content_offset = (0, sz - hg)

    ui.animate(do_scroll, 0.00001)
Esempio n. 33
0
def move_left(sender):
    def left():
        view2.x = 0
        #view2 is a custom view located to the right of the main view
        # add suviews to this view if you please.
        r[0].action = move_right

    r[0].title = '>'
    ui.animate(left, .5)
    def animate(self, sender=None):
        print 'in animate...'

        def animation():
            self.alpha = 0  # fade out
            self.value = self.alpha
            self.set_needs_display()

        ui.animate(animation, duration=2)
Esempio n. 35
0
    def _do_effect_scale(self):
        def ani():
            self.obj.transform = ui.Transform()

        self.obj.transform = ui.Transform.scale(self.x, self.y)
        ui.animate(ani,
                   duration=self.duration,
                   delay=self.delay,
                   completion=self.complete)
Esempio n. 36
0
 def layout(self):
     self.frame = (0,0, 320, 50)
     self.__tfF.frame = (10, 10, 100, 30)
     self.__tfR.frame = (120, 10, 100, 30)
     self.__bR.frame = (220, 10, 100, 30)
     self.__tfR.alpha = 0.0
     def f():
         self.__tfR.alpha = 1.0
     ui.animate(f, 1)
Esempio n. 37
0
    def touch_ended(self, touch):
        def closePalette():
            self.superview.superview["palette"].frame = (0, ss[1], ss[0], 200)

        ui.animate(closePalette, 0.6)
        global CURRENTCOLOR
        CURRENTCOLOR = self.colorName
        colorbtn.tint_color = self.colorName
        drawCanvas.color = self.colorName
def hide_action(sender):
    s = sender.superview
    s['view1'].hidden = True
    s2 = s['view2']

    def a():
        s2.transform = ui.Transform.scale(1.0, 1.33).concat(
            ui.Transform.translation(0, -100))

    ui.animate(a, 1.0)
Esempio n. 39
0
def reset_slider_values(sender):
    def animation():
        view['slider1'].value = 1.0
        view['slider2'].value = 0.05
        view['slider3'].value = 0.4
        view['slider4'].value = 0.75
        view['slider5'].value = 0.25

    ui.animate(animation, duration=1.0)
    update_sliders(view['slider1'])
Esempio n. 40
0
 def do_close(self):
     def ani():
         self.width=10
         self.y=self.overlay.height
         self.height=10
     def close():
         root=self.find_root(self.root)
         root.remove_subview(self.overlay)
     ui.animate(ani,0.25)
     ui.delay(close,0.25)
Esempio n. 41
0
    def layout(self):
        self.frame = (0, 0, 320, 50)
        self.__tvP.frame = (10, 5, 200, 30)
        self.__bC.frame = (220, 10, 100, 30)
        self.__tvP.alpha = 0.0

        def f():
            self.__tvP.alpha = 1.0

        ui.animate(f, duration=1.0)
Esempio n. 42
0
    def update_from_config(self, config_view):
        lg = ui.View()
        lg.present("sheet", hide_title_bar=True)

        logger.debug("Updating configuration")
        tv = self["editor_view"]["WebEditor"]["web_view"]
        config = config_view.config

        font_size = config.get_value("editor.font.size")
        gutter = config.get_value("editor.show.gutter")
        style = config.get_value("editor.style")
        margin = config.get_value("editor.print.margin")
        wrap = config.get_value("editor.line.wrap")
        soft_tab = config.get_value("editor.soft.tabs")
        tab_size = config.get_value("editor.tab.size")

        lb = ui.Label()
        lb.text = "Loading Style %r" % style
        lb.flex = "WH"
        lg.add_subview(lb)
        lb.size_to_fit()

        fs = '''for (var elm in document.getElementsByClass('.CodeMirror')) {
    elm.style.font_size = '%ipt';"
}''' % font_size

        logger.debug("Applying theme: %r", style)
        if len(themes.view_list) < 1:
            themes.get_view_list(self.superview)
            themes.get_view_list(self.superview.superview)
            themes.get_view_list(self.superview.fileViewer)
            themes.get_view_list(self.superview.fileViewer.listview)
            themes.get_view_list(self.superview.fileViewer.navview)

        def load():
            s = time.clock()
            self.superview.fileViewer.style = style
            self.superview.fileViewer.listview.reload()
            self.superview.fileViewer.set_style()
            themes.recursive_style_set(style)
            tv.eval_js("editor.setOption('theme', '%s')" % style)
            tv.eval_js("editor.setOption('tabSize', '%s')" % tab_size)
            tv.eval_js("editor.setOption('indentWithTabs', '%s')" % soft_tab)
            tv.eval_js("editor.setOption('lineWrapping', '%s')" % wrap)
            tv.eval_js("editor.setOption('lineNumbers', '%s')" % gutter)

            bc = themes.themes_data[style][0]
            tv.eval_js("document.body.style.backgroundColor = '%s'" % bc)

            e = time.clock()
            logger.debug("Took %.3f seconds to set the style", e - s)
            lg.close()

        ui.animate(load, duration=0.001, delay=0.001)
Esempio n. 43
0
def open_settings(sender):
    def animation():
        v['settingsView'].hidden = False
        # Stop Sending while we're changing settings
        v['transmitSwitch'].value = 0
        v['transmitSwitch'].enabled = False
        
        v['out_y'].alpha = v['transmitSwitch'].value
        v['out_x'].alpha = v['transmitSwitch'].value
        v['sending_label'].alpha = v['transmitSwitch'].value

    ui.animate(animation, duration=1.0)
Esempio n. 44
0
 def close_button(self,sender):
     marker = sender.superview.y
     tab = sender.superview
     tab_name = sender.superview.title
     self.sv.remove_subview(tab)
     def move():
         for i in range(len(self.sv.subviews)):
             if self.sv.subviews[i].y > marker:
                 self.sv.subviews[i].y -= self.tab_width*1.05
     ui.animate(move, duration = 0.3)
     self.count-=1
     del(self.d[tab_name])
Esempio n. 45
0
def configure(sender):
    sss_view = sender.superview.superview.superview
    ss_view = sender.superview.superview
    if sss_view:
        sss_view.config_view.present("sheet")
        sss_view.config_view.wait_modal()
        tv = sender.superview.superview["contentContainer"][
            "editor_view"]["WebEditor"]["web_view"]
        config = sss_view.config_view.config

        font_size = config.get_value("editor.font.size")
        gutter = config.get_value("editor.show.gutter")
        style = config.get_value("editor.style")
        margin = config.get_value("editor.print.margin")
        wrap = config.get_value("editor.line.wrap")
        soft_tab = config.get_value("editor.soft.tabs")
        tab_size = config.get_value("editor.tab.size")

        fs = '''for (var elm in document.getElementsByClass('.CodeMirror')) {
    elm.style.font_size = '%ipt';"
}''' % font_size

        if len(themes.view_list) < 1:
            themes.get_view_list(ss_view)
            themes.get_view_list(ss_view.superview)
            themes.get_view_list(ss_view.fileViewer)
            themes.get_view_list(ss_view.fileViewer.listview)
            themes.get_view_list(ss_view.fileViewer.navview)

        def load():
            s = time.clock()
            ss_view.fileViewer.style = style
            ss_view.fileViewer.listview.reload()
            ss_view.fileViewer.set_style()
            themes.recursive_style_set(style)
            tv.eval_js("editor.setOption('theme', '%s')" % style)
            tv.eval_js("editor.setOption('tabSize', '%s')" % tab_size)
            tv.eval_js("editor.setOption('indentWithTabs', '%s')" % soft_tab)
            tv.eval_js("editor.setOption('lineWrapping', '%s')" % wrap)
            tv.eval_js("editor.setOption('lineNumbers', '%s')" % gutter)

            bc = themes.themes_data[style][0]
            tv.eval_js("document.body.style.backgroundColor = '%s'" % bc)

            e = time.clock()
            logger.debug("Took %.3f seconds to set the style", e - s)
            # lg.close()

        ui.animate(load, duration=0.001, delay=0.001)
    else:
        console.alert("Configuration is only available through the Main View")
Esempio n. 46
0
    def open_dialog(self,sender):
        # expand out a view/dialog from sender
        root=self.find_root(self.root)
        overlay=ui.Button(frame=(0,0)+root.frame[2:],bg_color=(0,0,0,0.25),name='overlay')
        overlay.action=self.dispatch_cancel_action
        finalframe=self.frame
        self.width=5
        overlay.add_subview(self)

        root.add_subview(overlay)

        def ani():
            self.frame=finalframe
            self.center=overlay.center
            self.y=0
        ui.animate(ani,0.15)
        self.overlay=overlay
Esempio n. 47
0
 def stop_populating(self,sender):
     console.hide_activity()
     root=self.find_root()
     self._abort=True
     if not isinstance(sender,ui.Button):
         #take no action
         self.textfield.text=sender.items[ sender.selected_row]
         def act():
             if self.textfield.action:
                 self.textfield.action(self.textfield)
         ui.delay(act,0.1)
     
     def ani():
         self.dialog.height=0
     def cleanup():
         root.remove_subview(root['overlay'])
     ui.delay(cleanup,0.2)
     ui.animate(ani,0.15)
Esempio n. 48
0
	def dismiss_datepicker(self, sender):
		value = self.date_picker.date
		
		if self.selected_date_type == 'date':
			self.selected_date_cell.detail_text_label.text = value.strftime(self.selected_date_format)
		elif self.selected_date_type == 'time':
			self.selected_date_cell.detail_text_label.text = value.strftime(self.selected_date_format)
		else:
			self.selected_date_cell.detail_text_label.text = value.strftime(self.selected_date_format)

		self.values[self.selected_date_key] = value
		
		def fade_out():
			self.dismiss_datepicker_button.alpha = 0.0
			self.date_picker.transform = ui.Transform.translation(0, self.date_picker.height)
		def remove():
			self.container_view.remove_subview(self.shield_view)
			self.shield_view = None
		ui.animate(fade_out, 0.3, completion=remove)
Esempio n. 49
0
def show_menu_bar(sender):
    global mb_isopen
    mb = sender.superview.superview["view2"]
    sb = mb["sb"]
    def animation():
        w = 20 if mb_isopen else 175
        mb.frame = (0, 65.5, w, 568)
        sb.frame = (0, 0, w, 568)
    ui.animate(animation, duration=1.0)
    if mb_isopen:
        mb.background_color = (0, 0, 0, 0)
        mb.border_color = (0, 0, 0, 0)
        mb.border_width = 0
        sb.alpha = 0
    else:
        mb.background_color = (1, 1, 1, 1)
        mb.border_color = (0, 0, 0, 1)
        mb.border_width = 1
        sb.alpha = 1
    mb_isopen = not mb_isopen
Esempio n. 50
0
    def textfield_did_end_editing(self, textfield):
        if textfield.text != "":

            def show():
                search.hidden = False
                search.alpha = 0.9

            ui.animate(show, 0.4)
            try:
                con = sqlite3.connect("bible-sqlite.db")
                cur = con.cursor()
                substring = textfield.text
                sub_query = "select b,c,v,t from {} where t like '%{}%'".format(translation, substring)
                sub_all = [x for x in cur.execute(sub_query)]
                table.data_source = ui.ListDataSource(sub_all)
                table.reload()
                matches.text = str(len(sub_all))
                # table.reload_data()
            except:
                None
Esempio n. 51
0
	def show_panel(self):
		'''
		stops us showing muliple times.because we make this class
		on the fly, storing states inside the class does not make
		sense so we strore them in the parent :(
		'''
		if hasattr(self.parent, 'panel_displayed'):
			if self.parent.panel_displayed:
				return

		self.parent.panel_displayed = True

		ui.end_editing()

		# save and disable the menu buttons
		self.disable_menu_buttons()

		# removed the shield view. didnt think it was needed
		# as ui.Button is a ui.View. i changed some alpha vals.
		# seems to work the same...i hope so
		self.dismiss = ui.Button()
		self.dismiss.flex = 'WH'
		self.dismiss.frame = (0, 0, self.p_width, self.p_height)
		self.dismiss.background_color = (0, 0, 0, 0.5)
		self.dismiss.action = self.dismiss_action
		self.dismiss.alpha = 0.0

		self.panel.frame = (0, self.dismiss.height - self.panel.height,
		self.dismiss.width, self.panel.height )

		self.panel.flex = 'TW'
		self.panel.transform = ui.Transform.translation(0, self.panel.height)
		self.dismiss.add_subview(self.panel)

		self.view.add_subview(self.dismiss)

		def fade_in():
			self.dismiss.alpha = 1.0
			self.panel.transform = ui.Transform.translation(0, 0)

		ui.animate(fade_in, self.fade_in_duration)
Esempio n. 52
0
	def dismiss_action(self, sender = None):
		def fade_out():
			self.dismiss.alpha = 0 # modified from .5 to 0 because no shield
			self.panel.transform = ui.Transform.translation(0, self.panel.height)

		def remove():
			# make sure we clean up

			if hasattr(self.panel, 'release'):
				self.panel.release()

			self.dismiss.remove_subview(self.panel)
			self.view.remove_subview(self.dismiss)
			self.dismiss = None

			# try to be nice and not leave our
			# crap (attr) in the parent class
			delattr(self.parent, 'panel_displayed')
			self.reset_menu_buttons()

		ui.animate(fade_out, self.fade_out_duration, completion=remove)
Esempio n. 53
0
def change_text(sender):
	global i
	i+=1
	message_box2.text = entry_message.text
	def expand():
		message_box_container.width = message_box_container.width + 64
		message2.y-=64
		message.y-=64
	def shrink():
		def shrink_width():
			message_box_container.width = message_box_container.width - 64
		ui.animate(shrink_width,1,0)
	
	sound.play_effect('digital:HighDown')
	# If the message entry button counter is <= 3 (presses)...
	if i <= 4:
		# animate the width of the message2 box(expand) with a duration of 1 and a delay of 0, and then shrink it.
		# Also, move both message views 64 pixels up (negative)
		ui.animate(expand,1,0,shrink)
	else:
		message.y=message.location
		message2.y=message2.location
		i = 0
Esempio n. 54
0
 def open_finder(self,sender):
     # expand out a view/dialog from sender
     root=self.find_root()
     overlay=ui.Button(frame=(0,0)+tuple(root.frame)[2:],bg_color=(0,0,0,0.25),name='overlay')
     dialog=ui.View(frame=sender.frame,bg_color='white',name='dialog')
     self.tbl=ui.TableView()
     self.tbl.width=dialog.width
     self.tbl.height=dialog.height
     self.listsource=ui.ListDataSource(items=[])
     self.tbl.data_source=self.listsource
     self.tbl.delegate=self.listsource
     self.listsource.action=self.stop_populating
     self.tbl.flex='wh'
     dialog.add_subview(self.tbl)
     overlay.add_subview(dialog)
     overlay.action=self.stop_populating
     root.add_subview(overlay)
     self.dialog=dialog
     def ani():
         dialog.x,dialog.y=ui.convert_point((self.textfield.x,self.textfield.y+self.textfield.height),self,root)
         dialog.width=self.textfield.width
         dialog.height=min(400,root.height-ui.convert_point((0,dialog.y),self,root)[1])
     ui.delay(self.start_populating,0.16)
     ui.animate(ani,0.15)
Esempio n. 55
0
def show_search(sender):
    def show():
        search.hidden = False
        search.alpha = 0.9

    ui.animate(show, 0.4)
	def touch_began(self,touch):
		def animation():
			panel.alpha=0
		ui.animate(animation,.3)
Esempio n. 57
0
	def rotate(self,sender):
		self.angle += 1
		def anim():
			self.buttonView.transform=ui.Transform().rotation((pi/2*self.angle))
		ui.animate(anim,duration=0.5)
Esempio n. 58
0
def hide_search(sender):
    def hide():
        search.alpha = 0

    ui.animate(hide, 0.4)
Esempio n. 59
0
	def shrink():
		def shrink_width():
			message_box_container.width = message_box_container.width - 64
		ui.animate(shrink_width,1,0)