예제 #1
0
    def layout(self):
        if self.frame != self.oldframe:
            N = 9
            frames = []
            #Create frames
            for i in range(N):
                #Thanks to @JonB for this code.
                w = 370 / 1024. * self.width * exp(-2.4 * (abs(
                    (i - N / 2.0 + 0.5) / N)**(1.38 / N**0.25)))
                xc = 512 / 1024. * self.width + copysign(
                    470.0 / 1024 * self.width *
                    log(w / (370.0 / 1024 * self.width)), i - N / 2)
                yc = (192 / 1024. * self.width - w)
                frames.append((xc - 0.5 * w, yc + 0.5 * w, w, w))

            for sv in self.subviews:
                self.remove_subview(sv)
            #Create subviews for the minimum of 9 images
            for index, frame in enumerate(frames):
                iv = ui.ImageView(frame=frame)
                iv.image = self.images[index]
                iv.prev_frame = iv.frame
                self.add_subview(iv)
                if index > 4:
                    iv.send_to_back()

            #Handle any additional images that are provided
            for i in self.images[9:]:
                iv9 = ui.ImageView(frame=frames[-1])
                iv9.image = i
                iv9.prev_frame = iv9.frame
                self.add_subview(iv9)
                iv9.send_to_back()
            self.oldframe = self.frame
예제 #2
0
파일: romapui.py 프로젝트: hotnix87/romap
def visualmap(Interface):
    if len(ips) > 25:
        globals()["network"] += "\nToo many nodes for network visualization\n"
        sys.exit()
    if net_map and len(ips) > 1:
        globals()["router"] = networkmap.router
        try:
            v["Image"].hidden = False
        except:
            pass
        v["close"].hidden = False
        networkmap.maps(ips, router, localip)
        v.add_subview(ui.ImageView(name="Image"))
        image = v["Image"]
        image.image = ui.Image.named("romap_visual.png")
        v["Image"].height = 218.8
        v["Image"].width = 318.8
        v["Image"].frame = (-90, 195, 489, 341)
    elif net_map:
        try:
            v["Image"].hidden = False
        except:
            pass
        v["close"].hidden = False
        v.add_subview(ui.ImageView(name="Image"))
        image = v["Image"]
        image.image = ui.Image.named("romap_visual.png")
        v["Image"].height = 218.8
        v["Image"].width = 318.8
        v["Image"].frame = (-90, 195, 489, 341)
예제 #3
0
    def draw(self):

        self.height = 40
        self.y = 40 * len(
            self.superview.subviews[:self.superview.subviews.
                                    index(self)]) + self.ydent * 40
        self.x = 0
        self.width = self.superview.width
        indent = 32 * self.level

        for s in self.subviews:
            self.remove_subview(s)

        self.arrow = ui.ImageView(frame=(indent, 4, 32, 32))
        self.arrow.image = self.arrowOpened if self.open else self.arrowClosed
        self.add_subview(self.arrow)

        self.folder = ui.ImageView(frame=(indent + 32, 4, 32, 32))
        self.folder.image = self.folderIcon
        self.add_subview(self.folder)

        self.text = ui.Label(frame=(indent + 75, 4, 300, 32))
        self.text.text = str(os.path.abspath(self.path)).split('/')[-1]
        self.text.font = ('AvenirNext-Light', 20)
        self.add_subview(self.text)

        maxscroll = max(x.y + 40 for x in self.superview.subviews)
        self.superview.content_size = (0, maxscroll)
