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


Python ConfigurationAPI.reset_drips方法代码示例

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


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

示例1: test_drip_calibration_should_call_reset_when_reset_requested

# 需要导入模块: from api.configuration_api import ConfigurationAPI [as 别名]
# 或者: from api.configuration_api.ConfigurationAPI import reset_drips [as 别名]
    def test_drip_calibration_should_call_reset_when_reset_requested(self, mock_reset,mock_start,mock_load,mock_save):
        configuration_API = ConfigurationAPI(ConfigurationManager())
        mock_load.return_value = self.DEFAULT_CONFIG
        configuration_API.load_printer('printer')

        configuration_API.start_counting_drips()
        configuration_API.reset_drips()

        mock_reset.assert_called_with(0)
开发者ID:colehard,项目名称:peachyprintertools,代码行数:11,代码来源:configuration_api_test.py

示例2: DripCalibrationUI

# 需要导入模块: from api.configuration_api import ConfigurationAPI [as 别名]
# 或者: from api.configuration_api.ConfigurationAPI import reset_drips [as 别名]
class DripCalibrationUI(PeachyFrame, FieldValidations):
    
    def initialize(self):
        self._current_printer = self.kwargs['printer']
        self._configuration_api = ConfigurationAPI(self._configuration_manager)
        self._configuration_api.load_printer(self._current_printer)
        self.grid()

        self._dripper_type = StringVar()
        self._dripper_type.set(self._configuration_api.get_dripper_type())

        Label(self, text = 'Printer: ').grid(column=0,row=10)
        Label(self, text = self._configuration_api.current_printer()).grid(column=1,row=10)
        Button(self, text='?', command=self._help).grid(column=2, row=10,stick=N+E)
        
        Label(self).grid(column=1,row=15)

        Radiobutton(self, text="Microphone Dripper", variable=self._dripper_type, value="audio", command = self._dripper_type_changed).grid(column=0,row=20,sticky=N+S+E+W)
        Radiobutton(self, text="Emulated Dripper ", variable=self._dripper_type, value="emulated", command = self._dripper_type_changed).grid(column=1,row=20,sticky=N+S+E+W)

        
        # ---------------- Microphone Dripper Frame Start -------------------------
        self.update_drips_job = None
        self.drips = 0
        self._drip_count = IntVar()

        self.drips_per_mm_field_text = DoubleVar()
        self.drips_per_mm_field_text.set(self._configuration_api.get_drips_per_mm())

        self._height_mm_entry = IntVar()
        self._height_mm_entry.set(10)

        self._average_drips = StringVar()
        self._average_drips.set(0)

        self.real_dripper_frame = LabelFrame(self, text="Microphone Dripper Setup", padx=5, pady=5)
        self.real_dripper_frame.grid(column=0,row=30, columnspan=3)

        Label(self.real_dripper_frame,text='Drips', anchor="w").grid(column=0,row=20,sticky=N+S+E+W)
        Label(self.real_dripper_frame,textvariable=self._drip_count,  anchor="w").grid(column=1,row=20,sticky=N+S+E+W)
        Label(self.real_dripper_frame,text='Drips/Second (last 10 drips)', anchor="w").grid(column=0,row=25,sticky=N+S+E+W)
        Label(self.real_dripper_frame,textvariable=self._average_drips,  anchor="w").grid(column=1,row=25,sticky=N+S+E+W)
        Button(self.real_dripper_frame,text=u"Reset Counter", command=self._reset).grid(column=2,row=20,sticky=N+S+E+W)

        Label(self.real_dripper_frame,text="End Height in Millimeters", anchor="w",justify="right").grid(column=0,row=30,sticky=N+S+E+W)
        Entry(self.real_dripper_frame, width=5, justify="left", textvariable=self._height_mm_entry, validate = 'key', validatecommand=self.validate_int_command()).grid(column=1,row=30,sticky=N+S+E+W)

        Label(self.real_dripper_frame,text="Drips per mm", anchor="w", justify="right").grid(column=0,row=40,sticky=N+S+E+W)
        Label(self.real_dripper_frame,textvariable=self.drips_per_mm_field_text, anchor="w").grid(column=1,row=40,sticky=N+S+E+W)
        Button(self.real_dripper_frame,text=u"Mark", command=self._mark).grid(column=2,row=40,sticky=N+S+E+W)

        Label(self.real_dripper_frame).grid(column=1,row=45)

        self.real_dripper_frame.grid_remove()
        # ---------------- Microphone Dripper Frame Stop -------------------------
        # ---------------- Manual Dripper Frame Start ----------------------------
        self._drips_per_second = DoubleVar()
        self._drips_per_second.set(self._configuration_api.get_emulated_drips_per_second())

        self.fake_dripper_frame = LabelFrame(self, text="Emulated Dripper Setup", padx=5, pady=5)
        self.fake_dripper_frame.grid(column=0,row=40, columnspan=3,sticky=N+S+E+W)
        self.fake_dripper_frame.grid_remove()

        Label(self.fake_dripper_frame, text="Drips per second").grid(column=1,row=10)
        Entry(self.fake_dripper_frame, textvariable=self._drips_per_second).grid(column=2,row=10)
        # ---------------- Manual Dripper Frame Stop ----------------------------

        Button(self,text=u"Save", command=self._save).grid(column=2,row=50,sticky=NSEW) 
        Button(self,text=u"Back", command=self._back).grid(column=0,row=50,sticky=N+S+E+W)
        
        ## destory Automaticness
        self._dripper_type_changed()
        self.update()

    def _dripper_type_changed(self):
        if self._dripper_type.get() == 'audio':
            self._configuration_api.set_dripper_type('audio')
            self.fake_dripper_frame.grid_remove()
            self.real_dripper_frame.grid()
            self._configuration_api.start_counting_drips(drip_call_back = self._drips_updated)
        elif self._dripper_type.get() == 'emulated':
            self._configuration_api.set_dripper_type('emulated')
            self._configuration_api.stop_counting_drips()
            self.real_dripper_frame.grid_remove()
            self.fake_dripper_frame.grid()
        else:
            raise Exception('Unsupported Dripper: %s ' % self._dripper_type.get() )

    def _drips_updated(self, drips, height, drips_per_second):
        self._drip_count.set(drips)
        self._average_drips.set("%0.2f" % drips_per_second)

    def _reset(self):
        self._configuration_api.reset_drips()

    def _back(self):
        self.navigate(SetupUI)

    def _help(self):
        PopUp(self,'Help', help_text.setup_drip_calibration_help)
