tkinter btn
This commit is contained in:
parent
a155303c40
commit
feb97e994c
|
@ -1,5 +1,6 @@
|
||||||
import socket
|
import socket
|
||||||
import json
|
import json
|
||||||
|
import sys
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
import tkinter
|
import tkinter
|
||||||
|
|
||||||
|
@ -28,36 +29,44 @@ class SocketRobotArm:
|
||||||
self.host = "127.0.0.1"
|
self.host = "127.0.0.1"
|
||||||
self.port = 65432
|
self.port = 65432
|
||||||
|
|
||||||
|
self.tkinter_root = tkinter.Tk()
|
||||||
|
|
||||||
self.connect()
|
self.connect()
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_value, traceback):
|
def __exit__(self, exc_type, exc_value, traceback):
|
||||||
self.close()
|
self.socket.close()
|
||||||
|
|
||||||
def update_text(self, m, text):
|
def close(self):
|
||||||
label = tkinter.Label(m, text=text)
|
self.tkinter_root.destroy()
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
def set_text(self, text):
|
||||||
|
label = tkinter.Label(self.tkinter_root, text=text)
|
||||||
label.pack()
|
label.pack()
|
||||||
m.update()
|
self.tkinter_root.update()
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
self.socket.connect((self.host, self.port))
|
self.socket.connect((self.host, self.port))
|
||||||
|
|
||||||
m = tkinter.Tk()
|
self.tkinter_root.geometry("500x500")
|
||||||
m.geometry("500x500")
|
|
||||||
|
exit_button = tkinter.Button(self.tkinter_root, text="Exit", command=self.close)
|
||||||
|
exit_button.pack(pady=20)
|
||||||
|
|
||||||
self.get_axis()
|
self.get_axis()
|
||||||
self.update_text(m, text=f"Координаты осей {self.start_axis_coordinates}")
|
self.set_text(text=f"Координаты осей {self.start_axis_coordinates}")
|
||||||
|
|
||||||
self.get_world()
|
self.get_world()
|
||||||
self.update_text(m, text=f"Мировые координаты {self.start_world_coordinates}")
|
self.set_text( text=f"Мировые координаты {self.start_world_coordinates}")
|
||||||
|
|
||||||
self.get_command_count()
|
self.get_command_count()
|
||||||
self.update_text(m, text=f"Команд в очереди {self.remote_command_count}")
|
self.set_text( text=f"Команд в очереди {self.remote_command_count}")
|
||||||
|
|
||||||
self.send_data(self.set_global_speed())
|
self.send_data(self.set_global_speed())
|
||||||
self.update_text(m, text=f"Установили глобальную скорость {self.global_speed}")
|
self.set_text( text=f"Установили глобальную скорость {self.global_speed}")
|
||||||
|
|
||||||
self.send_data(self.start_cycle())
|
self.send_data(self.start_cycle())
|
||||||
self.update_text(m, text=f"Старт одиночного цикла")
|
self.set_text( text=f"Старт одиночного цикла")
|
||||||
|
|
||||||
self.add_rcc_list = (
|
self.add_rcc_list = (
|
||||||
[self.set_physical_speed(True), self.set_output_laser(True)]
|
[self.set_physical_speed(True), self.set_output_laser(True)]
|
||||||
|
@ -65,15 +74,15 @@ class SocketRobotArm:
|
||||||
+ [self.set_physical_speed(False), self.set_output_laser(False)]
|
+ [self.set_physical_speed(False), self.set_output_laser(False)]
|
||||||
)
|
)
|
||||||
|
|
||||||
my_label = tkinter.Label(m, text=f"Отправка данных")
|
my_label = tkinter.Label(self.tkinter_root, text=f"Отправка данных")
|
||||||
my_label.pack()
|
my_label.pack()
|
||||||
m.update()
|
self.tkinter_root.update()
|
||||||
step = 2
|
step = 2
|
||||||
for i in range(0, len(self.add_rcc_list), step):
|
for i in range(0, len(self.add_rcc_list), step):
|
||||||
print(f"Отправка данных {i}...{i+step-1}")
|
print(f"Отправка данных {i}...{i+step-1}")
|
||||||
# self.update_text(m, text=f"Отправка данных {i}...{i+step-1}")
|
# self.update_text(m, text=f"Отправка данных {i}...{i+step-1}")
|
||||||
my_label.config(text=f"Отправка данных {i}...{i+step-1}")
|
my_label.config(text=f"Отправка данных {i}...{i+step-1}")
|
||||||
m.update()
|
self.tkinter_root.update()
|
||||||
|
|
||||||
self.send_data(
|
self.send_data(
|
||||||
make_addrcc_data(self.add_rcc_list[i : i + step], int(not i))
|
make_addrcc_data(self.add_rcc_list[i : i + step], int(not i))
|
||||||
|
|
Loading…
Reference in New Issue