예제 #4
0
	def __init__(self):
		self.width, self.height = ui.get_screen_size()
		#self.frame = (0, 0, 424, 736)
		self.background_color = 'orange'
		self.flex = 'WHLRTB'
		
		# Accomodate iPhone 6p and smaller phones as well
		if is_iP6p():
			self.tf1 = ui.TextField(frame = (20, 80, 380, 50))
			self.tf2 = ui.TextField(frame = (70, 180, 275, 50))
			self.lb1 = ui.Label(frame = (70, 35, 275, 50))
			self.lb2 = ui.Label(frame = (70, 135, 275, 50))
			self.iv = ui.ImageView(frame = (55, 270, 300, 300))
		else:
			self.tf1 = ui.TextField(frame = (20, 80, 280, 50))
			self.tf2 = ui.TextField(frame = (70, 180, 175, 50))
			self.lb1 = ui.Label(frame = (25, 35, 275, 50))
			self.lb2 = ui.Label(frame = (20, 135, 275, 50))
			self.iv = ui.ImageView(frame = (45, 235, 225, 225))
			
		self.tf1.bordered = False
		self.tf1.background_color = 'cyan'
		self.tf1.corner_radius = 10
		self.tf1.font = ('<system-bold>', 16)
		self.tf1.flex = "WHLRTB"
		self.tf1.clear_button_mode = 'while_editing'
		self.tf1.delegate = self
		
		self.tf2.bordered = False
		self.tf2.background_color = 'cyan'
		self.tf2.corner_radius = 10
		self.tf2.font = ('<system-bold>', 16)
		self.tf2.flex = 'WHLRTB'
		self.tf2.clear_button_mode = 'while_editing'
		self.tf2.keyboard_type = ui.KEYBOARD_NUMBER_PAD
		
		self.lb1.alignment = ui.ALIGN_CENTER
		self.lb1.text = 'Enter A Movie Or TV Series Title:'
		self.lb1.font = ('<system-bold>', 18)
		self.lb1.flex = 'WHLRTB'
		
		self.lb2.alignment = ui.ALIGN_CENTER
		self.lb2.text = 'Enter Year Of Release If Known:'
		self.lb2.font = ('<system-bold>', 18)
		self.lb2.flex = 'WHLRTB'
		
		# Gif file needs to be in the same directory as this script
		self.iv.image = ui.Image.named('thin_blue_line.gif')
		
		self.add_subview(self.tf1)
		self.add_subview(self.tf2)
		self.add_subview(self.lb1)
		self.add_subview(self.lb2)
		self.add_subview(self.iv)
예제 #5
0
    def __init__(self, folder='~/Documents/slideshow', keep=True, **kwargs):
        super().__init__(**kwargs)
        self.slide_delay = 5  # seconds
        self.label_display_time = 3  # seconds
        self.label_font = 'Source Sans Pro'
        self.transition = self.transition_slide_and_fade
        self.airplaying = False
        self.keep = keep
        self.target_strategy = self.quadrant_targets
        self.position_jigger = 10
        self.rotation_jigger = 3

        fix_set_idle_timer_disabled(True)

        self.quadrants = [0, 0, 0, 0]
        # Order: top-left, top-right, bottom-left, bottom-right

        self.screen_switch_lock = threading.Lock()

        self.photo_index = 0
        self.loaders = {}
        self.prev_album = None

        self.driver = onedriver.OneDriver(onedrive_ids.client_id,
                                          onedrive_ids.client_secret)

        self.folder = pathlib.Path(folder).expanduser()
        self.folder.mkdir(parents=True, exist_ok=True)

        self.status = ui.Label(
            text_color='white',
            alignment=ui.ALIGN_CENTER,
        )
        self.add_subview(self.status)

        self.display = ui.ImageView(
            frame=self.bounds,
            flex='WH',
        )
        self.add_subview(self.display)

        self.control = ui.View(
            frame=self.bounds,
            flex='WH',
        )
        self.add_subview(self.control)

        self.old = ui.ImageView(frame=self.bounds,
                                flex='WH',
                                content_mode=ui.CONTENT_SCALE_ASPECT_FIT)
        self.display.add_subview(self.old)
예제 #6
0
    def tableview_cell_for_row(self, tv, section, row):
        if section == self._folder_section:
            item = self.items[row]
            node = item['node']
        else:
            item = self._files[row]
            node = None

        cell = ui.TableViewCell()

        cvb = cell.content_view.bounds

        x = 15 + cvb.x + item['level'] * 15

        if node and node.children_exists:
            image_view = ui.ImageView()
            image_view.frame = (x, 10, 24, 24)
            image_view.image = ui.Image.named(
                'iob:arrow_down_b_24' if node.path in
                self._expanded_node_paths else 'iob:arrow_right_b_24')
            cell.content_view.add_subview(image_view)

        x += 24 + 8

        image_view = ui.ImageView()
        image_view.frame = (x, 10, 24, 24)
        image_view.image = ui.Image.named(
            'iob:folder_24' if node else 'iob:document_24')
        cell.content_view.add_subview(image_view)

        x += 24 + 8

        title_label = ui.Label(flex='W')
        title_label.text = item['title']
        title_label.size_to_fit()
        title_label.frame = (x,
                             cvb.y + (cvb.height - title_label.height) / 2.0,
                             cvb.width - (x - cvb.x) - 8, title_label.height)
        cell.content_view.add_subview(title_label)

        separator = ui.View(flex='W')
        separator.background_color = (0, 0, 0, 0.05)
        x = title_label.frame.x - 12 - 8
        separator.frame = (x, cvb.y + cvb.height - 1, cvb.width - (x - cvb.x),
                           1)
        cell.content_view.add_subview(separator)

        cell_objc = ObjCInstance(cell)
        cell_objc.setSelectionStyle(0)

        return cell