#.........这里部分代码省略.........
开发者ID:superblobmonster,项目名称:peachyprintertools,代码行数:103,代码来源:configuration_ui.py

示例3: DripCalibrationUI

# 需要导入模块: from api.configuration_api import ConfigurationAPI [as 别名]
# 或者: from api.configuration_api.ConfigurationAPI import reset_drips [as 别名]
class DripCalibrationUI(PeachyFrame, FieldValidations):
    
    def initialize(self):
        self._current_printer = self.kwargs['printer']
        self._configuration_api = ConfigurationAPI(self._configuration_manager)
        self._configuration_api.load_printer(self._current_printer)

        self.update_drips_job = None
        self.drips = 0
        self._drip_count = IntVar()
        self.grid()

        self.drips_per_mm_field_text = DoubleVar()
        self.drips_per_mm_field_text.set(self._configuration_api.get_drips_per_mm())

        self._height_mm_entry = IntVar()
        self._height_mm_entry.set(10)

        Label(self, text = 'Printer: ').grid(column=0,row=10)
        Label(self, text = self._configuration_api.current_printer()).grid(column=1,row=10)
        Button(self, text='?', command=self._help).grid(column=2, row=10,stick=N+E)
        
        Label(self).grid(column=1,row=15)

        Label(self,text='Drips', anchor="w").grid(column=0,row=20,sticky=N+S+E+W)
        Label(self,textvariable=self._drip_count,  anchor="w").grid(column=1,row=20,sticky=N+S+E+W)
        Button(self,text=u"Reset Counter", command=self._reset).grid(column=2,row=20,sticky=N+S+E+W)

        Label(self,text="End Height in Millimeters", anchor="w",justify="right").grid(column=0,row=30,sticky=N+S+E+W)
        Entry(self, width=5, justify="left", textvariable=self._height_mm_entry, validate = 'key', validatecommand=self.validate_int_command()).grid(column=1,row=30,sticky=N+S+E+W)

        Label(self,text="Drips per mm", anchor="w", justify="right").grid(column=0,row=40,sticky=N+S+E+W)
        Label(self,textvariable=self.drips_per_mm_field_text, anchor="w").grid(column=1,row=40,sticky=N+S+E+W)
        Button(self,text=u"Mark", command=self._mark).grid(column=2,row=40,sticky=N+S+E+W)

        Label(self).grid(column=1,row=45)

        self._save_button = Button(self,text=u"Save", command=self._save, state=DISABLED)
        self._save_button.grid(column=2,row=50,sticky=NSEW) 
        Button(self,text=u"Back", command=self._back).grid(column=0,row=50,sticky=N+S+E+W)
        self._configuration_api.start_counting_drips(drip_call_back = self._drips_updated)
        self.update()

    def _drips_updated(self, drips, height):
        self._drip_count.set(drips)

    def _reset(self):
        self._configuration_api.reset_drips()

    def _back(self):
        self.navigate(SetupUI)

    def _help(self):
        PopUp(self,'Help', help_text.setup_drip_calibration_help)

    def _mark(self):
        try:
            self._configuration_api.set_target_height(self._height_mm_entry.get())
            self._configuration_api.mark_drips_at_target()
            self.drips_per_mm_field_text.set(self._configuration_api.get_drips_per_mm())
            self._save_button.config(state = NORMAL)
        except Exception as ex:
            tkMessageBox.showwarning(
            "Error",
            ex.message
        )

    def _save(self):
        self._configuration_api.stop_counting_drips()
        self._configuration_api.save()
        self.navigate(SetupUI)

    def close(self):
        self._configuration_api.stop_counting_drips()
开发者ID:colehard,项目名称:peachyprintertools,代码行数:76,代码来源:configuration_ui.py


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