class TestApp(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), on) self.connect(self.ui.pushButton_2, QtCore.SIGNAL("clicked()"), off)
class TestApp(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"),on) self.connect(self.ui.pushButton_2, QtCore.SIGNAL("clicked()"),off)
class MyForm(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.testportsButton.clicked.connect(serialfind) self.ui.pushButton_3.clicked.connect(testfunc3) self.ui.testComms.clicked.connect(commstest) self.ui.Launch1.clicked.connect(Launch1) def testfunc2(self,parent): #self.ui.pushButton_3.setText("HI!") testfunc3(self)
class MyForm(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.testportsButton.clicked.connect(serialfind) self.ui.pushButton_3.clicked.connect(testfunc3) self.ui.testComms.clicked.connect(commstest) self.ui.Launch0.clicked.connect(Launch0) self.ui.Launch1.clicked.connect(Launch1) self.ui.Launch2.clicked.connect(Launch2) self.ui.Launch3.clicked.connect(Launch3) #self.ui.BSel1a.mousePressEvent.connect(UpdateBikeSelect(self.ui.BSel1a.)) self.ui.UpdateNames.clicked.connect(UpdateBikeNames)
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.uploadButton.clicked.connect(selectFile) self.ui.tabWidget.setCurrentIndex(0) global ui ui = self.ui self.ui.nextButton1.clicked.connect(moveTabs) self.ui.nextButton2.clicked.connect(moveTabs) self.ui.nextButton3.clicked.connect(moveTabs) self.ui.homeButton.clicked.connect(moveTabs) self.ui.filterButton.clicked.connect(filterData) self.ui.runAlgorithmButton.clicked.connect(runDecisionTree) self.ui.progressBar.setValue(0) self.setWindowTitle('Pykit-Learn')
class MyForm(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.uploadButton.clicked.connect(selectFile) self.ui.tabWidget.setCurrentIndex(0) global ui ui = self.ui self.ui.nextButton1.clicked.connect(moveTabs) self.ui.nextButton2.clicked.connect(moveTabs) self.ui.nextButton3.clicked.connect(moveTabs) self.ui.homeButton.clicked.connect(moveTabs) self.ui.filterButton.clicked.connect(filterData) self.ui.runAlgorithmButton.clicked.connect(runDecisionTree) self.ui.progressBar.setValue(0) self.setWindowTitle('Pykit-Learn')
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.testportsButton.clicked.connect(serialfind) self.ui.pushButton_3.clicked.connect(testfunc3) self.ui.testComms.clicked.connect(commstest) self.ui.Launch1.clicked.connect(Launch1)
def __init__(self): QtGui.QMainWindow.__init__(self) Ui_MainWindow.__init__(self) self.setupUi(self) self.ds = DamascusServer(self) UiRegistry.create() UiRegistry().addWindow(self) self.channel_sliders = [self.channel_1, self.channel_2, self.channel_3, self.channel_4] self.channel_datas = [self.ch_data_1, self.ch_data_2, self.ch_data_3, self.ch_data_4] self.channel_descs = [self.ch_desc_1, self.ch_desc_2, self.ch_desc_3, self.ch_desc_4] return
def __init__(self): QtGui.QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), self.on) self.connect(self.ui.pushButton_2, QtCore.SIGNAL("clicked()"), self.off) self.connect(self.ui.pushPuerto, QtCore.SIGNAL("clicked()"), self.puerto) self.connect(self.ui.pushPuertoA, QtCore.SIGNAL("clicked()"), self.puertoA) self.connect(self.ui.pushManual, QtCore.SIGNAL("clicked()"), self.manual) self.connect(self.ui.pushAutomatic, QtCore.SIGNAL("clicked()"), self.automatic)
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self)
class TestApp(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), self.on) self.connect(self.ui.pushButton_2, QtCore.SIGNAL("clicked()"), self.off) self.connect(self.ui.pushPuerto, QtCore.SIGNAL("clicked()"), self.puerto) self.connect(self.ui.pushPuertoA, QtCore.SIGNAL("clicked()"), self.puertoA) self.connect(self.ui.pushManual, QtCore.SIGNAL("clicked()"), self.manual) self.connect(self.ui.pushAutomatic, QtCore.SIGNAL("clicked()"), self.automatic) def center(self): screen = QtGui.QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2) def closeEvent(self, event): reply = QtGui.QMessageBox.question(self, 'Message', "Esta seguro de querer cerrar la ventana", QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.Yes: event.accept() else: event.ignore() def automatic(self): self.ui.dial_ON.setDisabled(False) self.ui.dial_OFF.setDisabled(False) self.ui.pushButton.setDisabled(True) self.ui.pushButton_2.setDisabled(True) pinguino.pinMode(int(self.ui.spinPuerto.value()), "OUTPUT") if self.ui.esc_10_ON.isChecked(): tiempo_ON = self.ui.dial_ON.value() * 10 elif self.ui.esc_100_ON.isChecked(): tiempo_ON = self.ui.dial_ON.value() * 100 else: tiempo_ON = self.ui.dial_ON.value() if self.ui.esc_10_OFF.isChecked(): tiempo_OFF = self.ui.dial_OFF.value() * 10 elif self.ui.esc_100_OFF.isChecked(): tiempo_OFF = self.ui.dial_OFF.value() * 100 else: tiempo_OFF = self.ui.dial_OFF.value() # self.ui.lcd_ON.display(tiempo_ON) # self.ui.lcd_OFF.display(tiempo_OFF) #...........# self.connect(self.ui.dial_ON, QtCore.SIGNAL('valueChanged(int)'), self.ui.lcd_ON, QtCore.SLOT('display(int)')) self.connect(self.ui.dial_OFF, QtCore.SIGNAL('valueChanged(int)'), self.ui.lcd_OFF, QtCore.SLOT('display(int)')) #...........# for i in range(20): pinguino.digitalWrite(self.ui.spinPuerto.value(), "HIGH") pinguino.delay(tiempo_ON) pinguino.digitalWrite(self.ui.spinPuerto.value(), "LOW") pinguino.delay(tiempo_OFF) def manual(self): self.ui.pushButton.setDisabled(False) self.ui.pushButton_2.setDisabled(False) self.ui.dial_ON.setDisabled(True) self.ui.dial_OFF.setDisabled(True) def puerto(self): pinguino.pinMode(int(self.ui.spinPuerto.value()), "OUTPUT") def puertoA(self): pinguino.pinMode(self.ui.spinPuerto_A.value(), "INPUT") #i = 1 #while i == 1: potenciometro = pinguino.analogRead(self.ui.spinPuerto_A.value()) self.ui.lcdAnalog.display(potenciometro) #if self.ui.radioButton_ON.isChecked(): #i = 1 #else: #i = 0 def on(self): pinguino.digitalWrite(self.ui.spinPuerto.value(), 1) def off(self): pinguino.digitalWrite(self.ui.spinPuerto.value(), 0)
import sys from test_ui import Ui_MainWindow from PyQt4 import QtCore from PyQt4 import QtGui import vtk def ren1(): global iren iren.Initialize() iren.Start() ren = vtk.vtkRenderer() app = QtGui.QApplication(sys.argv) mainwindow = QtGui.QMainWindow() ui = Ui_MainWindow() ui.setupUi(mainwindow) ui.vtkWidget.GetRenderWindow().AddRenderer(ren) mainwindow.connect(ui.pushButton, QtCore.SIGNAL("clicked()"), ren1) iren = ui.vtkWidget.GetRenderWindow().GetInteractor() source1 = vtk.vtkSphereSource() source1.SetCenter(0, 0, 0) source1.SetRadius(5.0) mapper1 = vtk.vtkPolyDataMapper() mapper1.SetInputConnection(source1.GetOutputPort()) actor1 = vtk.vtkActor() actor1.SetMapper(mapper1) ren.AddActor(actor1) mainwindow.show() sys.exit(app.exec_())
def __init__(self): QtWidgets.QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.setWindowOpacity(0.9) # 设置窗口透明度 self.setAttribute(QtCore.Qt.WA_TranslucentBackground) # 设置窗口背景透明
class Calculate(QtWidgets.QMainWindow): def __init__(self): QtWidgets.QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.setWindowOpacity(0.9) # 设置窗口透明度 self.setAttribute(QtCore.Qt.WA_TranslucentBackground) # 设置窗口背景透明 def And(a, b): return int(a and b) def Or(a, b): return int(a or b) def Nand(a, b): return int(not Calculate.And(a, b)) def Xor(a, b): return Calculate.And(Calculate.Nand(a, b), Calculate.Or(a, b)) def Half_adder(a, b): s = Calculate.Xor(a, b) co = Calculate.And(a, b) return s, co def Full_adder(a, b, ci): s, co1 = Calculate.Half_adder(a, b) s, co2 = Calculate.Half_adder(ci, s) co = Calculate.Or(co1, co2) return s, co # 二进制字符-1运算 def Eight_bit_adder(x, y, sub, length): # sub=0:add, sub=1:subtract result = "" y = list(y) for i in range(len(y)): y[i] = Calculate.Xor(sub, y[i]) ans = [ Calculate.Full_adder(int(x[length * 4 - 1]), int(y[length * 4 - 1]), sub) ] for i in range(length * 4 - 2, -1, -1): ans.insert(0, Calculate.Full_adder(int(x[i]), int(y[i]), ans[0][1])) ans.insert(0, (Calculate.Xor(sub, ans[0][1]), None)) for eachBit in ans: result += str(eachBit[0]) return result[1:] # 十六进制转换二进制 def exchange_hex_to_binary(hex_num): return str(bin(int(hex_num.upper(), 16)))[2:] # 二进制转换十进制 def exchange_binary_to_int(binary_num): return str(int(binary_num, 2)) # 十六进制转换十进制 def exchange_hex_to_int(hex_num): return str(int(hex_num.upper(), 16)) def get_complement_code(num): # print(~int(num)) return ~int(num) # 二进制字符补齐0,为-1运算前做处理 def polish_binary_code(binary_code): length = len(binary_code) % 4 if length == 0: return binary_code else: for i in range(0, 4 - length): binary_code = "0" + binary_code return binary_code # 二进制字符1补齐0,为-1运算前做处理 def polish_sub(binary_code): length = len(binary_code) result = "1" for i in range(0, length - 1): result = "0" + result return result def calculate_with_symbol(num, coefficient, offset, length): binary_code = Calculate.polish_binary_code( Calculate.exchange_hex_to_binary(num)) # 将输入的十六进制的字符转换为二进制,并补齐0 if binary_code[0] == "1": Calculate.Eight_bit_adder(binary_code, Calculate.polish_sub(binary_code), 1, length) compement_code = Calculate.get_complement_code( Calculate.exchange_hex_to_int(num)) result = compement_code * coefficient + offset print("-----------", num, coefficient, offset, result) elif binary_code[0] == "0": result = Calculate.exchange_hex_to_int(num) * coefficient + offset print(num, coefficient, offset, result) def calculate_without_symbol(num, coefficient, offset): int_num = int(Calculate.exchange_hex_to_int(num)) result = int_num * coefficient + offset print(num, coefficient, offset, result) @staticmethod def calculate_main(num, length, coefficient, offset, symbol): if symbol == 1: Calculate.calculate_with_symbol(num, coefficient, offset, length) else: Calculate.calculate_without_symbol(num, coefficient, offset)