예제 #7
0
 def __init__(self, **kvargs):
     super().__init__(self, **kvargs)
     self.frame = (0, 0, 500, 500)
     self.wmin = 300
     self.hmin = 300
     iv = ui.ImageView()
     iv.image = ui.Image('iob:arrow_expand_24')
     iv.frame = (500 - 28, 500 - 28, 24, 24)
     iv.flex = 'LT'
     self.add_subview(iv)
     iv = ui.ImageView()
     iv.image = ui.Image('iob:ios7_circle_outline_32')
     iv.frame = (500 - 32, 500 - 32, 32, 32)
     iv.flex = 'LT'
     self.add_subview(iv)
예제 #8
0
        def __init__(self, frame=(100, 100, 600, 400), *args, **kwargs):
            """ clipping all beyond frame
			"""
            super().__init__(frame=frame, *args, **kwargs)
            #self.bounds = frame # internal coord, origin defaults to 0
            #self.background_color = 'white'
            self.bg_color = 'white'
            ivL = ui.ImageView(frame=(10, 10, 280, 280))
            print('iv.frame=%s iv.bounds=%s self.bounds=%s' %
                  (ivL.frame, ivL.bounds, self.bounds))
            self.add_subview(ivL)
            ivR = ui.ImageView(frame=(310, 10, 280, 280))
            self.add_subview(ivR)
            self.ctx1 = uiImage_context(ivL, user)
            self.ctx2 = uiImage_context(ivR, user.sub_frame(yofs=-0))
예제 #9
0
    def unimage(self, params):
        xratio = self.screen_size[0] / 800.0
        yratio = self.screen_size[1] / 600.0
        self.unimages.append([])
        if self.kivy:
            from kivy.uix.image import Image

            self.unimages[len(self.unimages) - 1] = Image(
                source=params[4],
                allow_stretch=True,
                size_hint=(None, None),
                size=(params[2] * xratio, params[3] * yratio),
                pos=(params[0] * xratio, params[1] * yratio))

            self.root.add_widget(self.unimages[len(self.unitexts) - 1])

        else:
            import ui

            self.unimages[len(self.unimages) - 1] = (ui.ImageView
            (name = 'Image', frame = (params[0] * xratio, \
            (600 - params[1] - params[3]) * yratio, \
            params[2] * xratio, params[3] * yratio)))

            self.root.add_subview(self.unimages[len(self.unimages) - 1])

            self.unimages[len(self.unitexts) - 1].image = ui.Image.named(
                params[4])
 def __init__(self, image_mask = None, *args, **kwargs):
     ui.View.__init__(self, *args, **kwargs)      
     self.iv = ui.ImageView()
     self.iv.image = ui.Image('test:Mandrill')
     self.iv.frame = self.bounds
     self.add_subview(self.iv)
     self.add_subview(image_mask)
예제 #11
0
    def __init__(self,
                 path,
                 finished_handler,
                 frame=(0, 0, 500, 500),
                 background_color=(1.0, 1.0, 1.0)):
        self.background_color = background_color
        self.frame = frame
        self.scroll = ui.ScrollView(frame=(0, 0, self.width, self.height))
        self.scroll.delegate = SVDelegate()
        self.scroll.add_subview(DropDown(path, 0))
        self.add_subview(self.scroll)

        self.selectedIndex = None
        self.finished_handler = finished_handler

        self.selectIcon = ui.Image.named('iob:ios7_checkmark_empty_256')

        self.checkscroll = ui.ScrollView(frame=(0, 0, self.width, self.height))
        self.checkscroll.touch_enabled = 0
        self.add_subview(self.checkscroll)

        self.check = ui.ImageView(frame=(self.width - 32, 0, 32, 32))
        self.check.image = self.selectIcon
        self.check.hidden = 1
        self.checkscroll.add_subview(self.check)
