Commits

Richard Gerkin committed 4cdb30c

Preparting for QT

Comments (0)

Files changed (13)

Add a comment to this file

ALL-BEGIN-C.bbc

Binary file removed.

Binary file removed.

Binary file removed.

Binary file removed.

-##Examples using ctypes to communicate with ACCES I/O products
-##Examples below are tested with USB-IIRO-16 and USB-IDIO-16 modules,
-##but can be modified to work with other USB modules using the ACCES AIOUSB driver
-##Chris Allen 2012
-
-import time
-from ctypes import *
-
-
-###############################################################################
-##This determines the device address/addresses
-def GET_DEVICES():
-    DEVICES=windll.AIOUSB.VBGetDevices()
-    print DEVICES
-    BIT=0
-    while 1 << BIT <= DEVICES:
-        STATE=(DEVICES & (1 << BIT)) >> BIT
-        if STATE==1:
-            print "Device present at address ", BIT
-        else:
-            pass
-        BIT += 1
-
-        
-###############################################################################
-##Initialise the USB IO Module and ensure all outputs are off
-def INITIALIZE():
-    global DEVICE
-    ##Set this value to our device ID- usually 0 if only one device is connected
-    DEVICE=0
-
-    resetall=c_long(65535)
-
-    DIO=windll.AIOUSB.VBDIO_WriteAll(DEVICE, pointer(resetall))
-    IO_ERROR(DIO)
-
-
-def IO_ERROR(value):
-    VALUE=value
-    if VALUE==0:
-        print "SUCCESS"
-        pass
-    else:
-        print "ERROR, DEVICE NOT FOUND. ERROR:",VALUE
-###############################################################################
-##GET THE IO STATUS FROM THE DEVICE using ReadAll
-def GET_IO_STATUS():
-
-    readback=c_long(0)
-    
-    DIO=windll.AIOUSB.VBDIO_ReadAll(DEVICE, pointer(readback))
-    IO_ERROR(DIO)
-    
-    ##OUTPUTS
-    ##NOTE: For some reason the outputs seem inverted-
-    ##for example an output returns 1 when the output is off, but 0 when the output is on
-    ##Likewise when you wish to turn an output on- 0 is on, 1 is off
-    OUT_0=(readback.value>>0)&1
-    OUT_1=(readback.value>>1)&1
-    OUT_2=(readback.value>>2)&1
-    OUT_3=(readback.value>>3)&1
-    OUT_4=(readback.value>>4)&1
-    OUT_5=(readback.value>>5)&1
-    OUT_6=(readback.value>>6)&1
-    OUT_7=(readback.value>>7)&1
-    OUT_8=(readback.value>>8)&1
-    OUT_9=(readback.value>>9)&1
-    OUT_10=(readback.value>>10)&1
-    OUT_11=(readback.value>>11)&1
-    OUT_12=(readback.value>>12)&1
-    OUT_13=(readback.value>>13)&1
-    OUT_14=(readback.value>>14)&1
-    OUT_15=(readback.value>>15)&1
-    ##print the value of out outputs
-    print "OUTPUTS: \t", OUT_0, OUT_1, OUT_2, OUT_3, OUT_4, OUT_5, OUT_6,\
-        OUT_7, OUT_8, OUT_9, OUT_10, OUT_11, OUT_12, OUT_13, OUT_14, OUT_15
-    ##INPUTS
-    IN_0=(readback.value>>16)&1
-    IN_1=(readback.value>>17)&1
-    IN_2=(readback.value>>18)&1
-    IN_3=(readback.value>>19)&1
-    IN_4=(readback.value>>20)&1
-    IN_5=(readback.value>>21)&1
-    IN_6=(readback.value>>22)&1
-    IN_7=(readback.value>>23)&1
-    IN_8=(readback.value>>24)&1
-    IN_9=(readback.value>>25)&1
-    IN_10=(readback.value>>26)&1
-    IN_11=(readback.value>>27)&1
-    IN_12=(readback.value>>28)&1
-    IN_13=(readback.value>>29)&1
-    IN_14=(readback.value>>30)&1
-    IN_15=(readback.value>>31)&1
-    ##print the value of our inputs
-    print "INPUTS: \t", IN_0, IN_1, IN_2, IN_3, IN_4, IN_5, IN_6,\
-        IN_7, IN_8 , IN_9, IN_10, IN_11, IN_12, IN_13, IN_14, IN_15
-
-
-###############################################################################
-##SETUP VARIABLES FOR OUTPUTS
-OUT0=0
-OUT1=1
-OUT2=2
-OUT3=3
-OUT4=4
-OUT5=5
-OUT6=6
-OUT7=7
-OUT8=8
-OUT9=9
-OUT10=10
-OUT11=11
-OUT12=12
-OUT13=13
-OUT14=14
-OUT15=15
-
-ON=0##Note to turn an output ON, the value must be 0
-OFF=1##Note to turn an output OFF, the value must be 1
-
-##Turns OUT_0 on for 5 seconds, then turns it off again using DIO_Write1
-def TOGGLE_OUT_0():
-    GET_IO_STATUS()
-    print "Lets turn OUT_0 ON for 5 seconds"
-    time.sleep(1)
-
-    DIO=windll.AIOUSB.VBDIO_Write1(DEVICE, OUT0, ON)
-    IO_ERROR(DIO)
-    print "Now check to see if it did indeed turn on..."
-    GET_IO_STATUS()
-    time.sleep(5)
-
-    DIO=windll.AIOUSB.VBDIO_Write1(DEVICE, OUT0, OFF)
-    IO_ERROR(DIO)
-
-    print "Now lets check the IO Status to see that OUT_0 is off..."
-    GET_IO_STATUS()
-    
-
-###############################################################################
-##Uses DIO_WriteAll to toggle all outputs on in sequence then switch them all off
-def TOGGLE_OUTPUTS_ON():
-    for i in xrange(0, 17):
-        thisbit=65535<<i
-        print "thisbit: ", thisbit
-        outputs=c_short(thisbit)
-        DIO=windll.AIOUSB.VBDIO_WriteAll(DEVICE, pointer(outputs))
-        IO_ERROR(DIO)
-        GET_IO_STATUS()
-        time.sleep(1)
-    print "Switch all outputs off again..."
-    outputs=c_short(65535)
-    DIO=windll.AIOUSB.VBDIO_WriteAll(DEVICE, pointer(outputs))
-    GET_IO_STATUS()
-
-    
-##############################################################################
-##Uses arguments to select the output and state to switch
-##for example SWITCH_OUTPUT(OUT1, ON) will turn output 1 on
-def SWITCH_OUTPUT(output, state):
-    OUT = output
-    STATUS = state
-    if STATUS==0:
-        TSTATE="ON"
-    else:
-        TSTATE="OFF"
-    print "Turning OUT_",OUT , TSTATE
-    DIO=windll.AIOUSB.VBDIO_Write1(DEVICE, OUT, STATUS)
-    IO_ERROR(DIO)
-    
-  
-
+from qt import *
+
+############ Program Logic #################
+
+if __name__ == "__main__":
+	main()
+
+def mouseLick():
+    TurnLickLightGreen()

