Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CCS
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marko Mecina
CCS
Commits
90912d4a
Commit
90912d4a
authored
Jul 30, 2021
by
Marko Mecina
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/sebastian' into marko
parents
3140ef85
96509739
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Tst/tst/tc_management.py
+179
-12
179 additions, 12 deletions
Tst/tst/tc_management.py
Tst/tst/tst.py
+16
-128
16 additions, 128 deletions
Tst/tst/tst.py
Tst/tst/view.py
+12
-0
12 additions, 0 deletions
Tst/tst/view.py
with
207 additions
and
140 deletions
Tst/tst/tc_management.py
+
179
−
12
View file @
90912d4a
#!/usr/bin/env python3
import
gi
gi
.
require_version
(
"
Gtk
"
,
"
3.0
"
)
gi
.
require_version
(
"
GtkSource
"
,
"
3.0
"
)
from
gi.repository
import
Gtk
,
GtkSource
from
gi.repository
import
Gtk
,
Gdk
,
GtkSource
import
confignator
import
sys
sys
.
path
.
append
(
confignator
.
get_option
(
'
paths
'
,
'
ccs
'
))
import
ccs_function_lib
as
cfl
import
tc_management
as
tcm
tc_type
=
None
dictionary_of_commands
=
cfl
.
get_tc_list
()
read_in_list_of_commands
=
list
(
dictionary_of_commands
.
keys
())
list_of_commands
=
[]
type_list
=
[]
subtype_list
=
[]
descr_list
=
[]
calibrations_list
=
[]
minval_list
=
[]
maxval_list
=
[]
altxt_list
=
[]
alval_list
=
[]
for
command
in
read_in_list_of_commands
:
command
=
list
(
command
)
del
command
[
0
]
myorder
=
[
2
,
3
,
0
,
1
]
command
=
[
command
[
i
]
for
i
in
myorder
]
command
[
0
]
=
int
(
command
[
0
])
command
[
1
]
=
int
(
command
[
1
])
list_of_commands
.
append
(
command
)
if
command
[
0
]
not
in
type_list
:
type_list
.
append
(
command
[
0
])
type_list
.
sort
()
subtype_list
.
sort
()
def
get_variables
(
tc_type
):
...
...
@@ -107,12 +138,147 @@ def get_calibrations(tc_type, cpc_descr):
descr_list
=
[]
calibrations_list
=
[]
minval_list
=
[]
maxval_list
=
[]
altxt_list
=
[]
alval_list
=
[]
"""
Gesamtbild bestehend aus TcTable und CommandDescriptionBox hier einfügen
"""
class
TcBox
(
Gtk
.
Box
):
pass
"""
TcTable hier einfügen
"""
class
TcTable
(
Gtk
.
Grid
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
().
__init__
(
*
args
,
**
kwargs
)
self
.
set_size_request
(
500
,
500
)
# self.set_orientation(Gtk.Orientation.VERTICAL)
# self.grid = Gtk.Grid
self
.
telecommand_liststore
=
Gtk
.
ListStore
(
int
,
int
,
str
,
str
)
for
telecommand_ref
in
list_of_commands
:
self
.
telecommand_liststore
.
append
(
list
(
telecommand_ref
))
self
.
current_filter_telecommand
=
None
# Creating the filter, feeding it with the liststore model
self
.
telecommand_filter
=
self
.
telecommand_liststore
.
filter_new
()
# setting the filter function
self
.
telecommand_filter
.
set_visible_func
(
self
.
telecommand_filter_func
)
# Create ListStores for the ComboBoxes
self
.
type_liststore
=
Gtk
.
ListStore
(
int
)
for
type_ref
in
type_list
:
self
.
type_liststore
.
append
([
type_ref
,
])
# self.current_filter_type = None
self
.
type_combo
=
Gtk
.
ComboBox
.
new_with_model
(
self
.
type_liststore
)
self
.
type_combo
.
connect
(
"
changed
"
,
self
.
on_type_combo_changed
)
renderer_text
=
Gtk
.
CellRendererText
()
self
.
type_combo
.
pack_start
(
renderer_text
,
True
)
self
.
type_combo
.
add_attribute
(
renderer_text
,
"
text
"
,
0
)
self
.
attach
(
self
.
type_combo
,
0
,
0
,
1
,
1
)
self
.
clear_button
=
Gtk
.
Button
(
label
=
"
Clear
"
)
self
.
clear_button
.
connect
(
"
clicked
"
,
self
.
on_clear_button_clicked
)
self
.
attach_next_to
(
self
.
clear_button
,
self
.
type_combo
,
Gtk
.
PositionType
.
RIGHT
,
1
,
1
)
# creating the treeview, making it use the filter a model, adding columns
self
.
treeview
=
Gtk
.
TreeView
.
new_with_model
(
Gtk
.
TreeModelSort
(
self
.
telecommand_filter
))
for
i
,
column_title
in
enumerate
(
[
"
#TYPE
"
,
"
SUBTYPE
"
,
"
DESCR
"
,
"
LONGDESCR
"
]
):
renderer
=
Gtk
.
CellRendererText
()
column
=
Gtk
.
TreeViewColumn
(
column_title
,
renderer
,
text
=
i
)
column
.
set_sort_column_id
(
i
)
self
.
treeview
.
append_column
(
column
)
# Handle selection
self
.
selected_row
=
self
.
treeview
.
get_selection
()
self
.
selected_row
.
connect
(
"
changed
"
,
self
.
item_selected
)
# setting up layout, treeview in scrollwindow
self
.
scrollable_treelist
=
Gtk
.
ScrolledWindow
()
self
.
scrollable_treelist
.
set_vexpand
(
True
)
self
.
scrollable_treelist
.
set_hexpand
(
True
)
self
.
attach
(
self
.
scrollable_treelist
,
0
,
1
,
8
,
10
)
self
.
scrollable_treelist
.
add
(
self
.
treeview
)
self
.
command_entry
=
Gtk
.
Entry
()
self
.
command_entry
.
set_placeholder_text
(
"
<Command Variables>
"
)
self
.
attach_next_to
(
self
.
command_entry
,
self
.
scrollable_treelist
,
Gtk
.
PositionType
.
BOTTOM
,
8
,
1
)
self
.
variable_box
=
CommandDescriptionBox
()
self
.
attach_next_to
(
self
.
variable_box
,
self
.
command_entry
,
Gtk
.
PositionType
.
BOTTOM
,
8
,
5
)
# Set up Drag and Drop
self
.
treeview
.
drag_source_set
(
Gdk
.
ModifierType
.
BUTTON1_MASK
,
[],
Gdk
.
DragAction
.
COPY
)
self
.
treeview
.
drag_source_set_target_list
(
None
)
self
.
treeview
.
drag_source_add_text_targets
()
self
.
treeview
.
connect
(
"
drag-data-get
"
,
self
.
on_drag_data_get
)
self
.
treeview
.
connect
(
"
drag-begin
"
,
self
.
on_drag_begin
)
self
.
show_all
()
def
on_type_combo_changed
(
self
,
combo
):
combo_iter
=
combo
.
get_active_iter
()
if
combo_iter
is
not
None
:
model
=
combo
.
get_model
()
number
=
model
[
combo_iter
][
0
]
# print(number)
self
.
current_filter_telecommand
=
int
(
number
)
self
.
telecommand_filter
.
refilter
()
def
on_clear_button_clicked
(
self
,
widget
):
self
.
current_filter_telecommand
=
None
self
.
telecommand_filter
.
refilter
()
def
item_selected
(
self
,
selection
):
model
,
row
=
selection
.
get_selected
()
if
row
is
not
None
:
global
descr
descr
=
model
[
row
][
2
]
self
.
command_entry
.
set_text
(
cfl
.
make_tc_template
(
descr
,
comment
=
False
))
global
tc_type
tc_type
=
descr
cpc_descr
=
get_cpc_descr
(
tc_type
)
global
descr_list
descr_list
.
clear
()
descr_list
=
cpc_descr
self
.
variable_box
.
refresh_descr_treeview
()
calibrations_list
.
clear
()
self
.
variable_box
.
refresh_cal_treeview
()
else
:
pass
def
telecommand_filter_func
(
self
,
model
,
iter
,
data
):
if
(
self
.
current_filter_telecommand
is
None
or
self
.
current_filter_telecommand
==
"
None
"
):
return
True
else
:
return
model
[
iter
][
0
]
==
self
.
current_filter_telecommand
def
on_drag_data_get
(
self
,
treeview
,
drag_context
,
selection_data
,
info
,
time
,
*
args
):
treeselection
=
treeview
.
get_selection
()
model
,
my_iter
=
treeselection
.
get_selected
()
selection_data
.
set_text
(
cfl
.
make_tc_template
(
descr
,
comment
=
False
),
-
1
)
def
on_drag_begin
(
self
,
*
args
):
pass
...
...
@@ -134,7 +300,7 @@ class CommandDescriptionBox(Gtk.Box):
# setting the filter function
self
.
descr_filter
.
set_visible_func
(
self
.
descr_filter_func
)
self
.
treeview
=
Gtk
.
TreeView
(
model
=
self
.
descr_filter
)
self
.
descr_
treeview
=
Gtk
.
TreeView
(
model
=
self
.
descr_filter
)
for
i
,
column_title
in
enumerate
(
...
...
@@ -143,12 +309,12 @@ class CommandDescriptionBox(Gtk.Box):
renderer
=
Gtk
.
CellRendererText
()
column
=
Gtk
.
TreeViewColumn
(
column_title
,
renderer
,
text
=
i
)
column
.
colnr
=
i
self
.
treeview
.
append_column
(
column
)
self
.
descr_
treeview
.
append_column
(
column
)
# item selection
# self.treeview.connect("button-press-event", self.on_cell_clicked)
self
.
selected_row
=
self
.
treeview
.
get_selection
()
self
.
selected_row
=
self
.
descr_
treeview
.
get_selection
()
self
.
selected_row
.
connect
(
"
changed
"
,
self
.
item_selected
)
...
...
@@ -156,7 +322,7 @@ class CommandDescriptionBox(Gtk.Box):
self
.
scrollable_treelist
.
set_vexpand
(
True
)
self
.
pack_start
(
self
.
scrollable_treelist
,
True
,
True
,
0
)
self
.
scrollable_treelist
.
add
(
self
.
treeview
)
self
.
scrollable_treelist
.
add
(
self
.
descr_
treeview
)
...
...
@@ -220,7 +386,7 @@ class CommandDescriptionBox(Gtk.Box):
self
.
descr_liststore
=
Gtk
.
ListStore
(
str
)
for
descr_ref
in
descr_list
:
self
.
descr_liststore
.
append
(
tuple
(
descr_ref
))
self
.
treeview
.
set_model
(
self
.
descr_liststore
)
self
.
descr_
treeview
.
set_model
(
self
.
descr_liststore
)
def
cal_filter_func
(
self
,
model
,
iter
,
data
):
...
...
@@ -233,6 +399,7 @@ class CommandDescriptionBox(Gtk.Box):
return
model
[
iter
][
2
]
==
self
.
current_filter_descr
def
refresh_cal_treeview
(
self
):
self
.
cal_liststore
=
Gtk
.
ListStore
(
str
,
str
,
str
,
str
)
if
calibrations_list
==
[]
or
calibrations_list
==
[[]]:
...
...
This diff is collapsed.
Click to expand it.
Tst/tst/tst.py
+
16
−
128
View file @
90912d4a
...
...
@@ -24,27 +24,12 @@ import toolbox
import
tc_management
as
tcm
# creating lists for type and subtype to get rid of duplicate entries, for TC List
dictionary_of_commands
=
cfl
.
get_tc_list
()
read_in_list_of_commands
=
list
(
dictionary_of_commands
.
keys
())
list_of_commands
=
[]
type_list
=
[]
subtype_list
=
[]
for
command
in
read_in_list_of_commands
:
command
=
list
(
command
)
del
command
[
0
]
myorder
=
[
2
,
3
,
0
,
1
]
command
=
[
command
[
i
]
for
i
in
myorder
]
command
[
0
]
=
int
(
command
[
0
])
command
[
1
]
=
int
(
command
[
1
])
list_of_commands
.
append
(
command
)
if
command
[
0
]
not
in
type_list
:
type_list
.
append
(
command
[
0
])
type_list
.
sort
()
subtype_list
.
sort
()
path_icon
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'
style/tst.svg
'
)
menu_xml
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'
app_menu.xml
'
)
...
...
@@ -316,10 +301,21 @@ class TstAppWindow(Gtk.ApplicationWindow):
self
.
feature_area
.
append_page
(
child
=
self
.
log_view
,
tab_label
=
self
.
label_widget_log_view
)
# command list tab
self
.
tcm
=
tcm
.
TcTable
()
self
.
label_widget_tcm
=
Gtk
.
Label
()
self
.
label_widget_tcm
.
set_text
(
'
TC Table
'
)
self
.
feature_area
.
append_page
(
child
=
self
.
tcm
,
tab_label
=
self
.
label_widget_tcm
)
"""
self.tcm = TCTableClass()
self.label_widget_tcm = Gtk.Label()
self.label_widget_tcm.set_text(
'
TC Table
'
)
self.feature_area.append_page(child=self.tcm, tab_label=self.label_widget_tcm)
"""
self
.
box
.
pack_start
(
self
.
work_desk
,
True
,
True
,
0
)
...
...
@@ -763,114 +759,6 @@ class TstAppWindow(Gtk.ApplicationWindow):
Gtk
.
STYLE_PROVIDER_PRIORITY_APPLICATION
)
Gtk
.
StyleContext
.
reset_widgets
(
Gdk
.
Screen
.
get_default
())
class
TCTableClass
(
Gtk
.
Grid
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
().
__init__
(
*
args
,
**
kwargs
)
self
.
set_size_request
(
500
,
500
)
# self.set_orientation(Gtk.Orientation.VERTICAL)
# self.grid = Gtk.Grid
self
.
telecommand_liststore
=
Gtk
.
ListStore
(
int
,
int
,
str
,
str
)
for
telecommand_ref
in
list_of_commands
:
self
.
telecommand_liststore
.
append
(
list
(
telecommand_ref
))
self
.
current_filter_telecommand
=
None
# Creating the filter, feeding it with the liststore model
self
.
telecommand_filter
=
self
.
telecommand_liststore
.
filter_new
()
# setting the filter function
self
.
telecommand_filter
.
set_visible_func
(
self
.
telecommand_filter_func
)
# Create ListStores for the ComboBoxes
self
.
type_liststore
=
Gtk
.
ListStore
(
int
)
for
type_ref
in
type_list
:
self
.
type_liststore
.
append
([
type_ref
,
])
# self.current_filter_type = None
self
.
type_combo
=
Gtk
.
ComboBox
.
new_with_model
(
self
.
type_liststore
)
self
.
type_combo
.
connect
(
"
changed
"
,
self
.
on_type_combo_changed
)
renderer_text
=
Gtk
.
CellRendererText
()
self
.
type_combo
.
pack_start
(
renderer_text
,
True
)
self
.
type_combo
.
add_attribute
(
renderer_text
,
"
text
"
,
0
)
self
.
attach
(
self
.
type_combo
,
0
,
0
,
1
,
1
)
self
.
clear_button
=
Gtk
.
Button
(
label
=
"
Clear
"
)
self
.
clear_button
.
connect
(
"
clicked
"
,
self
.
on_clear_button_clicked
)
self
.
attach_next_to
(
self
.
clear_button
,
self
.
type_combo
,
Gtk
.
PositionType
.
RIGHT
,
1
,
1
)
# creating the treeview, making it use the filter a model, adding columns
self
.
treeview
=
Gtk
.
TreeView
.
new_with_model
(
Gtk
.
TreeModelSort
(
self
.
telecommand_filter
))
for
i
,
column_title
in
enumerate
(
[
"
#TYPE
"
,
"
SUBTYPE
"
,
"
DESCR
"
,
"
LONGDESCR
"
]
):
renderer
=
Gtk
.
CellRendererText
()
column
=
Gtk
.
TreeViewColumn
(
column_title
,
renderer
,
text
=
i
)
column
.
set_sort_column_id
(
i
)
self
.
treeview
.
append_column
(
column
)
# Handle selection
self
.
selected_row
=
self
.
treeview
.
get_selection
()
self
.
selected_row
.
connect
(
"
changed
"
,
self
.
item_selected
)
# setting up layout, treeview in scrollwindow
self
.
scrollable_treelist
=
Gtk
.
ScrolledWindow
()
self
.
scrollable_treelist
.
set_vexpand
(
True
)
self
.
scrollable_treelist
.
set_hexpand
(
True
)
self
.
attach
(
self
.
scrollable_treelist
,
0
,
1
,
8
,
10
)
self
.
scrollable_treelist
.
add
(
self
.
treeview
)
self
.
command_entry
=
Gtk
.
Entry
()
self
.
command_entry
.
set_placeholder_text
(
"
<Command Variables>
"
)
self
.
attach_next_to
(
self
.
command_entry
,
self
.
scrollable_treelist
,
Gtk
.
PositionType
.
BOTTOM
,
8
,
1
)
self
.
variable_box
=
tcm
.
CommandDescriptionBox
()
self
.
attach_next_to
(
self
.
variable_box
,
self
.
command_entry
,
Gtk
.
PositionType
.
BOTTOM
,
8
,
5
)
self
.
show_all
()
def
on_type_combo_changed
(
self
,
combo
):
combo_iter
=
combo
.
get_active_iter
()
if
combo_iter
is
not
None
:
model
=
combo
.
get_model
()
number
=
model
[
combo_iter
][
0
]
# print(number)
self
.
current_filter_telecommand
=
int
(
number
)
self
.
telecommand_filter
.
refilter
()
def
on_clear_button_clicked
(
self
,
widget
):
self
.
current_filter_telecommand
=
None
self
.
telecommand_filter
.
refilter
()
def
item_selected
(
self
,
selection
):
model
,
row
=
selection
.
get_selected
()
if
row
is
not
None
:
descr
=
model
[
row
][
2
]
self
.
command_entry
.
set_text
(
cfl
.
make_tc_template
(
descr
,
comment
=
False
))
tcm
.
tc_type
=
descr
cpc_descr
=
tcm
.
get_cpc_descr
(
tcm
.
tc_type
)
tcm
.
descr_list
.
clear
()
tcm
.
descr_list
=
cpc_descr
self
.
variable_box
.
refresh_descr_treeview
()
tcm
.
calibrations_list
.
clear
()
self
.
variable_box
.
refresh_cal_treeview
()
else
:
pass
def
telecommand_filter_func
(
self
,
model
,
iter
,
data
):
if
(
self
.
current_filter_telecommand
is
None
or
self
.
current_filter_telecommand
==
"
None
"
):
return
True
else
:
return
model
[
iter
][
0
]
==
self
.
current_filter_telecommand
class
ViewModelAsJson
(
Gtk
.
Box
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
...
...
This diff is collapsed.
Click to expand it.
Tst/tst/view.py
+
12
−
0
View file @
90912d4a
...
...
@@ -701,10 +701,21 @@ class StepWidget(Gtk.EventBox):
self
.
commands_view
.
set_indent_on_tab
(
True
)
self
.
commands_view
.
set_insert_spaces_instead_of_tabs
(
True
)
self
.
commands_buffer
=
self
.
commands_view
.
get_buffer
()
# draganddrop here
"""
self.commands_view.drag_dest_set(Gtk.DestDefaults.ALL, [], Gdk.DragAction.COPY)
self.commands_view.drag_dest_set_target_list(None)
self.commands_view.drag_dest_add_text_targets()
self.commands_view.connect(
"
drag-motion
"
, self.on_drag_motion_2)
self.commands_view.connect(
"
drag-leave
"
, self.on_drag_leave)
"""
self
.
commands_buffer
.
set_language
(
lngg
)
# self.commands_buffer.set_style_scheme(self.board.current_scheme)
self
.
commands_scrolled_window
.
add
(
self
.
commands_view
)
self
.
whole_commands_box
.
pack_start
(
self
.
lbl_box_commands
,
False
,
False
,
0
)
self
.
whole_commands_box
.
pack_start
(
self
.
commands_scrolled_window
,
True
,
True
,
0
)
self
.
detail_box
.
pack_start
(
self
.
whole_commands_box
,
True
,
True
,
0
)
...
...
@@ -1595,6 +1606,7 @@ class Edit_Pre_Post_Con_Dialog(Gtk.Dialog):
self
.
make_section_dict
()
self
.
view
()
self
.
show_all
()
def
make_section_dict
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment