示例#1
0
def key_click_text_ctrl(control, interaction, delay):
    """ Performs simulated typing of a key on the given wxObject
    after a delay.

    Parameters
    ----------
    control : wxTextCtrl
        The wx Object to be acted on.
    interaction : instance of command.KeyClick
        The interaction object holding the key input
        to be simulated being typed
    delay : int
        Time delay (in ms) in which the key click will be performed.
    """
    if not control.IsEditable():
        raise Disabled("{!r} is disabled.".format(control))
    if not control.HasFocus():
        control.SetFocus()
        control.SetInsertionPointEnd()
    if interaction.key == "Enter":
        wx.MilliSleep(delay)
        event = wx.CommandEvent(wx.EVT_TEXT_ENTER.typeId, control.GetId())
        control.ProcessEvent(event)
    elif interaction.key == "Backspace":
        wx.MilliSleep(delay)
        if control.GetStringSelection():
            control.Remove(*control.GetSelection())
        else:
            pos = control.GetInsertionPoint()
            control.Remove(max(0, pos - 1), pos)
    else:
        check_key_compat(interaction.key)
        wx.MilliSleep(delay)
        control.WriteText(interaction.key)
示例#2
0
    def SpScreen(self):
        wx.MilliSleep(50)

        #self.mutex.acquire()

        self.image = SPLASH_IMAGE

        self.splash = VeSplashScreen(self, bitmapfile=self.image)
        self.splash.Bind(wx.EVT_CLOSE, self.OnSplashExit)
        self.splash.SetTextColor(wx.BLACK)
        self.splash.SetTextPosition((155, 43))
        self.splash.SetTextFont(
            wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, "Arial"))
        versionString = "Version 2.2.2"
        self.splash.SetText(versionString)
        self.splash.Show(True)

        if self.state.GetSurface("NameServer"):
            self.splash.SetText(versionString, "Starting Name Server...")
            wx.MilliSleep(1000)
        if self.state.GetSurface("Xplorer"):
            self.splash.SetText(versionString, "Starting Xplorer...")
            wx.MilliSleep(500)
        if self.state.GetSurface("Conductor"):
            self.splash.SetText(versionString, "Starting Conductor...")
            wx.MilliSleep(1000)

        self.splash.SetText(versionString, "Preparing to Launch VE-Suite...")
        wx.MilliSleep(1000)

        self.splash.OnCloseWindow()
示例#3
0
    def test_caption_position(self):
        """ Test if the caption positions don't when expanding and collapsing"""
        wx.MilliSleep(test.SLEEP_TIME)

        ini_positions = [i.GetPosition() for i in self.foldpanelitems]
        #print ini_positions

        # Panel 1 COLLAPSE
        event = self.build_caption_event(self.app.test_frame.panel_1)
        wx.PostEvent(self.app.test_frame.panel_1, event)
        test.gui_loop()
        test.gui_loop()

        new_positions = [i.GetPosition() for i in self.foldpanelitems]
        #print new_positions

        self.assertEqual(ini_positions[0], new_positions[0])
        self.assertGreater(ini_positions[1][1], new_positions[1][1])
        self.assertGreater(ini_positions[2][1], new_positions[2][1])

        wx.MilliSleep(test.SLEEP_TIME)

        # Panel 1 EXPAND
        wx.PostEvent(self.app.test_frame.panel_1, event)
        test.gui_loop()
        test.gui_loop()

        new_positions = [i.GetPosition() for i in self.foldpanelitems]

        self.assertEqual(new_positions, ini_positions)

        wx.MilliSleep(test.SLEEP_TIME)

        # Panel 2 EXPAND
        event = self.build_caption_event(self.app.test_frame.panel_2)
        wx.PostEvent(self.app.test_frame.panel_2, event)
        test.gui_loop()
        test.gui_loop()

        new_positions = [i.GetPosition() for i in self.foldpanelitems]

        self.assertEqual(ini_positions[0], new_positions[0])
        self.assertEqual(new_positions[1][1], ini_positions[1][1])
        self.assertGreater(new_positions[2][1], ini_positions[2][1])

        wx.MilliSleep(test.SLEEP_TIME)

        # Panel 2 COLLAPSE
        wx.PostEvent(self.app.test_frame.panel_2, event)
        test.gui_loop()
        test.gui_loop()

        new_positions = [i.GetPosition() for i in self.foldpanelitems]

        self.assertEqual(new_positions, ini_positions)

        wx.MilliSleep(test.SLEEP_TIME)
