Основываясь на вводе файла Excel, я хочу перечислить имена серверов в окне и отобразить кружок рядом с ним, который принимает зеленый цвет, если сервер работает, или красный, если сервер не работает.
Моя задача - как динамически назначить переменную объекту черепахи для круга
Приведенный ниже код просто отображает имя сервера и перемещает кружок для каждого объекта.
import turtle
import pandas as pd
import os
# Initialize variables
df = pd.DataFrame()
path="C:/Users/Avengers/Downloads/applist.xlsx"
df_excel = pd.read_excel(path)
wn = turtle.Screen()
wn.title("Server Availability Dashboard")
in_light=turtle.Turtle()
var=turtle.Turtle()
in_light.shape("circle")
in_light.color("grey")
in_light.penup()
var.penup()
ypos = 150
xpos = -110
var.goto(-150,ypos)
in_light.goto(-100,ypos)
#Ping servers based on file to check if server is up or down
for c in df_excel['IP']: #Extract the ip address of each server
rep = os.system("ping " + c) #Perform a ping using the ipaddress
if rep == 0: #Ping returns a o if up, 1 if down
row = df_excel[df_excel.IP == c]
server = row['DisplayName'].values
var.write(server) #Display the server names
in_light.color("green")
else:
row = df_excel[df_excel.IP == c]
server = row['DisplayName'].values
var.write(server)
in_light.color("red")
ypos=ypos-20
var.goto(-150,ypos)
in_light.goto(-100,ypos)
wn.mainloop()
Как минимум, я хочу отобразить результаты десяти лучших приложений.
Однако стремление состоит в том, чтобы прочесать файл Excel и вывести на экран столько записей, сколько есть в файле.