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


Python kivy.config方法代码示例

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


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

示例1: window_request_close

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import config [as 别名]
def window_request_close(self, win):
        if self.desktop_changed:
            # if the desktop changed we reset the window size and pos
            if self.config.get('UI', 'screen_size') != 'none':
                self.config.set('UI', 'screen_size', 'auto')
            if self.config.get('UI', 'screen_pos') != 'none':
                self.config.set('UI', 'screen_pos', 'auto')

            self.config.write()

        elif self.is_desktop == 2 or self.is_desktop == 3:
            if self.config.get('UI', 'screen_size') != 'none':
                # Window.size is automatically adjusted for density, must divide by density when saving size
                self.config.set('UI', 'screen_size', "{}x{}".format(int(Window.size[0] / Metrics.density), int(Window.size[1] / Metrics.density)))

            if self.config.get('UI', 'screen_pos') != 'none':
                self.config.set('UI', 'screen_pos', "{},{}".format(Window.top, Window.left))
                Logger.info('SmoothieHost: close Window.size: {}, Window.top: {}, Window.left: {}'.format(Window.size, Window.top, Window.left))

            self.config.write()

        return False 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:24,代码来源:main.py

示例2: _load_modules

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import config [as 别名]
def _load_modules(self):
        if not self.config.has_section('modules'):
            return

        try:
            for key in self.config['modules']:
                Logger.info("load_modules: loading module {}".format(key))
                mod = importlib.import_module('modules.{}'.format(key))
                if mod.start(self.config['modules'][key]):
                    Logger.info("load_modules: loaded module {}".format(key))
                    self.loaded_modules.append(mod)
                else:
                    Logger.info("load_modules: module {} failed to start".format(key))

        except Exception:
            Logger.warn("load_modules: exception: {}".format(traceback.format_exc())) 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:18,代码来源:main.py

示例3: _new_macro

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import config [as 别名]
def _new_macro(self, opts):
        if opts and opts['Name'] and opts['Command']:
            btn = Factory.MacroButton()
            btn.text = opts['Name']
            btn.bind(on_press=partial(self.send, opts['Command']))
            btn.ud = True
            self.add_widget(btn)
            # write it to macros.ini
            try:
                config = configparser.ConfigParser()
                config.read(self.macro_file)
                if not config.has_section("macro buttons"):
                    config.add_section("macro buttons")
                config.set("macro buttons", opts['Name'], opts['Command'])
                with open(self.macro_file, 'w') as configfile:
                    config.write(configfile)

                Logger.info('MacrosWidget: added macro button {}'.format(opts['Name']))

            except Exception as err:
                Logger.error('MacrosWidget: ERROR - exception writing config file: {}'.format(err)) 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:23,代码来源:macros_widget.py

示例4: _init_coils

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import config [as 别名]
def _init_coils(self):
        time_interval = int(eval(self.config.get("Simulation",
                                                 "time interval")))
        minval = int(eval(self.config.get("Modbus Protocol",
                                          "bin min")))
        maxval = int(eval(self.config.get("Modbus Protocol",
                                          "bin max")))

        self.data_model_coil.init(
            blockname="coils",
            simulate=self.simulating,
            time_interval=time_interval,
            minval=minval,
            maxval=maxval,
            _parent=self
        )
        self.data_model_discrete_inputs.init(
            blockname="discrete_inputs",
            simulate=self.simulating,
            time_interval=time_interval,
            minval=minval,
            maxval=maxval,
            _parent=self
        ) 
开发者ID:riptideio,项目名称:modbus-simulator,代码行数:26,代码来源:gui.py

示例5: activate_module

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import config [as 别名]
def activate_module(self, name, win):
        '''Activate a module on a window'''
        if name not in self.mods:
            Logger.warning('Modules: Module <%s> not found' % name)
            return

        mod = self.mods[name]

        # ensure the module has been configured
        if 'module' not in mod:
            self._configure_module(name)

        pymod = mod['module']
        if not mod['activated']:
            context = mod['context']
            msg = 'Modules: Start <{0}> with config {1}'.format(
                  name, context)
            Logger.debug(msg)
            pymod.start(win, context)
            mod['activated'] = True 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:22,代码来源:__init__.py

示例6: _on_keyboard

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import config [as 别名]
def _on_keyboard(self, keyboard, key, scancode, codepoint, modifier):
        if key == 27:  # go up to home screen
            self.switchMainView('home')

        if not self.screenMgr.current == 'home':
            return

        if key == 97:  # ASCII 'a'
            self.switchMainView('analysis')

        if key == 100:  # ASCII 'd'
            self.switchMainView('dash')

        if key == 115:  # ASCII 's'
            self.switchMainView('config')

        if key == 112:  # ASCII 'p'
            self.switchMainView('preferences')

        if key == 116:  # ASCII 't'
            self.switchMainView('status')

        if key == 113 and 'ctrl' in modifier:  # ctrl-q
            self._shutdown_app() 
开发者ID:autosportlabs,项目名称:RaceCapture_App,代码行数:26,代码来源:main.py

示例7: build_config_view

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import config [as 别名]
def build_config_view(self):
        config_view = ConfigView(name='config',
                                rcpConfig=self.rc_config,
                                rc_api=self._rc_api,
                                databus=self._databus,
                                settings=self.settings,
                                base_dir=self.base_dir,
                                track_manager=self.track_manager,
                                preset_manager=self.preset_manager,
                                 status_pump=self._status_pump)
        config_view.bind(on_read_config=self.on_read_config)
        config_view.bind(on_write_config=self.on_write_config)
        config_view.bind(on_show_main_view=lambda instance, view: self.switchMainView(view))
        self.config_listeners.append(config_view)
        self.tracks_listeners.append(config_view)
        return config_view 