예제 #12
0
 def __init__(self, frame, colorName, using, colorHex=None):
     if colorName == "yellow" or colorName == "lightgrey":
         self.dark = True
     else:
         self.dark = False
     self.name = colorName
     self.colorName = colorName
     self.frame = frame
     self.background_color = self.colorName
     self.using = using
     if self.using == True:
         self.checkmark = ui.ImageView()
         if self.dark == True:
             self.checkmark.image = ui.Image('iob:checkmark_32')
         else:
             self.checkmark.image = ui.Image('iow:checkmark_32')
         self.checkmark.frame = (105, 60, 40, 40)
         self.add_subview(self.checkmark)
     self.nameLabel = ui.Label()
     self.nameLabel.text = "   " + self.colorName
     self.nameLabel.frame = (0, self.frame[3] - 40, self.frame[2], 40)
     if self.colorName == "lightgrey" or self.colorName == "yellow":
         self.nameLabel.text_color = "black"
     else:
         self.nameLabel.text_color = "white"
     self.add_subview(self.nameLabel)
예제 #13
0
    def __init__(self, *args, **kwargs):
        PinchView.__init__(self, *args, **kwargs)
        # prevent resize from causing redraw until we r ready
        self.ready = threading.Lock()
        #self.ready.acquire()

        self.img_view = ui.ImageView(frame=self.bounds, flex='WH')
        self.add_subview(self.img_view)
        self.b = io.BytesIO()

        #store base xlim and ylim, only update when drag ends
        self.xlim = plt.xlim()
        self.ylim = plt.ylim()
        self.centroid = tuple(self.center)  # zoom center

        # fast and slow dpi..
        self.high_dpi = 72.0
        self.low_dpi = 16
        # set output image size to match view size.  this probably should be modified to use actual device dpi and size.  fonts and line width are based on pts, not pixels
        plt.gcf().set_size_inches(self.width / self.high_dpi,
                                  self.height / self.high_dpi)
        #update plot, ensuring update really happens
        self.update_plt(dpi=self.high_dpi, waitForLock=True)

        ObjCInstance(self).becomeFirstResponder()
예제 #14
0
    def __init__(self, x, y, width=200, height=200):
        global sketch, mv
        # the sketch region
        self.bg_color = 'lightgrey'
        iv = ui.ImageView(
            frame=(0, 0, width,
                   height))  #, border_width=1, border_color='black')
        pv = PathView(iv.bounds)
        pv.action = self.path_action
        self.add_subview(iv)
        self.add_subview(pv)
        self.image_view = iv
        self.bounds = iv.bounds
        self.x = x
        self.y = y
        mv.add_subview(self)

        # some info
        lb = ui.Label()
        self.text = 'sample ' + str(len(sketch))
        lb.text = self.text
        lb.flex = ''
        lb.x = x + 50
        lb.y = y + 205
        lb.widht = 100
        lb.height = 20
        lb.alignment = ui.ALIGN_CENTER
        mv.add_subview(lb)
        self.label = lb
예제 #15
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.imageview = ui.ImageView(frame=self.bounds,
                                      flex='WH',
                                      content_mode=ui.CONTENT_SCALE_ASPECT_FIT)
        self.add_subview(self.imageview)

        self.camera_button = ui.ButtonItem(tint_color='black',
                                           image=SymbolImage('camera',
                                                             8,
                                                             weight=THIN),
                                           action=partial(
                                               self.get_photo_action,
                                               picker_camera))
        self.photos_button = ui.ButtonItem(
            tint_color='black',
            image=SymbolImage('photo.on.rectangle', 8, weight=THIN),
            action=partial(self.get_photo_action, picker_photos))
        self.copy_button = ui.ButtonItem(tint_color='black',
                                         title='Copy',
                                         enabled=False,
                                         action=self.copy_action)
        self.share_button = ui.ButtonItem(tint_color='black',
                                          title='Share',
                                          enabled=False,
                                          action=self.share_action)

        self.left_button_items = [
            self.copy_button,
            self.share_button,
        ]
        self.right_button_items = [
            self.camera_button,
            self.photos_button,
        ]