示例#4
0
 def waiting_thread(self):
     wx.MilliSleep(100)
     while self.thread_runing:
         self.gauge.SetValue(self.percent_now)
         self.percent_now += self.percent_unit
         if self.percent_now > 100:
             self.percent_now = 0
         wx.MilliSleep(100)
     self.Destroy()
 def record(self):
     self.startRecord()
     self.playRecLabel.SetLabel("Запись")
     delay_time = self.test_settings.delay * 1000    # getting delay in milliseconds
     count = 0
     while count < delay_time:
         count += 250
         self.countdownLabel.SetLabel(self.get_countdown_text(delay_time, count))
         wx.MilliSleep(250)
     self.stopRecord()
     wx.Yield()
     wx.MilliSleep(250)
示例#6
0
    def test_lib_busy5(self):
        message = """A long message with line breaks:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit
esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum."""
        with BusyInfo(message, self.frame):
            wx.MilliSleep(delay * 2)
        wx.MilliSleep(delay)
        self.myYield()
示例#7
0
    def test_scrollbar_on_collapse(self):
        """ A vertical scroll bar should appear when a panel is expanded and
            its content will not fit within the parent window. """

        fpb = self.app.test_frame.fpb

        wx.MilliSleep(test.SLEEP_TIME)

        # Put back into more or less original state
        self.app.test_frame.panel_1.Expand()
        self.app.test_frame.panel_2.Collapse()
        self.app.test_frame.panel_3.Expand()

        # The first and third panel should be expanded, the second one collapsed
        self.assertEqual(self.app.test_frame.panel_1.IsExpanded(), True)
        self.assertEqual(self.app.test_frame.panel_2.IsExpanded(), False)
        self.assertEqual(self.app.test_frame.panel_3.IsExpanded(), True)

        false_pos_warn = ("This might be a false positive. "
                          "Run test module stand-alone to verify")

        self.assertEqual(fpb.has_vert_scrollbar(), False, false_pos_warn)
        self.assertEqual(fpb.has_horz_scrollbar(), False, false_pos_warn)

        bottom_panel_2 = self.app.test_frame.panel_2.GetPosition()[1] + \
                         self.app.test_frame.panel_2.GetSize().GetHeight()
        top_panel_3 = self.app.test_frame.panel_3.GetPosition()[1]

        # The top of panel 3 should align with the bottom of panel 2
        self.assertEqual(bottom_panel_2, top_panel_3)

        # Expand the 2nd panel
        event = self.build_caption_event(self.app.test_frame.panel_2)
        wx.PostEvent(self.app.test_frame.panel_2, event)
        test.gui_loop()
        test.gui_loop()

        # Scroll bar should be visible now
        self.assertEqual(fpb.has_vert_scrollbar(), True)
        self.assertEqual(fpb.has_horz_scrollbar(), False)

        wx.MilliSleep(test.SLEEP_TIME)

        # Collapse the 2nd panel
        wx.PostEvent(self.app.test_frame.panel_2, event)
        test.gui_loop()
        test.gui_loop()

        # Scroll bar should be hidden again
        self.assertEqual(fpb.has_vert_scrollbar(), False)
        self.assertEqual(fpb.has_horz_scrollbar(), False)