Binary file added.

Binary file added.

Binary file added.

Binary file added.

Binary file added.

+from ui import *
+
+def main():
+    import sys
+    app = QtGui.QApplication(sys.argv)
+    MainWindow = QtGui.QMainWindow()
+    ui = Ui_MainWindow()
+    ui.setupUi(MainWindow)
+    MainWindow.show()
+    sys.exit(app.exec_())
+
+def TurnLickLightGreen():
+    ui.lickButton.changeColor('green')
+

qt/pyolfaction.ui

+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>640</width>
+    <height>480</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>PyOlfaction</string>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <widget class="QLCDNumber" name="hits">
+    <property name="geometry">
+     <rect>
+      <x>130</x>
+      <y>110</y>
+      <width>64</width>
+      <height>23</height>
+     </rect>
+    </property>
+    <property name="intValue" stdset="0">
+     <number>50</number>
+    </property>
+   </widget>
+   <widget class="QLCDNumber" name="misses">
+    <property name="geometry">
+     <rect>
+      <x>130</x>
+      <y>160</y>
+      <width>64</width>
+      <height>23</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QSlider" name="reinforcementDuration">
+    <property name="geometry">
+     <rect>
+      <x>360</x>
+      <y>60</y>
+      <width>160</width>
+      <height>22</height>
+     </rect>
+    </property>
+    <property name="orientation">
+     <enum>Qt::Horizontal</enum>
+    </property>
+   </widget>
+   <widget class="QTableWidget" name="tableWidget">
+    <property name="geometry">
+     <rect>
+      <x>30</x>
+      <y>240</y>
+      <width>256</width>
+      <height>192</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QProgressBar" name="progressBar">
+    <property name="geometry">
+     <rect>
+      <x>360</x>
+      <y>150</y>
+      <width>118</width>
+      <height>23</height>
+     </rect>
+    </property>
+    <property name="value">
+     <number>24</number>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="pushButton">
+    <property name="geometry">
+     <rect>
+      <x>360</x>
+      <y>260</y>
+      <width>114</width>
+      <height>32</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>PushButton</string>
+    </property>
+   </widget>
+   <widget class="QCheckBox" name="checkBox">
+    <property name="geometry">
+     <rect>
+      <x>240</x>
+      <y>50</y>
+      <width>87</width>
+      <height>20</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>CheckBox</string>
+    </property>
+   </widget>
+   <widget class="QTabWidget" name="tabWidget">
+    <property name="geometry">
+     <rect>
+      <x>430</x>
+      <y>10</y>
+      <width>120</width>
+      <height>80</height>
+     </rect>
+    </property>
+    <property name="currentIndex">
+     <number>1</number>
+    </property>
+    <widget class="QWidget" name="tab">
+     <attribute name="title">
+      <string>Tab 1</string>
+     </attribute>
+    </widget>
+    <widget class="QWidget" name="tab_2">
+     <attribute name="title">
+      <string>Tab 2</string>
+     </attribute>
+    </widget>
+   </widget>
+  </widget>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>640</width>
+     <height>22</height>
+    </rect>
+   </property>
+   <widget class="QMenu" name="menuPyOlfaction">
+    <property name="title">
+     <string>File</string>
+    </property>
+    <addaction name="actionNew"/>
+    <addaction name="actionOpen"/>
+    <addaction name="actionSave"/>
+   </widget>
+   <widget class="QMenu" name="menuSettings">
+    <property name="title">
+     <string>Settings</string>
+    </property>
+    <addaction name="actionSpecies"/>
+   </widget>
+   <addaction name="menuPyOlfaction"/>
+   <addaction name="menuSettings"/>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+  <action name="actionNew">
+   <property name="text">
+    <string>New</string>
+   </property>
+  </action>
+  <action name="actionOpen">
+   <property name="text">
+    <string>Open</string>
+   </property>
+  </action>
+  <action name="actionSave">
+   <property name="text">
+    <string>Save</string>
+   </property>
+  </action>
+  <action name="actionSpecies">
+   <property name="text">
+    <string>Species</string>
+   </property>
+  </action>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file 'pyolfaction.ui'
+#
+# Created: Fri Apr  5 13:28:13 2013
+#      by: PyQt4 UI code generator 4.9.4
+#
+# WARNING! All changes made in this file will be lost!
+
+from PyQt4 import QtCore, QtGui
+
+try:
+    _fromUtf8 = QtCore.QString.fromUtf8
+except AttributeError:
+    _fromUtf8 = lambda s: s
+
+class Ui_MainWindow(object):
+    def setupUi(self, MainWindow):
+        MainWindow.setObjectName(_fromUtf8("MainWindow"))
+        MainWindow.resize(640, 480)
+        self.centralwidget = QtGui.QWidget(MainWindow)
+        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
+        self.hits = QtGui.QLCDNumber(self.centralwidget)
+        self.hits.setGeometry(QtCore.QRect(130, 110, 64, 23))
+        self.hits.setProperty("intValue", 50)
+        self.hits.setObjectName(_fromUtf8("hits"))
+        self.misses = QtGui.QLCDNumber(self.centralwidget)
+        self.misses.setGeometry(QtCore.QRect(130, 160, 64, 23))
+        self.misses.setObjectName(_fromUtf8("misses"))
+        self.reinforcementDuration = QtGui.QSlider(self.centralwidget)
+        self.reinforcementDuration.setGeometry(QtCore.QRect(360, 60, 160, 22))
+        self.reinforcementDuration.setOrientation(QtCore.Qt.Horizontal)
+        self.reinforcementDuration.setObjectName(_fromUtf8("reinforcementDuration"))
+        self.tableWidget = QtGui.QTableWidget(self.centralwidget)
+        self.tableWidget.setGeometry(QtCore.QRect(30, 240, 256, 192))
+        self.tableWidget.setObjectName(_fromUtf8("tableWidget"))
+        self.tableWidget.setColumnCount(0)
+        self.tableWidget.setRowCount(0)
+        self.progressBar = QtGui.QProgressBar(self.centralwidget)
+        self.progressBar.setGeometry(QtCore.QRect(360, 150, 118, 23))
+        self.progressBar.setProperty("value", 24)
+        self.progressBar.setObjectName(_fromUtf8("progressBar"))
+        self.pushButton = QtGui.QPushButton(self.centralwidget)
+        self.pushButton.setGeometry(QtCore.QRect(360, 260, 114, 32))
+        self.pushButton.setObjectName(_fromUtf8("pushButton"))
+        self.checkBox = QtGui.QCheckBox(self.centralwidget)
+        self.checkBox.setGeometry(QtCore.QRect(240, 50, 87, 20))
+        self.checkBox.setObjectName(_fromUtf8("checkBox"))
+        self.tabWidget = QtGui.QTabWidget(self.centralwidget)
+        self.tabWidget.setGeometry(QtCore.QRect(430, 10, 120, 80))
+        self.tabWidget.setObjectName(_fromUtf8("tabWidget"))
+        self.tab = QtGui.QWidget()
+        self.tab.setObjectName(_fromUtf8("tab"))
+        self.tabWidget.addTab(self.tab, _fromUtf8(""))
+        self.tab_2 = QtGui.QWidget()
+        self.tab_2.setObjectName(_fromUtf8("tab_2"))
+        self.tabWidget.addTab(self.tab_2, _fromUtf8(""))
+        MainWindow.setCentralWidget(self.centralwidget)
+        self.menubar = QtGui.QMenuBar(MainWindow)
+        self.menubar.setGeometry(QtCore.QRect(0, 0, 640, 22))
+        self.menubar.setObjectName(_fromUtf8("menubar"))
+        self.menuPyOlfaction = QtGui.QMenu(self.menubar)
+        self.menuPyOlfaction.setObjectName(_fromUtf8("menuPyOlfaction"))
+        self.menuSettings = QtGui.QMenu(self.menubar)
+        self.menuSettings.setObjectName(_fromUtf8("menuSettings"))
+        MainWindow.setMenuBar(self.menubar)
+        self.statusbar = QtGui.QStatusBar(MainWindow)
+        self.statusbar.setObjectName(_fromUtf8("statusbar"))
+        MainWindow.setStatusBar(self.statusbar)
+        self.actionNew = QtGui.QAction(MainWindow)
+        self.actionNew.setObjectName(_fromUtf8("actionNew"))
+        self.actionOpen = QtGui.QAction(MainWindow)
+        self.actionOpen.setObjectName(_fromUtf8("actionOpen"))
+        self.actionSave = QtGui.QAction(MainWindow)
+        self.actionSave.setObjectName(_fromUtf8("actionSave"))
+        self.actionSpecies = QtGui.QAction(MainWindow)
+        self.actionSpecies.setObjectName(_fromUtf8("actionSpecies"))
+        self.menuPyOlfaction.addAction(self.actionNew)
+        self.menuPyOlfaction.addAction(self.actionOpen)
+        self.menuPyOlfaction.addAction(self.actionSave)
+        self.menuSettings.addAction(self.actionSpecies)
+        self.menubar.addAction(self.menuPyOlfaction.menuAction())
+        self.menubar.addAction(self.menuSettings.menuAction())
+
+        self.retranslateUi(MainWindow)
+        self.tabWidget.setCurrentIndex(1)
+        QtCore.QMetaObject.connectSlotsByName(MainWindow)
+
+    def retranslateUi(self, MainWindow):
+        MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "PyOlfaction", None, QtGui.QApplication.UnicodeUTF8))
+        self.pushButton.setText(QtGui.QApplication.translate("MainWindow", "PushButton", None, QtGui.QApplication.UnicodeUTF8))
+        self.checkBox.setText(QtGui.QApplication.translate("MainWindow", "CheckBox", None, QtGui.QApplication.UnicodeUTF8))
+        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), QtGui.QApplication.translate("MainWindow", "Tab 1", None, QtGui.QApplication.UnicodeUTF8))
+        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), QtGui.QApplication.translate("MainWindow", "Tab 2", None, QtGui.QApplication.UnicodeUTF8))
+        self.menuPyOlfaction.setTitle(QtGui.QApplication.translate("MainWindow", "File", None, QtGui.QApplication.UnicodeUTF8))
+        self.menuSettings.setTitle(QtGui.QApplication.translate("MainWindow", "Settings", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionNew.setText(QtGui.QApplication.translate("MainWindow", "New", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionOpen.setText(QtGui.QApplication.translate("MainWindow", "Open", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionSave.setText(QtGui.QApplication.translate("MainWindow", "Save", None, QtGui.QApplication.UnicodeUTF8))
+        self.actionSpecies.setText(QtGui.QApplication.translate("MainWindow", "Species", None, QtGui.QApplication.UnicodeUTF8))
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.