Ejemplo n.º 1
0
 def registerPublisher(self):
     Publisher().subscribe(self.rewriteShowTextCtrl,
                           CommonData.ViewPublisherc.MAINFRAME_REWRITETEXT)
     Publisher().subscribe(self.appendShowTextCtrl,
                           CommonData.ViewPublisherc.MAINFRAME_APPENDTEXT)
     Publisher().subscribe(
         self.refreshStaticText,
         CommonData.ViewPublisherc.MAINFRAME_REFRESHSTATIC)
     Publisher().subscribe(
         self.refreshFileList,
         CommonData.ViewPublisherc.MAINFRAME_REFRESHFILETABLE)
Ejemplo n.º 2
0
    def __init__(self, args, parent = None, id = -1, title = "Tap", size = (WIDTH, HEIGHT)):
        state = St(args)
        wx.Frame.__init__(self, parent, id, title, size)
        setup(self, state)
        self.state = state
        self.Centre()
        self.Show(True)

        Publisher().subscribe(self.on_load, "tap_load")
        Publisher().subscribe(self.on_stop, "tap_stop")
        Publisher().subscribe(self.on_volume, "tap_volume")
Ejemplo n.º 3
0
 def run(self):
     try:
         self.message = " " + self.username + " : " + self.message + '\n'
         self.connection.send(self.message)
         wx.MutexGuiEnter()
         Publisher().sendMessage("PrintMsg", self.message)
         wx.MutexGuiLeave()
         
     except Exception, e:
         wx.MutexGuiEnter()
         Publisher().sendMessage("PrintMsg", str(e))
         wx.MutexGuiLeave()
Ejemplo n.º 4
0
 def import_db(self):
     
     # No abort signal is listened to here
     try:
         wx.CallAfter(Publisher().sendMessage, "update","Updating with backed-up data.....")
         self.SU.import_db(self.DB)
         wx.CallAfter(Publisher().sendMessage, "update","Backup updation completed")
     except:
         
         wx.CallAfter(Publisher().sendMessage, "error_report","Could not restore backed-up data.You may manually import the database")
         return 0
     return True
Ejemplo n.º 5
0
    def __init__(self,
                 playerLock,
                 video_parent_panel=None,
                 videoPanelClickCallback=None):
        self.Instance = None
        self.player = None
        self.event_manager = None
        self.discovery_start_time = 0
        self.ready_to_play = False
        self.asked_to_start = False
        self.current_media_str = None
        self.current_media_options = None
        self._volume = 10
        self._mute = False
        self._brightness = 1.0
        self._contrast = 1.0
        self._gamma = 1.0
        self._hue = 0
        self._saturation = 1.0

        if (video_parent_panel):
            self.video_panel = wx.Panel(video_parent_panel)
            video_parent_panel.GetSizer().Add(self.video_panel)
            self.video_panel.SetBackgroundColour(wx.BLACK)
            #self.video_panel.SetBackgroundColour( 'blue' )

            self.videoPanelClickCallback = videoPanelClickCallback
            if (self.videoPanelClickCallback is not None):
                print('binding videopanel with {}'.format(
                    self.videoPanelClickCallback))
                #self.video_panel.Bind( wx.EVT_LEFT_UP, self.videoPanelClickCallback )
                self.video_panel.Bind(wx.EVT_LEFT_DCLICK,
                                      self.videoPanelClickCallback)
                #self.video_panel.Bind( wx.EVT_LEFT_DCLICK, self.VideopanelClicked )

        self.playerLock = playerLock

        self._uuid = uuid.uuid4()
        self._error_observers = []
        self._stereo_mono_observers = []
        self._EndOfTrack_observers = []
        self._PosChangeObservers = []
        self._playing_observers = []
        self._paused_observers = []
        self._END_OF_TRACK_MESSAGE_NAME = 'end_of_track_{}'.format(
            self._uuid)  #unique per media_player
        #print( '_END_OF_TRACK_MESSAGE_NAME: {}'.format( self._END_OF_TRACK_MESSAGE_NAME ) )
        self._POS_CHANGE_MESSAGE_NAME = 'pos_change_{}'.format(
            self._uuid)  #unique per media_player
        Publisher().subscribe(self._UpdateEndOfTrackObservers,
                              self._END_OF_TRACK_MESSAGE_NAME)
        Publisher().subscribe(self._UpdatePosChangeObservers,
                              self._POS_CHANGE_MESSAGE_NAME)
    def run(self):
        for i in range(self.num_tasks):
            # Do 'work', sending a tick message after every step
            #time.sleep(1.0)
            sum(range(5000000))
            print 'a'
            #Publisher().sendMessage("signals.ProgressGauge.tick")
            wx.CallAfter(Publisher().sendMessage, "signals.ProgressGauge.tick")

        # Notify ProgressGauge that the work is done
        #Publisher().sendMessage("signals.ProgressGauge.done")
        wx.CallAfter(Publisher().sendMessage, "signals.ProgressGauge.done")
