예제 #1
0
    def _on_timer(self, event):
        while True:
            if self.__dead_event.is_set():
                self.notify_observers(
                    Event(name="stop_searching",
                          kwargs={
                              "md5": None,
                              "path": None,
                              "current_dir": None,
                              "stop": True
                          }))
                self.__dead_event.clear()
                self.__is_alive = False
                break

            try:
                md5, path, current_dir = self.__queue.get_nowait()
                self.notify_observers(
                    Event(name="find",
                          kwargs={
                              "md5": md5,
                              "path": path,
                              "current_dir": current_dir,
                              "stop": not self.__is_alive
                          }))
            except queue.Empty:
                break
예제 #2
0
 def onButton1Release(self, event):
     self.delete(self.__boxId)
     self.notify_observers(
         Event(name="rect_selected",
               args=(self.__start_x, self.__start_y, event.x, event.y)))
     self.__start_x = None
     self.__start_y = None
예제 #3
0
    def draw(self, *args, **kwargs):
        try:
            curve_name = kwargs.pop('curve_name')
        except KeyError:
            curve_name = 'curve'

        for figure in self:
            figure.plot_function(*args, **kwargs)
        self.__list.insert('end', curve_name)

        color = None
        if 'color' in kwargs:
            color = colormap.get(kwargs['color'], None)
        if not color:
            line_object = self[0].line_objects[-1]
            if isinstance(line_object, matplotlib.container.StemContainer):
                color = line_object.stemlines.get_color()[0]
            elif isinstance(line_object,
                            matplotlib.collections.PathCollection):
                color = "#000000"
            else:
                color = line_object[0].get_color()
            if isinstance(color, ndarray):
                color = [int(c * 255) for c in color]
                color = "#{:02x}{:02x}{:02x}".format(*color)
            else:
                color = colormap.get(color, color)

        self.__list.item_config('end', fg=color)
        self.notify_observers(Event(kwargs={}))
예제 #4
0
 def ApplicationEvents4_Quit(self, this):
     self.parent_node._on_app_quit(self)
     self.parent_node.notify_observers(Event(
         sender = this,
         name = "Quit",
         kwargs = dict(
             app='Word',
             source='Application')))
예제 #5
0
 def DocumentEvents2_Close(self, this, doc_wrapper):
     self.parent_node.notify_observers(Event(
         sender = this, 
         name = "Close",
         kwargs = dict(
             app='Word',
             source='Document')))
     self._doc_list.remove(doc_wrapper)
예제 #6
0
 def ApplicationEvents4_DocumentOpen(self, this, doc):
     self.parent_node.notify_observers(Event(
         sender = this,
         name = "DocumentOpen",
         kwargs = dict(
             app='Word', 
             source='Application', 
             doc=doc)))
예제 #7
0
 def _on_list_click(self, index, label):
     index = int(index)
     for figure in self:
         for line in figure.line_objects:
             pyplot.setp(line, linewidth=1)
         pyplot.setp(figure.line_objects[index], linewidth=2)
         figure.update()
     self.__selected_curve = (index, label)
     self.notify_observers(Event(kwargs=dict(curve_selected=True)))
예제 #8
0
 def _on_auto_button_click(self):
     self.notify_observers(
         Event(kwargs=dict(xlim=None,
                           ylim=None,
                           major_x_tick=None,
                           major_y_tick=None,
                           minor_x_tick=None,
                           minor_y_tick=None,
                           auto_scale=True)))
예제 #9
0
 def clear(self):
     for fig in self:
         fig.clear()
     self.__list.clear()
     del self.data_pool[:]
     self.current_figure.indicators.clear()
     self.update_indicator_list()
     self.notify_observers(
         Event(kwargs=dict(major_grid=False, minor_grid=False)))
예제 #10
0
 def ApplicationEvents4_WindowDeactivate(self, this, doc, win):
     # When a window loses focus or it is destroyed, 
     # this will be triggered. 
     self.parent_node.notify_observers(Event(
         sender = this,
         name = "WindowDeactivate",
         kwargs = dict(
             app='Word',
             source='Application',
             doc=doc, 
             win=win)))
예제 #11
0
 def __timer_callback(self):
     if self.active:
         if self.__counter > 0:
             self.__counter -= 1
         if self.__counter == 0:
             # This is the last time executing the timer function. 
             self.active = False
             
         self.notify_observers(Event())
         # Observer protocol.
         
         self.__widget.after(self.interval, self.__timer_callback)
예제 #12
0
 def update(self, event=None):  # Usually called by a timer.
     try:
         while True:
             stream_type, content, extras = self.queue.get_nowait()
             self.notify_observers(
                 Event(sender=self,
                       kwargs={
                           "stream_type": stream_type,
                           "content": content,
                           "extras": extras
                       }))
     except queue.Empty:
         pass
