Python - Ayuda con este mensaje

 
Vista:
sin imagen de perfil

Ayuda con este mensaje

Publicado por jose ignacio (2 intervenciones) el 05/10/2021 08:15:25
Buenas Foreros, yo tenia esta programación que corría todo bien, en mi computadora vieja. Me cambie de computadora y ahora no corre bien, de hecho me tira una advertencia. Me gustaría saber si me pueden ayudar.

La programación es en lenguaje python pero so librerías de tkinter y xbee, para recibir mensajes, de antenas xbee.

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
import functools
import tkinter as tk
from concurrent import futures
 
from digi.xbee.devices import XBeeDevice
 
PORT = "COM5"
BAUD_RATE = 9600
device = XBeeDevice(PORT, BAUD_RATE)
 
thread_pool_executor = futures.ThreadPoolExecutor(max_workers=1)
 
 
def tk_after(target):
 
    @functools.wraps(target)
    def wrapper(self, *args, **kwargs):
        args = (self,) + args
        self.after(0, target, *args, **kwargs)
 
    return wrapper
 
 
def submit_to_pool_executor(executor):
    '''Decora un método para ser enviado al ejecutor pasado'''
    def decorator(target):
 
        @functools.wraps(target)
        def wrapper(*args, **kwargs):
            result = executor.submit(target, *args, **kwargs)
            result.add_done_callback(executor_done_call_back)
            return result
 
        return wrapper
 
    return decorator
 
 
def executor_done_call_back(future):
    exception = future.exception()
    if exception:
        raise exception
 
 
class App(tk.Tk):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)
        self.title("Sistema de Monitoreo de Paneles Solares del SESLab")
        self.config(bg="#919F89")
 
        width_of_window = 600
        height_of_window = 280
 
        screen_width = self.winfo_screenwidth()
        screen_height = self.winfo_screenheight()
 
        x_coordinate = (screen_width/2)-(width_of_window/2)
        y_coordinate = (screen_height/2)-(height_of_window/2)
 
        self.geometry((f'{width_of_window}x{height_of_window}+'
                       f'{x_coordinate:.0f}+{y_coordinate:.0f}'))
 
        self.form_frame = FormFrame(self)
        self.form_frame.pack()
        self.btn = tk.Button(
            self, bg="#E2BBAC", text="Iniciar ", command=self.on_btn)
        self.btn.pack()
 
    def btn_enable(self, enable=True):
        self.btn.config(state='normal' if enable else 'disabled')
 
    def on_btn(self):
        self.btn_enable(False)
        self.update()
 
    @submit_to_pool_executor(thread_pool_executor)
    def update(self):
 
        device.open()
        DATA_TO_SEND = "Hola XBee!"
        device.send_data_broadcast(DATA_TO_SEND)
 
        try:
            device.flush_queues()
            while True:
                xbee_message = device.read_data()
                if xbee_message is not None:
                    data = xbee_message.data.decode()
                    self.form_frame.set_str_variables(data.split(","))
        finally:
            if device is not None and device.is_open():
                device.close()
            self.btn_enable()
 
 
class FormFrame(tk.Frame):
    def __init__(self, *args, **kwargs) -> None:
        kwargs['width'] = '1200'
        kwargs['height'] = '600'
        super().__init__(*args, **kwargs)
        self.config(bg="#98A7AC")
        self.str_variables = []
 
        label1 = tk.Label(
            self, text="Sistema de monitoreo de Paneles del SESLab", font=18)
        label1.grid(row=0, column=0, padx=5, pady=5, columnspan=2)
 
        for row_index, text in (
            (1, 'Fecha de medición : '), (2, 'Hora de medición : '),
            (4, 'Voltage de Panel 1 : '), (5, 'Voltage de Panel 2 : '),
            (6, 'Voltage de Panel 3 : '), (7, 'Promedio : '),
                (9, 'Panel con Menor Voltaje : ')):
            label = tk.Label(self, text=text)
            label.grid(row=row_index, column=0, padx=2, pady=5)
 
            str_variable = tk.StringVar()
            entry = tk.Entry(self, textvariable=str_variable)
            entry.grid(row=row_index, column=1, padx=1, pady=5)
            entry.config(fg="black", justify="center", state='readonly')
            self.str_variables.append(str_variable)
 
    @tk_after
    def set_str_variables(self, results):
        for str_variable, result in zip(self.str_variables, results):
            str_variable.set(result)
 
if __name__ == '__main__':
    app = App()
    app.mainloop()
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder