當前位置: 首頁>>代碼示例>>Python>>正文


Python ui.Button方法代碼示例

本文整理匯總了Python中ui.Button方法的典型用法代碼示例。如果您正苦於以下問題:Python ui.Button方法的具體用法?Python ui.Button怎麽用?Python ui.Button使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ui的用法示例。


在下文中一共展示了ui.Button方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import ui [as 別名]
# 或者: from ui import Button [as 別名]
def __init__(self, app, cell, category_name, tool_name, tool_url):
        self.app, self.cell = app, cell
        self.category_name, self.tool_name, self.tool_url = category_name, tool_name, tool_url

        self.btn = ui.Button()
        self.cell.content_view.add_subview(self.btn)
        self.btn.font = ('Helvetica', 12)
        self.btn.background_color = 'white'
        self.btn.border_width = 1
        self.btn.corner_radius = 5
        self.btn.size_to_fit()
        self.btn.width = 58
        self.btn.x = self.app.nav_view.width - self.btn.width - 8
        self.btn.y = (self.cell.height - self.btn.height) / 2

        if self.app.is_tool_installed(self.category_name, tool_name):
            self.set_state_uninstall()
        else:
            self.set_state_install() 
開發者ID:ywangd,項目名稱:pythonista-tools-installer,代碼行數:21,代碼來源:ptinstaller.py

示例2: makeButtons

# 需要導入模塊: import ui [as 別名]
# 或者: from ui import Button [as 別名]
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) 
開發者ID:controversial,項目名稱:maze-cv,代碼行數:22,代碼來源:MazeEditView.py

示例3: __init__

# 需要導入模塊: import ui [as 別名]
# 或者: from ui import Button [as 別名]
def __init__(self, lcd, phone, backfn, label = 'Weather'):  
        self.phone = phone
        super().__init__(lcd,backfn,label,ui.WHITE,ui.BLACK,ui.GREY)
        y = const(30)
        self.city = ui.Label(self,10,y-10,108,10,self.fg,self.bg,"City",1,1)
        self.weather = ui.Label(self,10,y,108,10,self.fg,self.bg,"Weather",1,0)
        self.icon = ui.Image(self,72,y+15,50,50,None)
        self.temperature = ui.Label(self,10,y+15,54,20,self.fg,self.bg,"Temp",3,1,False)
        self.humidity = ui.Label(self,10,y+35,54,10,self.fg,self.bg,"Humidity",1,0,False)
        self.pressure = ui.Label(self,10,y+45,54,10,self.fg,self.bg,"Pressure",1,0,False)
        self.wind = ui.Label(self,10,y+55,54,10,self.fg,self.bg,"Wind",1,0,False)
        self.sunrise = ui.Label(self,10,y+75,80,10,self.fg,self.bg,"Sunrise",1,0,False)
        self.sunset = ui.Label(self,10,y+85,80,10,self.fg,self.bg,"Sunset",1,0,False)
        self.location1  = ui.Button(self,0,135,30,20,self.fg,self.bb,'Lon')
        self.location1.callback(lambda x = 'GB/London': self.do_update(x))
        self.location2  = ui.Button(self,40,135,30,20,self.fg,self.bb,'Ros')
        self.location2.callback(lambda x = 'FR/Roscoff': self.do_update(x)) 
開發者ID:jeffmer,項目名稱:micropython-upyphone,代碼行數:19,代碼來源:upyapps.py

示例4: __init__

# 需要導入模塊: import ui [as 別名]
# 或者: from ui import Button [as 別名]
def __init__(self, elements, saveCallBack, addElementAction, saveFlowAction, runFlowAction, showElementRuntimeView, thememanager, flowType, flowTypeSelection):
		self.flowType = flowType
		self.elements = elements
		self.saveCallBack = saveCallBack
		self.flowTypeSelection = flowTypeSelection
		self.showElementRuntimeView = showElementRuntimeView
		self.extraRows = 2
		self.adminRow = 0
		self.typeRow = 1
		self.title = ''
		self.currentElementNumber = -1
		self.addElementButton = ui.ButtonItem(title = 'Add Element', action = addElementAction)
		self.saveFlowButton = ui.ButtonItem(title='Save', action=saveFlowAction)
		self.runFlowButton = ui.ButtonItem(title='Run', action=runFlowAction)
		self.titleButton = ui.Button(title='Change Title')
		self.editButtonsRight = [self.addElementButton]
		self.editButtonsLeft = [self.saveFlowButton]
		self.runButtonsRight = [self.runFlowButton]
		self.runButtonsLeft = []
		self.thememanager = thememanager 
