Python ui.View() Examples
The following are 30
code examples of ui.View().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
ui
, or try the search function
.
Example #1
Source File: dropdown.py From pythonista-scripts with MIT License | 6 votes |
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)
Example #2
Source File: splitview.py From pythonista-scripts with MIT License | 6 votes |
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()
Example #3
Source File: multipanel.py From pythonista-scripts with MIT License | 6 votes |
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")
Example #4
Source File: MazeEditView.py From maze-cv with MIT License | 6 votes |
def makeButtons(self): buttonsize = int(self.height / CELLS_PER_ROW) self.startx = int(self.width / 2 - self.height / 2) rot=ui.Button(frame=(self.startx-2*buttonsize-10,10,2*buttonsize,2*buttonsize)) rot.image = ui.Image.named('ionicons-ios7-refresh-empty-256') rot.action = self.rotate rot.tint_color = 'black' self.add_subview(rot) self.buttonView = ui.View(frame=(self.startx, 0, buttonsize*16,buttonsize*16)) for x in range(CELLS_PER_ROW): for y in range(CELLS_PER_ROW): frame = (x*buttonsize, y*buttonsize, buttonsize, buttonsize) b = ui.Button(frame = frame) b.background_color = self.load[x,y] b.action = self.invert self.buttonView.add_subview(b) self.add_subview(self.buttonView)
Example #5
Source File: live_camera_view.py From pythonista-scripts with MIT License | 6 votes |
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()
Example #6
Source File: objcnew.py From pythonista-scripts with MIT License | 6 votes |
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
Example #7
Source File: autolayout.py From blackmamba with MIT License | 6 votes |
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
Example #8
Source File: autolayout.py From blackmamba with MIT License | 6 votes |
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
Example #9
Source File: dropdown.py From pythonista-scripts with MIT License | 6 votes |
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)
Example #10
Source File: easy_config.py From stash with MIT License | 6 votes |
def __init__(self): ui.View.__init__(self) self.background_color = "#ffffff" self.table = ui.TableView() self.table.delegate = self.table.data_source = self self.table.flex = "WH" self.add_subview(self.table) self.ai = ui.ActivityIndicator() self.ai.style = ui.ACTIVITY_INDICATOR_STYLE_WHITE_LARGE self.ai.hides_when_stopped = True self.ai.x = self.width / 2.0 - (self.ai.width / 2.0) self.ai.y = self.height / 2.0 - (self.ai.height / 2.0) self.ai.flex = "LRTB" self.ai.background_color = "#000000" self.ai.alpha = 0.7 self.ai.corner_radius = 5 self.add_subview(self.ai) self.subview_open = False self.cur_tf = None self.hide_kb_button = ui.ButtonItem( "Hide Keyboard", action=self.hide_keyboard, enabled=False, ) self.right_button_items = (self.hide_kb_button, )
Example #11
Source File: multipanel.py From pythonista-scripts with MIT License | 6 votes |
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")
Example #12
Source File: uidir.py From pythonista-scripts with MIT License | 5 votes |
def __init__(self,setter, base_dir = '.', *args, **kargs): self.table = ui.TableView(*args, **kargs) self.name=os.path.split(os.path.abspath(base_dir))[1] self.src = MyTableViewDataSource(setter, base_dir) self.table.data_source = self.src self.table.delegate = self.src self.table.flex = 'WHTBLR' self.setter=setter #self.view = ui.View(name = base_dir) self.background_color = 'white' self.add_subview(self.table)
Example #13
Source File: DashBoard.py From pythonista-scripts with MIT License | 5 votes |
def __init__(self, *args, **kwargs): ui.View.__init__(self, *args, **kwargs) self.header = None self.border_color = 'black' self.border_width = 2 self.corner_radius = 6
Example #14
Source File: BoxLayout.py From pythonista-scripts with MIT License | 5 votes |
def add_subview(self,subviews): if not hasattr(subviews,'__contains__'): subviews=[subviews] _hidden=self.hidden self.hidden=True for s in subviews: self.originalSizes.append(s.frame[2:]) print 'bf add' ui.View.add_subview(self,s) self.hidden=_hidden #self.originalSizes.append(s.frame[2:]) print 'bf lay' self.layout()
Example #15
Source File: mazecraze.py From pythonista-scripts with MIT License | 5 votes |
def __init__(self): ui.View.__init__(self) self.tv = None self.difficulty = 1 self.starting = True
Example #16
Source File: BoxLayout.py From pythonista-scripts with MIT License | 5 votes |
def add_subview(self,subviews): if not hasattr(subviews,'__contains__'): subviews=[subviews] for s in subviews: self.originalSizes.append(s.frame[2:3]) ui.View.add_subview(self,s) self.layout()
Example #17
Source File: VerticalSlider.py From pythonista-scripts with MIT License | 5 votes |
def layout(self): '''force internal slider to follow this Views width/height''' s=self.slider s.height,s.width=self.height,self.width # s.x=s.y=0 # i thought this might be needed, but it seems not to be. # we want various View parameters to masquerade as the internal slider's. # the importand ones seem to be # tint_color, bg_color, action, continuous, value # though a few others like alpha, borderparameters, etc might be needed # if you plan on modifying from within the action
Example #18
Source File: AdvancedTextView.py From pythonista-scripts with MIT License | 5 votes |
def __init__(self, frame=(0, 0, 600, 400), **kwargs): self._undo = UndoStack() self._tv = ui.TextView(frame=(0,0,self.width,self.height),bg_color=(1.0,1.0,1.0)) self._tv.flex='WH' self.add_subview(self._tv) ui.View.__init__(self,**kwargs) #ui props self.frame=frame self._tv.delegate = self
Example #19
Source File: PopupButton.py From pythonista-scripts with MIT License | 5 votes |
def add_subview(self,subview): #override add_subview to add to longtapbox ui.View.add_subview(self.flow,subview)
Example #20
Source File: SPLView11.py From pythonista-scripts with MIT License | 5 votes |
def __init__(self, N_onscreen=700,*args, **kwargs): ui.View.__init__(self,*args,**kwargs) # ready lock is used to protect calls to matplotlib self.ready=threading.Lock() #set up zoomable sliders self.hslider=ZoomSlider(frame=(self.width*0.08,0,self.width*0.84,self.height*0.08),vert=0,flex='wt') self.vslider=ZoomSlider(frame=(0,self.height*0.08,self.width*0.08,self.height*0.84),vert=1,flex='hr') self.add_subview(self.hslider) self.add_subview(self.vslider) self.hslider.barvalue=0.125 self.hslider.barwidth=0.25 self.vslider.barvalue=0.5 self.vslider.barwidth=1.0 self.hslider.action=self.did_slide self.vslider.action=self.did_slide #matplotlib image output self.img_view = ui.ImageView(frame=[self.width*0.08,self.height*0.08,self.width*0.84,self.height*0.84],flex='WH',bg_color=(1,1,1)) self.add_subview(self.img_view) # image buffer self.b = io.BytesIO() #store base xlim and ylim, only update when drag ends self.xlim=plt.xlim() self.ylim=plt.ylim() self.N_onscreen=N_onscreen # number of points onscreen # fast and slow dpi.. set low_dpi to lower number for snappier response self.high_dpi=92 self.low_dpi=16. self.device_dpi=72 # 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.img_view.width/self.device_dpi,self.img_view.height/self.device_dpi) #update plot, ensuring update really happens #self.update_plt(dpi=self.high_dpi, waitForLock=True) #ObjCInstance(self).becomeFirstResponder()
Example #21
Source File: SkChessView.py From pythonista-scripts with MIT License | 5 votes |
def make_board_scene(self, center_frame): board_scene = SkChessBoardScene(self.game, center_frame) scene_view = sk.View(board_scene) scene_view.frame = center_frame # center_square() scene_view.shows_fps = True scene_view.shows_node_count = True scene_view.shows_physics = True return scene_view #@classmethod
Example #22
Source File: multipanel.py From pythonista-scripts with MIT License | 5 votes |
def __init__(self): # Init self.views = [] self.curview = None self.root = ui.View(name="Multipanel") self.close = ui.Button() self.close.name = "close" self.close.enabled = False self.close.image = ui.Image.named("ionicons-close-round-32") self.close.action = self.close_tapped self.root.add_subview(self.close) self.close.frame = self.root.width - 32, 0, 32, 32 self.close.flex = "LB" self.tabs = ui.SegmentedControl() self.tabs.name = "tabs" self.tabs.enabled = False self.tabs.selected_index = -1 self.tabs.segments = [PLACEHOLDER_TEXT] self.tabs.action = self.segment_changed self.root.add_subview(self.tabs) self.tabs.frame = 0, 0, self.root.width - self.close.width, self.tabs.height self.tabs.flex = "WB" self.placeholder = ui.View() self.placeholder.background_color = "lightgray" self.ph_label = ui.Label() self.ph_label.font = ("<system-bold>", 24) self.ph_label.text_color = "gray" self.ph_label.text = "No View Selected" self.placeholder.add_subview(self.ph_label) self.ph_label.size_to_fit() self.ph_label.center = self.placeholder.center self.ph_label.flex = "TBLR" self.update_view()
Example #23
Source File: KeyboardFrame.py From pythonista-scripts with MIT License | 5 votes |
def setupkb(self): #define keys redokey=key(title='redo',action=self.redoaction) undokey=key(title='undo',subkeys=[redokey], action=self.undoaction) hidekey=key(title='hide',action=self.hideaction) keymap=[key('\t',title='TAB'),key('_'),key('#',['@']),key('<',['<=']),key('>',['>=']), key('{'),key('}'),key('['),key(']'),key("'",['"']),key('('),key(')'), key(':',[';']), undokey]+[key(str(n)) for n in range(1,9)]+[key('0'),key('+',['%']),key('-'),key('/',['\\n','\\t','\\','/']),key('*'),key('=',['!=']), hidekey] #customkb component customkb=FlowContainer(frame=(0,self.height-100,self.width,100),flex='') customkb.name='customkb' self.add_subview(customkb) minimizedkb=ui.Button(frame=(0,self.height-15,self.width,15),flex='',bg_color=(.7, .7, .7)) minimizedkb.action=self.showaction minimizedkb.title=u'\u2550'*10 minimizedkb.name='minimizedkb' self.add_subview(minimizedkb) customkb.bring_to_front() customkb.hidden=True for k in keymap: customkb.add_subview(k.makeButton()) customkb.flex='WT' customkb.y=self.height-customkb.height #contentframe content=ui.View(frame=(0,0,self.width,self.height-15)) content.name='content' self.add_subview(content) content.send_to_back() content.border_color=(0,0,1) content.border_width=3 self.content=content
Example #24
Source File: ZoomSlider.py From pythonista-scripts with MIT License | 5 votes |
def __init__(self,vert=1,barwidth=0.25,barvalue=0.5,*args,**kwargs): self.bg_color=(0.9,.9,.9) ui.View.__init__(self,*args,**kwargs) self.vert=vert self.barwidth=barwidth self.barvalue=barvalue self.multitouch_enabled=True self.dragging=False self.touches={}
Example #25
Source File: MiniPhotoView.py From pythonista-scripts with MIT License | 5 votes |
def __init__(self): self.view = ui.View(background_color='lightyellow') self.view.name = 'MiniPhotoView' scrollview1 = ui.ScrollView() scrollview1.name = 'scrollview1' scrollview1.flex = 'WH' scrollview1.content_size = (2000,2000) self.view.add_subview(scrollview1) self.view.present('full_screen') self.sv1 = self.view['scrollview1'] width, height = self.sv1.content_size self.sv1.add_subview(MyPictureView(width,height))
Example #26
Source File: SpecialButton2.py From pythonista-scripts with MIT License | 5 votes |
def __init__(self): #self.view = ui.load_view('SpecialButton') self.view = ui.View() self.view.background_color = 'white' self.view.present('fullscreen') img = ui.Image.named('Girl') width,height = img.size img = None self.btn = MyButtonClass(100,100,width,height,'red') self.view.add_subview(self.btn)
Example #27
Source File: AreYouEnabledView.py From pythonista-scripts with MIT License | 5 votes |
def popover(self, msg): textview = ui.TextView() textview.editable = False textview.font = ('AmericanTypewriter', 24) textview.alignment = ui.ALIGN_CENTER textview.text = msg pov = ui.View() pov.width = textview.width = 222 pov.add_subview(textview) pov.present('popover') # in the .pyui file, the "Custom View Class" must be set to AreYouEnabledView
Example #28
Source File: MapView.py From pythonista-scripts with MIT License | 5 votes |
def __init__(self, *args, **kwargs): ui.View.__init__(self, *args, **kwargs) MKMapView = ObjCClass('MKMapView') frame = CGRect(CGPoint(0, 0), CGSize(self.width, self.height)) self.mk_map_view = MKMapView.alloc().initWithFrame_(frame) flex_width, flex_height = (1<<1), (1<<4) self.mk_map_view.setAutoresizingMask_(flex_width|flex_height) self_objc = ObjCInstance(self) self_objc.addSubview_(self.mk_map_view) self.mk_map_view.release()
Example #29
Source File: ToastView.py From pythonista-scripts with MIT License | 5 votes |
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)
Example #30
Source File: SPLView.py From pythonista-scripts with MIT License | 5 votes |
def __init__(self, *args, **kwargs): ui.View.__init__(self, *args, **kwargs) self.pinchgesture_recognizer_target = ui.Button() self.pinchgesture_recognizer_target.action = self.did_pinch self.pangesture_recognizer_target = ui.Button() self.pangesture_recognizer_target.action = self.did_pan self.gr_delegate=GRDelegate.alloc().init().autorelease() self.recognizers={} self_objc = ObjCInstance(self) pinchobjctarget=ObjCInstance(self.pinchgesture_recognizer_target) panobjctarget=ObjCInstance(self.pangesture_recognizer_target) pinchrecognizer = ObjCClass('UIPinchGestureRecognizer').alloc() self.recognizers['pinch'] = pinchrecognizer.initWithTarget_action_( pinchobjctarget, sel('invokeAction:')).autorelease() panrecognizer = ObjCClass('UIPanGestureRecognizer').alloc() self.recognizers['pan'] = panrecognizer.initWithTarget_action_( panobjctarget, sel('invokeAction:')).autorelease() self.recognizers['pan'].setMinimumNumberOfTouches_(2) for r in self.recognizers.values(): self_objc.addGestureRecognizer_(r) r.setDelegate_(self.gr_delegate) self.panx,self.pany,self.sx,self.sy=0,0,1,1 self.panx0,self.pany0,self.sx0,self.sy0=0,0,1,1