Ejemplo n.º 7
0
 def run(self):
     while True:
         if self.stop_flag != 1:
             # get memory info and return to window
             server_memory = self.server.get_memory_used()
             wx.CallAfter(Publisher().sendMessage, "update_memory",
                          server_memory)
             # get CPU info and return to window,
             # it will keep 1s sleep at remote server
             server_cpu = self.server.get_cup_used()
             wx.CallAfter(Publisher().sendMessage, "update_cpu", server_cpu)
         else:
             return 1
Ejemplo n.º 8
0
 def extract(self):
     if self.stopped:
         wx.CallAfter(Publisher().sendMessage, "update","Aborted")
         return 0
     try:
         wx.CallAfter(Publisher().sendMessage, "update","Extracting downloaded archives")
         self.SU.extract()
         wx.CallAfter(Publisher().sendMessage, "update","Extraction completed")
     except:
         
         wx.CallAfter(Publisher().sendMessage, "error_report","Extraction failed")
         return 0
     return True
Ejemplo n.º 9
0
 def backup(self):
     if self.stopped:
         wx.CallAfter(Publisher().sendMessage, "update","Aborted")
         return 0
     try:
         wx.CallAfter(Publisher().sendMessage, "update","Backing up database automatically")
         self.SU.backup_db(self.DB)
         wx.CallAfter(Publisher().sendMessage, "update","Backing up success")
     except:
         
         wx.CallAfter(Publisher().sendMessage, "error_report","Backup failed")
         return 0
     return True
Ejemplo n.º 10
0
 def __init__(self,user,passw):
     """This function sets the dimensions of the frame and
     the layout of the buttons"""
     self.user = user
     self.passw=passw
     wx.Frame.__init__(self, None, -1, 'Friends', 
             size=(500, 350))
     self.panel = ScrolledPanel(self, size = wx.Size( 500, 350 ))
     self.panel.SetupScrolling()
     self.Bind(wx.EVT_CLOSE, self.OnCloseMe)
     self.sizer = wx.FlexGridSizer(5,2,5,5)
     self.buttons=[]
     Publisher().subscribe(self.createButton, "update")
     Publisher().subscribe(self.updateButton, "updatebuttons")
Ejemplo n.º 11
0
 def run(self):
     try:
         self.createGraph()
         self.computeCC()
         self.createShp()
         self.consolePrintCreatedFiles()
         wx.CallAfter(Publisher().sendMessage, self.callback,
                      self.path_2_log)
     except:
         print traceback.print_exc()
         wx.CallAfter(
             Publisher().sendMessage, "catchError",
             "An error occured during the computation of edge closeness.")
         self.stop()