示例#8
0
	def run(self):
		"""
		Place your openCV processing codes in here
		Currently the codes in here are just for testing
		"""

		gr = GestureRecognizer(True)
		counter = 0
		commandExecuted = False
		#gr.videoinit("/dev/video0")
		gr.videoinit(-1)
		while(True):
			gesture = gr.recognize(gr.readVideo())

			# if gr.handCenterSpeed != 0: print "Speed: {}".format(gr.handCenterSpeed)
			#print "Steady time: {} Finger count: {}".format(gr.noMovementCounter, gr.fingerCount)

			# gr.showProcessedFrames()
			# timeoutCounter += 1
			# if timeoutCounter > timeoutLimit: timeout = True
			if(not commandExecuted):
				if(gesture == Gesture.select): 
					print("Made selection")
					wx.CallAfter(Publisher.sendMessage,"make selection","")
					wx.MilliSleep(self.latency)
					commandExecuted = True
				
				elif(gesture == Gesture.submit): 
					print("Sent order")
					wx.CallAfter(Publisher.sendMessage,"send order","")
					wx.MilliSleep(self.latency)
					time.sleep(3)
					commandExecuted = True	
				
				elif(gr.handState == HandState.movingFast):
					if(gr.handMovementDirection == 'right'):
						print("PREVIOUS PIC!")
						wx.CallAfter(Publisher.sendMessage,"previous picture","")
						wx.MilliSleep(self.latency)
					else:
						print("NEXT PIC!")
						wx.CallAfter(Publisher.sendMessage,"next picture","")
						wx.MilliSleep(self.latency)
		 					# command = Command.RIGHT if gr.handMovementDirection == 'right' else Command.LEFT
		 			commandExecuted = True
	 		else:
	 			counter += 1
	 			if(counter > 20):
	 				counter = 0
	 				commandExecuted = False
	 				print("counter reset")
示例#9
0
    def test_ZoomMove(self):
        mpp = 0.0001
        self.view.mpp.value = mpp
        self.assertEqual(mpp, self.view.mpp.value)

        # add images
        im1 = model.DataArray(numpy.zeros((11, 11, 3), dtype="uint8"))
        px1_cent = (5, 5)
        # Red pixel at center, (5,5)
        im1[px1_cent] = [255, 0, 0]
        im1.metadata[model.MD_PIXEL_SIZE] = (mpp * 10, mpp * 10)
        im1.metadata[model.MD_POS] = (0, 0)
        stream1 = RGBStream("s1", im1)

        self.view.addStream(stream1)
        # view might set its mpp to the mpp of first image => reset it
        self.view.mpp.value = mpp

        shift = (10, 10)
        self.canvas.shift_view(shift)

        test.gui_loop()
        wx.MilliSleep(500)
        test.gui_loop()
        resultIm = GetImageFromBuffer(self.canvas)

        px1 = GetRGB(resultIm, self.canvas._bmp_buffer_size[0] / 2 + 10,
                     self.canvas._bmp_buffer_size[1] / 2 + 10)
        self.assertEqual(px1, (255, 0, 0))

        # zoom in
        self.canvas.Zoom(2)
        self.assertEqual(mpp / (2**2), self.view.mpp.value)
        test.gui_loop()
        wx.MilliSleep(500)
        test.gui_loop()
        resultIm = GetImageFromBuffer(self.canvas)

        px1 = GetRGB(resultIm, self.canvas._bmp_buffer_size[0] / 2 + 40,
                     self.canvas._bmp_buffer_size[1] / 2 + 40)
        self.assertEqual(px1, (255, 0, 0))

        # fit to content without recentering should always zoom less or as much
        # as with recentering
        self.canvas.fit_view_to_content(recenter=False)
        mpp_no_recenter = self.view.mpp.value
        self.canvas.fit_view_to_content(recenter=True)
        mpp_recenter = self.view.mpp.value
        self.assertGreaterEqual(mpp_no_recenter, mpp_recenter)