예제 #16
0
	def tableview_cell_for_row(self, tableview, section, row):
		id = book_lists_list[row]
		item = book_lists_data[id]
		
		cell = ui.TableViewCell()
		cell.bg_color = INFO_STYLE
		
		cover = ui.ImageView()
		cover.frame = (10,20,40,60)
		cover.load_from_url(cover_url_encode(item['cover']))
		
		title = ui.Label()
		title.frame = (60,8,305,18)
		title.font = ('<System-Bold>',16)
		title.text_color = SYSTEM_STYLE
		title.text = item['title']
		
		
		desc = ui.Label()
		desc.frame = (60,24,305,56)
		desc.number_of_lines = 0
		desc.font = ('<System>',12)
		desc.text_color = '#6e6e6e'
		desc.text = '作者:{author}\n简介:{desc}'.format(**item)
		
		info = ui.Label()
		info.frame = (60,80,305,12)
		info.font = ('<System>',12)
		info.text_color = 'red'
		info.text = '共{bookCount}本书  |  {collectorCount}人收藏'.format(**item)
		cell.content_view.add_subview(cover)
		cell.content_view.add_subview(title)
		cell.content_view.add_subview(desc)
		cell.content_view.add_subview(info)
		return cell
예제 #17
0
	def tableview_cell_for_row(self, tableview, section, row):
		style = style_list[row]
		cell = ui.TableViewCell()
		cell.bg_color = style_data[style]
		cell.border_width = 0.3
		cell.border_color = 'white'
		
		cell_selected_icon = ui.ImageView()
		cell_selected_icon.image = ui.Image.named('iow:checkmark_round_24')
		cell_selected_icon.frame = (30,15,20,20)
		
		cell_bg = ui.View()
		cell_bg.frame = (0,0,200,50)
		cell_bg.bg_color = style_data[style]
		cell_bg.corner_radius = 6
		
		cell_title = ui.Label()
		cell_title.frame = (0,0,200,50)
		cell_title.alignment = ui.ALIGN_CENTER
		cell_title.number_of_lines = 3
		cell_title.font = ('<System-Bold>',20)
		cell_title.text_color = 'white' if style_mode == 'system_theme' else 'black'
		cell_title.text = style
		cell.content_view.add_subview(cell_bg)
		cell.content_view.add_subview(cell_title)
		
		if style_data[style] == SYSTEM_STYLE or style_data[style] == READER_STYLE:
			cell.content_view.add_subview(cell_selected_icon)
		return cell
예제 #18
0
	def tableview_cell_for_row(self, tableview, section, row):
		self.book_id = bookcase_list[row]
		self.book_info = bookcase_data[self.book_id]
		cell = ui.TableViewCell('subtitle')
		cell.bg_color = INFO_STYLE
		cell.tint_color = SYSTEM_STYLE
		cell.detail_text_label.text_color = '#008923'
		cell.accessory_type = 'detail_button'
		
		cover = ui.ImageView()
		cover.frame = (15,10,45,60)
		img_path = path.join(BOOK_DATA_DIR,'.cache/{}.jpg'.format(self.book_id))
		
		cover.image = ui.Image.named(img_path)
		
		title = ui.Label()
		title.frame = (70,5,255,40)
		title.font = ('<System-Bold>',18)
		title.text = self.book_info['title']
		
		status = ui.Label()
		status.frame = (70,35,255,40)
		status.number_of_lines = 0
		status.font = ('<System>',16)
		status.text_color = '#44a179'
		status.number_of_lines = 2
		if 'update_data' in globals() and self.book_id in update_data:
			title.text_color = status.text_color = '#ff00d9'
			status.text = update_data[self.book_id]
		else:
			status.text = self.book_info['lastChapter']
		cell.content_view.add_subview(cover)
		cell.content_view.add_subview(title)
		cell.content_view.add_subview(status)
		return cell
예제 #19
0
	def __init__ (self,mode):
		self.mode = mode
		self.name = 'sourceview'
		self.bg_color = 'white'
		self.corner_radius = 15
		self.border_width = 1
		self.border_color = SYSTEM_STYLE
		
		self.close = ui.ImageView()
		self.close.image = ui.Image.named('iob:close_round_24')
		self.close.frame = (115,260,30,30)

		self.table = ui.TableView()
		self.table.frame = (0,0,250,350)
		self.table.row_height = 50
		self.table.shows_vertical_scroll_indicator = False
		self.table.bg_color = 'white'
		self.table.data_source = BookSourceDataSource(self.mode)
		self.table.delegate = BookSourceDelegate()
		
		if self.mode == 'reader':
			self.frame = (w/2-250/2,h/2-350/2,250,350)
		elif self.mode == 'chapter':
			self.frame = (65,120,250,300)
			self.table.height = 250
			self.add_subview(self.close)
		self.add_subview(self.table)
