python类View()的实例源码

DocsetView.py 文件源码 项目:PyDoc 作者: shaun-h 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def tableview_cell_for_row(self, tableview, section, row):
        cell = ui.TableViewCell()
        cell.border_color = self.theme_manager.currentTheme.tintColour
        cell.background_color = self.theme_manager.currentTheme.backgroundColour
        cell.bar_tint_color = self.theme_manager.currentTheme.toolbarBackgroundColour
        cell.bg_color = self.theme_manager.currentTheme.backgroundColour
        cell.tint_color = self.theme_manager.currentTheme.tintColour
        cell.title_color = self.theme_manager.currentTheme.tintColour
        cell.text_label.text_color = self.theme_manager.currentTheme.textColour
        cell.text_label.text = self.data[row].plural
        cell.accessory_type = 'disclosure_indicator'
        selectedBackgroundView = ui.View()
        selectedBackgroundView.background_color = self.theme_manager.currentTheme.cellSelectionColour
        if not self.theme_manager.currentTheme.showCellSelection:
            selectedBackgroundView.alpha = 0
        cell.selected_background_view = selectedBackgroundView
        if not self.data[row].icon == None:
            cell.image_view.image = self.data[row].icon
        return cell
SettingsView.py 文件源码 项目:PyDoc 作者: shaun-h 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def tableview_cell_for_row(self, tableview, section, row):
        cell = ui.TableViewCell()       
        cell.border_color = self.theme_manager.currentTheme.borderColour
        cell.background_color = self.theme_manager.currentTheme.backgroundColour
        cell.bg_color = self.theme_manager.currentTheme.backgroundColour
        cell.tint_color = self.theme_manager.currentTheme.tintColour
        cell.text_label.text_color = self.theme_manager.currentTheme.textColour
        selectedBackgroundView = ui.View()
        selectedBackgroundView.background_color = self.theme_manager.currentTheme.settingsCellSelectionColour
        if not self.theme_manager.currentTheme.showSettingsCellSelection:
            selectedBackgroundView.alpha = 0
        cell.selected_background_view = selectedBackgroundView
        if section == self.docset_section_number:
            cell.text_label.text = self.data[row]
            cell.accessory_type = 'disclosure_indicator'
        elif section == self.ack_section_number:
            cell.text_label.text = self.ack_data[row]['text']
        elif section == self.pydoc_updates_section_number:
            cell.text_label.text = self.updates_data[row]
        elif section == self.theme_section_number:
            cell.text_label.text = self.theme_data[row]
        elif section == self.websearch_section_number:
            cell.text_label.text = self.webSearch_data[row]
        return cell
DocsetIndexView.py 文件源码 项目:PyDoc 作者: shaun-h 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def tableview_cell_for_row(self, tableview, section, row):
        cell = ui.TableViewCell()
        cell.text_label.text = self.data[row]['name']
        cell.accessory_type = 'disclosure_indicator'
        cell.border_color = self.theme_manager.currentTheme.tintColour
        cell.background_color = self.theme_manager.currentTheme.backgroundColour
        cell.bar_tint_color = self.theme_manager.currentTheme.toolbarBackgroundColour
        cell.bg_color = self.theme_manager.currentTheme.backgroundColour
        cell.tint_color = self.theme_manager.currentTheme.tintColour
        cell.title_color = self.theme_manager.currentTheme.tintColour
        cell.text_label.text_color = self.theme_manager.currentTheme.textColour
        selectedBackgroundView = ui.View()
        selectedBackgroundView.background_color = self.theme_manager.currentTheme.cellSelectionColour
        if not self.theme_manager.currentTheme.showCellSelection:
            selectedBackgroundView.alpha = 0
        cell.selected_background_view = selectedBackgroundView      
        if not self.data[row]['type'].icon == None:
            cell.image_view.image = self.data[row]['type'].icon
        return cell
