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


Python widget.Widget方法代碼示例

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


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

示例1: program_run

# 需要導入模塊: from kivy.uix import widget [as 別名]
# 或者: from kivy.uix.widget import Widget [as 別名]
def program_run(self, index, button):
        """Loads the currently viewed photo in an external program using an external program preset.
        Argument:
            index: Integer, index of the preset to use.
            button: Widget, the button that called this function.
        """

        name, command, argument = self.programs[index]
        if os.path.isfile(command):
            button.disabled = True  # Disable the button so the user knows something is happening
            photo_info = self.database_exists(self.fullpath)
            if photo_info:
                photo_file = os.path.join(photo_info[2], photo_info[0])
                abs_photo = os.path.abspath(photo_file)
                argument_replace = argument.replace('%i', '"'+abs_photo+'"')
                argument_replace = argument_replace.replace('%%', '%')

                run_command = command+' '+argument_replace
                Clock.schedule_once(lambda *dt: self.program_run_finish(run_command, photo_info, button))
        else:
            self.popup_message(text='Not A Valid Program') 
開發者ID:snuq,項目名稱:Snu-Photo-Manager,代碼行數:23,代碼來源:main.py

示例2: new_description

# 需要導入模塊: from kivy.uix import widget [as 別名]
# 或者: from kivy.uix.widget import Widget [as 別名]
def new_description(self, description_editor, root):
        """Update the description of a folder or album.
        Arguments:
            description_editor: Widget, the text input object that was edited.
            root: The screen that owns the text input widget.  Has information about the folder or album being edited.
        """

        if not description_editor.focus:
            folder = root.selected
            description = description_editor.text
            if root.type == 'Folder':
                self.database_folder_update_description(folder, description)
                self.folders.commit()
                self.update_photoinfo(folders=[folder])
            elif root.type == 'Album':
                index = self.album_find(folder)
                if index >= 0:
                    self.album_update_description(index, description) 
開發者ID:snuq,項目名稱:Snu-Photo-Manager,代碼行數:20,代碼來源:main.py

示例3: new_title

# 需要導入模塊: from kivy.uix import widget [as 別名]
# 或者: from kivy.uix.widget import Widget [as 別名]
def new_title(self, title_editor, root):
        """Update the title of a folder or album.
        Arguments:
            title_editor: Widget, the text input object that was edited.
            root: The screen that owns the text input widget.  Has information about the folder or album being edited.
        """

        if not title_editor.focus:
            folder = root.selected
            title = title_editor.text
            if root.type == 'Folder':
                self.database_folder_update_title(folder, title)
                self.folders.commit()
                self.update_photoinfo(folders=[folder])
                root.update_folders = True
                root.update_treeview() 
開發者ID:snuq,項目名稱:Snu-Photo-Manager,代碼行數:18,代碼來源:main.py

示例4: create_inspector

# 需要導入模塊: from kivy.uix import widget [as 別名]
# 或者: from kivy.uix.widget import Widget [as 別名]
def create_inspector(win, ctx, *l):
    '''Create an Inspector instance attached to the *ctx* and bound to the
    Windows :meth:`~kivy.core.window.WindowBase.on_keyboard` event for capturing
    the keyboard shortcut.

        :Parameters:
            `win`: A :class:`Window <kivy.core.window.WindowBase>`
                The application Window to bind to.
            `ctx`: A :class:`~kivy.uix.widget.Widget` or subclass
                The Widget to be inspected.

    '''
    # Dunno why, but if we are creating inspector within the start(), no lang
    # rules are applied.
    ctx.inspector = Inspector(win=win)
    win.bind(children=ctx.inspector.on_window_children,
             on_keyboard=ctx.inspector.keyboard_shortcut) 
開發者ID:BillBillBillBill,項目名稱:Tickeys-linux,代碼行數:19,代碼來源:inspector.py

示例5: update

# 需要導入模塊: from kivy.uix import widget [as 別名]
# 或者: from kivy.uix.widget import Widget [as 別名]
def update(self, dt):
        self.mcnay.update()
        self.background.update()
        # Loop through and update obstacles. Replace obstacles which went off the screen.
        for obstacle in self.obstacles:
            obstacle.update()
            if obstacle.x < self.mcnay.x and not obstacle.marked:
                obstacle.marked = True
                self.score += 1
                self.new_obstacle(remove=False)
        if len(self.obstacles) == 0:
            self.new_obstacle(remove=False)
        elif self.obstacles[0].x < 0:
            self.remove_obstacle()
        # If obstacles is emply
        # See if the player collides with any obstacles
        for obstacle in self.obstacles:
            if self.mcnay.collide_widget(Widget(pos=(obstacle.x, obstacle.gap_top + 20), size=(obstacle.width, obstacle.height - obstacle.gap_top))):
                # This will be replaced later on
                sys.exit()
            if self.mcnay.collide_widget(Widget(pos=(obstacle.x, 0), size=(obstacle.width, obstacle.gap_top - obstacle.gap_size))):
                # This will also be replaced
                sys.exit() 
開發者ID:undercase,項目名稱:FlappyKivy,代碼行數:25,代碼來源:FlappyBird.py

示例6: init_ui

# 需要導入模塊: from kivy.uix import widget [as 別名]
# 或者: from kivy.uix.widget import Widget [as 別名]
def init_ui(game):
    view = Widget()

    _heading(game, view)
    _notes(game, view)
    _scales(game, view)
    _tuning(game, view)

    view.add_widget(game)

    if platform in ('android', 'ios'):
        from kivy.core.window import Window
        from kivy.uix.scrollview import ScrollView

        app_view = view
        app_view.size = (960, 540)
        app_view.size_hint = (None, None)

        view = ScrollView(size=Window.size)
        view.effect_cls = ScrollEffect
        view.add_widget(app_view)

    return view 
開發者ID:mvasilkov,項目名稱:kivy-2014,代碼行數:25,代碼來源:ui.py

示例7: remove_widget

# 需要導入模塊: from kivy.uix import widget [as 別名]
# 或者: from kivy.uix.widget import Widget [as 別名]
def remove_widget(self, widget):
        if widget is self.side_panel:
            self._side_panel.remove_widget(widget)
            self.side_panel = None
        elif widget is self.main_panel:
            self._main_panel.remove_widget(widget)
            self.main_panel = None
        else:
            raise NavigationDrawerException(
                'Widget is neither the side or main panel, can\'t remove it.') 
開發者ID:pythonindia,項目名稱:PyCon-Mobile-App,代碼行數:12,代碼來源:__init__.py

示例8: start_emulation

# 需要導入模塊: from kivy.uix import widget [as 別名]
# 或者: from kivy.uix.widget import Widget [as 別名]
def start_emulation(filename, file_content, threaded=False):
    root = None
    has_error = False
    if os.path.splitext(filename)[1] =='.kv':    # load the kivy file directly
        try:    # cacthing error with kivy files
            Builder.unload_file(filename)
            root = Builder.load_file(filename)
        except:
            has_error = True
            trace = traceback.format_exc()
            Logger.error("Emulator: {}".format(trace))

    elif os.path.splitext(filename)[1] =='.py':
        load_defualt_kv(filename, file_content)
        try:    # cahching error with python files
            root = load_py_file(filename, file_content)
        except:
            has_error = True
            trace = traceback.format_exc()
            Logger.error("Emulator: {}".format(trace))
    else:
        Logger.warning("KivyStudio: can't emulate file type {}".format(filename))

    if not root and not has_error:
        Logger.error('Emulator: No root widget found.')
    elif not isinstance(root,Widget) and not has_error:
        Logger.error("KivyStudio: root instance found = '{}' and is not a widget".format(root))
    elif root:
        if threaded:
            emulation_done(root, filename)
        else:
            get_emulator_area().screen_display.screen.add_widget(root)

    dirname=os.path.dirname(filename)
    sys.path.pop()
    resource_remove_path(dirname) 
開發者ID:mahart-studio,項目名稱:kivystudio,代碼行數:38,代碼來源:__init__.py

示例9: checkscreen

# 需要導入模塊: from kivy.uix import widget [as 別名]
# 或者: from kivy.uix.widget import Widget [as 別名]
def checkscreen(self):
        """Updates the screen depending on the state of the league object."""
        # If there are league matches, clear the screen
        if self.leagueobject:
            self.leaguename = self.leagueobject.LeagueName
            if self.newbox:
                self.newbox.clear_widgets()
            else:
                self.newbox = BoxLayout(orientation="vertical",
                                        size_hint_y=0.8)
                self.leaguebox.add_widget(self.newbox)

            # Get the stack of league matches
            self.leaguestack = self.createStack()

            # And work out how to place it in the middle of the screen.
            if self.spacer:
                sph = ((self.parent.height * .8) - self.h) / 2.0
                self.newbox.add_widget(Widget(size_hint=(1, None), height=sph))

            self.newbox.add_widget(self.leaguestack)

            if self.spacer:
                self.newbox.add_widget(Widget(size_hint=(1, None), height=sph))

        # No league matches
        else:
            if self.newbox:
                self.leaguebox.remove_widget(self.newbox)
            self.leaguename = "No league matches found." 
開發者ID:elParaguayo,項目名稱:RPi-InfoScreen-Kivy,代碼行數:32,代碼來源:screen.py

示例10: build

