2019-10-11 01:02:28 +01:00
|
|
|
from enum import Enum
|
2019-09-18 19:26:26 +01:00
|
|
|
|
2019-09-16 07:45:13 +01:00
|
|
|
from PIL import Image, ImageTk
|
|
|
|
|
2019-12-19 17:30:21 +00:00
|
|
|
from core.gui.appconfig import LOCAL_ICONS_PATH
|
2019-09-18 19:20:22 +01:00
|
|
|
|
2019-09-16 07:45:13 +01:00
|
|
|
|
|
|
|
class Images:
|
|
|
|
images = {}
|
|
|
|
|
2019-11-03 06:47:43 +00:00
|
|
|
@classmethod
|
2019-11-13 01:32:34 +00:00
|
|
|
def create(cls, file_path, width, height=None):
|
|
|
|
if height is None:
|
|
|
|
height = width
|
2019-11-03 06:47:43 +00:00
|
|
|
image = Image.open(file_path)
|
2019-11-13 01:32:34 +00:00
|
|
|
image = image.resize((width, height), Image.ANTIALIAS)
|
2019-11-03 06:47:43 +00:00
|
|
|
return ImageTk.PhotoImage(image)
|
|
|
|
|
2019-11-01 17:45:47 +00:00
|
|
|
@classmethod
|
|
|
|
def load_all(cls):
|
2019-11-01 23:31:40 +00:00
|
|
|
for image in LOCAL_ICONS_PATH.glob("*"):
|
2019-11-13 01:32:34 +00:00
|
|
|
cls.images[image.stem] = str(image)
|
2019-09-16 07:45:13 +01:00
|
|
|
|
|
|
|
@classmethod
|
2019-11-13 01:32:34 +00:00
|
|
|
def get(cls, image_enum, width, height=None):
|
|
|
|
file_path = cls.images[image_enum.value]
|
|
|
|
return cls.create(file_path, width, height)
|
2019-10-02 00:25:26 +01:00
|
|
|
|
2019-11-07 19:33:40 +00:00
|
|
|
@classmethod
|
2019-11-15 18:22:30 +00:00
|
|
|
def get_custom(cls, name, width, height=None):
|
2019-11-13 01:32:34 +00:00
|
|
|
file_path = cls.images[name]
|
|
|
|
return cls.create(file_path, width, height)
|
2019-11-07 19:33:40 +00:00
|
|
|
|
2019-10-02 00:25:26 +01:00
|
|
|
|
2019-10-11 01:02:28 +01:00
|
|
|
class ImageEnum(Enum):
|
|
|
|
SWITCH = "lanswitch"
|
|
|
|
CORE = "core-icon"
|
|
|
|
START = "start"
|
|
|
|
MARKER = "marker"
|
|
|
|
ROUTER = "router"
|
|
|
|
SELECT = "select"
|
|
|
|
LINK = "link"
|
|
|
|
HUB = "hub"
|
|
|
|
WLAN = "wlan"
|
2019-11-01 15:35:14 +00:00
|
|
|
EMANE = "emane"
|
2019-10-11 01:02:28 +01:00
|
|
|
RJ45 = "rj45"
|
|
|
|
TUNNEL = "tunnel"
|
|
|
|
OVAL = "oval"
|
|
|
|
RECTANGLE = "rectangle"
|
|
|
|
TEXT = "text"
|
|
|
|
HOST = "host"
|
|
|
|
PC = "pc"
|
|
|
|
MDR = "mdr"
|
2019-11-21 20:33:43 +00:00
|
|
|
PROUTER = "prouter"
|
2019-10-11 01:02:28 +01:00
|
|
|
OVS = "OVS"
|
2019-11-21 20:33:43 +00:00
|
|
|
EDITNODE = "edit-node"
|
2019-10-11 01:02:28 +01:00
|
|
|
PLOT = "plot"
|
|
|
|
TWONODE = "twonode"
|
2019-11-27 16:48:21 +00:00
|
|
|
PAUSE = "pause"
|
2019-10-11 01:02:28 +01:00
|
|
|
STOP = "stop"
|
|
|
|
OBSERVE = "observe"
|
|
|
|
RUN = "run"
|
2019-10-19 00:42:00 +01:00
|
|
|
DOCUMENTNEW = "document-new"
|
2019-11-12 00:34:41 +00:00
|
|
|
DOCUMENTSAVE = "document-save"
|
2019-10-19 00:42:00 +01:00
|
|
|
FILEOPEN = "fileopen"
|
|
|
|
EDITDELETE = "edit-delete"
|
|
|
|
ANTENNA = "antenna"
|
2019-11-15 21:09:53 +00:00
|
|
|
DOCKER = "docker"
|
|
|
|
LXC = "lxc"
|
2019-12-12 18:49:52 +00:00
|
|
|
ALERT = "alert"
|