Ejemplo n.º 12
0
    def action(self, event):
        wantLocal = self.sizerHRadius.isChecked()
        fnBase = getFileNameBase(get_param_selectedProjectName(),
                                 self.sizerHNetNod.isNetwork(),
                                 fn_closeness,
                                 local=wantLocal)
        fileNames = getGeneratedFiles(fnBase)

        errorMsg = ''  # reset error messages
        errorMsg += self.sizerHSave.check(fileNames)
        if wantLocal: errorMsg += self.sizerHRadius.check()
        if errorMsg == '':
            if self.sizerHSave.isOverwritten():
                path = self.sizerHSave.getValue()
                if self.sizerHRadius.isChecked():
                    radius = self.sizerHRadius.getValue()
                Publisher().subscribe(self.catchError, 'catchError')
                normalized = self.sizerHNorm.isNormalized()
                if self.isNetworkProject:
                    weighted = self.sizerHWeighted.isWeighted()
                else:
                    weighted = True if wantLocal else False
                self.Hide()
                self.load = Loading(self, "Computation")

                self.start = time.time()
                callback = "actionEnd"
                Publisher().subscribe(self.actionEnd,
                                      callback)  # create a pubsub receiver
                #launch computation
                if self.sizerHNetNod.isNetwork():
                    if wantLocal:
                        EdgeLocalCloseness(path, radius, fnBase, callback,
                                           weighted, normalized)
                    else:
                        EdgeCloseness(path, fnBase, callback, weighted,
                                      normalized)
                else:
                    if wantLocal:
                        NodeLocalCloseness(path, radius, fnBase, callback,
                                           weighted, normalized)
                    else:
                        NodeCloseness(path, fnBase, callback, weighted,
                                      normalized)

        else:
            dlg = wx.MessageDialog(self, errorMsg, 'Errors',
                                   wx.CANCEL | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
Ejemplo n.º 13
0
    def populateObstaclesEnd(self, msg):
        if self.wantObstacles:
            consoleAppend(' > Populate obstacles in %s' %
                          GetTextTime(time.time() - self.ts))
            self.tmpO = msg.data

        self.ts = time.time()
        callback = "gridNetworkEnd"
        Publisher().subscribe(self.gridNetworkEnd, callback)
        pubDial = "publishDialog"
        Publisher().subscribe(self.publishDialog, pubDial)
        # the srs of the grid network is always the srs out of the polygon
        GridNetwork(callback, pubDial, self.res, self.srsProject,
                    self.projectName, self.wantObstacles)
Ejemplo n.º 14
0
    def __init__(self, *args, **kwds):
        # begin wxGlade: update_win.__init__
        kwds["style"] = wx.DEFAULT_DIALOG_STYLE
        wx.Dialog.__init__(self, *args, **kwds)
        self.label_installed_version = wx.StaticText(self, wx.ID_ANY, ("Installed Version:"))
        self.label_latest_version = wx.StaticText(self, wx.ID_ANY, ("Latest Version"))
        self.label_is_update = wx.StaticText(self, wx.ID_ANY, ("If Update available"))
        self.progress_bar = wx.Gauge(self, wx.ID_ANY, range=100)
        self.animation_panel = wx.Panel(self, wx.ID_ANY)
        self.label_status = wx.StaticText(self, wx.ID_ANY, (""))
        self.button_close = wx.Button(self, wx.ID_ANY, ("Cancel"))
        self.button_install = wx.Button(self, wx.ID_ANY, ("Check for Update"))

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.on_cancel, self.button_close)
        self.Bind(wx.EVT_BUTTON, self.on_install, self.button_install)
        self.Bind(wx.EVT_CLOSE, self.on_close)

        
        self.animation_panel.gif = None
        
        
        # create a pubsub receiver
        Publisher().subscribe(self.update, "update")
        Publisher().subscribe(self.error_report, "error_report")
        Publisher().subscribe(self.update_progress_bar, "progress_bar")
        Publisher().subscribe(self.get_versions, "update_versions")
        Publisher().subscribe(self.is_update, "is_update")
        Publisher().subscribe(self.play_animation, "play_animation")
        Publisher().subscribe(self.stop_animation, "stop_animation")
        Publisher().subscribe(self.updation_successful, "updation_successful")
Ejemplo n.º 15
0
 def wait_stop(test_mode):
     if not self.frame.sett3.IsChecked(): self.model.stop_record()
     wx.CallAfter(Publisher().sendMessage, "update_status",
                  "Wait for updates ... ")
     while not self.model.get_process_status(
     ) or self.model.is_process_running():
         time.sleep(2)
     best = self.model.get_last_result()[0]
     wx.CallAfter(Publisher().sendMessage, "toogle_button",
                  "toogle_stop")
     self.total_computing_time = time.time() - self.total_computing_time
     wx.CallAfter(
         Publisher().sendMessage, "update_status",
         "Best speaker is " + best[0] + " found in " +
         str(int(self.total_computing_time)) + " seconds")