예제 #20
0
def tableView_cellForRowAtIndexPath_(sel,cmd,tableView,indexPath):
	ip = ObjCInstance(indexPath)
	ds = ObjCInstance(sel)
	data = ds.data[ip.row()]
	tv = ObjCInstance(sel)
	cell = ui.TableViewCell('subtitle')
	cell.text_label.text = data['name']
	cell.detail_text_label.text = data['docsetname']
	cell.image_view.image = data['icon']
	cell.border_color = Theme_manager.currentTheme.borderColour
	cell.background_color = Theme_manager.currentTheme.backgroundColour
	cell.bg_color = Theme_manager.currentTheme.backgroundColour
	cell.tint_color = Theme_manager.currentTheme.tintColour
	cell.text_label.text_color = Theme_manager.currentTheme.textColour
	cell.detail_text_label.text_color = Theme_manager.currentTheme.subTextColour
	selectedBackgroundView = ui.View()
	selectedBackgroundView.background_color = Theme_manager.currentTheme.cellSelectionColour
	if not Theme_manager.currentTheme.showCellSelection:
		selectedBackgroundView.alpha = 0
	cell.selected_background_view = selectedBackgroundView
	iv = ui.ImageView()
	cell.content_view.add_subview(iv)
	iv.image = data['type'].icon
	iv.width = 15
	iv.height = 15
	iv.x = cell.content_view.width - (iv.width * 2)
	iv.y = (cell.content_view.height) / 2 - (iv.height)
	iv.flex = 'L'
	return ObjCInstance(cell).ptr
예제 #21
0
 def tableview_cell_for_row(self, tv, section, row):
     cell = ui.TableViewCell()
     entry = self.flat_entries[row]
     level = entry.level - 1
     image_view = ui.ImageView(frame=(44 + 20 * level, 5, 34, 34))
     label_x = 44 + 34 + 8 + 20 * level
     label_w = cell.content_view.bounds.w - label_x - 8
     label_frame = (label_x, 0, label_w, 44)
     label = ui.Label(frame=label_frame)
     label.font = ('<System>', 18)
     label.text = entry.title
     label.flex = 'W'
     cell.content_view.add_subview(label)
     if entry.leaf and not entry.enabled:
         label.text_color = '#999'
     cell.content_view.add_subview(image_view)
     if not entry.leaf:
         has_children = entry.expanded
         btn = ui.Button(image=ui.Image.named(
             'CollapseFolder' if has_children else 'ExpandFolder'))
         btn.frame = (20 * level, 0, 44, 44)
         btn.action = self.expand_dir_action
         cell.content_view.add_subview(btn)
     if entry.icon_name:
         image_view.image = ui.Image.named(entry.icon_name)
     else:
         image_view.image = None
     cell.selectable = entry.enabled
     return cell
예제 #22
0
    def __init__(self, x, y, w, h):
        global mv
        self.border_width = 1
        self.border_color = 'black'
        self.bg_color = 'lightgrey'
        self.frame = (x, y, w, h)
        iv = ui.ImageView(
            frame=(0, 0, w,
                   h))  # NB: subview x,y is relative to parent view!!!
        self.add_subview(iv)
        self.iv = iv
        self.x = x
        self.y = y
        self.w = w
        self.h = h
        mv.add_subview(self)

        # some info
        lb = ui.Label()
        lb.text = 'In the region below some information will be displayed later'
        lb.flex = ''
        lb.x = x
        lb.y = y - 30
        lb.width = w
        lb.height = 20
        lb.alignment = ui.ALIGN_CENTER
        mv.add_subview(lb)
        self.label = lb

        self.context = None
예제 #23
0
    def tableview_cell_for_row(self, tableview, section, row):
        entry = self.sections[self.section_indices[section]][row]

        cell = ui.TableViewCell('subtitle')
        cell.text_label.text = entry['title']

        if len(entry['item_author']) > 1:
            author = ' • by ' + entry['item_author']
        else:
            author = ''

        dt = parse_date(entry['dt']).strftime("%H:%M")

        cell.detail_text_label.text = entry['feed_title'] + \
            author + ' • ' + dt

        favicon = ui.ImageView(frame=(2, 10, 16, 16))
        favicon.image = ui.Image.from_data(
            base64.decodebytes(
                entry['feed_favicon'].partition('base64,')[2].encode('utf-8')),
            2)
        cell.content_view.add_subview(favicon)

        cell.text_label.number_of_lines = 0
        return cell
예제 #24
0
def displayCoins():
    global coinAmount
    global currentX
    global currentRow
    global questionCounter

    questionCounter -= 1
    totalCoins = random.randint(3, 10)

    for i in range(totalCoins):

        picture1 = ui.ImageView()
        value, coinImage = random.choice(list(coins.items()))

        coinAmount += value
        imageViewWidth = getCoinWidth(value)

        if currentX + imageViewWidth + gap > coinContainer.width:
            currentX = 0
            currentRow += 1

        coinY = currentRow * (rowHeight + gap)
        picture1.y = coinY
        picture1.x = currentX
        currentX += imageViewWidth + gap

        picture1.width = imageViewWidth
        picture1.height = imageViewWidth
        picture1.image = coinImage

        coinContainer.add_subview(picture1)
def build_pin(path):
    my_ui_image = ui.Image.named(path)
    dx, dy = 28, 86
    v = ui.View(frame=(0, 0, dx, dx), corner_radius=dx / 2)
    iv = ui.ImageView(frame=(0, 0, dx, dx))
    iv.image = my_ui_image
    v.add_subview(iv)
    with ui.ImageContext(dx, dx) as ctx:
        v.draw_snapshot()  # if circular cropped
        my_ui_image = ctx.get_image()
    # image with pin and its foot, coloured circle replaced by the photo)
    with ui.ImageContext(dx, dy) as ctx:
        foot = ui.Path.oval(dx / 2 - 2, dy / 2 - 1, 4, 2)
        ui.set_color((0, 0, 0, 1))
        foot.fill()
        pin = ui.Path.rounded_rect(dx / 2 - 1, dx / 2, 2, dy / 2 - dx / 2, 1)
        ui.set_color((0.6, 0.6, 0.6, 1))
        pin.fill()
        my_ui_image.draw(0, 0, dx, dx)
        my_ui_image = ctx.get_image()
    # circular image without foot not pin
    #d = 28
    #v = ui.View(frame=(0,0,d,d),corner_radius=d/2)
    #iv = ui.ImageView(frame=(0,0,d,d))
    #v.add_subview(iv)
    #iv.image = my_ui_image
    #with ui.ImageContext(d,d) as ctx:
    #	v.draw_snapshot()						# if circular cropped
    #	my_ui_image = ctx.get_image()
    return my_ui_image
예제 #26
0
def getIM(name):
    v = ui.View(frame=(200, 200, 300, 450))
    f = open("imageList.txt", "r")
    rfl = f.readlines()
    for i in rfl:
        j = i.strip("\n")
        j = j.split(":")
        if name in j[0]:
            try:
                j = j[1]
                im = photos.get_asset_with_local_id(j)

                img_view = ui.ImageView(frame=(2 + 1 * 25, 50, 250, 250),
                                        flex='wh')

                img_view.content_mode = ui.CONTENT_SCALE_ASPECT_FILL

                img_view.image = im.get_ui_image(size=(500, 500), crop=False)

                v.add_subview(img_view)
                v.present()
                #time.sleep(5)
                #v.remove_subview(img_view)
                break
            except:
                print("Sorry, i couldnt get that image")
                print(j)
                break
    else:
        print("Sorry, i couldnt get that image")
