def KeyEvent(self, event):
        keycode = event.GetKeyCode()
        if keycode == wx.WXK_LEFT:
            self.segment_indices[self.labels[self.label_index]] = max(
                min(self.segment_indices[self.labels[self.label_index]] - 1,
                    self.segment_maximums[self.labels[self.label_index]]),
                self.segment_minimums[self.labels[self.label_index]])
            self.point_Refresh()
            wx.PostEvent(self, wx.PaintEvent())

        elif keycode == wx.WXK_RIGHT:
            self.segment_indices[self.labels[self.label_index]] = max(
                min(self.segment_indices[self.labels[self.label_index]] + 1,
                    self.segment_maximums[self.labels[self.label_index]]),
                self.segment_minimums[self.labels[self.label_index]])
            self.point_Refresh()
            wx.PostEvent(self, wx.PaintEvent())

        elif keycode == wx.WXK_UP:
            self.label_index = (self.label_index + 1) % len(self.labels)
            self.point_Refresh()
            wx.PostEvent(self, wx.PaintEvent())

        elif keycode == wx.WXK_DOWN:
            self.label_index = (self.label_index - 1) % len(self.labels)
            self.point_Refresh()
            wx.PostEvent(self, wx.PaintEvent())

        else:
            event.Skip()
Esempio n. 2
0
 def KeyEvent(self, event):
     keycode = event.GetKeyCode()
     if keycode == wx.WXK_LEFT:
         self.index = (self.index - 1) % len(self.distances)
         self.point_Refresh()
         wx.PostEvent(self, wx.PaintEvent())
     elif keycode == wx.WXK_RIGHT:
         self.index = (self.index + 1) % len(self.distances)
         self.point_Refresh()
         wx.PostEvent(self, wx.PaintEvent())
     else:
         event.Skip()
Esempio n. 3
0
 def KeyEvent(self, event):
     keycode = event.GetKeyCode()
     if keycode == wx.WXK_LEFT:
         self.frame = (self.frame - 1) % len(self.labels)
         self.point_Refresh()
         wx.PostEvent(self, wx.PaintEvent())
     elif keycode == wx.WXK_RIGHT:
         self.frame = (self.frame + 1) % len(self.labels)
         self.point_Refresh()
         wx.PostEvent(self, wx.PaintEvent())
     else:
         self.point_Refresh()
         wx.PostEvent(self, wx.PaintEvent())
         event.Skip()
Esempio n. 4
0
    def KeyEvent(self, event):
        keycode = event.GetKeyCode()
        if keycode == wx.WXK_LEFT :
            self.index = (self.index - 1) % len(self.persistences['persistences'])
	    self.point_Refresh()
            wx.PostEvent(self,wx.PaintEvent())
	    print self.index
        elif keycode == wx.WXK_RIGHT :
            self.index = (self.index + 1) % len(self.persistences['persistences'])
	    self.point_Refresh()
	    wx.PostEvent(self,wx.PaintEvent())
            print self.index
        else :
            event.Skip()
Esempio n. 5
0
 def execute_command(self, command, hidden=False):
     """ Execute a command, not only in the model, but also in the
         view.
     """
     # XXX: This method needs to be integrated in the base fronted
     # interface
     if hidden:
         return self.shell.execute(command)
     else:
         # XXX: we are not storing the input buffer previous to the
         # execution, as this forces us to run the execution
         # input_buffer a yield, which is not good.
         ##current_buffer = self.shell.control.input_buffer
         command = command.rstrip()
         if len(command.split('\n')) > 1:
             # The input command is several lines long, we need to
             # force the execution to happen
             command += '\n'
         cleaned_command = self.prefilter_input(command)
         self.input_buffer = command
         # Do not use wx.Yield() (aka GUI.process_events()) to avoid
         # recursive yields.
         self.ProcessEvent(wx.PaintEvent())
         self.write('\n')
         if not self.is_complete(cleaned_command + '\n'):
             self._colorize_input_buffer()
             self.render_error('Incomplete or invalid input')
             self.new_prompt(
                 self.input_prompt_template.substitute(
                     number=(self.last_result['number'] + 1)))
             return False
         self._on_enter()
         return True
