mirror of
https://bitbucket.org/svk28/rac-gui
synced 2024-12-04 18:46:52 +00:00
Чистка кода
This commit is contained in:
parent
72cae7dc26
commit
93b908eb2e
@ -658,7 +658,6 @@ proc AddToplevel {lbl img {win_name .add}} {
|
||||
toplevel $win_name
|
||||
wm title $win_name $lbl
|
||||
wm iconphoto $win_name tcl
|
||||
#wm iconphoto $win_name server_grey_64
|
||||
ttk::label $win_name.lbl -image $img
|
||||
|
||||
set frm [ttk::labelframe $win_name.frm -text $lbl -labelanchor nw]
|
||||
@ -672,7 +671,8 @@ proc AddToplevel {lbl img {win_name .add}} {
|
||||
grid $frm -row 0 -column 1 -sticky nw -padx 5 -pady 5
|
||||
grid $frm_btn -row 1 -column 1 -sticky se -padx 5 -pady 5
|
||||
pack $frm_btn.btn_cancel -side right
|
||||
pack $frm_btn.btn_ok -side right -padx 10
|
||||
pack $frm_btn.btn_ok -side right -padx 10
|
||||
|
||||
return $frm
|
||||
}
|
||||
|
||||
@ -721,6 +721,8 @@ proc Add::agent_admin {tree host value} {
|
||||
Run::admins $tree $host $active_cluster
|
||||
destroy .add
|
||||
}
|
||||
|
||||
|
||||
return $frm
|
||||
}
|
||||
|
||||
@ -1080,6 +1082,7 @@ proc Add::cluster {tree host values} {
|
||||
Run::server $tree $host ""
|
||||
destroy .add
|
||||
}
|
||||
|
||||
return $frm
|
||||
}
|
||||
|
||||
@ -1909,3 +1912,4 @@ proc Del::server {tree host values} {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
20
lib/gui.tcl
20
lib/gui.tcl
@ -6,17 +6,17 @@
|
||||
# https://bitbucket.org/svk28/rac-gui
|
||||
######################################################
|
||||
|
||||
|
||||
|
||||
# установка размера и положения основного окна
|
||||
# можно установить в переменную topLevelGeometry в конфиг программы
|
||||
if {[info exists topLevelGeometry]} {
|
||||
wm geometry . $topLevelGeometry
|
||||
} else {
|
||||
wm geometry . 1024x768
|
||||
}
|
||||
|
||||
# Заголовок окна
|
||||
wm title . "1C Rac GUI"
|
||||
wm iconname . "1C Rac Gui"
|
||||
|
||||
# иконка окна (берется из файла lib/imges.tcl)
|
||||
wm iconphoto . tcl
|
||||
wm protocol . WM_DELETE_WINDOW Quit
|
||||
wm overrideredirect . 0
|
||||
@ -28,16 +28,15 @@ wm positionfrom . user
|
||||
#ttk::style configure Custom.Treeview -foreground red
|
||||
#ttk::style configure Custom.Treeview -rowheight 20
|
||||
|
||||
ttk::style theme use clam
|
||||
|
||||
# Панель инсрументов
|
||||
set frm_tool [frame .frm_tool]
|
||||
pack $frm_tool -side left -fill y
|
||||
|
||||
ttk::panedwindow .panel -orient horizontal -style TPanedwindow
|
||||
pack .panel -expand true -fill both
|
||||
pack propagate .panel false
|
||||
|
||||
ttk::style theme use clam
|
||||
|
||||
ttk::button $frm_tool.btn_add -command Add -image add_grey_32
|
||||
ttk::button $frm_tool.btn_del -command Del -image del_grey_32
|
||||
ttk::button $frm_tool.btn_edit -command Edit -image edit_grey_32
|
||||
@ -47,6 +46,8 @@ pack $frm_tool.btn_add $frm_tool.btn_del $frm_tool.btn_edit -side top -padx 5 -p
|
||||
#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
|
||||
|
||||
# Дерево с полосами прокрутки
|
||||
set frm_tree [frame .frm_tree]
|
||||
|
||||
ttk::scrollbar $frm_tree.hsb1 -orient horizontal -command [list $frm_tree.tree xview]
|
||||
@ -60,9 +61,11 @@ grid $frm_tree.hsb1 -row 1 -column 0 -sticky nsew
|
||||
grid columnconfigure $frm_tree 0 -weight 1
|
||||
grid rowconfigure $frm_tree 0 -weight 1
|
||||
|
||||
# назначение обработчика нажатия кнопкой мыши
|
||||
#bind $frm_tree.tree <ButtonRelease> "TreePress %x %y %X %Y $frm_tree.tree"
|
||||
bind $frm_tree.tree <ButtonRelease> "TreePress $frm_tree.tree"
|
||||
|
||||
# Список для данных (таблица)
|
||||
set frm_work [frame .frm_work]
|
||||
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]
|
||||
@ -82,7 +85,7 @@ $tree_work tag configure light -background $color(light_table_bg)
|
||||
|
||||
#$tree_work heading Creator -text "Creator" -anchor center
|
||||
#$tree_work heading Year -text "Year" -anchor center
|
||||
|
||||
# Пазмещение элементов на форме
|
||||
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
|
||||
@ -95,4 +98,3 @@ pack $frm_tree $frm_work -side left -expand true -fill both
|
||||
.panel add $frm_tree -weight 1
|
||||
.panel add $frm_work -weight 1
|
||||
|
||||
|
||||
|
32
rac_gui.tcl
32
rac_gui.tcl
@ -8,22 +8,24 @@ exec wish "$0" -- "$@"
|
||||
# Author: Sergey Kalinin svk@nuk-svk.ru
|
||||
# Home page: https://bitbucket.org/svk28/rac-gui
|
||||
######################################################
|
||||
|
||||
# Устанавливаем текущий каталог
|
||||
set dir(root) [pwd]
|
||||
|
||||
# Устанавливаем рабочий каталог, если его нет то создаём
|
||||
set dir(work) [file join $env(HOME) .rac_gui]
|
||||
if {[file exists $dir(work)] == 0 } {
|
||||
file mkdir $dir(work)
|
||||
}
|
||||
set dir(msg) "[file join $dir(root) msgs]"
|
||||
# каиалог с модулями
|
||||
set dir(lib) "[file join $dir(root) lib]"
|
||||
|
||||
# загружаем пользовательский конфиг, если он отсутствует, то копируем дефолтный
|
||||
if {[file exists [file join $dir(work) rac_gui.cfg]] ==0} {
|
||||
file copy [file join [pwd] rac_gui.cfg] [file join $dir(work) rac_gui.cfg]
|
||||
}
|
||||
|
||||
source [file join $dir(work) rac_gui.cfg]
|
||||
|
||||
# Код проверки наличия rac и правильности указания пути в конфиге
|
||||
# если программа не найдена то будет выведен диалог для указанием корректного пути
|
||||
# и этот путь будет записан в пользовательский конфиг
|
||||
if {[file exists $rac_cmd] == 0} {
|
||||
set rac_cmd [tk_getOpenFile -initialdir $env(HOME) -parent . -title "Укажите путь до rac" -initialfile rac]
|
||||
file copy [file join $dir(work) rac_gui.cfg] [file join $dir(work) rac_gui.cfg.bak]
|
||||
@ -40,30 +42,16 @@ if {[file exists $rac_cmd] == 0} {
|
||||
close $orig_file
|
||||
#return "$host:$port"
|
||||
file delete [file join $dir(work) 1c_srv.cfg.bak]
|
||||
|
||||
} else {
|
||||
puts "Found $rac_cmd"
|
||||
}
|
||||
|
||||
set dir(msg) "[file join $dir(root) msgs]"
|
||||
set dir(lib) "[file join $dir(root) lib]"
|
||||
|
||||
## SETTINGS ENVIRONMENT LANGUAGE ##
|
||||
if [info exists env(LANG)] {
|
||||
set locale $env(LANG)
|
||||
} else {
|
||||
set locale $locale
|
||||
}
|
||||
|
||||
::msgcat::mclocale $locale
|
||||
::msgcat::mcload $dir(msg)
|
||||
|
||||
set cluster_user ""
|
||||
set cluster_pwd ""
|
||||
set agent_user ""
|
||||
set agent_pwd ""
|
||||
## LOAD FILE ##
|
||||
# Load modules but maain.tcl must last loaded
|
||||
# Загружаем модули кроме gui.tcl так как его надо загрузить последним
|
||||
foreach modFile [lsort [glob -nocomplain [file join $dir(lib) *.tcl]]] {
|
||||
if {[file tail $modFile] ne "gui.tcl"} {
|
||||
source $modFile
|
||||
@ -73,12 +61,14 @@ foreach modFile [lsort [glob -nocomplain [file join $dir(lib) *.tcl]]] {
|
||||
source [file join $dir(lib) gui.tcl]
|
||||
source [file join $dir(work) rac_gui.cfg]
|
||||
|
||||
# Читаем файл со списком серверов 1С
|
||||
if [file exists [file join $dir(work) 1c_srv.cfg]] {
|
||||
set f [open [file join $dir(work) 1c_srv.cfg] "RDONLY"]
|
||||
while {[gets $f line] >=0} {
|
||||
.frm_tree.tree insert {} end -id "server::$line" -text "$line" -values "$line"
|
||||
}
|
||||
}
|
||||
|
||||
# set editor(fg) grey
|
||||
# set editor(bg) black
|
||||
# option add *Entry.Foreground $editor(fg) interactive
|
||||
@ -100,3 +90,5 @@ if [file exists [file join $dir(work) 1c_srv.cfg]] {
|
||||
# option add *ScrolledWindow.Background $editor(bg) interactive
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user