示例#10
0
    def test_scrollbar_on_resize(self):
        """ Test the scroll bar """
        wx.MilliSleep(test.SLEEP_TIME)

        # Put back into more or less original state
        self.app.test_frame.panel_1.Expand()
        self.app.test_frame.panel_2.Collapse()
        self.app.test_frame.panel_3.Expand()

        # The first and third panel should be expanded, the second one collapsed
        self.assertEqual(self.app.test_frame.panel_1.IsExpanded(), True)
        self.assertEqual(self.app.test_frame.panel_2.IsExpanded(), False)
        self.assertEqual(self.app.test_frame.panel_3.IsExpanded(), True)

        fpb = self.app.test_frame.fpb
        false_pos_warn = ("This might be a false positive. "
                          "Run test module stand-alone to verify")

        self.assertEqual(fpb.has_vert_scrollbar(), False, false_pos_warn)
        self.assertEqual(fpb.has_horz_scrollbar(), False, false_pos_warn)

        # Squeeze the window horizontally
        self.app.test_frame.SetSize((100, 400))
        test.gui_loop()
        test.gui_loop()

        wx.MilliSleep(test.SLEEP_TIME)

        # No scroll bars should appear
        self.assertEqual(fpb.has_vert_scrollbar(), False, false_pos_warn)
        self.assertEqual(fpb.has_horz_scrollbar(), False, false_pos_warn)

        # Squeeze the window vertically
        self.app.test_frame.SetSize((400, 100))
        #self.app.test_frame.Refresh()
        test.gui_loop()
        test.gui_loop()

        # A vertical scroll bars should appear
        self.assertEqual(fpb.has_vert_scrollbar(), True, false_pos_warn)
        self.assertEqual(fpb.has_horz_scrollbar(), False, false_pos_warn)

        wx.MilliSleep(test.SLEEP_TIME)

        # Reset Size
        self.app.test_frame.SetSize((400, 400))
        self.app.test_frame.Layout()
        test.gui_loop()
        test.gui_loop()
示例#11
0
def key_click_text_entry(
        control,
        interaction,
        delay,
        get_selection=lambda control: control.GetSelection(),
):
    """Performs simulated typing of a key on the given wxObject
    after a delay.

    Parameters
    ----------
    control : wxTextEntry
        The wx Object to be acted on.
    interaction : instance of command.KeyClick
        The interaction object holding the key input
        to be simulated being typed
    delay : int
        Time delay (in ms) in which the key click will be performed.
    get_selection: callable(wx.TextEntry) -> tuple(int, int)
        Callable that takes an instance of wx.TextEntry and return the
        current selection span. Default is to call `GetSelection` method.
        Useful for when the TextEntry.GetSelection is overridden by a subclass
        that does not conform to the common API.
    """
    if not (control.IsEnabled() and control.IsEditable()):
        raise Disabled("{!r} is disabled.".format(control))
    if not control.HasFocus():
        control.SetFocus()
        control.SetInsertionPointEnd()
    if interaction.key == "Enter":
        wx.MilliSleep(delay)
        event = wx.CommandEvent(wx.EVT_TEXT_ENTER.typeId, control.GetId())
        control.ProcessEvent(event)
    elif interaction.key == "End":
        wx.MilliSleep(delay)
        control.SetInsertionPointEnd()
    elif interaction.key == "Backspace":
        wx.MilliSleep(delay)
        start, end = get_selection(control)
        if end > start:
            control.Remove(start, end)
        else:
            pos = control.GetInsertionPoint()
            control.Remove(max(0, pos - 1), pos)
    else:
        check_key_compat(interaction.key)
        wx.MilliSleep(delay)
        control.WriteText(interaction.key)
示例#12
0
    def OnButton(self, evt):
        max = 100
        dlg = wx.ProgressDialog(
            "Macro: %s" % __name__,
            "%s" % __desc__,
            maximum=max,
            parent=self,
            style=wx.PD_CAN_ABORT
            | wx.PD_APP_MODAL
            #| wx.PD_CAN_SKIP
            #| wx.PD_ELAPSED_TIME
            #| wx.PD_SMOOTH
            #| wx.PD_ESTIMATED_TIME
            #| wx.PD_REMAINING_TIME
        )

        keepGoing = True
        skip = False
        count = 0

        while keepGoing and not skip:
            wx.MilliSleep(50)
            (keepGoing, skip) = dlg.Pulse("Half-update!")

        dlg.Destroy()