UISearchBarWrapper.py 文件源码 项目:PyDoc 作者: shaun-h 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __init__(self, tableView, filterData, *args, **kwargs):
        ui.View.__init__(self, *args, **kwargs)
        frame = CGRect(CGPoint(0, 0), CGSize(self.width, self.height))
        self.tv = tableView
        self.tableView = ObjCInstance(self.tv)
        flex_width, flex_height = (1<<1), (1<<4)
        self.tableView.setAutoresizingMask_(flex_width|flex_height)
        sd = createSearchDelegateClass()
        self.searchDelegate = sd.alloc().init().autorelease()
        self.searchDelegate.filt = filterData
        searchBar = UISearchBar.alloc().init()
        searchBar.setPlaceholder_(ns('Search'))
        searchBar.setDelegate_(self.searchDelegate)
        #searchBar.setShowsBookmarkButton_(ns(True))
        searchBar.setShowsCancelButton_(ns(True))
        #searchBar.setShowsSearchResultsButton_(ns(True))
        #searchBar.setScopeButtonTitles_(ns(['test1','hi']))
        #searchBar.setShowsScopeBar(ns(True))

        self.tableView.setTableHeaderView_(searchBar)
        searchBar.sizeToFit()

        self_objc = ObjCInstance(self)
        self_objc.addSubview_(self.tableView)
        self.tableView.release()
gap.py 文件源码 项目:GAP 作者: Tileyon 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def uniframe(self, params):
        if self.kivy:
            from kivy.graphics import Color
            from kivy.graphics import Rectangle
            self.root.canvas.add(Color (params[4][0],params[4][1], \
                params[4][2]))
            self.root.canvas.add(Rectangle(pos = (params[0] * self.xratio, \
                params[1] * self.yratio), size = (params[2] * self.xratio, \
                params[3] * self.yratio)))
        else:
            import ui
            self.uniframes.append([])
            self.uniframes[len(self.uniframes) - 1] = \
                ui.View(frame=(params[0] * self.xratio, \
                (600 - params[1] - params[3]) * self.yratio, \
                params[2] * self.xratio, params[3] * self.yratio))
            self.uniframes[len(self.uniframes) - 1].background_color = \
                (params[4][0],params[4][1], params[4][2],1.0)
            self.root.add_subview(self.uniframes[len(self.uniframes) - 1])
gap12.py 文件源码 项目:GAP 作者: Tileyon 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def uniframe(self, params):
        if self.kivy:
            from kivy.graphics import Color
            from kivy.graphics import Rectangle
            self.root.canvas.add(Color (params[4][0],params[4][1], \
                params[4][2]))
            self.root.canvas.add(Rectangle(pos = (params[0] * self.xratio, \
                params[1] * self.yratio), size = (params[2] * self.xratio, \
                params[3] * self.yratio)))
        else:
            import ui
            self.uniframes.append([])
            self.uniframes[len(self.uniframes) - 1] = \
                ui.View(frame=(params[0] * self.xratio, \
                (600 - params[1] - params[3]) * self.yratio, \
                params[2] * self.xratio, params[3] * self.yratio))
            self.uniframes[len(self.uniframes) - 1].background_color = \
                (params[4][0],params[4][1], params[4][2],1.0)
            self.root.add_subview(self.uniframes[len(self.uniframes) - 1])
gap21.py 文件源码 项目:GAP 作者: Tileyon 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def uniframe(self, params):
        if self.kivy:
            from kivy.graphics import Color
            from kivy.graphics import Rectangle
            self.root.canvas.add(Color (params[4][0],params[4][1], \
                params[4][2]))
            self.root.canvas.add(Rectangle(pos = (params[0] * self.xratio, \
                params[1] * self.yratio), size = (params[2] * self.xratio, \
                params[3] * self.yratio)))
        else:
            import ui
            self.uniframes.append([])
            self.uniframes[len(self.uniframes) - 1] = \
                ui.View(frame=(params[0] * self.xratio, \
                (600 - params[1] - params[3]) * self.yratio, \
                params[2] * self.xratio, params[3] * self.yratio))
            self.uniframes[len(self.uniframes) - 1].background_color = \
                (params[4][0],params[4][1], params[4][2],1.0)
            self.root.add_subview(self.uniframes[len(self.uniframes) - 1])
demo.py 文件源码 项目:ui2 作者: controversial 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def demo_ChainedAnimation():
    v = ui.View(frame=(0, 0, 500, 500), background_color="red")
    b = ui.View(frame=(100, 200, 100, 100), background_color="white")
    v.add_subview(b)

    def animation_a():
        b.x = 300

    def animation_b():
        b.x = 100

    a_anim = ui2.Animation(animation_a, 1, easing=ui2.ANIMATE_EASE_IN)
    b_anim = ui2.Animation(animation_b, 1, easing=ui2.ANIMATE_EASE_OUT)

    v.present("sheet", hide_title_bar=True)

    chain = ui2.ChainedAnimation(a_anim, b_anim, a_anim, b_anim, completion=_f)
    chain.play()
