update code and reset code

master
bettleChen 1 year ago
parent 33f627beb9
commit 2fe7674452

@ -13,27 +13,6 @@ from PIL import ImageTk, Image
from dbUtil import search, execute_sql from dbUtil import search, execute_sql
host_img = ImageTk.PhotoImage(
Image.open(sys.path[0] + "/../datas/images/主机.png").resize((60, 60)))
host_img_tm = ImageTk.PhotoImage(
Image.open(sys.path[0] + "/../datas/images/主机_tm.png").resize((60, 60)))
router_img = ImageTk.PhotoImage(
Image.open(sys.path[0] + "/../datas/images/路由器.png").resize((60, 60)))
router_img_tm = ImageTk.PhotoImage(
Image.open(sys.path[0] + "/../datas/images/路由器_tm.png").resize((60, 60)))
switch_img = ImageTk.PhotoImage(
Image.open(sys.path[0] + "/../datas/images/交换机.png").resize((60, 60)))
switch_img_tm = ImageTk.PhotoImage(
Image.open(sys.path[0] + "/../datas/images/交换机_tm.png").resize((60, 60)))
hub_img = ImageTk.PhotoImage(
Image.open(sys.path[0] + "/../datas/images/集线器.png").resize((60, 60)))
hub_img_tm = ImageTk.PhotoImage(
Image.open(sys.path[0] + "/../datas/images/集线器_tm.png").resize((60, 60)))
class SimBase(): class SimBase():
# todo: 组件父类 # todo: 组件父类
""" """
@ -115,18 +94,6 @@ class SimBase():
创建图片 创建图片
:return: :return:
""" """
if self.ObjType == 1:
self.img = host_img
self.img_tm = host_img_tm
elif self.ObjType == 2:
self.img = router_img
self.img_tm = router_img_tm
elif self.ObjType == 3:
self.img = switch_img
self.img_tm = switch_img_tm
else:
self.img = hub_img
self.img_tm = hub_img_tm
self.canvas.delete("L") self.canvas.delete("L")
id = self.canvas.create_image(self.ObjX - 30, self.ObjY - 30, id = self.canvas.create_image(self.ObjX - 30, self.ObjY - 30,
image=self.img if self.ConfigCorrect == 1 else self.img_tm, anchor="nw", image=self.img if self.ConfigCorrect == 1 else self.img_tm, anchor="nw",
@ -488,6 +455,10 @@ class SimHost(SimBase):
self.interface = [{}] self.interface = [{}]
self.connections = [None] self.connections = [None]
self.set_default_config() self.set_default_config()
self.img = ImageTk.PhotoImage(
Image.open(sys.path[0] + "/../datas/images/主机.png").resize((60, 60)))
self.img_tm = ImageTk.PhotoImage(
Image.open(sys.path[0] + "/../datas/images/主机_tm.png").resize((60, 60)))
def create_packet(self, ip, mac, message): def create_packet(self, ip, mac, message):
""" """
@ -548,6 +519,10 @@ class SimRouter(SimBase):
self.ObjLabel = label if label is not None else self.set_default_name() self.ObjLabel = label if label is not None else self.set_default_name()
self.router_table = {} self.router_table = {}
self.set_default_router_table() self.set_default_router_table()
self.img = ImageTk.PhotoImage(
Image.open(sys.path[0] + "/../datas/images/路由器.png").resize((60, 60)))
self.img_tm = ImageTk.PhotoImage(
Image.open(sys.path[0] + "/../datas/images/路由器_tm.png").resize((60, 60)))
def set_default_router_table(self): def set_default_router_table(self):
""" """
@ -653,6 +628,10 @@ class SimSwitch(SimBase):
self.ObjLabel = label if label is not None else self.set_default_name() self.ObjLabel = label if label is not None else self.set_default_name()
self.mac_table = {} self.mac_table = {}
self.set_default_mac_table() self.set_default_mac_table()
self.img = ImageTk.PhotoImage(
Image.open(sys.path[0] + "/../datas/images/交换机.png").resize((60, 60)))
self.img_tm = ImageTk.PhotoImage(
Image.open(sys.path[0] + "/../datas/images/交换机_tm.png").resize((60, 60)))
def set_default_mac_table(self): def set_default_mac_table(self):
""" """
@ -742,6 +721,10 @@ class SimHub(SimBase):
super().__init__(canvas, x, y, self.ObjID, config, label) super().__init__(canvas, x, y, self.ObjID, config, label)
self.ObjType = 4 self.ObjType = 4
self.ObjLabel = label if label is not None else self.set_default_name() self.ObjLabel = label if label is not None else self.set_default_name()
self.img = ImageTk.PhotoImage(
Image.open(sys.path[0] + "/../datas/images/集线器.png").resize((60, 60)))
self.img_tm = ImageTk.PhotoImage(
Image.open(sys.path[0] + "/../datas/images/集线器_tm.png").resize((60, 60)))
def transmit(self, packet: SimPacket): def transmit(self, packet: SimPacket):
""" """

Binary file not shown.
Loading…
Cancel
Save