Ejemplo n.º 16
0
 def __init__(self, parent = None, id = wx.ID_ANY):
     wx.Frame.__init__(self, parent, id,
                       "Introduction to Databases Final Project",
                       size=(self.FRAME_WIDTH, self.FRAME_HEIGHT))
     self.selected  = 'None'
     self.pick      = 0
     self.logged_in = False
     self.Admin     = False
     self.panel     = wx.Panel(self)
     self.panel.SetBackgroundColour(BG_COLOUR)
     self.init_window_elements()
     self.SetPosition((200, 100))
     Publisher().subscribe(self.usrLogin, ("user"))
     Publisher().subscribe(self.adminLogin, ("admin"))
     self.override_pass()
Ejemplo n.º 17
0
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition,
                          wx.Size(1000, 1000))
        self.current_filename = ''
        self.data = {}

        self.lowerSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.mainSizer = wx.BoxSizer(wx.VERTICAL)

        self.tool_bar = self.CreateToolBar()  #ToolBar(self)
        #next_icon = './go-next-4.png'
        save_icon = './document-save-2.png'
        reset_icon = './edit-delete-6.png'
        undo_icon = './edit-undo-3.png'
        open_icon = './document-open-4.png'
        opentool = self.tool_bar.AddLabelTool(wx.ID_ANY, 'open an image',
                                              wx.Bitmap(open_icon))
        #nexttool = self.tool_bar.AddLabelTool(wx.ID_ANY, 'next image',
        #                                      wx.Bitmap(next_icon))
        resettool = self.tool_bar.AddLabelTool(wx.ID_ANY, 'clear marks',
                                               wx.Bitmap(reset_icon))
        undotool = self.tool_bar.AddLabelTool(wx.ID_ANY, 'undo mark',
                                              wx.Bitmap(undo_icon))
        savetool = self.tool_bar.AddLabelTool(wx.ID_ANY, 'Quit',
                                              wx.Bitmap(save_icon))
        self.tool_bar.Realize()

        self.Bind(wx.EVT_TOOL, self.OnReset, resettool)
        self.Bind(wx.EVT_TOOL, self.OnBrowse, opentool)
        #self.Bind(wx.EVT_TOOL, self.OnNext, nexttool)
        self.Bind(wx.EVT_TOOL, self.OnUndo, undotool)
        self.Bind(wx.EVT_TOOL, self.OnSaveRequest, savetool)

        self.img_panel = ImgPanel(self)
        self.ctrl_panel = CtrlPanel(self)

        #        self.mainSizer.Add(self.tool_bar, 0, wx.ALL, 5)
        self.lowerSizer.Add(self.img_panel, 0, wx.ALL, 5)
        self.lowerSizer.Add(self.ctrl_panel, 1, wx.EXPAND, 5)
        self.mainSizer.Add(self.lowerSizer, 0, wx.ALL, 5)
        self.SetSize((1000, 1000))
        self.SetSizer(self.mainSizer)
        self.mainSizer.Fit(self)

        Publisher().subscribe(self.OnImgLeft, ("img.leftclick"))
        Publisher().subscribe(self.OnImgRight, ("img.rightclick"))

        self.click_history = []