示例#13
0
    def FetchData(self):
        self.checkList.Clear()
        self.checkListItems = []

        unselectedQualities = [
            self.listBoxItems[i] for i in range(len(self.listBoxItems))
            if i not in self.listBox.GetSelections()
        ]

        startWorker(self.OnDataFetched,
                    self.FetchDataWorker,
                    wargs=(self.listUrlTextInput.GetLineText(0),
                           unselectedQualities,
                           int(self.comboBox.GetSelection()) + 1,
                           self.userConfig["aliases"]))

        # Progress Dialog
        self.progress = 0
        self.keepGoing = True
        progressDialog = wx.ProgressDialog("Fetching data",
                                           "This may take a while...",
                                           parent=self,
                                           style=wx.PD_APP_MODAL
                                           | wx.PD_CAN_ABORT | wx.PD_AUTO_HIDE)

        while self.keepGoing and self.progress < 100:
            wx.MilliSleep(250)
            wx.Yield()
            (self.keepGoing, skip) = progressDialog.Update(self.progress)
        progressDialog.Destroy()
示例#14
0
    def Notify(self):
        """ It's time to hide a ToasterBox! """

        if len(winlist) == 0:
            return

        # clean the window list
        self.CleanList()

        # figure out how many blanks we have
        try:
            node = winlist[0]
        except:
            return

        if not node:
            return

        # move windows to fill in blank space
        for i in xrange(node.GetPosition()[1], self._popupposition[1], 4):
            if i > self._popupposition[1]:
                i = self._popupposition[1]

            # loop through all the windows
            for j in xrange(0, len(winlist)):
                ourNewHeight = i - (j * self._popupsize[1] - 8)
                tmpTb = winlist[j]
                # reset where the object THINKS its supposed to be
                tmpTb.SetPopupPosition((self._popupposition[0], ourNewHeight))
                # actually move it
                tmpTb.SetDimensions(self._popupposition[0], ourNewHeight,
                                    tmpTb.GetSize().GetWidth(),
                                    tmpTb.GetSize().GetHeight())

            wx.MilliSleep(self._sleeptime)
示例#15
0
def key_sequence_text_ctrl(control, interaction, delay):
    """ Performs simulated typing of a sequence of keys on the given wxObject
    after a delay.

    Parameters
    ----------
    control : wxTextCtrl
        The wx Object to be acted on.
    interaction : instance of command.KeySequence
        The interaction object holding the sequence of key inputs
        to be simulated being typed
    delay : int
        Time delay (in ms) in which each key click in the sequence will be
        performed.

    Raises
    ------
    Disabled
        If the control is either not enabled or not editable.
    """
    # fail early
    for char in interaction.sequence:
        check_key_compat(char)

    if not (control.IsEnabled() and control.IsEditable()):
        raise Disabled("{!r} is disabled.".format(control))
    if not control.HasFocus():
        control.SetFocus()
        control.SetInsertionPointEnd()
    for char in interaction.sequence:
        wx.MilliSleep(delay)
        control.WriteText(char)
        wx.SafeYield()