demo.py 文件源码 项目:ui2 作者: controversial 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def demo_ChainedTransition():
    v1 = ui.View(frame=(0, 0, 500, 500), background_color="pink")
    v1.add_subview(ui.Button(frame=(100, 100, 300, 20)))
    v1.subviews[0].title = "Hello! I'm a button"
    v1.add_subview(ui.Slider(frame=(100, 300, 100, 20)))
    v2 = ui.View(background_color="lightblue")
    v2.add_subview(ui.ImageView(frame=(100, 100, 300, 300)))
    v2.subviews[0].image = ui.Image.named('test:Peppers')
    v3 = ui.View(background_color="lightgreen")
    v3.add_subview(ui.Switch(frame=(100, 100, 20, 10)))
    v3.subviews[0].value = True

    t1 = ui2.Transition(v1, v2, ui2.TRANSITION_CURL_UP, 1.5)
    t2 = ui2.Transition(v2, v3, ui2.TRANSITION_FLIP_FROM_LEFT, 1)
    t3 = ui2.Transition(v3, v1, ui2.TRANSITION_CROSS_DISSOLVE, 1)

    v1.present("sheet", hide_title_bar=True)

    ui2.delay(ui2.ChainedTransition(t1, t2, t3).play, 1)
demo.py 文件源码 项目:ui2 作者: controversial 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def demo_BlurView():
    a = ui.View(frame=(0, 0, 500, 500))
    a.add_subview(ui.ImageView(frame=(0, 0, 500, 500)))
    a.subviews[0].image = ui.Image.named('test:Peppers')
    a.add_subview(ui2.BlurView())
    a.subviews[1].frame = (100, 100, 100, 100)
    a.present('sheet', hide_title_bar=True)

    toggle = ui2.Animation(a.subviews[1].toggle_brightness, 0.5)
    def movea():
        a.subviews[1].x = 300
    def moveb():
        a.subviews[1].y = 300
    def movec():
        a.subviews[1].x = 100
    def moved():
        a.subviews[1].y = 100
    movea = ui2.Animation(movea, 1)
    moveb = ui2.Animation(moveb, 1)
    movec = ui2.Animation(movec, 1)
    moved = ui2.Animation(moved, 1)
    ui2.ChainedAnimation(movea, moveb, movec, moved, toggle,
                         movea, moveb, movec, moved).play()
live_camera_view.py 文件源码 项目:pythonista-scripts 作者: khilnani 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __init__(self,device=1, *args, **kwargs):
      ui.View.__init__(self,*args,**kwargs)
      self._session=ObjCClass('AVCaptureSession').alloc().init()
      self._session.setSessionPreset_('AVCaptureSessionPresetHigh');
      inputDevices=ObjCClass('AVCaptureDevice').devices()
      self._inputDevice=inputDevices[device]

      deviceInput=ObjCClass('AVCaptureDeviceInput').deviceInputWithDevice_error_(self._inputDevice, None);
      if self._session.canAddInput_(deviceInput):
         self._session.addInput_(deviceInput)
      self._previewLayer=ObjCClass('AVCaptureVideoPreviewLayer').alloc().initWithSession_(self._session)
      self._previewLayer.setVideoGravity_( 
         'AVLayerVideoGravityResizeAspectFill')
      rootLayer=ObjCInstance(self).layer()
      rootLayer.setMasksToBounds_(True)
      self._previewLayer.setFrame_(
         CGRect(CGPoint(-70, 0), CGSize(self.height,self.height)))
      rootLayer.insertSublayer_atIndex_(self._previewLayer,0)
      self._session.startRunning()
