当前位置: 首页>>代码示例>>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;未经允许,请勿转载。