from cxwidgets.auxwidgets import BaseGridW from preset_mgr import KickersPresetMgr class PresetMgrW(BaseGridW): def __init__(self, parent=None): super(PresetMgrW, self).__init__(parent) self.preset_names = ['p0', 'p1', 'p2', 'p3'] self.preset_bs = [ QtWidgets.QPushButton('-->' + x) for x in self.preset_names ] for ind in range(len(self.preset_bs)): self.grid.addWidget(self.preset_bs[ind], ind, 0) self.preset_bs[ind].clicked.connect(self.bs_proc) self.mgr = KickersPresetMgr() def bs_proc(self): ind = self.preset_bs.index(self.sender()) self.mgr.copy(src='hw', dst=self.preset_names[ind]) app = QtWidgets.QApplication(['preset manager']) w = PresetMgrW() w.show() app.exec_()
def mode_saved(self, dict_msg): self.flist.update_modenum() self.flist.update_modelist() self.print_msg("mode saved", dict_msg['time']) def update_db(self): self.flist.update_modenum() self.flist.update_modelist(update_marked=True) def set_zeros(self): self.mode_cli.set_zeros(self.selected_sys, self.selected_kinds) def print_msg(self, msg, srv_time=None): if srv_time is None: msg_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) else: msg_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(srv_time / 1e6)) self.status_text.appendPlainText(msg_time + ": " + msg) self.status_text.ensureCursorVisible() app = QtWidgets.QApplication(['saver']) w = SaverWidget() w.show() w.setFixedSize(w.size()) w.flist.update_modelist() app.exec_()
self.b_stop = QtWidgets.QPushButton('stop') self.grid.addWidget(self.b_stop, 0, 1) self.lin_st = linstarter.LinStarter() self.b_start.clicked.connect(self.run_counter) self.b_stop.clicked.connect(self.lin_st.stop) self.lin_st.runmodeChanged.connect(print) self.lin_st.nshotsChanged.connect(print) self.lin_st.runDone.connect(self.rundone_proc) self.st_time = 0 self.fi_time = 0 def rundone_proc(self): self.fi_time = time.time() print('run time:', self.fi_time - self.st_time) self.run_counter() def run_counter(self): self.st_time = time.time() self.lin_st.start() app = QtWidgets.QApplication(['linstarter test']) w = LinstarterWidget() w.show() app.exec_()
self.outMsg.emit('no mode selected') return self.loadMode.emit(self.selected_mode) def btn_save_cb(self): comment = str2u(self.comment_line.text()) if len(comment) == 0: self.outMsg.emit('no comment - no save') return author = str2u(self.author_line.text()) if len(author) == 0: self.outMsg.emit('save: it isn`t polite to operate machine anonymously') return self.saveMode.emit(author, comment) if __name__ == '__main__': app = QtWidgets.QApplication(['mode list test']) w3 = ModeListCtrl() w3.resize(900, 800) w3.show() w3.markMode.connect(print) w3.archiveMode.connect(print) w3.loadMode.connect(print) w3.saveMode.connect(print) w3.setZeros.connect(print) w3.outMsg.connect(print) app.exec_()
extr.unexpectedShot.connect(self.unexpected_shot_proc) extr.extractionDone.connect(self.extr_proc) self.st_time = 0 self.fi_time = 0 def extr_proc(self): self.fi_time = time.time() print('run time:', self.fi_time - self.st_time) self.extract() def unexpected_shot_proc(self): print("unexpected shot") def extract(self): self.st_time = time.time() extr.extract() app = QtWidgets.QApplication(['extractor_test']) extr = extractor.Extractor() w = ExtractorWidget() w.show() w2 = TrainingCtlW() w2.show() app.exec_()