예제 #13
0
    def _on_add(self):
        indicatorType = self.__indicator_combo.get()

        def askSpan(orient='v'):
            win = Toplevel()
            pxmin = LabeledEntry(win)
            pxmin.pack()
            pxmin.label_text = 'xmin' if orient == 'v' else 'ymin'
            pxmax = LabeledEntry(win)
            pxmax.pack()
            pxmax.label_text = 'xmax' if orient == 'v' else 'ymax'

            def formatter(val):
                val = float(val)
                val /= 100.
                return '{0:0.2f}'.format(val)

            alphaScale = LabeledScale(win,
                                      from_=0,
                                      to=100,
                                      name='alpha',
                                      formatter=formatter)
            alphaScale.set(50.0)
            alphaScale.pack()
            win.protocol('WM_DELETE_WINDOW', win.quit)
            win.focus_set()
            win.grab_set()
            win.mainloop()
            xmin = pxmin.entry.get()
            xmax = pxmax.entry.get()
            alpha = alphaScale.get() / 100.
            win.destroy()
            return map(float, (xmin, xmax, alpha))

        if indicatorType in ('axvspan', 'axhspan'):
            try:
                the_min, the_max, alpha = askSpan(indicatorType[2])
            except ValueError:
                return
            meta = {'type': indicatorType, 'props': {'alpha': alpha}}
            if indicatorType == 'axvspan':
                meta['xmin'] = the_min
                meta['xmax'] = the_max
                meta['ymin'] = 0.0
                meta['ymax'] = 1.0
            else:
                meta['xmin'] = 0.0
                meta['xmax'] = 1.0
                meta['ymin'] = the_min
                meta['ymax'] = the_max
            self.notify_observers(Event(kwargs=dict(meta=meta)))
예제 #14
0
 def on_property_button_click():
     ret = askgridprop()
     props = {'major': {}, 'minor': {}}
     for index, name in enumerate(('major', 'minor')):
         for key in ret[index]:
             value = ret[index][key][1].get()
             if value:
                 props[name][key] = value
     major.set(1)
     minor.set(1)
     self.notify_observers(
         Event(kwargs=dict(major_grid=major.get(),
                           minor_grid=minor.get(),
                           props=props)))
예제 #15
0
 def ApplicationEvents4_NewDocument(self, this, doc):            
     for doc_idx in range(self.com_handle.Documents.Count):
         idx1 = doc_idx+1
         if self.com_handle.Documents.Item(idx1) == doc:
             doc = self.com_handle.Documents.Item(idx1)
             doc_wrapper = WordDocumentObject(parent=self, handle=doc)
             doc_wrapper._event_connection = client.GetEvents(doc, doc_wrapper)
             self._doc_list.append(doc_wrapper)          
     self.parent_node.notify_observers(Event(
         sender = this,
         name = "NewDocument",
         kwargs = dict(
             app='Word',
             source='Application',
             doc=doc)))
예제 #16
0
    def _on_confirm_button_click(self, event=None):
        def to_float(x):
            try:
                return float(x)
            except:
                return None

        p = [to_float(v.get()) for v in self.__params]
        self.notify_observers(
            Event(kwargs=dict(xlim=p[0:2],
                              ylim=p[2:4],
                              major_x_tick=p[4],
                              major_y_tick=p[5],
                              minor_x_tick=p[6],
                              minor_y_tick=p[7])))
예제 #17
0
 def update(self):
     self.__canvas.draw()
     self.notify_observers(Event(kwargs={}))
예제 #18
0
 def __init__(self):
     super().__init__()
     self.__busy = Event(sender=self, name="busy")
     self.__available = Event(sender=self, name="available")
예제 #19
0
 def on_timer(event=None):
     self.__counter += 1
     if self.__counter == divide_by:
         self.notify_observers(Event())
         self.__counter = 0
예제 #20
0
 def _on_delete_selected(self):
     self.notify_observers(Event(kwargs=dict(del_type='sel')))
예제 #21
0
 def _on_clear_all(self):
     self.notify_observers(Event(kwargs=dict(del_type='all')))
예제 #22
0
 def _on_tab_change(self, event):
     self.notify_observers(Event(kwargs={}))
     self.update_indicator_list()
예제 #23
0
 def _on_title_click(self):
     title_string = askstring('Title', 'Enter the title of current figure:')
     self.notify_observers(
         Event(dict(label_type='title', label_string=title_string)))
예제 #24
0
 def _on_check_click(self):
     self.notify_observers(
         Event(kwargs=dict(major_grid=self.__major.get(),
                           minor_grid=self.__minor.get())))