Notepad++ generated in local folder (no need)
parent
043097a122
commit
31357a8838
|
|
@ -1,79 +0,0 @@
|
||||||
import base
|
|
||||||
import random
|
|
||||||
from sight import Sight
|
|
||||||
|
|
||||||
class SightFactory():
|
|
||||||
def __init__(self):
|
|
||||||
self.list = {}
|
|
||||||
self.data = {} #Global data(s) for the sight(s)
|
|
||||||
|
|
||||||
def create(self, id, type):
|
|
||||||
print("----- "+type+"-"+str(id)+"-------")
|
|
||||||
|
|
||||||
if str(id) == "main" and self.checkKey(id):
|
|
||||||
print("The 'main' window already exist! You can't create more than one 'main' type window!")
|
|
||||||
return None
|
|
||||||
|
|
||||||
if base.data["sight_mode"] == "single":
|
|
||||||
if len(id) == 0:
|
|
||||||
print("No ID was given! In single mode need declare an ID to the Sight in advance!")
|
|
||||||
return None
|
|
||||||
if self.checkKey(id):
|
|
||||||
print("This ['"+type+"'-'"+str(id)+"'] already exist!")
|
|
||||||
return None
|
|
||||||
if base.data["sight_mode"] == "multiple":
|
|
||||||
if len(id) == 0:
|
|
||||||
id = self.createUniqueId()
|
|
||||||
if len(id) > 0 and self.checkKey(id) and str(id) != "main":
|
|
||||||
id = self.createUniqueId()
|
|
||||||
|
|
||||||
self.list[id] = Sight(id,type)
|
|
||||||
print("The ['"+type+"'-'"+str(id)+"'] is created now!")
|
|
||||||
return id
|
|
||||||
|
|
||||||
def show(self, id):
|
|
||||||
if self.checkKey(id):
|
|
||||||
self.list[id].show()
|
|
||||||
print("The '"+str(id)+"' sight is showed!")
|
|
||||||
return True
|
|
||||||
print("This '"+str(id)+"' id isn't exist to show!")
|
|
||||||
return False
|
|
||||||
|
|
||||||
def get(self, id):
|
|
||||||
if self.checkKey(id):
|
|
||||||
return self.list[id]
|
|
||||||
print("This '"+str(id)+"' id isn't exist to get!")
|
|
||||||
|
|
||||||
def close(self, id):
|
|
||||||
if self.checkKey(id):
|
|
||||||
if id == "main":
|
|
||||||
print("Program Exit!")
|
|
||||||
base.app.exit(0)
|
|
||||||
self.list[id].close()
|
|
||||||
self.list[id].destroy()
|
|
||||||
del self.list[id]
|
|
||||||
print("The '"+str(id)+"' is closed now!")
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
print("The '"+str(id)+"' isn't exist'")
|
|
||||||
return False
|
|
||||||
|
|
||||||
def processes(self):
|
|
||||||
print(self.list)
|
|
||||||
|
|
||||||
def checkKey(self, id):
|
|
||||||
if id in self.list:
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
def addGlobalData(self, key, value):
|
|
||||||
self.data[key] = value
|
|
||||||
def getGlobalData(self, key):
|
|
||||||
if key in self.data:
|
|
||||||
return self.data[key]
|
|
||||||
return None
|
|
||||||
|
|
||||||
def createUniqueId(self):
|
|
||||||
new_id = str(random.randint(1000, 9999))
|
|
||||||
if self.checkKey(new_id):
|
|
||||||
self.createUniqueId()
|
|
||||||
return new_id
|
|
||||||
Loading…
Reference in New Issue