Esempio n. 6
0
 def show_traceback(self):
     start_line = self.GetCurrentLine()
     PrefilterFrontEnd.show_traceback(self)
     self.ProcessEvent(wx.PaintEvent())
     #wx.Yield()
     for i in range(start_line, self.GetCurrentLine()):
         self._markers[i] = self.MarkerAdd(i, _ERROR_MARKER)
Esempio n. 7
0
	def paint(self, show_choice = False, show_pv = False):
		if not show_choice:
			self.choices = None;
		if not show_pv:
			self.pv = None;
		evt = wx.PaintEvent(self.panel_board.GetId());
		self.panel_board.GetEventHandler().ProcessEvent(evt);
Esempio n. 8
0
 def emptyPipe(self):
     while (True):
         if (self.persistences.poll(0.025)):
             (index, points, segment,
              segment_dict) = self.persistences.recv()
             self.point_array[index] = (points, segment, segment_dict)
             if (self.save_dir != None):
                 # Create PNG Plot of data
                 figure_file = Figure()
                 from matplotlib.backends.backend_agg import FigureCanvasAgg
                 canvas_file = FigureCanvasAgg(figure_file)
                 axes_file = figure_file.add_subplot(111)
                 figure_title = figure_file.suptitle(
                     "Segment of size %s starting at %s\nWindow size %d stride %s"
                     % (segment_dict['segment size'],
                        segment_dict['segment start'],
                        segment_dict['window size'],
                        segment_dict['window stride']))
                 x = [p[0] for p in points if p[2] != 0]
                 y = [p[1] for p in points if p[2] != 0]
                 max_xy = max(max(x), max(y))
                 axes_file.scatter(x, y, color='red', s=50)
                 axes_file.plot([0, max_xy], [0, max_xy], color='black')
                 figure_file.savefig("%s/%05d.png" % (self.save_dir, index))
                 # Save off the persistence
                 segment_dict['persistence'] = points
                 with open("%s/%05d.json" % (self.save_dir, index),
                           'w') as p_save:
                     json.dump(segment_dict, p_save)
             if (index == self.frame):
                 self.point_Refresh()
                 wx.PostEvent(self, wx.PaintEvent())
Esempio n. 9
0
    def mouseUp(self, event):
        if (event != None and event.xdata != None):
            click_segment = None
            click_index = None
            for (persistence, index) in itertools.izip(
                    self.persistences.diagrams,
                    range(len(self.persistences.diagrams))):
                if persistence['segment_start'] < int(event.xdata):
                    click_segment = persistence
                    click_index = index

            self.click = self.click + 1
            if self.click % 2 == 1:
                self.index_a = click_index
            else:
                self.index_b = click_index

            self.similarities = [(segment['segment_start'],segment['segment_size'],similarity) for (segment, similarity) in \
                                 itertools.izip(self.segments.segments, self.kernel.kernel_matrix[int(click_index)])]
            self.point_Refresh()
        else:
            self.caption.set_text("No segment at %s, %s" %
                                  (event.xdata, event.ydata))

        wx.PostEvent(self, wx.PaintEvent())
Esempio n. 10
0
    def mouseMove(self, event):
        if (event != None and event.xdata != None):
            click_segment = None
            for segment in self.segments.segments:
                if (segment['segment_start'] < int(event.xdata) and
                    (segment['segment_start'] + segment['segment_size']) > int(
                        event.xdata)):
                    click_segment = segment
            similarity = None
            for (x, y, z) in self.similarities:
                if x < int(event.xdata) and (x + y) > int(event.xdata):
                    similarity = z

            if (click_segment != None):
                if similarity != None:
                    self.caption.set_text("Segment Labels %s start %s size %s similarity %s" % (\
                        click_segment['labels'], click_segment['segment_start'], click_segment['segment_size'], similarity))
                else:
                    self.caption.set_text("Segment Labels %s start %s size %s" % (\
                        click_segment['labels'], click_segment['segment_start'], click_segment['segment_size']))

        else:
            self.caption.set_text("No segment at %s, %s" %
                                  (event.xdata, event.ydata))

        wx.PostEvent(self, wx.PaintEvent())
