当前位置: 首页>>代码示例>>Python>>正文


Python kivy.app方法代码示例

本文整理汇总了Python中kivy.app方法的典型用法代码示例。如果您正苦于以下问题:Python kivy.app方法的具体用法?Python kivy.app怎么用?Python kivy.app使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kivy的用法示例。


在下文中一共展示了kivy.app方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _moveto

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import app [as 别名]
def _moveto(self, x=None, y=None, z=None):
        cmd = ""
        if x:
            cmd += "X{} ".format(x)

        if y:
            cmd += "Y{} ".format(y)

        if z:
            cmd += "Z{}".format(z)

        if cmd:
            self.app.comms.write("G90 G0 {}\n".format(cmd))
            # wait for it to complete
            if not self.app.comms.okcnt.wait(120):
                raise Exception("moveto timed out")

            self.app.comms.okcnt.clear()
            if self.app.main_window.status == 'Alarm':
                raise Exception("ALARM detected") 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:22,代码来源:tool_scripts.py

示例2: _moveby

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import app [as 别名]
def _moveby(self, x=None, y=None, z=None):
        cmd = ""
        if x:
            cmd += "X{} ".format(x)

        if y:
            cmd += "Y{} ".format(y)

        if z:
            cmd += "Z{}".format(z)

        if cmd:
            self.app.comms.write("G91 G0 {} G90\n".format(cmd))
            # wait for it to complete
            if not self.app.comms.okcnt.wait(120):
                raise Exception("moveby timed out")

            self.app.comms.okcnt.clear()
            if self.app.main_window.status == 'Alarm':
                raise Exception("ALARM detected") 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:22,代码来源:tool_scripts.py

示例3: enter_wpos

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import app [as 别名]
def enter_wpos(self, axis, v):
        i = ord(axis) - ord('x')
        v = v.strip()
        if v.startswith('/'):
            # we divide current value by this
            try:
                d = float(v[1:])
                v = str(self.app.wpos[i] / d)
            except Exception:
                Logger.warning("DROWidget: cannot divide by: {}".format(v))
                self.app.wpos[i] = self.app.wpos[i]
                return

        try:
            # needed because the filter does not allow -ive numbers WTF!!!
            f = float(v.strip())
        except Exception:
            Logger.warning("DROWidget: invalid float input: {}".format(v))
            # set the display back to what it was, this looks odd but it forces the display to update
            self.app.wpos[i] = self.app.wpos[i]
            return

        Logger.debug("DROWidget: Set axis {} wpos to {}".format(axis, f))
        self.app.comms.write('G10 L20 P0 {}{}\n'.format(axis.upper(), f))
        self.app.wpos[i] = f 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:27,代码来源:main.py

示例4: handle_action

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import app [as 别名]
def handle_action(self):
        # Run button pressed
        if self.selected_index == -1:
            # change feed override
            self.app.comms.write('M220 S{}\n'.format(round(self.last_pos, 1)))
            return

        if self.app.main_window.is_printing and not self.app.main_window.is_suspended:
            return

        # if in non MPG mode then issue G0 in abs or rel depending on settings
        # if in MPG mode then issue $J commands when they occur
        if not self.ids.mpg_mode_tb.state == 'down':
            # normal mode
            cmd = 'G90' if self.ids.abs_mode_tb.state == 'down' else 'G91'

            # print('{} {}{} {}'.format(cmd1, self.selected_axis, round(self.last_pos, 3), cmd2))
            self.app.comms.write('M120 {} G0 {}{} M121\n'.format(cmd, self.selected_axis, round(self.last_pos, 3))) 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:20,代码来源:main.py

示例5: do_action

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import app [as 别名]
def do_action(self, key):
        if key == 'Send':
            # Logger.debug("KbdWidget: Sending {}".format(self.display.text))
            if self.display.text.strip():
                self._add_line_to_log('<< {}'.format(self.display.text))
                self.app.comms.write('{}\n'.format(self.display.text))
                self.last_command = self.display.text
            self.display.text = ''
        elif key == 'Repeat':
            self.display.text = self.last_command
        elif key == 'BS':
            self.display.text = self.display.text[:-1]
        elif key == '?':
            self.handle_input('?')
        else:
            self.display.text += key 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:18,代码来源:main.py

示例6: start_print

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import app [as 别名]
def start_print(self):
        if self.is_printing:
            if not self.paused:
                # we clicked the pause button
                self.app.comms.stream_pause(True)
            else:
                # we clicked the resume button
                if self.is_suspended:
                    # as we were suspended we need to resume the suspend first
                    # we let Smoothie tell us to resume from pause though
                    self.app.comms.write('resume\n')
                else:
                    self.app.comms.stream_pause(False)

                self.is_suspended = False

        else:
            # get file to print
            f = Factory.filechooser()
            f.open(self.last_path, cb=self._start_print) 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:22,代码来源:main.py

示例7: _upload_gcode

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import app [as 别名]
def _upload_gcode(self, file_path, dir_path):
        if not file_path:
            return

        try:
            self.nlines = Comms.file_len(file_path, self.app.fast_stream)  # get number of lines so we can do progress and ETA
            Logger.debug('MainWindow: number of lines: {}'.format(self.nlines))
        except Exception:
            Logger.warning('MainWindow: exception in file_len: {}'.format(traceback.format_exc()))
            self.nlines = None

        self.start_print_time = datetime.datetime.now()
        self.display('>>> Uploading file: {}, {} lines'.format(file_path, self.nlines))

        if not self.app.comms.upload_gcode(file_path, progress=lambda x: self.display_progress(x), done=self._upload_gcode_done):
            self.display('WARNING Unable to upload file')
            return
        else:
            self.is_printing = True 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:21,代码来源:main.py