objcnew.py 文件源码 项目:pythonista-scripts 作者: khilnani 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __new__(cls, ptr):
        # If there is already an instance that wraps this pointer, return the same object...
        # This makes it a little easier to put auxiliary data into the instance (e.g. to use in an ObjC callback)
        # Note however that a new instance may be created for the same underlying ObjC object if the last instance gets garbage-collected.
        if isinstance(ptr, ui.View):
            ptr = ptr._objc_ptr
        if isinstance(ptr, ObjCInstance):
            return ptr
        if isinstance(ptr, c_void_p):
            ptr = ptr.value
        cached_instance = _cached_instances.get(ptr)
        if cached_instance:
            return cached_instance
        objc_instance = super(ObjCInstance, cls).__new__(cls)
        _cached_instances[ptr] = objc_instance
        if isinstance(ptr, ui.View):
            ptr = ptr._objc_ptr
        objc_instance.ptr = ptr
        objc_instance._as_parameter_ = ptr
        objc_instance._cached_methods = weakref.WeakValueDictionary()
        objc_instance.weakrefs = weakref.WeakValueDictionary()
        if ptr:
            # Retain the ObjC object, so it doesn't get freed while a pointer to it exists:
            objc_instance.retain(restype=c_void_p, argtypes=[])
        return objc_instance
splitview.py 文件源码 项目:pythonista-scripts 作者: khilnani 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __init__(self,detailwidth=320-22,style='slide',delegate=None,mainview= None,detailview=None, initial_state=0,**kwargs):
        ui.View.__init__(self,**kwargs)
        self._sv=ui.ScrollView()
        self._sv.flex='wh'
        self._sv.frame=self.bounds
        self._sv.content_size=(self.bounds[2]+1,self.bounds[3])
        self._mainviewcontainer=ui.View()
        self._mainviewcontainer.frame=self.bounds
        self._detailviewcontainer=ui.View()
        self._detailviewcontainer.frame=self.bounds
        self.detailwidth = detailwidth
        self._detailviewcontainer.width=detailwidth
        self._detailviewcontainer.x=-detailwidth
        self._mainviewcontainer.flex='WH'
        self._detailviewcontainer.flex='H'
        self._mainview=None
        self._detailview=None
        self.delegate=delegate
        self._sv.delegate=self
        self._sv.add_subview(self._mainviewcontainer)
        self._sv.add_subview(self._detailviewcontainer)
        self.add_subview(self._sv)
        self.style='slide'# 'slide','resize'
        self.state=0 #1 when detail shown
        self._modify_gesture()
dropdown.py 文件源码 项目:pythonista-scripts 作者: khilnani 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 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)
ui_settings_storage.py 文件源码 项目:pythonista-scripts 作者: khilnani 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def createView():
        main=ui.View(frame=(0,0,576,576))
        subpanel=ui.View(frame=(0,330,576,246))
        subpanel2=ui.View(frame=(0,0,576,246))
        slider=ui.Slider(frame=(10,10,150,44),name='slider1')
        slider.stored=True
        switch1=ui.Switch(frame=(10,66,70,44),name='switch1')
        switch1.stored=True
        switch2=ui.Switch(frame=(90,66,70,44)) #no name
        switch2.stored=True
        switch3=ui.Switch(frame=(10,120,70,44),name='switch3') #not stored
        tf1=ui.TextField(frame=(10,180,250,50),name='textfield')
        tf1.stored=True
        main.add_subview(subpanel)
        subpanel.add_subview(slider)
        subpanel.add_subview(switch1)
        subpanel.add_subview(switch2)
        subpanel.add_subview(switch3)
        subpanel.add_subview(tf1)
        slider2=ui.Slider(frame=(10,10,150,44),name='slider1')
        slider2.stored=True
        subpanel2.add_subview(slider2)
        main.add_subview(subpanel2)
        return main
dropdown.py 文件源码 项目:pythonista-scripts 作者: khilnani 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 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)
multipanel.py 文件源码 项目:pythonista-scripts 作者: khilnani 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def init():
    # Monkey-patch the ui module to use Multipanel
    try:
        ui.view_real_present
    except AttributeError:
        ui.view_real_present = ui.View.present

    def present(self, mode, **kwargs):
        if mode == "panel":
            ui.multipanel.add_view(self)
        else:
            ui.view_real_present(self, mode, **kwargs)

    instancemethod = type(Multipanel.add_view)
    # ui.View is too builtin for us mere mortals to change its methods.
    ##ui.View.present = instancemethod(present, None, ui.View)

    ui.multipanel = Multipanel()
    ui.view_real_present(ui.multipanel.root, "panel")