Esempio n. 11
0
    def KeyEvent(self, event):
        keycode = event.GetKeyCode()
        if keycode == wx.WXK_LEFT:
            self.index = (self.index - 2) % len(self.data_indices) + 1

            self.SetTitle("Column %s" % (self.data_indices[self.index - 1], ))
            self.point_Refresh()
            wx.PostEvent(self, wx.PaintEvent())
        elif keycode == wx.WXK_RIGHT:
            self.index = (self.index) % len(self.data_indices) + 1

            self.SetTitle("Column %s" % (self.data_indices[self.index - 1], ))
            self.point_Refresh()
            wx.PostEvent(self, wx.PaintEvent())
        else:
            self.point_Refresh()
            wx.PostEvent(self, wx.PaintEvent())
            event.Skip()
Esempio n. 12
0
 def set_label(self, label=None):
     """
     """
     if self.msg:
         self.refresh()
         if label:
             self.msg.SetLabel(label)
         evt = wx.PaintEvent(self.msg.GetId())
         self.msg.GetEventHandler().ProcessEvent(evt)
Esempio n. 13
0
 def KeyEvent(self, event):
     keycode = event.GetKeyCode()
     if keycode == wx.WXK_LEFT:
         if (self.frame > 0):
             self.frame = self.frame - 1
             self.SetTitle("Segment %s" % (self.frame, ))
             self.point_Refresh()
             wx.PostEvent(self, wx.PaintEvent())
     elif keycode == wx.WXK_RIGHT:
         if (self.frame < self.num_segments - 1):
             self.frame = self.frame + 1
             self.SetTitle("Segment %s" % (self.frame, ))
             self.point_Refresh()
             wx.PostEvent(self, wx.PaintEvent())
     else:
         self.point_Refresh()
         wx.PostEvent(self, wx.PaintEvent())
         event.Skip()
Esempio n. 14
0
    def OnMenuOptionsGenerate(self, event):
        ctx.fGenerateCoins = event.IsChecked()
        ctx.transactionsUpdated += 1
        with Tx.PyWalletDB() as walletdb:
            walletdb.write_setting(Tx.PyWalletDB.DBKEY_SETTING_GEN_COIN,
                                   ctx.fGenerateCoins)

        self.MinerThread(ctx.fGenerateCoins)

        self.Refresh()
        self.AddPendingEvent(wx.PaintEvent())
Esempio n. 15
0
    def KeyEvent(self, event):
        keycode = event.GetKeyCode()
        if keycode == wx.WXK_LEFT :
#            self.label_index = (self.label_index - 1) % len(self.labels)
#            self.refresh()
            wx.PostEvent(self,wx.PaintEvent())
        elif keycode == wx.WXK_RIGHT :
#            self.label_index = (self.label_index + 1) % len(self.labels)
#            self.refresh()
            wx.PostEvent(self,wx.PaintEvent())
        elif keycode == wx.WXK_UP :
#            self.segment_index = (self.segment_index - 1) % len(self.full_data.segments)            
#            self.refresh()
            wx.PostEvent(self,wx.PaintEvent())
        elif keycode == wx.WXK_DOWN :
#            self.segment_index = (self.segment_index + 1) % len(self.full_data.segments)            
#            self.refresh()
            wx.PostEvent(self,wx.PaintEvent())
        else :
            pass
        event.Skip()
Esempio n. 16
0
 def KeyEvent(self, event):
     keycode = event.GetKeyCode()
     if keycode == wx.WXK_LEFT :
         self.simplices_index = (self.simplices_index - 1) % len(self.simplices)
         self.refresh()
         wx.PostEvent(self,wx.PaintEvent())
     elif keycode == wx.WXK_RIGHT :
         self.simplices_index = (self.simplices_index + 1) % len(self.simplices)
         self.refresh()
         wx.PostEvent(self,wx.PaintEvent())
     elif keycode == wx.WXK_UP :
         self.segment_index = (self.segment_index - 1) % len(self.full_rips_persistences)            
         self.refresh()
         wx.PostEvent(self,wx.PaintEvent())
     elif keycode == wx.WXK_DOWN :
         self.segment_index = (self.segment_index + 1) % len(self.full_rips_persistences) 
         self.refresh()
         wx.PostEvent(self,wx.PaintEvent())
     else :
         pass
     event.Skip()
