-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.tcl
81 lines (68 loc) · 1.49 KB
/
gui.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
#! /bin/env tclsh
package require Tk
package require comm
namespace import ::comm::comm
proc hand {master args} {
set name [namespace current]::[info cmdcount]
namespace eval $name {
proc init {master args} {
variable
}
set master
}
$name init
return $name
}
proc acquire {master args} {
set name [namespace current]::[info cmdcount]
namespace eval $name {
namespace export *
namespace ensemble create
proc tag w {
if {[namespace current] ni [bindtags $w]} {
bindtags $w [linsert [bindtags $w] 1 [namespace current]]
}
}
proc board master {
variable state
lassign [dict get $state board] x y
for {set i 0} {$i < $x} {incr i} {
for {set j 0} {$j < $y} {incr j} {
label $master.board$i$j -bg yellow -text $i.$j
tag $master.board$i$j
grid $master.board$i$j -column $i -row $j
}
}
}
proc init {master args} {
variable state [dict merge [set [namespace parent]::state] $args]
set board [frame $master.board]
pack $board
set hand [frame $master.hand]
board $board
}
}
$name init $master
return $name
}
variable state {
board {4 8}
players {}
}
proc controller {} {
namespace eval controller {
namespace export *
namespace ensemble create
}
return [namesapce current]::controller
}
proc main {argv0 argv} {
dict update argv controlport controlport {}
puts [list hey!]
set tile [comm send $controlport tile]
puts [list got tile $tile]
#frame .a1
#pack .a1
#acquire .a1 board {12 12}
}
main $argv0 $argv