本文整理汇总了Python中sender.Sender.reset方法的典型用法代码示例。如果您正苦于以下问题:Python Sender.reset方法的具体用法?Python Sender.reset怎么用?Python Sender.reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sender.Sender
的用法示例。
在下文中一共展示了Sender.reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Main
# 需要导入模块: from sender import Sender [as 别名]
# 或者: from sender.Sender import reset [as 别名]
class Main(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
# make variables
self.voltage = 0
self.current = 0
# load gui.ui
self.ui = loadUi('../gui/gui.ui')
self.ui.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
self.ui.destroyed.connect(self.shutdown)
# show window
self.ui.show()
# make new log object
self.log = Log(self.ui)
# make new sender object
self.sender = Sender(self.ui, self.log)
# set events
self.set_events()
# initial reset
self.sender.reset()
# new listener
self.listener = Listener()
# new_data_received signal
self.listener.data_received.connect(self.new_data_received)
# start listener
self.listener.start()
# new interpreter
self.interpreter = Interpreter(self.log, self.ui)
# add tree
self.add_tree()
def add_tree(self):
# Items for tree
voltage_item = QTreeWidgetItem(["Spannung", str(self.voltage) + " V"])
self.ui.treeView.addTopLevelItem(voltage_item)
current_item = QTreeWidgetItem(["Strom", str(self.current) + " A"])
self.ui.treeView.addTopLevelItem(current_item)
power_item = QTreeWidgetItem(["Watt", "0 W"])
self.ui.treeView.addTopLevelItem(power_item)
def set_events(self):
# sendButton clicked
self.ui.sendButton.clicked.connect(lambda: self.sender.send("debug"))
# holdButton clicked
self.ui.holdButton.clicked.connect(self.log.toggle_hold)
# clearButton clicked
self.ui.clearButton.clicked.connect(self.log.clear_log)
# messageInput return pressed
self.ui.messageInput.returnPressed.connect(lambda: self.sender.send("debug"))
# sliders value changed
self.ui.voltageSlider.sliderReleased.connect(lambda: self.sender.send("slider-voltage"))
self.ui.currentSlider.sliderReleased.connect(lambda: self.sender.send("slider-current"))
# reset action
self.ui.resetActionButton.triggered.connect(self.sender.reset)
# automode checkbox
self.ui.automodeCheckbox.stateChanged.connect(lambda: self.sender.send("checkbox-automode"))
# lamp checkboxes
self.ui.lamp1Checkbox.stateChanged.connect(lambda: self.sender.send("checkbox-lamp"))
self.ui.lamp2Checkbox.stateChanged.connect(lambda: self.sender.send("checkbox-lamp"))
self.ui.lamp3Checkbox.stateChanged.connect(lambda: self.sender.send("checkbox-lamp"))
self.ui.lamp4Checkbox.stateChanged.connect(lambda: self.sender.send("checkbox-lamp"))
def new_data_received(self, text):
self.interpreter.interpret(text)
def shutdown(self):
self.listener.exit()