Esempio n. 17
0
    def ShowSplashScreen(self):
        bmp = wx.Image(self.splashPath).ConvertToBitmap()
        self.splash = AdvancedSplash(None, bitmap=bmp)

        # process all events
        # even the events generated by splash themself during showing
        if wx.Platform == '__WXMSW__':
            self.splash.Show()
            self.splash.ProcessEvent(wx.PaintEvent())
        else:
            for dummy in range(0, 30):
                wx.Yield()
                time.sleep(0.01)
Esempio n. 18
0
    def mouseMove(self, event):
        if (event != None and event.xdata != None):
            click_span = None
            for span in self.spans:
                if span.data[0][0] < event.xdata and span.data[-1][
                        0] > event.xdata:
                    click_span = span
                    break
            if (click_span != None):
                self.caption.set_text(
                    "Span Label %s start %s end %s size %s" %
                    (click_span.label, click_span.data[0][0],
                     click_span.data[-1][0], len(click_span.data)))
            else:
                self.caption.set_text("No span at %s, %s" %
                                      (event.xdata, event.ydata))

            wx.PostEvent(self, wx.PaintEvent())
Esempio n. 19
0
 def execute_command(self, command, hidden=False):
     """ Execute a command, not only in the model, but also in the
         view.
     """
     # XXX: This needs to be moved to the IPython codebase.
     if hidden:
         result = self.shell.execute(command)
         # XXX: Fix bug where executing a hidden command still causes the
         # prompt number to increase.
         self.shell.current_cell_number -= 1
         return result
     else:
         # XXX: we are not storing the input buffer previous to the
         # execution, as this forces us to run the execution
         # input_buffer a yield, which is not good.
         ##current_buffer = self.shell.control.input_buffer
         command = command.rstrip()
         if len(command.split("\n")) > 1:
             # The input command is several lines long, we need to
             # force the execution to happen
             command += "\n"
         cleaned_command = self.prefilter_input(command)
         self.input_buffer = command
         # Do not use wx.Yield() (aka GUI.process_events()) to avoid
         # recursive yields.
         self.ProcessEvent(wx.PaintEvent())
         self.write("\n")
         if not self.is_complete(cleaned_command + "\n"):
             self._colorize_input_buffer()
             self.render_error("Incomplete or invalid input")
             self.new_prompt(
                 self.input_prompt_template.substitute(
                     number=(self.last_result["number"] + 1)))
             return False
         self._on_enter()
         return True
Esempio n. 20
0
 def KeyEvent(self, event):
     keycode = event.GetKeyCode()
     print "Key code %s" % keycode
     if keycode == wx.WXK_LEFT or keycode == wx.WXK_DOWN :
         self.step = (self.step - 1) if self.step > 1 else self.step
         print self.step
         self.point_Refresh()
         wx.PostEvent(self,wx.PaintEvent())
     elif keycode == wx.WXK_RIGHT or keycode == wx.WXK_UP :
         self.step = (self.step + 1)
         print self.step
         self.point_Refresh()
         wx.PostEvent(self,wx.PaintEvent())
     elif keycode == 65 : # 'A'
         self.frame_1 = (self.frame_1 - self.step) if self.frame_1 > self.step else 0
         print self.frame_1
         self.point_Refresh()
         wx.PostEvent(self,wx.PaintEvent())
     elif keycode == 68 : # 'D'
         self.frame_1 = (self.frame_1 + self.step) if (self.frame_1 + self.step) < len(self.data_1) else (len(self.data_1) - 1)
         print self.frame_1
         self.point_Refresh()
         wx.PostEvent(self,wx.PaintEvent())
     elif keycode == 74 : # 'J'
         self.frame_2 = (self.frame_2 - self.step) if self.frame_2 > self.step else 0
         print self.frame_2
         self.point_Refresh()
         wx.PostEvent(self,wx.PaintEvent())
     elif keycode == 76 : # 'L'
         self.frame_2 = (self.frame_2 + self.step) if (self.frame_2 + self.step) < len(self.data_2) else (len(self.data_2) - 1)
         print self.frame_2
         self.point_Refresh()
         wx.PostEvent(self,wx.PaintEvent())
     else :
         self.point_Refresh()
         wx.PostEvent(self,wx.PaintEvent())
         event.Skip()