autolayout.py 文件源码 项目:blackmamba 作者: zrzka 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def __init__(self, view, attribute, other=None, other_attribute=LayoutAttribute.notAnAttribute):
        assert(isinstance(view, LayoutProxy))
        assert(isinstance(attribute, LayoutAttribute))

        self._view = view
        self._attribute = attribute
        self._constraints = {}

        if other:
            assert(isinstance(other, ui.View))
            assert(isinstance(other_attribute, LayoutAttribute))

            self._other = other
            self._other_attribute = other_attribute
        else:
            self._other = None
            self._other_attribute = LayoutAttribute.notAnAttribute
autolayout.py 文件源码 项目:blackmamba 作者: zrzka 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def __init__(self, view):
        assert(isinstance(view, ui.View))

        self._view = view
        self.add_subview(self._view)

        self._view_objc = ObjCInstance(self._view)
        self._objc = ObjCInstance(self)

        self._view_objc.setTranslatesAutoresizingMaskIntoConstraints_(False)
        self._objc.setTranslatesAutoresizingMaskIntoConstraints_(False)

        attributes = [LayoutAttribute.left, LayoutAttribute.right, LayoutAttribute.top, LayoutAttribute.bottom]
        for attribute in attributes:
            constraint = _LayoutConstraint.constraintWithItem_attribute_relatedBy_toItem_attribute_multiplier_constant_(
                self._view_objc, int(attribute), int(LayoutRelation.equal), self._objc, int(attribute), 1.0, 0
            )
            self._objc.addConstraint_(constraint)

        self._layout = None
