Skip to content
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
lab_config
==========

Some lab configuration tools.
28 changes: 28 additions & 0 deletions conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package:
name: lab_config
version: {{ environ.get('GIT_DESCRIBE_TAG', '')[1:] }}{{ '+' + environ.get('GIT_DESCRIBE_NUMBER', '0') + '.' + environ.get('GIT_DESCRIBE_HASH', '0') if environ.get('GIT_DESCRIBE_NUMBER', '0') != '0' else "" }}

source:
git_url: ..
git_tag: HEAD

build:
number: 0
script: python setup.py install

requirements:
build:
- python

run:
- python
- pyside

test:
imports:
- config

about:
home: https://github.com/DudLab/lab_config
license: BSD???
summary: A package of utilities in use in our lab.
Empty file added config/__init__.py
Empty file.
6 changes: 6 additions & 0 deletions config/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import sys

import config_app

if __name__ == "__main__":
sys.exit(config_app.main(*sys.argv))
84 changes: 84 additions & 0 deletions config/config_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env python


from __future__ import print_function

import collections as col
import json
import os
import sys

try:
from PySide import QtCore, QtGui, QtUiTools
except ImportError:
from PyQt4 import QtCore, QtGui, uic

# Python 3 compatibility
try:
xrange
except NameError:
xrange = range

script_dir = os.path.dirname(os.path.abspath(__file__))

class Config(QtGui.QDialog):
"""
Parses the configuration the user applies
"""

def __init__(self, *args, **kwargs):
super(Config, self).__init__(*args, **kwargs)
self.modal = True

self.config = col.OrderedDict()

config_app_ui = os.path.join(
script_dir,
"config_app.ui"
)
try:
self.ui = QtUiTools.QUiLoader().load(config_app_ui)
except NameError:
self.ui = uic.loadUi(config_app_ui)

btn_box = self.ui.buttonBox
ok_btn = btn_box.button(
QtGui.QDialogButtonBox.Ok
)
ok_btn.clicked.connect(self.accept)

def show(self):
self.ui.show()
self.ui.activateWindow()
self.ui.raise_()

def accept(self):
table = self.ui.tableWidget
for i in xrange(table.rowCount()):
header_i = str(table.verticalHeaderItem(i).text())
self.config[header_i] = ""
item_i = table.item(0, i)
if item_i:
self.config[header_i] = str(item_i.text())

filename = QtGui.QFileDialog.getSaveFileName(
self,
"Save file",
"",
"*.json"
)
# PySide gives us a tuple.
# The actual filename is first
if isinstance(filename, tuple):
filename = filename[0]
with open(filename, "w") as f:
json.dump(self.config, f, indent=True)

def main(*argv):
app = QtGui.QApplication(sys.argv)
window = Config()
window.show()
return app.exec_()

if __name__ == "__main__":
sys.exit(main(*sys.argv))
183 changes: 183 additions & 0 deletions config/config_app.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>598</width>
<height>648</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTableWidget" name="tableWidget">
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderCascadingSectionResizes">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
<row>
<property name="text">
<string>Rig_Name</string>
</property>
</row>
<row>
<property name="text">
<string>User</string>
</property>
</row>
<row>
<property name="text">
<string>Proj_Code</string>
</property>
</row>
<row>
<property name="text">
<string>Rec_Sys</string>
</property>
</row>
<row>
<property name="text">
<string>Behav_Code_Ver</string>
</property>
</row>
<row>
<property name="text">
<string>NS_Path</string>
</property>
</row>
<row>
<property name="text">
<string>Behav_Path</string>
</property>
</row>
<row>
<property name="text">
<string>Jpos_X_Ch</string>
</property>
</row>
<row>
<property name="text">
<string>Jpos_Y_Ch</string>
</property>
</row>
<row>
<property name="text">
<string>Mpos_X_Ch</string>
</property>
</row>
<row>
<property name="text">
<string>Mpos_Y_Ch</string>
</property>
</row>
<row>
<property name="text">
<string>Lick_Ch</string>
</property>
</row>
<row>
<property name="text">
<string>Rew_Ch</string>
</property>
</row>
<row>
<property name="text">
<string>Trial_Start_Ch</string>
</property>
</row>
<row>
<property name="text">
<string>Trial_Event_Ch</string>
</property>
</row>
<column>
<property name="text">
<string>Input</string>
</property>
</column>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;b&gt;Lab Data Configuration Generator&lt;/b&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
15 changes: 15 additions & 0 deletions constructor.config/construct.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: lab_config
version: "0.1.0"

channels:
- http://repo.continuum.io/pkgs/free/
- https://conda.anaconda.org/jakirkham

specs:
- lab_config

keep_pkgs: true

conda_default_channels:
- http://repo.continuum.io/pkgs/free/
- https://conda.anaconda.org/jakirkham
26 changes: 26 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os

from distutils.core import setup

pkg_dir = os.path.dirname(os.path.abspath(
__file__
))

readme = ""
readme_filename = os.path.join(pkg_dir, "README.rst")
with open(readme_filename, "r") as readme_file:
readme = readme_file.read()

setup(
name="lab_config",
version="0.1.0",
license="BSD??",
description="A package of utilities in use in our lab.",
long_description=readme,
author="John Kirkham",
author_email="kirkhamj@janelia.hhmi.org",
url="https://github.com/DudLab/lab_config",
packages=["config"],
package_data={"config": ["*.ui"]},
classifiers=[]
)