Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
adc-testing
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
misc
adc-testing
Commits
a4615d13
Commit
a4615d13
authored
Sep 01, 2011
by
Federico Asara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qtGUI modules for selecting PAGE API modules.
parent
2f9a6d59
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
314 additions
and
0 deletions
+314
-0
ModuleSelector.py
qtGUI/ModuleSelector.py
+126
-0
Selector.py
qtGUI/Selector.py
+62
-0
selector.ui
qtGUI/selector.ui
+126
-0
No files found.
qtGUI/ModuleSelector.py
0 → 100644
View file @
a4615d13
from
PyQt4.QtCore
import
*
from
PyQt4.QtGui
import
*
import
PAGE
from
PAGE.Utilities
import
*
import
Selector
from
numpy
import
*
from
PyQt4.Qwt5
import
QwtPlotGrid
#FIXME: pressing tab while editing crashes everything
class
ModuleSelector
(
QDialog
):
names
=
{
'waveforms'
:
0
,
'generators'
:
1
,
'adcs'
:
2
}
decisionTable
=
(
PAGE
.
waveforms
,
PAGE
.
generators
,
PAGE
.
adcs
)
def
__init__
(
self
,
parent
=
None
,
kind
=
0
):
if
type
(
kind
)
is
str
:
kind
=
self
.
names
[
kind
]
QDialog
.
__init__
(
self
,
parent
)
self
.
ui
=
Selector
.
Ui_Dialog
()
self
.
ui
.
setupUi
(
self
)
self
.
table
=
self
.
decisionTable
[
kind
]
self
.
mods
=
[[
self
.
table
[
i
]
.
name
,
str
(
i
)]
for
i
in
range
(
len
(
self
.
table
))]
self
.
modc
=
[[(
j
,
i
.
target
.
_parameters
[
j
])
for
j
in
i
.
target
.
_parameters
]
for
i
in
self
.
table
]
items
=
[
QTreeWidgetItem
(
i
)
for
i
in
self
.
mods
]
self
.
ui
.
modules
.
addTopLevelItems
(
items
)
self
.
ui
.
modules
.
itemSelectionChanged
.
connect
(
self
.
slotUpdateConf
)
self
.
ui
.
modulesConfig
.
itemDoubleClicked
.
connect
(
self
.
slotEditParameter
)
self
.
dele
=
QItemDelegate
()
self
.
ui
.
modulesConfig
.
setItemDelegate
(
self
.
dele
)
self
.
dele
.
closeEditor
.
connect
(
self
.
slotCloseEditor
)
def
slotCloseEditor
(
self
,
editor
,
*
args
,
**
kwargs
):
self
.
ui
.
modulesConfig
.
closePersistentEditor
(
*
self
.
edItem
)
def
slotEditParameter
(
self
,
item
,
column
,
*
args
,
**
kwargs
):
self
.
edItem
=
item
,
1
# we don't always need to edit
key
=
str
(
item
.
text
(
2
))
index
=
int
(
self
.
ui
.
modules
.
currentItem
()
.
text
(
1
))
target
=
self
.
table
[
index
]
.
target
params
=
dict
(
target
.
_parameters
)
if
type
(
params
[
key
][
3
])
is
str
:
if
params
[
key
][
3
]
==
'file'
:
fileName
=
str
(
QFileDialog
.
getOpenFileName
(
self
,
caption
=
"Select device"
,
directory
=
'/dev'
,
filter
=
"*"
))
if
fileName
!=
""
:
item
.
setText
(
1
,
filename
)
return
self
.
ui
.
modulesConfig
.
openPersistentEditor
(
*
self
.
edItem
)
def
generatePrefs
(
self
):
index
=
int
(
self
.
ui
.
modules
.
currentItem
()
.
text
(
1
))
target
=
self
.
table
[
index
]
.
target
params
=
dict
(
target
.
_parameters
)
output
=
{}
lim
=
self
.
ui
.
modulesConfig
.
topLevelItemCount
()
i
=
0
temp
=
self
.
ui
.
modulesConfig
.
topLevelItem
(
0
)
while
(
temp
is
not
None
and
temp
!=
0
):
key
=
str
(
temp
.
text
(
2
))
value
=
str
(
temp
.
text
(
1
))
# name = str(temp.text(0))
ttt
=
params
[
key
]
output
[
key
]
=
ttt
[
3
](
value
)
if
(
ttt
[
3
]
is
not
str
and
ttt
[
3
]
!=
'file'
)
else
value
i
+=
1
temp
=
self
.
ui
.
modulesConfig
.
topLevelItem
(
i
)
return
target
,
output
def
slotUpdateConf
(
self
,
*
args
,
**
kwargs
):
s
=
self
.
ui
.
modules
.
currentItem
()
i
=
self
.
ui
.
modules
.
indexFromItem
(
s
)
.
row
()
temp
=
self
.
modc
[
i
]
self
.
ui
.
modulesConfig
.
clear
()
for
i
in
temp
:
y
=
QTreeWidgetItem
([
i
[
1
][
0
],
str
(
i
[
1
][
2
]),
i
[
0
]],
Qt
.
ItemIsSelectable
|
Qt
.
ItemIsUserCheckable
|
Qt
.
ItemIsEnabled
|
Qt
.
ItemIsEditable
)
self
.
ui
.
modulesConfig
.
addTopLevelItem
(
y
)
def
test
():
import
sys
import
PyQt4.QtCore
import
PyQt4.QtGui
# Create a Qt application
app
=
PyQt4
.
QtGui
.
QApplication
(
sys
.
argv
)
iii
=
[]
for
i
in
range
(
3
):
mw
=
ModuleSelector
(
kind
=
i
)
mw
.
show
()
iii
.
append
(
mw
)
# Enter Qt application main loop
app
.
exec_
()
for
i
in
iii
:
print
i
.
generatePrefs
()
if
__name__
==
'__main__'
:
test
()
qtGUI/Selector.py
0 → 100644
View file @
a4615d13
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'selector.ui'
#
# Created: Thu Aug 25 15:05:30 2011
# by: PyQt4 UI code generator 4.8.3
#
# 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_Dialog
(
object
):
def
setupUi
(
self
,
Dialog
):
Dialog
.
setObjectName
(
_fromUtf8
(
"Dialog"
))
Dialog
.
resize
(
734
,
409
)
self
.
verticalLayout_2
=
QtGui
.
QVBoxLayout
(
Dialog
)
self
.
verticalLayout_2
.
setObjectName
(
_fromUtf8
(
"verticalLayout_2"
))
self
.
horizontalLayout
=
QtGui
.
QHBoxLayout
()
self
.
horizontalLayout
.
setObjectName
(
_fromUtf8
(
"horizontalLayout"
))
self
.
verticalLayout
=
QtGui
.
QVBoxLayout
()
self
.
verticalLayout
.
setObjectName
(
_fromUtf8
(
"verticalLayout"
))
self
.
label
=
QtGui
.
QLabel
(
Dialog
)
self
.
label
.
setObjectName
(
_fromUtf8
(
"label"
))
self
.
verticalLayout
.
addWidget
(
self
.
label
)
self
.
modules
=
QtGui
.
QTreeWidget
(
Dialog
)
sizePolicy
=
QtGui
.
QSizePolicy
(
QtGui
.
QSizePolicy
.
Preferred
,
QtGui
.
QSizePolicy
.
MinimumExpanding
)
sizePolicy
.
setHorizontalStretch
(
0
)
sizePolicy
.
setVerticalStretch
(
0
)
sizePolicy
.
setHeightForWidth
(
self
.
modules
.
sizePolicy
()
.
hasHeightForWidth
())
self
.
modules
.
setSizePolicy
(
sizePolicy
)
self
.
modules
.
setObjectName
(
_fromUtf8
(
"modules"
))
self
.
modules
.
header
()
.
setVisible
(
False
)
self
.
verticalLayout
.
addWidget
(
self
.
modules
)
self
.
horizontalLayout
.
addLayout
(
self
.
verticalLayout
)
self
.
modulesConfig
=
QtGui
.
QTreeWidget
(
Dialog
)
self
.
modulesConfig
.
setColumnCount
(
2
)
self
.
modulesConfig
.
setObjectName
(
_fromUtf8
(
"modulesConfig"
))
self
.
horizontalLayout
.
addWidget
(
self
.
modulesConfig
)
self
.
verticalLayout_2
.
addLayout
(
self
.
horizontalLayout
)
self
.
buttonBox
=
QtGui
.
QDialogButtonBox
(
Dialog
)
self
.
buttonBox
.
setOrientation
(
QtCore
.
Qt
.
Horizontal
)
self
.
buttonBox
.
setStandardButtons
(
QtGui
.
QDialogButtonBox
.
Cancel
|
QtGui
.
QDialogButtonBox
.
Ok
)
self
.
buttonBox
.
setObjectName
(
_fromUtf8
(
"buttonBox"
))
self
.
verticalLayout_2
.
addWidget
(
self
.
buttonBox
)
self
.
retranslateUi
(
Dialog
)
QtCore
.
QObject
.
connect
(
self
.
buttonBox
,
QtCore
.
SIGNAL
(
_fromUtf8
(
"accepted()"
)),
Dialog
.
accept
)
QtCore
.
QObject
.
connect
(
self
.
buttonBox
,
QtCore
.
SIGNAL
(
_fromUtf8
(
"rejected()"
)),
Dialog
.
reject
)
QtCore
.
QMetaObject
.
connectSlotsByName
(
Dialog
)
def
retranslateUi
(
self
,
Dialog
):
Dialog
.
setWindowTitle
(
QtGui
.
QApplication
.
translate
(
"Dialog"
,
"Module selection"
,
None
,
QtGui
.
QApplication
.
UnicodeUTF8
))
self
.
label
.
setText
(
QtGui
.
QApplication
.
translate
(
"Dialog"
,
"Select a module:"
,
None
,
QtGui
.
QApplication
.
UnicodeUTF8
))
self
.
modules
.
headerItem
()
.
setText
(
0
,
QtGui
.
QApplication
.
translate
(
"Dialog"
,
"Modules"
,
None
,
QtGui
.
QApplication
.
UnicodeUTF8
))
self
.
modulesConfig
.
headerItem
()
.
setText
(
0
,
QtGui
.
QApplication
.
translate
(
"Dialog"
,
"Parameter"
,
None
,
QtGui
.
QApplication
.
UnicodeUTF8
))
self
.
modulesConfig
.
headerItem
()
.
setText
(
1
,
QtGui
.
QApplication
.
translate
(
"Dialog"
,
"Value"
,
None
,
QtGui
.
QApplication
.
UnicodeUTF8
))
qtGUI/selector.ui
0 → 100644
View file @
a4615d13
<?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>
734
</width>
<height>
409
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
<string>
Module selection
</string>
</property>
<property
name=
"sizeGripEnabled"
>
<bool>
true
</bool>
</property>
<property
name=
"modal"
>
<bool>
true
</bool>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_2"
>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<item>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout"
>
<item>
<widget
class=
"QLabel"
name=
"label"
>
<property
name=
"text"
>
<string>
Select a module:
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QTreeWidget"
name=
"modules"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Preferred"
vsizetype=
"MinimumExpanding"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<property
name=
"itemsExpandable"
>
<bool>
false
</bool>
</property>
<attribute
name=
"headerVisible"
>
<bool>
false
</bool>
</attribute>
<column>
<property
name=
"text"
>
<string>
Modules
</string>
</property>
</column>
</widget>
</item>
</layout>
</item>
<item>
<widget
class=
"QTreeWidget"
name=
"modulesConfig"
>
<property
name=
"itemsExpandable"
>
<bool>
false
</bool>
</property>
<property
name=
"columnCount"
>
<number>
2
</number>
</property>
<column>
<property
name=
"text"
>
<string>
Parameter
</string>
</property>
</column>
<column>
<property
name=
"text"
>
<string>
Value
</string>
</property>
</column>
</widget>
</item>
</layout>
</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>
</widget>
<resources/>
<connections>
<connection>
<sender>
buttonBox
</sender>
<signal>
accepted()
</signal>
<receiver>
Dialog
</receiver>
<slot>
accept()
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
227
</x>
<y>
387
</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>
295
</x>
<y>
393
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
286
</x>
<y>
274
</y>
</hint>
</hints>
</connection>
</connections>
</ui>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment