-
Notifications
You must be signed in to change notification settings - Fork 14
/
pbcgui.tcl
110 lines (94 loc) · 3.33 KB
/
pbcgui.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# hello emacs this is -*- tcl -*-
#
# GUI around pbctools.
#
# (c) 2009 by Olaf Lenz <lenzo@mpip-mainz.mpg.de>
########################################################################
#
# $Id: pbcgui.tcl,v 1.4 2013/04/15 16:48:10 johns Exp $
#
# create package and namespace and default all namespace global variables.
package provide pbcgui 3.1
package require pbctools 3.1
namespace eval ::pbcgui:: {
namespace export pbcgui
variable w; # handle to the base widget.
variable molid "0"; # molid of the molecule
variable moltxt "(none)"; # title the molecule
}
proc ::pbcgui::pbcgui {args} {
variable w
## stolen from GofRGUI by Axel Kohlmeyer
# main window frame
set w .pbcgui
catch {destroy $w}
toplevel $w
wm title $w "PBCTools GUI"
wm iconname $w "PBCToolsGUI"
wm minsize $w 520 200
# frame for settings
set in $w.in
labelframe $in -bd 2 -relief ridge -text "Settings:" -padx 1m -pady 1m
pack $in -side top -fill both
# Molecule selector
frame $in.molid
label $in.molid.l -text "Use Molecule:" -anchor w
menubutton $in.molid.m -relief raised -bd 2 -direction flush \
-text "test text" -textvariable ::pbcgui::moltxt \
-menu $in.molid.m.menu
menu $in.molid.m.menu -tearoff no
pack $in.molid.l -side left
pack $in.molid.m -side left
pack $in.molid -side top
grid config $in.molid.l -column 0 -row 0 -columnspan 1 -rowspan 1 -sticky "snew"
grid config $in.molid.m -column 1 -row 0 -columnspan 1 -rowspan 1 -sticky "snew"
grid columnconfigure $in.molid 0 -weight 1 -minsize 10
grid columnconfigure $in.molid 1 -weight 3 -minsize 10
# listen to updates in the molecule list
UpdateMolecule
global vmd_molecule
trace variable vmd_molecule w ::pbcgui::UpdateMolecule
}
# callback for VMD menu entry
proc pbcgui_tk_cb {} {
::pbcgui::pbcgui
return $::pbcgui::w
}
# update molecule list
proc ::pbcgui::UpdateMolecule {args} {
variable w
variable moltxt
variable molid
global vmd_molecule
puts "UpdateMolecule was called!"
# Update the molecule browser
set mollist [molinfo list]
$w.foot configure -state disabled
$w.in.molid.m configure -state disabled
$w.in.molid.m.menu delete 0 end
set moltxt "(none)"
if { [llength $mollist] > 0 } {
$w.foot configure -state normal
$w.in.molid.m configure -state normal
foreach id $mollist {
$w.in.molid.m.menu add radiobutton -value $id \
-command {global vmd_molecule ; if {[info exists vmd_molecule($::pbcgui::molid)]} {set ::pbcgui::moltxt "$::pbcgui::molid:[molinfo $::pbcgui::molid get name]"} {set ::pbcgui::moltxt "(none)" ; set molid -1} } \
-label "$id [molinfo $id get name]" \
-variable ::pbcgui::molid
if {$id == $molid} {
if {[info exists vmd_molecule($molid)]} then {
set moltxt "$molid:[molinfo $molid get name]"
} else {
set moltxt "(none)"
set molid -1
}
}
}
}
}
############################################################
# Local Variables:
# mode: tcl
# time-stamp-format: "%u %02d.%02m.%y %02H:%02M:%02S %s"
# End:
############################################################