diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..7614de9 --- /dev/null +++ b/README.rst @@ -0,0 +1,4 @@ +lab_config +========== + +Some lab configuration tools. diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml new file mode 100644 index 0000000..76746d8 --- /dev/null +++ b/conda.recipe/meta.yaml @@ -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. diff --git a/config/__init__.py b/config/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/config/__main__.py b/config/__main__.py new file mode 100644 index 0000000..de95820 --- /dev/null +++ b/config/__main__.py @@ -0,0 +1,6 @@ +import sys + +import config_app + +if __name__ == "__main__": + sys.exit(config_app.main(*sys.argv)) diff --git a/config/config_app.py b/config/config_app.py new file mode 100644 index 0000000..d80de28 --- /dev/null +++ b/config/config_app.py @@ -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)) diff --git a/config/config_app.ui b/config/config_app.ui new file mode 100644 index 0000000..aca09e1 --- /dev/null +++ b/config/config_app.ui @@ -0,0 +1,183 @@ + + + Dialog + + + + 0 + 0 + 598 + 648 + + + + + 0 + 0 + + + + Dialog + + + false + + + + + + + + true + + + false + + + false + + + + Rig_Name + + + + + User + + + + + Proj_Code + + + + + Rec_Sys + + + + + Behav_Code_Ver + + + + + NS_Path + + + + + Behav_Path + + + + + Jpos_X_Ch + + + + + Jpos_Y_Ch + + + + + Mpos_X_Ch + + + + + Mpos_Y_Ch + + + + + Lick_Ch + + + + + Rew_Ch + + + + + Trial_Start_Ch + + + + + Trial_Event_Ch + + + + + Input + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + <b>Lab Data Configuration Generator</b> + + + Qt::AutoText + + + false + + + + + + + + + buttonBox + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/constructor.config/construct.yaml b/constructor.config/construct.yaml new file mode 100644 index 0000000..66bd8b9 --- /dev/null +++ b/constructor.config/construct.yaml @@ -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 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..680f665 --- /dev/null +++ b/setup.py @@ -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=[] +)