SebastianJarsve_webbrowser.py 文件源码 项目:py-search 作者: vieira-rafael 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def init_size(self): # initialize with correct size when landscape      orientation = ui.WebView(frame=(0,0,100,200)).eval_js('window.orientation') if orientation in (-90, 90): self.frame = (0, 0, self.height, self.width)
 def did_load(self): self.init_buttons() self.init_webbrowser() self.init_addressbar() self.init_size() self.flex = 'WH' self.bookmarks = self.load_bookmarks() self.history = self.load_history() self.addressbar_is_editing = False self.webpage_has_loaded = False self.favourite_images = {True :ui.Image.named('ionicons-ios7-star-32'), False:ui.Image.named('ionicons-ios7-star-outline-32')}
 def save_history(self, filename=filename_history): with open(filename, 'w') as f:          url = self.get_url() if url in self.history: self.history.remove(url) self.history.append(url)          f.seek(0)           pickle.dump(self.history, f)  def clear_history(self, sender, filename=filename_history): with open(filename, 'w') as f: self.history = []          f.seek(0)           pickle.dump(self.history, f)            sender.superview.superview['history'].data_source.items = self.history          sender.superview.superview['history'].reload()
 def save_bookmark(self, filename=filename_bookmarks): with open(filename, 'w') as f:           url = self.get_url()            title = self.get_title() or self.parse_url(url) self.bookmarks[title] = url         f.seek(0)           json.dump(self.bookmarks, f, indent=4) self['controlpanel']['favourite'].image = self.favourite_images[True]
 def remove_bookmark(self, title=None, filename=filename_bookmarks): with open(filename, 'w') as f:         title = title or self.get_title() del self.bookmarks[title]         f.seek(0)           json.dump(self.bookmarks, f, indent=4) self['controlpanel']['favourite'].image = self.favourite_images[False]
 def popup_menu(self):      popup = ui.View(name='menu', frame=(0, 0, 320, 500))        toolbar = ui.View(frame=(-5, 0, 330, 100), name='toolbar')      toolbar.border_width = 0.5      toolbar.border_color = '#B2B2B2'        label = ui.Label()      label.text = 'Bookmarks'        label.alignment = ui.ALIGN_CENTER       label.frame = (0, 0, 320, 50)       label.name = 'title'        segment_ctrl = ui.SegmentedControl(name='segctrl')      segment_ctrl.segments = ['Bookmarks', 'History']        segment_ctrl.width = 170        segment_ctrl.center = popup.center      segment_ctrl.y = label.height       segment_ctrl.selected_index = 0     segment_ctrl.action = self.bookmarks_or_history         button = ui.Button()        button.frame = (segment_ctrl.x*3.5, segment_ctrl.y, 60, 30)     button.font = ('<system>', 15)      button.title= 'Clear'       button.name = 'clear'       button.action = self.clear_history      button.hidden = True        toolbar.add_subview(label)      toolbar.add_subview(segment_ctrl)       toolbar.add_subview(button)         popup.add_subview(toolbar)      data_source = ui.ListDataSource(sorted(self.bookmarks.keys()))      popup.add_subview(self.list_bookmarks_and_history(data_source, width=320,height=toolbar.superview.height-toolbar.height, y=toolbar.height, name='bookmarks'))       x, y = self['controlpanel']['bookmarks'].center     popup.present('popover', popover_location=(x, y), hide_title_bar=True)
 def bookmarks_or_history(self, sender):        toolbar = sender.superview if sender.selected_index == 0:           toolbar['clear'].hidden = True          toolbar['title'].text = 'Bookmarks'         data_source = ui.ListDataSource(sorted(self.bookmarks.keys()))          tv = self.list_bookmarks_and_history(data_source, width=320, height=toolbar.superview.height-toolbar.height, y=toolbar.height, name='bookmarks')            toolbar.superview.remove_subview(toolbar.superview['history']) else:            toolbar['clear'].hidden = False             toolbar['title'].text = 'History'           data_source = ui.ListDataSource(self.history[::-1])         tv = self.list_bookmarks_and_history(data_source, width=320, height=toolbar.superview.height-toolbar.height, y=toolbar.height, name='history')          toolbar.superview['bookmarks'].hidden=True          toolbar.superview.remove_subview(toolbar.superview['bookmarks'])        sender.superview.superview.add_subview(tv)
 def list_bookmarks_and_history(self, data_source, **kwargs):       tv = ui.TableView()     tv.data_source = data_source        tv.delegate = self for k, v in kwargs.items(): setattr(tv, k, v) return tv
 def show_more_menu(self):      popup = ui.TableView()      popup.width = 250       popup.height = 500      popup.name = 'More'     popup.data_source = popup.delegate = self       button = self['controlpanel']['more']       popup.present('popover', popover_location=(button.x, button.y+button.height))
 def button_tapped(self, sender): if sender.name == 'favourite': if self.get_url() in self.bookmarks.values(): self.remove_bookmark() else: self.save_bookmark() elif sender.name == 'bookmarks': self.popup_menu() elif sender.name == 'more': self.show_more_menu() else: eval("self['webview'].{}()".format(sender.name))
 def tableview_number_of_rows(self, tableview, section): if tableview.name == 'Bookmarks': return len(self.bookmarks) elif tableview.name == 'More': return 1
 def tableview_cell_for_row(self, tableview, section, row): if tableview.name == 'Bookmarks':           cell = ui.TableViewCell()           cell.text_label.text = sorted(self.bookmarks.keys())[row]           cell.image_view.image = ui.Image.named('ionicons-ios7-bookmarks-outline-32')            cell.image_view.tint_color = '#66CCFF' return cell elif tableview.name == 'More':           cell = ui.TableViewCell()           cell.text_label.text = 'Settings'           cell.image_view.image = ui.Image.named('ionicons-wrench-32') return cell
 @ui.in_background def tableview_did_select(self, tableview, section, row): if tableview.name == 'bookmarks':           url = self.bookmarks[sorted(self.bookmarks.keys())[row]] self.load_url(url)         tableview.superview.close() elif tableview.name == 'history':           url = tableview.data_source.items[row]          tableview.superview.close() self.load_url(url) elif tableview.name == 'More':           tableview.close()           console.hud_alert('No settings yet...', 'error', 1)
 def tableview_can_delete(self, tableview, section, row): return True
 def tableview_delete(self, tableview, section, row):       item = sorted(self.bookmarks.keys())[row] self.remove_bookmark(item)        tableview.reload()
 def textfield_did_begin_editing(self, textfield): self.addressbar_is_editing = True self.set_url() self['controlpanel']['reload'].hidden = True
 def textfield_did_end_editing(self, textfield): self.addressbar_is_editing = False self['controlpanel']['reload'].hidden = False self.set_url()
 def textfield_should_return(self, textfield):      url = self['controlpanel']['addressbar'].text self.load_url(url)        textfield.end_editing() return True
 def webview_did_start_load(self, webview): self.webpage_has_loaded = False
 def webview_did_finish_load(self, webview): if not self.addressbar_is_editing: self.set_url() self.webpage_has_loaded = True       page_is_bookmarked = unicode(self.get_url()) in self.bookmarks.values() self['controlpanel']['favourite'].image = self.favourite_images[page_is_bookmarked] self.save_history()
