本文整理汇总了Python中api.configuration_api.ConfigurationAPI.set_dripper_type方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigurationAPI.set_dripper_type方法的具体用法?Python ConfigurationAPI.set_dripper_type怎么用?Python ConfigurationAPI.set_dripper_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api.configuration_api.ConfigurationAPI
的用法示例。
在下文中一共展示了ConfigurationAPI.set_dripper_type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_set_dripper_type_should_return_current_type
# 需要导入模块: from api.configuration_api import ConfigurationAPI [as 别名]
# 或者: from api.configuration_api.ConfigurationAPI import set_dripper_type [as 别名]
def test_set_dripper_type_should_return_current_type(self, mock_load):
configuration_API = ConfigurationAPI(ConfigurationManager())
mock_load.return_value = self.default_config
configuration_API.load_printer('Printer')
expected = 'emulated'
configuration_API.set_dripper_type(expected)
actual = configuration_API.get_dripper_type()
self.assertEquals(expected, actual)
示例2: DripCalibrationUI
# 需要导入模块: from api.configuration_api import ConfigurationAPI [as 别名]
# 或者: from api.configuration_api.ConfigurationAPI import set_dripper_type [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)
#.........这里部分代码省略.........