# 需要導入模塊: from kivy.uix import widget [as 別名]
# 或者: from kivy.uix.widget import Widget [as 別名]
def build(self):
        '''Initializes the application; it will be called only once.
        If this method returns a widget (tree), it will be used as the root
        widget and added to the window.

        :return:
            None or a root :class:`~kivy.uix.widget.Widget` instance
            if no self.root exists.'''

        if not self.root:
            return Widget() 
開發者ID:BillBillBillBill,項目名稱:Tickeys-linux,代碼行數:13,代碼來源:app.py

示例11: run

# 需要導入模塊: from kivy.uix import widget [as 別名]
# 或者: from kivy.uix.widget import Widget [as 別名]
def run(self):
        '''Launches the app in standalone mode.
        '''
        if not self.built:
            self.load_config()
            self.load_kv(filename=self.kv_file)
            root = self.build()
            if root:
                self.root = root
        if self.root:
            if not isinstance(self.root, Widget):
                Logger.critical('App.root must be an _instance_ of Widget')
                raise Exception('Invalid instance in App.root')
            from kivy.core.window import Window
            Window.add_widget(self.root)

        # Check if the window is already created
        from kivy.base import EventLoop
        window = EventLoop.window
        if window:
            self._app_window = window
            window.set_title(self.get_application_name())
            icon = self.get_application_icon()
            if icon:
                window.set_icon(icon)
            self._install_settings_keys(window)
        else:
            Logger.critical("Application: No window is created."
                            " Terminating application run.")
            return

        self.dispatch('on_start')
        runTouchApp()
        self.stop() 
開發者ID:BillBillBillBill,項目名稱:Tickeys-linux,代碼行數:36,代碼來源:app.py

示例12: _create_popup

# 需要導入模塊: from kivy.uix import widget [as 別名]
# 或者: from kivy.uix.widget import Widget [as 別名]
def _create_popup(self, instance):
        # create popup layout
        content = BoxLayout(orientation='vertical', spacing='5dp')
        popup_width = min(0.95 * Window.width, dp(500))
        self.popup = popup = Popup(
            title=self.title, content=content, size_hint=(None, None),
            size=(popup_width, '250dp'))

        # create the textinput used for numeric input
        self.textinput = textinput = TextInput(
            text=self.value, font_size='24sp', multiline=False,
            size_hint_y=None, height='42sp')
        textinput.bind(on_text_validate=self._validate)
        self.textinput = textinput

        # construct the content, widget are used as a spacer
        content.add_widget(Widget())
        content.add_widget(textinput)
        content.add_widget(Widget())
        content.add_widget(SettingSpacer())

        # 2 buttons are created for accept or cancel the current value
        btnlayout = BoxLayout(size_hint_y=None, height='50dp', spacing='5dp')
        btn = Button(text='Ok')
        btn.bind(on_release=self._validate)
        btnlayout.add_widget(btn)
        btn = Button(text='Cancel')
        btn.bind(on_release=self._dismiss)
        btnlayout.add_widget(btn)
        content.add_widget(btnlayout)

        # all done, open the popup !
        popup.open() 
開發者ID:BillBillBillBill,項目名稱:Tickeys-linux,代碼行數:35,代碼來源:settings.py

示例13: run

# 需要導入模塊: from kivy.uix import widget [as 別名]
# 或者: from kivy.uix.widget import Widget [as 別名]
def run(self):
        o = []
        for x in range(10000):
            o.append(Widget()) 
開發者ID:BillBillBillBill,項目名稱:Tickeys-linux,代碼行數:6,代碼來源:benchmark.py

示例14: __init__

# 需要導入模塊: from kivy.uix import widget [as 別名]
# 或者: from kivy.uix.widget import Widget [as 別名]
def __init__(self):
        self.ctx = RenderContext()
        self.root = root = Widget()
        for x in range(10000):
            root.add_widget(Widget())
        self.ctx.add(self.root.canvas) 
開發者ID:BillBillBillBill,項目名稱:Tickeys-linux,代碼行數:8,代碼來源:benchmark.py

示例15: add_widget

# 需要導入模塊: from kivy.uix import widget [as 別名]
# 或者: from kivy.uix.widget import Widget [as 別名]
def add_widget(self, widget: Widget, index: int = 0, canvas: str = None):
        """ Add widget override. """
        if (widget.__class__ == blocks.PrintBlock and
            any(map(lambda w: w.__class__ == blocks.PrintBlock, self.children))):
            Notification(title='Warning',
                         message='Only one print block allowed!').open()
            return
        if not self.children:
            self.parent.parent.parent.remove_hint()
        super().add_widget(widget, index, canvas) 
開發者ID:AlvarBer,項目名稱:Persimmon,代碼行數:12,代碼來源:blackboard.py


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