Ejemplo n.º 18
0
    def __init__(self,parent,title,path):
        wx.Dialog.__init__(self,parent,title = title,size=(600,400))
        self.path = path
        self.panel = wx.Panel(self)

        topBox = wx.BoxSizer(wx.HORIZONTAL)
        txtLbl = wx.StaticText(self.panel,-1,'白名单所在路径:')
        self.urlTxt = wx.TextCtrl(self.panel,-1,value=self.path)
        topBox.Add(txtLbl,proportion=0,flag=wx.LEFT,border=5)
        topBox.Add(self.urlTxt,proportion=1,flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=5)

        self.cont = wx.TextCtrl(self.panel,-1,style=wx.HSCROLL|wx.VSCROLL|wx.TE_MULTILINE|wx.TE_READONLY)

        midBox = wx.BoxSizer(wx.HORIZONTAL)
        midBox.Add(self.cont,proportion=1,flag=wx.EXPAND|wx.ALL,border=5)

        footBox = wx.BoxSizer(wx.HORIZONTAL)
        self.updateBtn = wx.Button(self.panel,-1,label='更新')
        self.Bind(wx.EVT_BUTTON,self.OnUpdate,self.updateBtn)
        self.endBtn = wx.Button(self.panel,-1,label='停止')
        self.Bind(wx.EVT_BUTTON,self.OnEnd,self.endBtn)
        self.info = wx.StaticText(self.panel,-1)

        footBox.Add(self.updateBtn,proportion=0,flag=wx.ALIGN_RIGHT,border=5)
        footBox.Add(self.endBtn,proportion=0,flag=wx.ALIGN_RIGHT,border=5)
        footBox.Add(self.info,proportion=0,flag=wx.EXPAND|wx.LEFT,border=5)

        bigBox = wx.BoxSizer(wx.VERTICAL)
        bigBox.Add(topBox,proportion=0,flag=wx.EXPAND|wx.LEFT|wx.RIGHT)
        bigBox.Add(midBox,proportion=1,flag=wx.EXPAND)
        bigBox.Add(footBox,proportion=0,flag=wx.EXPAND|wx.LEFT|wx.RIGHT)
        self.panel.SetSizer(bigBox)

        self.Show()
        Publisher().subscribe(self.UpdateDisplay,'UpdateWhiteTrainer')
Ejemplo n.º 19
0
def unsubscribe(listener, topics=None):
    """
    unsubscribe listener from topic and log event
    """
    pubsub_logger.debug("UNSUBSCRIBE : %s unsubsrcibes from topic(s) %s",
                        name(listener), topics)
    Publisher().unsubscribe(listener, topics)
Ejemplo n.º 20
0
def get_tempmatches_par(A,
                        imgpaths,
                        img2flip=None,
                        T=0.8,
                        bb=None,
                        do_smooth=0,
                        xwinA=13,
                        ywinA=13,
                        xwinI=13,
                        ywinI=13,
                        MAX_MATS=50,
                        prevmatches=None,
                        DELT=0.5,
                        atleastone=False,
                        NP=None,
                        jobid=None):
    """ For each img in IMGPATHS, template match for A, using NP processes.
    A multiprocessing wrapper for get_tempmatches (see doc for get_tempmatches
    for more details).
    Input:
        IplImage A:
        lst IMGPATHS:
        tuple BB: (x1,y1,x2,y2)
            Search on each img in IMGPATHS inside BB.
        int NP: Number of processes, or None for auto.
        
    Output:
        dict MATCHES, of the form {str imgpath: [(x1, y1, x2, y2 float resp), ...]}
    """
    A_str = A.tostring()
    w, h = cv.GetSize(A)

    if jobid != None:
        manager = multiprocessing.Manager()
        queue_mygauge = manager.Queue()
        tick_thread = ThreadTicker(queue_mygauge, jobid)
        tick_thread.start()
    else:
        manager, queue_mygauge, tick_thread = None, None, None

    try:
        result = partask.do_partask(_do_get_tempmatches,
                                    imgpaths,
                                    _args=(A_str, img2flip, bb, T, do_smooth,
                                           xwinA, ywinA, xwinI, ywinI, w, h,
                                           MAX_MATS, prevmatches, DELT,
                                           atleastone, jobid, queue_mygauge),
                                    manager=manager,
                                    combfn='dict',
                                    singleproc=False)
    except Exception as e:
        traceback.print_exc()
        result = {}
    if jobid and wx.App.IsMainLoopRunning():
        wx.CallAfter(Publisher().sendMessage, "signals.MyGauge.done",
                     (jobid, ))
    if tick_thread:
        tick_thread.turn_me_off()

    return result
Ejemplo n.º 21
0
    def __init__(self, parent, *args, **kwargs):
        # Need to remove foreign keyword arguments
        vertical = True
        if 'orientation' in kwargs:
            if kwargs['orientation'] == 'horizontal':
                vertical = False
            del kwargs['orientation']
        popup_direction = 'default'
        if 'popup_direction' in kwargs:
            popup_direction = kwargs['popup_direction']
            del kwargs['popup_direction']
        wx.Panel.__init__(self, parent, *args, **kwargs)

        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)

        self._tabs = []
        if vertical:
            self._tab_renderer = SpringTabItemVerticalRenderer(popup_direction)
        else:
            self._tab_renderer = SpringTabItemHorizontalRenderer(
                popup_direction)
        self._radio = None

        self._debug_paint = False

        # Using a real wx.PopupWindow seems prevent the focus from being set to
        # the window in the popup.
        self._popup_cls = FakePopupWindow

        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Bind(wx.EVT_SIZE, self.OnSize)
        Publisher().subscribe(self.clearRadio, 'springtabs.remove')