開發者ID:khilnani,項目名稱:pythonista-scripts,代碼行數:22,代碼來源:FlowCreationView.py

示例5: create_new_window

# 需要導入模塊: import ui [as 別名]
# 或者: from ui import Button [as 別名]
def create_new_window(root,sender):
        v=ZoomView()
        v.bg_color=0.90, 0.90, 0.90
        v.border_color='grey'
        v.border_width=2
        v.x=random.randrange(75,300)
        v.y=random.randrange(75,300)
        v.width=v.height=300
        closebutton=ui.Button(frame=(250,0,50,50), bg_color='grey')
        closebutton.image=ui.Image.named('ionicons-close-round-32')
        closebutton.flex='bl'
        def closeview(sender):
            sender.superview.superview.remove_subview(sender.superview)
        closebutton.action=closeview
        tv=ui.TextView()
        tv.frame=(20,20,258,258)
        tv.flex='wh'
        v.add_subview(tv)
        v.add_subview(closebutton)
        root.add_subview(v) 
開發者ID:khilnani,項目名稱:pythonista-scripts,代碼行數:22,代碼來源:ZoomView.py

示例6: touch_ended

# 需要導入模塊: import ui [as 別名]
# 或者: from ui import Button [as 別名]
def touch_ended(self,touch):
        # dispatch whatever is under the touch
        # for multitouch probably only want to execute when there are no active touches left.
        # this method would need to clean out touches, but still keep info on the active gesture.  when there are no active touches left, then kill the gesture
        # for now.... just look under the touch, and call something appropriate.
        # need to handle each ui type!
        #print self.name, 'touch ended'
        for s in self.subviews:
            #probably need to check whether another view is on top...
            if TouchDispatcher.hit(s,ui.convert_point(touch.location,self,s)):
                if isinstance(s,ui.TextField):
                    #print '..textfield begin editing'
                    s.begin_editing()
                    #think about setting cursor.... HARD! but possible i think?
                elif isinstance(s, ui.Button):
                    #print '..button launch'
                    s.action(s)
                elif isinstance(s, TouchDispatcher):
                    # adjust touch location to subviews coordinates, then dispatch
                   # print '..touch end: dispatch: ', s.name
                    t=Touch(touch)
                    t.location=ui.convert_point(touch.location,self,s)
                    s.touch_ended(t) 
開發者ID:khilnani,項目名稱:pythonista-scripts,代碼行數:25,代碼來源:TouchDispatcher.py

示例7: addbut

# 需要導入模塊: import ui [as 別名]
# 或者: from ui import Button [as 別名]
def addbut(sender,toview):
        root=sender
        while root.superview:
            root=root.superview
        #add a button to parent view
        import random,string
        if root['switch'].value:
            w=random.randrange(30,110)
            h=random.randrange(20,75)
        else:
            w=40
            h=40
        title=string.ascii_letters[random.randint(0,26)]
        for v in toview:
            b=ui.Button(frame=(0,0,w,h),bg_color=(.8,.8,.8))
            b.border_width=1
            b.border_color=(0,0,0)
            b.corner_radius=10
            b.title=title
            b.action=lambda sender:addbut(sender,toview)
            v.add_subview(b) 
開發者ID:khilnani,項目名稱:pythonista-scripts,代碼行數:23,代碼來源:uicontainer.py

示例8: __init__

# 需要導入模塊: import ui [as 別名]
# 或者: from ui import Button [as 別名]
def __init__(self,frame=(0,0,300,32),name='dropdown', items=[]):
        '''Create a dropdown view, with items in list.
        items can be either an iterable, or a function returning an iterable.
        the function can be interrupted if it checks .abort(), which is set when user selects a row, for expensive ops like os.walk.
        pressing the dropdown button brings up the list, which can be aborted by selecting an item
        '''
        self.frame=frame
        self.textfield=ui.TextField(frame=frame,name='textfield')
        self.textfield.autocapitalization_type=ui.AUTOCAPITALIZE_NONE 
        self.textfield.autocorrection_type=False 
        self.button=ui.Button(name='button',bg_color=None)
        self.add_subview(self.textfield)
        self.add_subview(self.button)
        h=frame[3]
        self.button.frame=(self.width-32, h-32, 32,32)
        self.button.image=ui.Image.named('ionicons-arrow-down-b-32')
        self.button.action=self.open_finder
        
        self.base=os.path.expanduser('~/Documents')
        self._abort=False
        self.items=items
        self.button.flex='l'
        self.textfield.flex='w' 