caves.py 文件源码 项目:caves 作者: mikaelho 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def create_play_menu(self):
    play_menu = ui.View(frame=self.bg.bounds)
    self.bg.add_subview(play_menu)
    buttons = [
      [ 'iow:close_round_24', self.quit_game ],
      [ 'iow:arrow_right_b_32', self.next_turn ]
    ]
    return self.setup_bottom_menu(buttons)
gap12.py 文件源码 项目:GAP 作者: Tileyon 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def close(self):
        ui.View.close(self)
gap21.py 文件源码 项目:GAP 作者: Tileyon 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def close(self):
        ui.View.close(self)
test.py 文件源码 项目:ui2 作者: controversial 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_Generic(self):
        """ Test all generic attributes of any ui.View class """
        a = ui.View()
        # Store attributes
        a.background_color = "#ff00ff"
        # Encode + decode
        b = ui._view_from_dict(ui2.ui_io._view_to_dict(a), globals(), locals())
        # Check that type and attributes were preserved
        self.assertIsInstance(b, type(a))
        self.assertEqual(a.background_color, b.background_color)
__init__.py 文件源码 项目:ui2 作者: controversial 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def subclassable(view_type):
    """Return an inheritable version of an uninheritable ui.View class."""
    class ViewWrapper(ViewClassWrapper):
        def __init__(self, *args, **kwargs):
            super().__init__(view_type, *args, **kwargs)
    return ViewWrapper
demo.py 文件源码 项目:ui2 作者: controversial 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 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)
demo.py 文件源码 项目:ui2 作者: controversial 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def demo_ProgressPathView():
    import math
    import random

    p = ui.Path()
    p.move_to(20, 20)
    p.line_to(480, 20)
    p.line_to(480, 250)
    p.add_arc(250, 250, 230, 0, math.radians(110))
    p.add_curve(50, 450, 20, 250, 480, 250)
    p.close()  # This makes the end look nicer

    ppv = ui2.ProgressPathView(p)

    view = ui.View(background_color="white")
    view.add_subview(ppv)
    view.width = view.height = ppv.width = ppv.height = 500
    view.present("sheet", hide_title_bar=True)

    def advance():
        """Advance by a random amount and repeat."""
        pg = ppv.progress + random.random() / 20
        if pg < 1:
            ppv.progress = pg
            ui.delay(advance, random.random() / 2)
        else:
            ppv.progress = 1

    advance()
demo.py 文件源码 项目:ui2 作者: controversial 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def demo_Transition():
    v1 = ui.View(frame=(0, 0, 500, 500), background_color="red")
    v2 = ui.View(background_color="blue")
    v1.present('sheet', hide_title_bar=True)
    ui2.transition(v1, v2, ui2.TRANSITION_CURL_UP, 1.5, _f)
c64_painter.py 文件源码 项目:Pythonista-C64-Painter 作者: superrune 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def choose_color(self, sender):
        if sender.name in self.color:
            self.color[sender.name] = sender.value
            self.set_color()
        elif sender in self['palette'].subviews:
            self.set_color(sender.background_color)
        elif sender.name == 'color_input':
            try:
                c = sender.text if sender.text.startswith('#') else eval(sender.text)
                v = ui.View(background_color=c)
                self['color_input'].text = str(v.background_color)
                self.set_color(v.background_color)
            except Exception as e:
                console.hud_alert('Invalid Color', 'error')
Shield.py 文件源码 项目:ccMVC 作者: polymerchm 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self,view,tint=(1.0, 1.0, 1.0),alpha=0.7,name=None,local=False): # view is view to cover
        self.view = view
        shieldName = name if name else 'shield'
        self.shield = ui.View(frame=view.frame,background_color=tint,flex='WH',name=shieldName)
        self.shield.alpha = alpha
        self._frame = self.shield.frame
        self._position = (tuple(self._frame)[:2])
        if local:
            self.view.add_subview(self.shield)
        else:
            self.view.superview.add_subview(self.shield)
        self.shield.send_to_back()
        self.shield.hidden = True
        self.status = False


问题


面经


文章

微信
公众号

扫码关注公众号