2018-05-16 14:17:27 +03:00
|
|
|
|
######################################################
|
|
|
|
|
# Rac GUI
|
2018-06-03 13:36:21 +03:00
|
|
|
|
# Distributed under GNU Public License
|
2018-05-16 14:17:27 +03:00
|
|
|
|
# Author: Sergey Kalinin svk@nuk-svk.ru
|
2018-06-03 13:36:21 +03:00
|
|
|
|
# Copyright (c) "http://nuk-svk.ru" 2018
|
|
|
|
|
# https://bitbucket.org/svk28/rac-gui
|
2018-05-16 14:17:27 +03:00
|
|
|
|
######################################################
|
|
|
|
|
|
2018-07-02 16:48:23 +03:00
|
|
|
|
# установка размера и положения основного окна
|
|
|
|
|
# можно установить в переменную topLevelGeometry в конфиг программы
|
2018-05-16 14:17:27 +03:00
|
|
|
|
if {[info exists topLevelGeometry]} {
|
|
|
|
|
wm geometry . $topLevelGeometry
|
|
|
|
|
} else {
|
2018-06-23 15:00:39 +03:00
|
|
|
|
wm geometry . 1024x768
|
2018-05-16 14:17:27 +03:00
|
|
|
|
}
|
2018-07-02 16:48:23 +03:00
|
|
|
|
# Заголовок окна
|
2018-05-16 14:17:27 +03:00
|
|
|
|
wm title . "1C Rac GUI"
|
|
|
|
|
wm iconname . "1C Rac Gui"
|
2018-07-02 16:48:23 +03:00
|
|
|
|
# иконка окна (берется из файла lib/imges.tcl)
|
2018-06-12 19:56:42 +03:00
|
|
|
|
wm iconphoto . tcl
|
2018-05-16 14:17:27 +03:00
|
|
|
|
wm protocol . WM_DELETE_WINDOW Quit
|
|
|
|
|
wm overrideredirect . 0
|
|
|
|
|
wm positionfrom . user
|
2018-06-03 13:36:21 +03:00
|
|
|
|
|
2019-08-26 11:24:19 +03:00
|
|
|
|
bind . <Control-q> Quit
|
|
|
|
|
bind . <Control-Q> Quit
|
2019-09-13 13:36:09 +03:00
|
|
|
|
bind . <Control-eacute> Quit
|
|
|
|
|
bind . <Control-Insert> Add
|
|
|
|
|
bind . <Control-Delete> Del
|
|
|
|
|
bind . <Control-Return> Edit
|
|
|
|
|
bind . <F1> ShowHelpDialog
|
2019-08-26 11:24:19 +03:00
|
|
|
|
|
2018-06-03 13:36:21 +03:00
|
|
|
|
#ttk::style configure TPanedwindow -background blue
|
|
|
|
|
#ttk::style configure Sash -sashthickness 5
|
2018-06-06 12:35:20 +03:00
|
|
|
|
#ttk::style configure TButton -padding 60 -relief flat -bg black
|
|
|
|
|
#ttk::style configure Custom.Treeview -foreground red
|
|
|
|
|
#ttk::style configure Custom.Treeview -rowheight 20
|
|
|
|
|
|
2019-08-30 16:03:07 +03:00
|
|
|
|
|
|
|
|
|
if [info exists default(theme)] {
|
|
|
|
|
ttk::style theme use $default(theme)
|
|
|
|
|
}
|
2018-06-03 13:36:21 +03:00
|
|
|
|
|
2018-07-02 16:48:23 +03:00
|
|
|
|
# Панель инсрументов
|
2018-08-02 13:10:23 +03:00
|
|
|
|
set frm_tool [ttk::frame .frm_tool]
|
2018-06-03 13:36:21 +03:00
|
|
|
|
pack $frm_tool -side left -fill y
|
|
|
|
|
ttk::panedwindow .panel -orient horizontal -style TPanedwindow
|
|
|
|
|
pack .panel -expand true -fill both
|
|
|
|
|
pack propagate .panel false
|
2018-05-18 12:12:28 +03:00
|
|
|
|
|
2018-05-19 16:31:48 +03:00
|
|
|
|
ttk::button $frm_tool.btn_add -command Add -image add_grey_32
|
|
|
|
|
ttk::button $frm_tool.btn_del -command Del -image del_grey_32
|
2018-06-12 19:14:52 +03:00
|
|
|
|
ttk::button $frm_tool.btn_edit -command Edit -image edit_grey_32
|
2018-05-19 16:31:48 +03:00
|
|
|
|
ttk::button $frm_tool.btn_quit -command Quit -image quit_grey_32
|
|
|
|
|
|
2018-06-12 19:14:52 +03:00
|
|
|
|
pack $frm_tool.btn_add $frm_tool.btn_del $frm_tool.btn_edit -side top -padx 5 -pady 5
|
|
|
|
|
#label $frm_tool.lbl_logo -image tcl
|
|
|
|
|
pack $frm_tool.btn_quit -side bottom -padx 5 -pady 5
|
|
|
|
|
#pack $frm_tool.lbl_logo -side bottom -padx 5 -pady 5
|
2018-07-02 16:48:23 +03:00
|
|
|
|
|
|
|
|
|
# Дерево с полосами прокрутки
|
2018-08-02 13:10:23 +03:00
|
|
|
|
set frm_tree [ttk::frame .frm_tree]
|
2018-05-16 14:17:27 +03:00
|
|
|
|
|
|
|
|
|
ttk::scrollbar $frm_tree.hsb1 -orient horizontal -command [list $frm_tree.tree xview]
|
|
|
|
|
ttk::scrollbar $frm_tree.vsb1 -orient vertical -command [list $frm_tree.tree yview]
|
2018-06-03 13:36:21 +03:00
|
|
|
|
set tree [ttk::treeview $frm_tree.tree -show tree \
|
|
|
|
|
-xscrollcommand [list $frm_tree.hsb1 set] -yscrollcommand [list $frm_tree.vsb1 set]]
|
2018-05-16 14:17:27 +03:00
|
|
|
|
|
|
|
|
|
grid $tree -row 0 -column 0 -sticky nsew
|
|
|
|
|
grid $frm_tree.vsb1 -row 0 -column 1 -sticky nsew
|
|
|
|
|
grid $frm_tree.hsb1 -row 1 -column 0 -sticky nsew
|
|
|
|
|
grid columnconfigure $frm_tree 0 -weight 1
|
|
|
|
|
grid rowconfigure $frm_tree 0 -weight 1
|
|
|
|
|
|
2018-07-02 16:48:23 +03:00
|
|
|
|
# назначение обработчика нажатия кнопкой мыши
|
2018-05-16 14:17:27 +03:00
|
|
|
|
#bind $frm_tree.tree <ButtonRelease> "TreePress %x %y %X %Y $frm_tree.tree"
|
|
|
|
|
bind $frm_tree.tree <ButtonRelease> "TreePress $frm_tree.tree"
|
|
|
|
|
|
2018-07-02 16:48:23 +03:00
|
|
|
|
# Список для данных (таблица)
|
2018-08-02 13:10:23 +03:00
|
|
|
|
set frm_work [ttk::frame .frm_work]
|
2018-05-16 14:17:27 +03:00
|
|
|
|
ttk::scrollbar $frm_work.hsb -orient horizontal -command [list $frm_work.tree_work xview]
|
|
|
|
|
ttk::scrollbar $frm_work.vsb -orient vertical -command [list $frm_work.tree_work yview]
|
2018-06-03 13:36:21 +03:00
|
|
|
|
set tree_work [
|
2018-06-06 12:35:20 +03:00
|
|
|
|
ttk::treeview $frm_work.tree_work \
|
2018-06-03 16:38:01 +03:00
|
|
|
|
-show headings -columns "par val" -displaycolumns "par val"\
|
2018-06-03 13:36:21 +03:00
|
|
|
|
-xscrollcommand [list $frm_work.hsb set] \
|
|
|
|
|
-yscrollcommand [list $frm_work.vsb set]
|
|
|
|
|
]
|
2018-06-06 12:35:20 +03:00
|
|
|
|
# table rows background colors
|
2019-08-30 16:03:07 +03:00
|
|
|
|
|
|
|
|
|
if {[info exists default(theme)] == 1} {
|
|
|
|
|
$tree_work tag configure dark -background $color(dark_table_bg)
|
|
|
|
|
$tree_work tag configure light -background $color(light_table_bg)
|
|
|
|
|
}
|
2018-07-20 11:23:20 +03:00
|
|
|
|
bind $tree_work <Double-ButtonPress-1> Edit
|
2018-06-06 12:35:20 +03:00
|
|
|
|
|
2018-08-03 09:19:59 +03:00
|
|
|
|
$tree tag configure selected -background white -foreground black
|
|
|
|
|
$tree_work tag configure selected -background white -foreground black
|
|
|
|
|
|
|
|
|
|
bind $tree_work <ButtonRelease-1> {
|
|
|
|
|
$tree_work tag remove selected
|
|
|
|
|
$tree_work item [.frm_work.tree_work selection] -tags selected
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-26 11:24:19 +03:00
|
|
|
|
|
2018-06-03 13:36:21 +03:00
|
|
|
|
#$tree_work heading par -text "Параметр" -anchor center
|
|
|
|
|
#$tree_work heading val -text "Значение" -anchor center
|
2018-05-16 14:17:27 +03:00
|
|
|
|
#set tree_work [ttk::treeview $frm_work.tree_work \
|
|
|
|
|
|
|
|
|
|
#$tree_work heading Creator -text "Creator" -anchor center
|
|
|
|
|
#$tree_work heading Year -text "Year" -anchor center
|
2018-07-02 16:48:23 +03:00
|
|
|
|
# Пазмещение элементов на форме
|
2018-05-16 14:17:27 +03:00
|
|
|
|
grid $tree_work -row 0 -column 0 -sticky nsew
|
|
|
|
|
grid $frm_work.vsb -row 0 -column 1 -sticky nsew
|
|
|
|
|
grid $frm_work.hsb -row 1 -column 0 -sticky nsew
|
|
|
|
|
grid columnconfigure $frm_work 0 -weight 1
|
|
|
|
|
grid rowconfigure $frm_work 0 -weight 1
|
|
|
|
|
#pack $tree_work -expand true -fill both
|
|
|
|
|
pack $frm_tree $frm_work -side left -expand true -fill both
|
2018-05-27 15:40:36 +03:00
|
|
|
|
|
2018-06-03 13:36:21 +03:00
|
|
|
|
#.panel add $frm_tool -weight 1
|
|
|
|
|
.panel add $frm_tree -weight 1
|
|
|
|
|
.panel add $frm_work -weight 1
|
2018-08-03 05:49:36 +03:00
|
|
|
|
|