Ejemplo n.º 22
0
    def show(self, colormapper, progress=None):
        if not self.cube: return

        try:
            # remove old image for memory management purposes
            del self.image
            self.image = None
            
            refresh=False
            if self.indexes:
                if len(self.indexes)!=len(self.bands):
                    refresh=True
                else:
                    for i in range(len(self.indexes)):
                        if self.indexes[i]!=self.bands[i][0]:
                            refresh=True
                            break
            
            if refresh or not self.bands:
                self.loadBands()
            
            self.processFilters(progress)
            rgb = colormapper.getRGB(self.height, self.width, self.planes)
            
            # image uses the rgb data and doesn't create a new copy
            self.image = wx.ImageFromBuffer(self.width, self.height, rgb)
            # self.Refresh()
        except Exception, e:
            import traceback
            dprint(traceback.format_exc())
            Publisher().sendMessage('peppy.log.error', traceback.format_exc())
            
            # recreate empty image if necessary
            self.initBitmap()
Ejemplo n.º 23
0
 def status_display(self, message, level=0, field=0):
     if level == 1:
         wx.CallAfter(self.status_display, message)
     elif level == 2:
         wx.CallAfter(Publisher().sendMessage, "update", message)
     else:
         self.status_bar.SetStatusText(message, field)
Ejemplo n.º 24
0
def makeOneFile_(prefix, src, radix, dst):
    #pickle.dump((prefix, src, radix, dst), open("f", "w"))
    #exit(0)
    out = open(dst, "wb")
    tout = open(dst+".type", "wb")
    now = time.time()
    for i,(each,score) in enumerate(src):
        if i%1000 == 0:
            print 'loop', time.time()-now
            now = time.time()
            if wx.App.IsMainLoopRunning():
                wx.CallAfter(Publisher().sendMessage, "signals.MyGauge.tick")
        #tout.write("X")
        #out.write("a"*(100*50))
        #open(os.path.join(prefix, each)).read()
        #continue
        #if i%100 == 0:
        #    print i
        img = Image.open(os.path.join(prefix, each))
        dat = img.getdata()
        if type(dat[0]) != type(tuple()):
            s = "".join((chr(x) for x in dat))
            tout.write("A")
        else:
            s = "".join((chr(x[0])+chr(x[1])+chr(x[2]) for x in dat))
            tout.write("B")

        out.write(s)

    if src:
        open(dst+".size", "w").write(str(img.size))
                
    out.close()
    tout.close()
Ejemplo n.º 25
0
    def run(self):
        while True:
            if self.Ser.isOpen() and self.Ser.inWaiting():
                text = self.Ser.read(self.Ser.inWaiting())
                wx.CallAfter(Publisher().sendMessage('update', text))

            time.sleep(0.01)
Ejemplo n.º 26
0
 def install_updates(self):
     if self.stopped:
         wx.CallAfter(Publisher().sendMessage, "update","Aborted")
         return 0
     try:
         wx.CallAfter(Publisher().sendMessage, "update","Installing updates....")
         if self.SU.install(self.DB)==0: #successful if return value 0
             wx.CallAfter(Publisher().sendMessage, "update","Installation completed")
         else:
             wx.CallAfter(Publisher().sendMessage, "error_report","Error in installation process")
             return 0
     except:
         
         wx.CallAfter(Publisher().sendMessage, "error_report","Installation failed")
         return 0
     return True
