-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnxt_rc1.py
151 lines (104 loc) · 3.11 KB
/
nxt_rc1.py
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/env python
# -*- coding: latin-1 -*-
# REMOTE NXT
# you need programming on nxt-g or another language to receive the data on mailbox 1. This program send 1,2,3,4,5 to
# control up,down,left,right or sound.
import pygtk
pygtk.require('2.0')
import gtk
import os, sys
import nxt.locator
class nxt_control:
def enter_up(self, widget, nxt):
print "clicked"
nxt.message_write(0,'1')
self.status_bar.push(1, 'Send up')
def enter_down(self, widget, nxt):
print "clicked"
nxt.message_write(0,'2')
self.status_bar.push(1, 'Send down')
def enter_left(self, widget, nxt):
print "clicked"
nxt.message_write(0,'3')
self.status_bar.push(1, 'Send left')
def enter_right(self, widget, nxt):
print "clicked"
nxt.message_write(0,'4')
self.status_bar.push(1, 'Send right')
def enter_stop(self, widget, nxt):
print "clicked"
nxt.message_write(0,'5')
self.status_bar.push(1, 'Send stop')
def enter_sound(self, widget, nxt):
print "clicked"
nxt.message_write(5,'1')
self.status_bar.push(1, 'Send sound')
#funcion principal
def __init__(self):
# create a new window
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_size_request(140, 150)
window.set_border_width(3)
window.set_title("nxt rc")
window.set_resizable(False)
window.connect("delete_event", lambda w,e: gtk.main_quit())
window.show()
table = gtk.Table(5, 3, True)
window.add(table)
table.set_border_width(5)
table.show()
self.status_bar = gtk.Statusbar()
table.attach(self.status_bar, 0, 3, 4, 5)
self.status_bar.show()
print "connecting ..."
s = nxt.locator.find_one_brick()
b = s.connect()
print "connected"
self.status_bar.push(1, 'connected')
#------------------------------control-----------------------------------
#tabla control
control = gtk.Table(3, 3, False)
table.attach(control, 0, 3, 0, 3)
control.set_border_width(12)
control.show()
#marco control
framec = gtk.Frame()
table.attach(framec, 0, 3, 0,4)
framec.show()
#boton ▲
buttonau = gtk.Button("▲")
buttonau.connect("clicked", self.enter_up, b)
control.attach(buttonau, 1,2, 0, 1)
buttonau.show()
#boton ▼
buttonad = gtk.Button("▼")
buttonad.connect("clicked", self.enter_down, b)
control.attach(buttonad, 1,2, 2,3)
buttonad.show()
#boton ■
buttonstop = gtk.Button("■")
buttonstop.connect("clicked", self.enter_stop, b)
control.attach(buttonstop, 1,2, 1,2)
buttonstop.show()
#boton ◀
buttonal = gtk.Button("↶")
buttonal.connect("clicked", self.enter_left, b)
control.attach(buttonal, 0,1, 1, 2)
buttonal.show()
#boton ▶
buttonar = gtk.Button("↷")
buttonar.connect("clicked", self.enter_right, b)
control.attach(buttonar, 2,3, 1,2)
buttonar.show()
#boton sound
buttonsound = gtk.Button("⊚")
buttonsound.connect("clicked", self.enter_sound, b)
control.attach(buttonsound, 0,1, 0,1)
buttonsound.show()
#-------------------------------------------------------------------------
def main():
gtk.main()
return 0
if __name__ == "__main__":
nxt_control()
main()