開發者ID:khilnani,項目名稱:pythonista-scripts,代碼行數:25,代碼來源:dropdown.py

示例9: open_finder

# 需要導入模塊: import ui [as 別名]
# 或者: from ui import Button [as 別名]
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) 
開發者ID:khilnani,項目名稱:pythonista-scripts,代碼行數:26,代碼來源:dropdown.py

示例10: stop_populating

# 需要導入模塊: import ui [as 別名]
# 或者: from ui import Button [as 別名]
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) 
開發者ID:khilnani,項目名稱:pythonista-scripts,代碼行數:20,代碼來源:dropdown.py

示例11: __init__

# 需要導入模塊: import ui [as 別名]
# 或者: from ui import Button [as 別名]
def __init__(self, default_user_name='Name'):
        self.name = 'Enter your username:'
        self.background_color = 0.40, 0.80, 1.00
        self.frame=(0, 0, 500, 500)
        self.label = ui.Label(frame=(12, 100, 2000, 55))
        self.label.text = 'What is your name?'
        self.label.text_color = 'black'
        self.label.font = ('Avenir-Black', 55)
        self.add_subview(self.label)
        self.text_field = ui.TextField(frame=(155, 175, 200, 32))
        self.text_field.text = default_user_name
        self.text_field.text_color = 'grey'
        self.text_field.clear_button_mode = 'while_editing'
        self.add_subview(self.text_field)
        button = ui.Button(background_color='white',
                   frame=(360, 175, 75, 36),
                   image=ui.Image.named('ionicons-arrow-right-a-32'))
        self.add_subview(button) 
開發者ID:khilnani,項目名稱:pythonista-scripts,代碼行數:20,代碼來源:CloudJump2.py

示例12: open_dialog

# 需要導入模塊: import ui [as 別名]
# 或者: from ui import Button [as 別名]
def open_dialog(self,sender):
        # expand out a view/dialog from sender
        root=self.find_root(self.root)
        overlay=ui.Button(frame=(0,0)+tuple(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 
開發者ID:khilnani,項目名稱:pythonista-scripts,代碼行數:19,代碼來源:uidialog.py

示例13: make_button

# 需要導入模塊: import ui [as 別名]
# 或者: from ui import Button [as 別名]
def make_button(title, action):
    button = ui.Button(title=title)
    button.action = action
    button.background_color ='lightgrey'
    button.border_color = 'black'
    button.border_width = 1
    button.flex = 'WB'
    return button 
開發者ID:shaun-h,項目名稱:pythonista-youtubedl-downloader,代碼行數:10,代碼來源:Youtube-dl downloader.py

示例14: __init__

# 需要導入模塊: import ui [as 別名]
# 或者: from ui import Button [as 別名]
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() 
開發者ID:dgelessus,項目名稱:pythonista-scripts,代碼行數:41,代碼來源:multipanel.py

示例15: _vk_tapped

# 需要導入模塊: import ui [as 別名]
# 或者: from ui import Button [as 別名]
def _vk_tapped(self, sender):
        """
        Called when a key was tapped
        :param sender: sender of the event
        :type sender: ui.Button
        """
        # resolve key
        mapping = [
            # we can not use a dict here because ui.Button is unhashable
            # instead, we use a pair of (key, value) and apply a liner search
            # a binary search may be more efficient, but come on, this is definetly not required here
            (self.k_tab, K_TAB),
            (self.k_hist, K_HIST),
            (self.k_hup, K_HUP),
            (self.k_hdn, K_HDN),
            (self.k_CC, K_CC),
            (self.k_CD, K_CD),
            (self.k_CU, K_CU),
            (self.k_CZ, K_CZ),
            (self.k_KB, K_KB),
        ]
        key = None
        for k, v in mapping:
            if sender is k:
                key = v
        if key is None:
            raise ValueError("Unknown sender: " + repr(sender))
        
        # call action
        self.stash.user_action_proxy.vk_tapped(key)

# ObjC related stuff 
開發者ID:ywangd,項目名稱:stash,代碼行數:34,代碼來源:pythonista_ui.py


注:本文中的ui.Button方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。