def __init__(self): Subject.__init__(self) Pyro.core.ObjBase.__init__(self) self.debugq = Queue.Queue() self.debugon = False self.log = logging.getLogger("mallorymain")
def __init__(self, model): """ Constructor :param model: The model from which the view gets the data """ Subject.__init__(self) self.model = model
def __init__(self, model): tk.Tk.__init__(self) Subject.__init__(self) # VIEW OBSERVES THE MODEL FOR STATE CHANGES Observer.__init__(self) self.model = model self.model.attach(self) for x in self.model.layout_algos: print(x, self.model.layout_algos[x]) for x in self.model.algos: print(x, self.model.algos[x]) self.info_menu = None self.geometry("1920x1080") # Init. canvas self.tabs = {} self.nb = ttk.Notebook(self, name="nb") self.index = 0 self.nb.grid(column=0, row=0, sticky=tk.N) self.bind("<Control-t>", self.open_new_graph) self.bind("<Control-w>", self.delete_tab) self.bind("<Control-s>", self.do_algo) self.bind("<Control-r>", self.zoom_out) self.bind("<Control-f>", self.zoom_in)
def __init__(self, rules = [], config = config.Config()): Subject.__init__(self) self.log = logging.getLogger("mallorymain") self.config = config self.rules = rules #Will be used to know where to start new "runp" thread on plug in conf self.persistent = 0
def __init__(self, rules=[], config=config.Config()): Subject.__init__(self) self.log = logging.getLogger("mallorymain") self.config = config self.rules = rules #Will be used to know where to start new "runp" thread on plug in conf self.persistent = 0
def __init__(self,a=1.0,f=1.0,p=0.0,o=0.0,color='red'): Subject.__init__(self) self.signal=[] self.a,self.f,self.p,self.o=a,f,p,o self.color=color self.time = 1 self.generate_signal()
def __init__(self, save=False, filepath="."): Subject.__init__(self) self.filepath = filepath self.last_time = 0 self.simulations = [] if (save): self.saver = DataSaver(filepath) self.attach(self.saver, simulation=False)
def __init__(self, rules = [], config = config.Config()): Subject.__init__(self) self.log = logging.getLogger("mallorymain") self.config = config self.rules = rules self.plugin_manager = None self.friendly_name = "Undefined" self.done = False
def __init__(self): Subject.__init__(self) self.__notes = [ "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" ] self.chordInPrepare = [] self.chordsList = [["C4", "E4", "G4"]] pass
def __init__(self,aX=0.0,fX=0.0,pX=0.0,oX=0.0,colorX='red', aY=0.0,fY=0.0,pY=0.0,oY=0.0,colorY='blue'): Subject.__init__(self) self.X = Generator(aX,fX,pX,oX,colorX) self.X.generate_signal() self.Y = Generator(aY,fY,pY,oY,colorY) self.Y.generate_signal() self.XY = [] self.generate_XYCurve()
def detach(self, observer, index=None): if (observer): Subject.detach(self, observer) for i in range(len(self.observers)): if (observer == self.observers[i]): self.simulations.pop(i) return self.simulations.pop(self.observers[index]) self.observers.pop(index) print('Detached; ', (self.observers))
class TestSubject(unittest.TestCase): @classmethod def setUpClass(self): self.s = Subject() self.dec_obs = DecimalViewer() self.hex_obs = HexViewer() def test_a_observer_list_shall_be_empty_initially(self): self.assertEqual(len(self.s._observers), 0) def test_b_observers_shall_be_attachable(self): self.s.attach(self.dec_obs) self.assertEqual(isinstance(self.s._observers[0], DecimalViewer), True) self.assertEqual(len(self.s._observers), 1) self.s.attach(self.hex_obs) self.assertEqual(isinstance(self.s._observers[1], HexViewer), True) self.assertEqual(len(self.s._observers), 2) def test_c_observers_shall_be_detachable(self): self.s.detach(self.dec_obs) # hex viewer shall be remaining if dec viewer is detached first self.assertEqual(isinstance(self.s._observers[0], HexViewer), True) self.assertEqual(len(self.s._observers), 1) self.s.detach(self.hex_obs) self.assertEqual(len(self.s._observers), 0)
class MockGDBStub(object): def __init__(self): self.event_subject = Subject() self.running = True def add_event_observer(self, observer): self.event_subject.add_observer(observer) def remove_exit_observer(self, observer): self.event_subject.remove_observer(observer) def execute(self, command): if command == 'continue': self.running = True def pause(self): assert self.running self.running = False self.event_subject.notify() def execute_sync(self, command): self.execute(command) def simulate_exit(self): assert self.running self.running = False self.event_subject.notify()
def __init__(self, options): Subject.__init__(self) self.log = logging.getLogger("mallorymain") config.logsetup(self.log) self.configured_protos = [] self.configured_plugin_managers = [] self.protoinstances = [] self.opts = options.options self.dbname = self.opts.trafficdb self.debugon = False self.debugger = Debugger() self.config_protocols = config_proto.ConfigProtocols() self.config_rules = config_rule.ConfigRules() self.rpcserver = rpc.RPCServer() self.nftool = netfilter.NetfilterTool()
def __init__(self, model): """Inits the class.""" Subject.__init__(self) QMainWindow.__init__(self) # Set model self.model = model # Create interface elements self.menu_bar = MenuBar(self) self.tool_bar = ToolBar(self) self.exif_area = ExifWidget(self) self.image_area = ImageWidget(self) self.status_bar = StatusBar() about_text = 'IEViewer 1.0' \ '<br><br>' \ 'Copyright © 2021 by' \ '<br>' \ 'Paula Mihalcea' \ '<br>' \ '<a href="mailto:[email protected]">[email protected]</a>' \ '<br><br>' \ 'This program uses PyQt5, a comprehensive set of Python bindings for Qt v5. Qt is a set of cross-platform C++ libraries that implement high-level APIs for accessing many aspects of modern desktop and mobile systems.\n' \ '<br><br>' \ 'PyQt5 is copyright © Riverbank Computing Limited. Its homepage is <a href="https://www.riverbankcomputing.com/software/pyqt/">https://www.riverbankcomputing.com/software/pyqt/</a>.' \ '<br><br>' \ 'No genasi were harmed in the making of this application. <a href="https://www.dndbeyond.com/races/genasi#WaterGenasi">#GenasiLivesMatter#NereisThalian</a>' self.about = AboutWidget('About IEViewer', about_text, image_path='icons/about_img.png') # Disable GUI elements that are unavailable when no image is opened self.menu_bar.disable_widgets() self.exif_area.hide() # Set layout self.setCentralWidget(Layout(self).central_widget) # Set window properties self.set_window_properties() # Install additional event filters self.image_area.installEventFilter(self)
def __init__(self): """ Checks if all needed paths exists and starts to load data which is needed by the application """ Subject.__init__(self) if not os.path.exists("graphs"): logger.debug("Making graphs directory") os.makedirs("graphs") if not os.path.exists("algorithms"): logger.debug("Making algorithms directory") os.makedirs("algorithms") self.is_connected = False self.acyclic = False self.is_undirected_tree = False self.loaded_graphs: Dict[str, Graph] = dict() self.layout_algos: Dict[str, LayoutAlgorithm] = dict() self.algos = dict() self.load_layouting_algos() self.load_algos() self.view = None
def __init__(self, rules = [], config = config.Config()): Subject.__init__(self) self.log = logging.getLogger("mallorymain") self.config = config self.rules = rules self.eventQ = Queue.Queue(0)
def __init__(self): self.event_subject = Subject() self.running = True
def setUpClass(cls): cls.s = Subject() cls.dec_obs = DecimalViewer() cls.hex_obs = HexViewer()
def attach(self, observer) -> None: """ Adds an observer to the mdoel which listens to user input :param observer: The observer which should be listening """ Subject.attach(self, observer)
def setUpClass(self): self.s = Subject() self.dec_obs = DecimalViewer() self.hex_obs = HexViewer()
def attach(self, observer, simulation=False): self.simulations.append(simulation) Subject.attach(self, observer) print('Attached; ', self.observers)
def attach(self, observer) -> None: Subject.attach(self, observer)
def attach(self, observer): Subject.attach(self, observer)
from chain import Request, MidddlewareHandler, ControllerHandler from observer import ObserverOne, ObserverTwo, Subject from command import Application from strategy import ApiDemo, JsonParser, XMLParser ctrl = ControllerHandler() ctrl.set_anterior(MidddlewareHandler()) ctrl.handle_request(Request()) subject = Subject() subject.add_observer(ObserverTwo()) subject.add_observer(ObserverOne()) subject.state = 'Changed' subject.state = 'Changed 2' subject.state = 'Changed 3' app = Application() app.add_btn_click() app.add_btn_click() app.add_btn_click() app.add_btn_click() app.delete_btn_click() app.undo() app.undo() api_json = ApiDemo(JsonParser()) api_xml = ApiDemo(XMLParser()) api = ApiDemo()
def __init__(self): Subject.__init__(self) self.ability_event = None
def __init__(self): Subject.__init__(self) self.signal = [] self.a, self.f, self.p, self.h = 1.0, 1.0, 0.0, 1
def __init__(self, rules=[], config=config.Config()): Subject.__init__(self) self.log = logging.getLogger("mallorymain") self.config = config self.rules = rules self.eventQ = Queue.Queue(0)