开发者ID:autosportlabs,项目名称:RaceCapture_App,代码行数:18,代码来源:main.py

示例8: __init__

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import config [as 别名]
def __init__(self, **kwargs):
        super(MainWindow, self).__init__(**kwargs)
        self.app = App.get_running_app()
        self._trigger = Clock.create_trigger(self.async_get_display_data)
        self._q = queue.Queue()
        self.config = self.app.config
        self.last_path = self.config.get('General', 'last_gcode_path')
        self.paused = False
        self.last_line = 0

        # print('font size: {}'.format(self.ids.log_window.font_size))
        # Clock.schedule_once(self.my_callback, 2) # hack to overcome the page layout not laying out initially 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:14,代码来源:main.py

示例9: connect

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import config [as 别名]
def connect(self):
        if self.app.is_connected:
            if self.is_printing:
                mb = MessageBox(text='Cannot Disconnect while printing - Abort first, then wait', cancel_text='OK')
                mb.open()
            else:
                self._disconnect()

        else:
            port = self.config.get('General', 'serial_port')
            self.add_line_to_log("Connecting to {}...".format(port))
            self.app.comms.connect(port) 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:14,代码来源:main.py

示例10: change_port

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import config [as 别名]
def change_port(self):
        ll = self.app.comms.get_ports()
        ports = [self.config.get('General', 'serial_port')]  # current port is first in list
        for p in ll:
            ports.append('serial://{}'.format(p.device))

        ports.append('network...')

        sb = SelectionBox(title='Select port', text='Select the port to open from drop down', values=ports, cb=self._change_port)
        sb.open() 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:12,代码来源:main.py

示例11: _change_port

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import config [as 别名]
def _change_port(self, s):
        if s:
            Logger.info('MainWindow: Selected port {}'.format(s))

            if s.startswith('network'):
                mb = InputBox(title='Network address', text='Enter network address as "ipaddress[:port]"', cb=self._new_network_port)
                mb.open()

            else:
                self.config.set('General', 'serial_port', s)
                self.config.write() 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:13,代码来源:main.py

示例12: _new_network_port

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import config [as 别名]
def _new_network_port(self, s):
        if s:
            self.config.set('General', 'serial_port', 'net://{}'.format(s))
            self.config.write() 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:6,代码来源:main.py

示例13: build_config

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import config [as 别名]
def build_config(self, config):
        config.setdefaults('General', {
            'last_gcode_path': os.path.expanduser("~"),
            'last_print_file': '',
            'serial_port': 'serial:///dev/ttyACM0',
            'report_rate': '1.0',
            'blank_timeout': '0',
            'manual_tool_change': 'false',
            'wait_on_m0': 'false',
            'fast_stream': 'false',
            'v2': 'false',
            'is_spindle_camera': 'false'
        })
        config.setdefaults('UI', {
            'display_type': "RPI Touch",
            'cnc': 'false',
            'tab_top': 'false',
            'screen_size': 'auto',
            'screen_pos': 'auto',
            'filechooser': 'default'
        })

        config.setdefaults('Extruder', {
            'last_bed_temp': '60',
            'last_hotend_temp': '185',
            'length': '20',
            'speed': '300',
            'hotend_presets': '185 (PLA), 230 (ABS)',
            'bed_presets': '60 (PLA), 110 (ABS)'
        })
        config.setdefaults('Web', {
            'webserver': 'false',
            'show_video': 'false',
            'camera_url': 'http://localhost:8080/?action=stream'
        }) 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:37,代码来源:main.py

示例14: on_config_change

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import config [as 别名]
def on_config_change(self, config, section, key, value):
        # print("config changed: {} - {}: {}".format(section, key, value))
        token = (section, key)
        if token == ('UI', 'cnc'):
            was_cnc = self.is_cnc
            self.is_cnc = value == "1"
            self.main_window.ids.macros.reload()
            if was_cnc and not self.is_cnc and self.is_desktop < 3:
                self.main_window.display("NOTICE: May need to Restart to get Extruder panel")
        elif token == ('UI', 'display_type'):
            self.desktop_changed = True
            self.main_window.display("NOTICE: Restart is needed")
        elif token == ('UI', 'tab_top'):
            self.tab_top = value == "1"
        elif token == ('Extruder', 'hotend_presets'):
            self.main_window.ids.extruder.ids.set_hotend_temp.values = value.split(',')
        elif token == ('Extruder', 'bed_presets'):
            self.main_window.ids.extruder.ids.set_bed_temp.values = value.split(',')
        elif token == ('General', 'blank_timeout'):
            self.blank_timeout = float(value)
        elif token == ('General', 'manual_tool_change'):
            self.manual_tool_change = value == '1'
        elif token == ('General', 'wait_on_m0'):
            self.wait_on_m0 = value == '1'
        elif token == ('Web', 'camera_url'):
            self.camera_url = value
        elif token == ('General', 'fast_stream'):
            self.fast_stream = value == '1'
        else:
            self.main_window.display("NOTICE: Restart is needed") 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:32,代码来源:main.py

示例15: on_start

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import config [as 别名]
def on_start(self):
        # in case we added something to the defaults, make sure they are written to the ini file
        self.config.update_config(self.config_file) 
开发者ID:wolfmanjm,项目名称:kivy-smoothie-host,代码行数:5,代码来源:main.py


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