Esempio n. 21
0
 def Repaint(self):
     self.Refresh()
     wx.PostEvent(self, wx.PaintEvent())
Esempio n. 22
0
    def mouseUp(self, event):
        if (event != None and event.xdata != None):
            click_span = None
            for span in self.spans:
                if span.data[0][0] < event.xdata and span.data[-1][
                        0] > event.xdata:
                    click_span = span
                    break
            if (click_span != None):
                self.caption.set_text(
                    "Span Label %s start %s end %s size %s" %
                    (click_span.label, click_span.data[0][0],
                     click_span.data[-1][0], len(click_span.data)))
                if self.state[0] != None and self.state[0] == 'mouse down':
                    self.state = ('mouse up', (self.state[1], event.xdata))
                elif self.state[0] != None and self.state[0] == 'mouse up':
                    start_0 = min(self.state[1][0], self.state[1][1])
                    end_0 = max(self.state[1][0], self.state[1][1])
                    start_1 = event.xdata - (end_0 - start_0) / 2
                    end_1 = event.xdata + (end_0 - start_0) / 2
                    if start_1 < 0:
                        start_1 = 0
                        end_1 = end_0 - start_0
                    elif end_1 > self.spans[-1].data[-1][0]:
                        end_1 = self.data_len
                        start_1 = end_1 - (end_0 - start_0)

                    sfd = SegmentFileDescriptor.fromSegmentList([
                        dict([('file', self.filename),
                              ('label index', self.label_column),
                              ('data index', self.index),
                              ('segment start', int(start_0)),
                              ('segment size', int(end_0 - start_0)),
                              ('segment stride', int(abs(start_1 - start_0))),
                              ('window size', self.window_size),
                              ('window stride', self.window_stride)]),
                        dict([('file', self.filename),
                              ('label index', self.label_column),
                              ('data index', self.index),
                              ('segment start', int(start_1)),
                              ('segment size', int(end_1 - start_1)),
                              ('segment stride', int(abs(start_1 - end_1))),
                              ('window size', self.window_size),
                              ('window stride', self.window_stride)])
                    ])
                    pg = PersistenceGenerator.PersistenceGenerator(
                        sfd, max_simplices=self.max_simplices)
                    persistences = map(
                        PersistenceGenerator.process,
                        itertools.product(sfd, [self.max_simplices]))
                    pk = PersistenceKernel.PersistenceKernel(
                        training_list=persistences,
                        testing_list=None,
                        degree=1,
                        kernel=(lambda a, b: ssk_similarity(
                            a, b, self.kernel_scale)))
                    print "Computed similarity between Segment 0 (%s, %s) and Segment 1 (%s, %s) : %s" % (\
                        int(start_0), int(end_0), int(start_1), int(end_1), pk.compute_training()[0][1],)
                    self.state = (None, 0)

            else:
                self.caption.set_text("No span at %s, %s" %
                                      (event.xdata, event.ydata))

            wx.PostEvent(self, wx.PaintEvent())
Esempio n. 23
0
 def refresh(self):
     """
     """
     evt = wx.PaintEvent(self.GetId())
     return self.GetEventHandler().ProcessEvent(evt)
Esempio n. 24
0
	def update(self):
		"""
		Force a paint event.
		"""
		if not self._gl_init_flag: return
		wx.PostEvent(self, wx.PaintEvent())
Esempio n. 25
0
 def OnTimerEvent(self, event):
     self.GetEventHandler().ProcessEvent(wx.PaintEvent())
Esempio n. 26
0
def mainframe_repaint():
    if ctx.frameMain:
        print("MainFrameRepaint()")
        ctx.frameMain.Refresh()
        ctx.frameMain.GetEventHandler().AddPendingEvent(wx.PaintEvent())
Esempio n. 27
0
 def test_PaintEvent_ctor(self):
     evt = wx.PaintEvent()
 def TimeEvent(self, event):
     self.point_Refresh()
     wx.PostEvent(self, wx.PaintEvent())
Esempio n. 29
0
 def requestRedraw(self):
     if self.redrawRequested:
         return
     else:
         self.redrawRequested = True
         wx.PostEvent(self,wx.PaintEvent(self.GetId()))