示例8: __init__

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import app [as 别名]
def __init__(self,instance,host="localhost",port=None,autoreload=False):
        super(WebServer, self).__init__()
        self.app=None
        self.instance=instance
        self.host=host
        self.autoreload=autoreload

        if port is not None:
            self.port = port

        while not isFree("localhost", self.port):
            self.port += 1

        self.instance._webserver=(self.host,self.port)

        try: # https://bugs.python.org/issue37373 FIX: tornado/py3.8 on windows
            if sys.platform == 'win32':
                asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
        except:
            pass 
开发者ID:manatlan,项目名称:guy,代码行数:22,代码来源:guy.py

示例9: build

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import app [as 别名]
def build(self):
        """Initialize the GUI based on the kv file and set up events.

        Returns:
          (:class:`kivy.uix.anchorlayout.AnchorLayout`): Root widget specified
            in the kv file of the app
        """
        self.language = self.config.get('user_settings', 'language')

        user_interval = self.config.get('user_settings', 'timer_interval')
        self.timer_interval = TIMER_OPTIONS[user_interval]

        self.carousel = self.root.ids.carousel
        self.progress_bar = self.root.ids.progress_bar
        self.progress_bar.max = self.property('timer').get_max(self)

        self.start_timer()
        self.carousel.bind(on_touch_down=self.stop_timer)
        self.carousel.bind(current_slide=self.delay_timer)
        return self.root 
开发者ID:hackebrot,项目名称:cookiedozer,代码行数:22,代码来源:{{cookiecutter.repo_name}}.py

示例10: on_release

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import app [as 别名]
def on_release(self):
        app = App.get_running_app()
        base_url, chain = None, app.chain.chain_1209k
        txid = self.history.tx_obj.id()
        if app.explorer == "blockcypher":
            base_url = "https://live.blockcypher.com/{}/tx/{}/"
            if app.chain == nowallet.TBTC:
                chain = "btc-testnet"
        elif app.explorer == "smartbit":
            base_url = "https://{}.smartbit.com.au/tx/{}/"
            if app.chain == nowallet.BTC:
                chain = "www"
            elif app.chain == nowallet.TBTC:
                chain = "testnet"
        url = base_url.format(chain, txid)
        open_url(url) 
开发者ID:metamarcdw,项目名称:nowallet,代码行数:18,代码来源:main.py

示例11: open_url

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import app [as 别名]
def open_url(url):
    if platform == 'android':
        ''' Open a webpage in the default Android browser.  '''
        from jnius import autoclass, cast
        context = autoclass('org.renpy.android.PythonActivity').mActivity
        Uri = autoclass('android.net.Uri')
        Intent = autoclass('android.content.Intent')

        intent = Intent()
        intent.setAction(Intent.ACTION_VIEW)
        intent.setData(Uri.parse(url))
        currentActivity = cast('android.app.Activity', context)
        currentActivity.startActivity(intent)
    else:
        import webbrowser
        webbrowser.open(url) 
开发者ID:metamarcdw,项目名称:nowallet,代码行数:18,代码来源:main.py

示例12: _on_preference_change

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import app [as 别名]
def _on_preference_change(self, instance, section, key, value):
        """Called any time the app preferences are changed
        """
        token = (section, key)

        if token == ('preferences', 'send_telemetry'):
            if value == "1":  # Boolean settings values are 1/0, not True/False
                if self.rc_config.connectivityConfig.cellConfig.cellEnabled:
                    alertPopup('Telemetry error', "Disable the telemetry module before enabling app telemetry.")
                Clock.schedule_once(lambda dt: self._enable_telemetry())
            else:
                Clock.schedule_once(lambda dt: self._disable_telemetry())

        if token == ('preferences', 'conn_type'):
            # User changed their RC connection type
            Logger.info("RaceCaptureApp: RC connection type changed to {}, restarting comms".format(value))
            Clock.schedule_once(lambda dt: self._restart_comms()) 
开发者ID:autosportlabs,项目名称:RaceCapture_App,代码行数:19,代码来源:main.py

示例13: __init__

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import app [as 别名]
def __init__(self, **kwargs):
        super(ToolScripts, self).__init__(**kwargs)
        self.app = App.get_running_app()

    # public methods 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:7,代码来源:tool_scripts.py

示例14: _probe

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import app [as 别名]
def _probe(self, x=None, y=None, z=None):
        cmd = ""
        if x:
            cmd += "X{} ".format(x)

        if y:
            cmd += "Y{} ".format(y)

        if z:
            cmd += "Z{}".format(z)

        if not cmd:
            raise Exception("need to specify an axis to probe")

        self.app.comms.write("G38.2 {}\n".format(cmd))

        # wait for it to complete
        if not self.app.comms.okcnt.wait(120):
            raise Exception("probe timed out")

        self.app.comms.okcnt.clear()

        r = self.app.last_probe
        if not r["status"]:
            raise Exception("probe failed")

        # return result
        return r 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:30,代码来源:tool_scripts.py

示例15: select_wcs

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import app [as 别名]
def select_wcs(self, v):
        self.app.comms.write('{}\n'.format(v)) 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:4,代码来源:main.py


注:本文中的kivy.app方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。