Ejemplo n.º 27
0
 def _OnEndOfTrack(self, event):
     with self.playerLock:
         #We use wx.CallAfter because _OnEndOfTrack has been called from a forked thread and cannot update wx.Widgets
         #whcih is what is eventually done when calling _EndOfTrack_observers.OnEndOfTrack
         #print( 'Track ended. Will publish message {}'.format( self._END_OF_TRACK_MESSAGE_NAME ) )
         wx.CallAfter(Publisher().sendMessage,
                      self._END_OF_TRACK_MESSAGE_NAME)
    def getcaptcha(self, br):
        for i in BeautifulSoup(br.response().read()).findAll('img'):
            if i.get('src').startswith('/signup/captcha/'):
                captchaimage = i.get('src')
        image_response = br.open_novisit(captchaimage)
        image = image_response.read()
        writing = open('captcha.jpeg', 'wb')
        writing.write(image)
        writing.close()
        if not self.trader:
            Publisher().sendMessage("captcha", None)
            while not self.captcha:
                sleep(1)

        else:
            br3 = self.createbrowser()
            br3.open('http://www.captchatrader.com/documentation/manual_submit/file')
            br3.select_form(nr=1)
            br3.form['username'] = self.capuser
            br3.form['password'] = self.cappwd
            br3.form['api_key'] = self.capapi
            picturew = os.getcwd() + '/captcha.jpeg'
            br3.form.add_file(open(picturew), 'text/plain', picturew, name='value')
            br3.submit()
            captcha = findit(re.compile('"(.*)"'), br3.response().read())[0]
            print captcha
        return self.captcha
    def __init__(self, parent, title):
	
	self.mysize = wx.GetDisplaySize()
	wx.Frame.__init__(self, parent, wx.ID_ANY, title=title, pos=(0,40), size=(420,400))
	self.CreateStatusBar() # A Statusbar in the bottom of the window	
	self.searchButton = wx.Button(self, label="Search")
	self.Bind(wx.EVT_BUTTON, self.OnClick, self.searchButton)
	#self.searchButton.Enable(False)
	self.check = checkPanel(self)
	self.nb = wx.Notebook(self)
	self.corpus = recordSearchPanel(self.nb)
	self.wordnet = searchPanel(self.nb)
	self.staLine = wx.StaticLine(self, -1, size=(300,1))
	self.nb.AddPage(self.corpus, "Corpus query mode")
	self.nb.AddPage(self.wordnet, "WordNet associated")
	
	
        self.relativePos = (int(self.mysize[0]*0.3),40)
        
	self.topSizer = wx.BoxSizer(wx.VERTICAL) 
	self.topSizer.Add(self.check, 0, wx.EXPAND)
	self.topSizer.Add(self.staLine, 0, wx.EXPAND|wx.ALIGN_CENTER)
	self.topSizer.Add(self.nb, 1, wx.EXPAND)
	self.topSizer.Add(self.searchButton, 0, wx.EXPAND|wx.BOTTOM)
	
	self.SetSizer(self.topSizer)
	
        self.SetAutoLayout(1)
        #self.topSizer1.Fit(self)
        self.Show()
	Publisher().subscribe(self.updateDisplay, "update")
Ejemplo n.º 30
0
 def actionKeystroke(self, evt, multiplier=1):
     uchar = unichr(evt.GetKeyCode())
     for i in range(multiplier):
         if uchar in u'nN':
             self.minibuffer.win.OnFindN(
                 None, help=self.minibuffer.win.help_status)
         elif uchar in u'yY ':
             self.minibuffer.win.OnReplace(None)
         elif uchar in u'pP^':
             self.minibuffer.win.OnFindP(
                 None, help=self.minibuffer.win.help_status)
         elif uchar in u'qQ':
             self.minibuffer.win.OnExit()
         elif uchar in u'.':
             self.minibuffer.win.OnReplace(None, find_next=False)
             self.minibuffer.win.OnExit()
         elif uchar in u',':
             self.minibuffer.win.OnReplace(None, find_next=False)
         elif uchar in u'!':
             self.minibuffer.win.OnReplaceAll(None)
         elif uchar in u'fF':
             self.minibuffer.win.OnTabToFind(None)
         elif uchar in u'rR':
             self.minibuffer.win.OnTabToReplace(None)
         elif uchar in u'?':
             Publisher().sendMessage(
                 'peppy.log.info',
                 (self.minibuffer.mode.frame, self.minibuffer.win.__doc__))
             break