예제 #27
0
	def __init__(self,file=None, data=None):
		#create image view that fills this top level view.
		#  since this RoomAreaView is the one that gets presented, it will be resized automatically, so we want the imageview to stay tied to the full view size, so we use flex.  Also, the content mode is important to prevent the image from being squished
		iv=ui.ImageView(frame=self.bounds)
		iv.flex='wh'
		iv.content_mode=ui.CONTENT_SCALE_ASPECT_FIT
		self.add_subview(iv)
		# right now, read in file from constructor.  a future improvement would be to have a file menu to select an image, which sets the iv.image
		if file:
			iv.image=ui.Image.named(file)
		else:
			iv.image=ui.Image.from_data(data)
		iv.touch_enabled=False
		self.iv=iv
		# add the overlay. this is the touch sensitive 'drawing' layer, and store a refernce to it.  this is set to the same size as the imageview
		rv=RoomAreaOverlay(frame=self.bounds, flex='wh')
		self.add_subview(rv)
		self.rv=rv
		self.g=Gestures(delegate=rv)
		self.pinch=self.g.add_pinch(self,self.did_pinch)
		self.pan=self.g.add_pan(self,self.did_pan,2,2)
		self.pan1=self.g.add_pan(self.rv,self.rv.touch_movedn,1,1)
		self.tap=self.g.add_tap(self.rv, self.rv.touch_movedn,1,1)
		self.tap.requireGestureRecognizerToFail_(self.pinch)
		self.tap.requireGestureRecognizerToFail_(self.pan)
		self.prevscale=1
		self.curscale=1
		self.tr=(0,0)
		self.prevtr=(0,0)
		
		clear=ui.Button(title='clear')
		clear.action=rv.clear
		self.add_subview(clear)
예제 #28
0
    def __init__(self, image_mask=None, *args, **kwargs):
        ui.View.__init__(self, *args, **kwargs)

        self.iv = ui.ImageView()
        self.iv.image = ui.Image.from_data(photos.pick_image(raw_data=True))
        self.add_subview(self.iv)
        self.add_subview(image_mask)
예제 #29
0
def pickerView_viewForRow_forComponent_reusingView_(self, cmd, picker_view,
                                                    row, component, view_ptr):
    idx = row % len(assets)
    if (idx, component) in view_of_row:  # add V0.1
        #print('reuse',component,row,idx)					# test						# add V0.1
        view = view_of_row[(idx, component)]  # reuse view			# add V0.1
        view.setHidden_(False)  # not sure needed	# add V0.1
        return view.ptr  # add V0.1
    UIPickerView = ObjCInstance(picker_view)
    if view_ptr == None:
        #print(row, component)
        view = ObjCClass('UILabel').alloc().init()
        #view.text = str(row)+','+str(component)			# test only			# add V0.1
        iv = ui.ImageView()
        iv.frame = (0, 0, UIPickerView.myRowWidth, UIPickerView.myRowHeight)
        iv.content_mode = ui.CONTENT_SCALE_ASPECT_FIT
        if type(assets) is str:
            iv.image = emoji_to_image(assets[idx], w=iv.width, h=iv.height)
        else:
            iv.image = assets[idx].get_ui_image(size=(iv.width, iv.height))
        view.addSubview_(ObjCInstance(iv))
        view_of_row[(idx, component)] = view  # add V0.1
    else:
        view = ObjCInstance(view_ptr)
    return view.ptr
예제 #30
0
 def __init__(self, **kwargs):
     super().__init__()
     self.frame = kwargs.get('frame')
     image_file = kwargs.get('image_file')
     self.name = kwargs.get('name')
     self.action_prev = kwargs.get('action_prev')
     self.action_next = kwargs.get('action_next')
     image = ui.Image.named(image_file)
     w, h = image.size
     if os.path.splitext(image_file)[1].lower() != '.gif':
         self.imageview = ui.ImageView(
             frame=get_coordinate(0, 0, self.width, self.height, w, h),
             image=image,
             name='imageview'
             )
         self.add_subview(self.imageview)
     else:
         self.imageview = ui.ImageView(
             frame=get_coordinate(0, 0, self.width, self.height, w, h),
             name='imageview'
             )
         if w < self.width and h < self.height:
             v = ui.WebView(
                 background_color='white',
                 height=h,
                 touch_enabled=False,
                 width=w
                 )
             v.center=self.imageview.center
             line_flag = False
         else:
             v = ui.WebView(
                 background_color='white',
                 frame=get_coordinate(0, 0, self.width, self.height, w, h),
                 touch_enabled=False
                 )
             line_flag = True
         v.load_url(image_file)
         self.add_subview(v)
         if line_flag:
             self.add_subview(ui.ImageView(
                 background_color='white',
                 frame=(0, v.y + v.height - 1, self.width, 1)
                 ))
         self.add_subview(self.imageview)
     self.x_prev, self.y_prev, self.w_prev, self.h_prev = self['imageview'].frame
     self.x_orginal, self.y_orginal, self.w_orginal, self.h_orginal = self['imageview'].frame