示例#16
0
def mouse_click_notebook_tab_index(control, index, delay):
    """ Performs a mouseclick on a Noteboook List Editor on the tab specified
    by index.

    Parameters
    ----------
    control : wx.Window
        The control of the DockWindow
    index : int
        The index of the child object in the Panel to be clicked
    delay : int
        Time delay (in ms) in which click will be performed.
    """
    controls_list = control.GetSizer().GetContents().get_controls()
    wx.MilliSleep(delay)

    # find the boundaries of the tab to be clicked
    bx, by, bdx, bdy = controls_list[index].drag_bounds
    # find the center
    tab_center = wx.Point(bx + bdx//2, by + bdy//2)

    click_down_event = wx.MouseEvent(
        wx.wxEVT_LEFT_DOWN
    )
    click_down_event.SetPosition(tab_center)
    click_up_event = wx.MouseEvent(
        wx.wxEVT_LEFT_UP
    )
    click_up_event.SetPosition(tab_center)
    control.ProcessEvent(click_down_event)
    control.ProcessEvent(click_up_event)
示例#17
0
def mouse_click_ImageButton(wrapper, interaction):
    """ Performs a mouce click on an pyface.ui.wx.ImageButton object.

    Parameters
    ----------
    wrapper : UIWrapper
        The wrapper object wrapping the Custom Button Editor which utilizes
        an ImageButton.
    interaction : instance of traitsui.testing.tester.command.MouseClick
        interaction is unused here, but it is included so that the function
        matches the expected format for a handler.  Note this handler is
        intended to be used with an interaction_class of a MouseClick.
    """

    control = wrapper.target.control
    if not control.IsEnabled():
        return
    wx.MilliSleep(wrapper.delay)

    left_down_event = wx.MouseEvent(
        wx.wxEVT_LEFT_DOWN
    )
    left_up_event = wx.MouseEvent(
        wx.wxEVT_LEFT_UP
    )
    control.ProcessEvent(left_down_event)
    control.ProcessEvent(left_up_event)
示例#18
0
 def DownloadFileContent(self,download_file_path,req,download_progress_dlg):
     is_cancel = False
     f = open(download_file_path, "wb")
     try:
         for chunk in req.iter_content(chunk_size=512):
             if chunk:
                 if not download_progress_dlg.keep_going:
                     is_cancel = True
                     break
                 f.write(chunk)
                 download_progress_dlg._progress += len(chunk)
                 if sysutils.isWindows():
                     Publisher.sendMessage(NOVAL_MSG_UI_DOWNLOAD_PROGRESS,temp = download_progress_dlg._progress,msg="")
                 else:
                     wx.MilliSleep(50)
                     wx.SafeYield(download_progress_dlg,True)
                     wx.CallAfter(Publisher.sendMessage,NOVAL_MSG_UI_DOWNLOAD_PROGRESS,temp=download_progress_dlg._progress,msg="")
     except Exception as e:
         wx.MessageBox(_("Download fail:%s") % e,style=wx.OK|wx.ICON_ERROR)
         time.sleep(1)
         download_progress_dlg.Destroy()
         return
     f.close()
     time.sleep(1)
     download_progress_dlg.keep_going = False
     download_progress_dlg.Destroy()
     if self._call_back is not None and not is_cancel:
         wx.CallAfter(self._call_back,download_file_path)
示例#19
0
    def gaugeTest(self):
        max = 80

        dlg = wx.ProgressDialog("Load Test Temperature...",
                                "Load test!",
                                maximum=max,
                                parent=self,
                                style=wx.PD_CAN_ABORT
                                | wx.PD_APP_MODAL
                                | wx.PD_ELAPSED_TIME
                                | wx.PD_REMAINING_TIME
                                | wx.PD_AUTO_HIDE)

        keepGoing = True
        count = 0

        while keepGoing and count < max:
            count += 1
            wx.MilliSleep(700)  # 1 minute

            if count >= max / 2:
                (keepGoing, skip) = dlg.Update(count, "Half-time!")
            else:
                (keepGoing, skip) = dlg.Update(count)

        dlg.Destroy()
示例#20
0
 def waitit(self):
     #self.timer = wx.Timer(self)
     #self.timer.Start(5000)
     #self.timer.Stop()
     wx.Yield()
     for indx in xrange(5):
         wx.MilliSleep(1000)
示例#21
0
    def OnButton(self, evt):
        max = 80

        dlg = wx.ProgressDialog(
            "Progress dialog example",
            "An informative message",
            maximum=max,
            parent=self,
            style=0
            | wx.PD_APP_MODAL
            | wx.PD_CAN_ABORT
            #| wx.PD_CAN_SKIP
            #| wx.PD_ELAPSED_TIME
            | wx.PD_ESTIMATED_TIME
            | wx.PD_REMAINING_TIME
            #| wx.PD_AUTO_HIDE
        )

        keepGoing = True
        count = 0

        while keepGoing and count < max:
            count += 1
            wx.MilliSleep(250)
            wx.Yield()

            if count >= max / 2:
                (keepGoing, skip) = dlg.Update(count, "Half-time!")
            else:
                (keepGoing, skip) = dlg.Update(count)

        dlg.Destroy()
示例#22
0
    def SmartAnalyse(self, interpreter):
        if interpreter.IsBuiltIn:
            return
        try:
            interpreter.GetDocPath()
            interpreter.GetSysPathList()
            interpreter.GetBuiltins()
            self.package_panel.LoadPackages(interpreter, True)
        except Exception as e:
            wx.MessageBox(str(e), style=wx.OK | wx.ICON_ERROR)
            return
        self.path_panel.AppendSysPath(interpreter)
        self.builtin_panel.SetBuiltiins(interpreter)
        self.smart_analyse_btn.Enable(False)

        dlg = AnalyseProgressDialog(self)
        try:
            intellisence.IntellisenceManager().generate_intellisence_data(
                interpreter, dlg)
        except:
            return
        while True:
            if not dlg.KeepGoing:
                break
            wx.MilliSleep(250)
            wx.Yield()
            dlg.Pulse()

        dlg.Destroy()
        self.smart_analyse_btn.Enable(True)
示例#23
0
 def showDir(self, folder):
     # self.parentClass.Freeze()
     self._updating = True
     self.ShowDir(folder, extensions = wildcard_on_thumb)
     wx.MilliSleep(2000)
     self._updating = False
     self.SetFocus()
示例#24
0
    def OpenPort(self, port, speed):

        if self.ser.is_open:
            # terminate thread first
            if self.thread.IsRunning():
                self.thread.Stop()
            # join the thread
            while self.thread.IsRunning():
                wx.MilliSleep(100)
            # then close the port
            self.ser.close()

        # set port number and speed
        self.ser.port = port
        self.ser.baudrate = int(speed)
        # setting read timeout is crucial for the safe termination of thread
        self.ser.timeout = 1

        # open the serial port
        try:
            self.ser.open()
        except:
            return False
        else:
            pass

        if self.ser.is_open:
            # start thread
            self.thread.Start()
            return True
        else:
            return False
示例#25
0
    def StopRec(self):
        """停止录制"""

        self.timer.Stop()  # 停止定时器
        self.recording = False
        self.OnHide(None)

        # 启动生成GIF线程
        t = Thread(target=self.CreateGif)
        t.setDaemon(True)
        t.start()

        # 弹出模态的等待对话窗
        count, count_max = 0, 100
        style = wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME | wx.PD_ESTIMATED_TIME | wx.PD_REMAINING_TIME | wx.PD_AUTO_HIDE
        dlg = wx.ProgressDialog("生成GIF",
                                "共计%d帧,正在渲染,请稍候..." % len(self.imgs),
                                parent=self,
                                style=style)

        while self.saveing and count < count_max:
            dlg.Pulse()
            wx.MilliSleep(100)

        dlg.Destroy()  # 关闭等待生成GIF结束的对话窗
        self.OnOpenFolder(None)  # 打开动画文件保存路径
示例#26
0
 def applicationThreads(self, event):
     fflowThread = myThread(1, "FeatureFlow", self.inputFile,
                            self.outputPath, self.interpNum)
     dlg = None
     counter = 0
     if self.inputFile == '' and self.outputPath == '':
         self.missingFileDialog()
     else:
         fflowThread.start()
         dlg = wx.ProgressDialog('Interpolating Frames',
                                 'Please wait..',
                                 style=wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME
                                 | wx.PD_CAN_ABORT | wx.STAY_ON_TOP)
         # while fflowThread.isAlive():
         while fflowThread.is_alive():
             wx.MilliSleep(300)
             """ dlg.Pulse("Interpolation In Progress {} out of {}".format(
                 indexObj.getInterpolationIndex(), rangeObj.getInterpolationRange())) """
             dlg.Pulse("Interp in progress")
             wx.GetApp().Yield()
             counter += 1
         del dlg
     fflowThread.kill()
     fflowThread.join()
     self.completeDialog()
示例#27
0
    def RequestUserAttention(self, dc, window, text, rect, pane):
        """
        Requests the user attention by intermittently highlighting the pane caption.

        :param `dc`: a `wx.DC` device context;
        :param `window`: an instance of `wx.Window`;
        :param `text`: the text to be displayed;
        :param `rect`: the pane caption rectangle;
        :param `pane`: the pane for which the text is drawn.
        """

        state = pane.state
        pane.state &= ~optionActive

        for indx in xrange(6):
            active = (indx % 2 == 0 and [True] or [False])[0]
            if active:
                pane.state |= optionActive
            else:
                pane.state &= ~optionActive

            self.DrawCaptionBackground(dc, rect, pane)
            self.DrawCaption(dc, window, text, rect, pane)
            wx.SafeYield()
            wx.MilliSleep(350)

        pane.state = state
    def stopRecord(self):
        self.update()
        test_item = self.testing_model.testingItems[self.current_testing_item]
        test_item.resultAudioFilePath = test_item.initialAudioFilePath
        wav_file_with_speech = stop_recording(test_item.resultAudioFilePath, self.recording_data,
                                              self.recognition_service_settings)
        self.playRecLabel.SetLabel("Распознавание")
        print("Stop Recording")

        if self.recognition_service_settings.is_svc_available:
            text = recognize_wav_file(wav_file_with_speech,
                                      self.recognition_service_settings.recognize_service_url)
            print("Result : {}".format(text))

            self.textRes.Clear()
            if text is None:
                self.textRes.write("< Произошла ошибка, подробности в консоли >")
                return

            self.textRes.write(text)
            test_item.resultTest = text.lower()
            test_item.isCorrect = test_item.initialText == test_item.resultTest
        else:
            self.textRes.write("< Сервис распознавания речи недоступен >")
            test_item.resultTest = "автоматически не распознано"
            test_item.isCorrect = test_item.initialText == test_item.resultTest
        wx.Yield()
        wx.MilliSleep(1000)
示例#29
0
    def run(self):
        if self._type == MESSAGE_LOADING:
            message = self._message + ('\n\n' + self._message_secondary
                if self._message_secondary else '')
            self._dialog = wx.ProgressDialog(
                parent=None,
                title=self._title,
                message=message,
                style=wx.PD_CAN_ABORT)
            self._dialog.Pulse(message)

            while not self._interrupt:
                cont, skip = self._dialog.UpdatePulse()
                if not cont:
                    return False
                wx.MilliSleep(50)
                wx.Yield()

        else:
            self._dialog = wx.MessageDialog(
                parent=None,
                message=self._message + ('\n\n' + self._message_secondary
                    if self._message_secondary else ''),
                caption=self._title,
                style=_mappings[self._buttons] | _mappings[self._type])

            response = self._dialog.ShowModal()
            if response == wx.ID_OK:
                return True
            elif response == wx.ID_CANCEL:
                return False
示例#30
0
    def wrapper(*args):

        title = arg
        new_path = args[-1]
        if isinstance(new_path, str) and os.path.isfile(new_path):
            message = _("Loading %s ...") % os.path.basename(new_path)
        else:
            message = _('Please wait..')

        progress_dlg = wx.ProgressDialog(title,
                                         message,
                                         style=wx.PD_APP_MODAL
                                         | wx.PD_CAN_ABORT)

        thread = ThreadWithReturnValue(target=f, args=args)
        thread.start()

        while thread.isAlive():

            if progress_dlg.WasCancelled() or progress_dlg.WasSkipped():
                thread.kill()
            else:
                wx.MilliSleep(300)
                progress_dlg.Pulse(thread.getLog())
                wx.SafeYield()

        progress_dlg.Destroy()

        return thread.join()