python类PostEvent()的实例源码

squaremap.py 文件源码 项目:BigBrotherBot-For-UrT43 作者: ptitbigorneau 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def OnKeyUp(self, event):
        event.Skip()
        if not self.selectedNode or not self.hot_map:
            return

        if event.KeyCode == wx.WXK_HOME:
            self.SetSelected(HotMapNavigator.firstNode(self.hot_map))
            return
        elif event.KeyCode == wx.WXK_END:
            self.SetSelected(HotMapNavigator.lastNode(self.hot_map))
            return

        parent, children, index = HotMapNavigator.findNode(self.hot_map, self.selectedNode)
        if event.KeyCode == wx.WXK_DOWN:
            self.SetSelected(HotMapNavigator.nextChild(children, index))
        elif event.KeyCode == wx.WXK_UP:
            self.SetSelected(HotMapNavigator.previousChild(children, index))
        elif event.KeyCode == wx.WXK_RIGHT:
            self.SetSelected(HotMapNavigator.firstChild(children, index))
        elif event.KeyCode == wx.WXK_LEFT and parent:
            self.SetSelected(parent)
        elif event.KeyCode == wx.WXK_RETURN:
            wx.PostEvent(self, SquareActivationEvent(node=self.selectedNode,
                                                     map=self))
padherder_proxy.py 文件源码 项目:padherder_proxy 作者: jgoldshlag 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def onDNSEvent(self, event):
        if self.proxy_master is not None:
            self.proxy_master.shutdown()

        if event.message.startswith('api-na'):
            region = 'NA'
        else:
            region = 'JP'

        config = wx.ConfigBase.Get()
        host = config.Read("host") or socket.gethostbyname(socket.gethostname())
        httpsport = config.Read("httpsport") or "443"

        try:
            proxy_config = proxy.ProxyConfig(port=int(httpsport), host=host, mode='reverse', upstream_server=cmdline.parse_server_spec('https://%s:443/' % event.message))
            proxy_server = ProxyServer(proxy_config)
        except Exception as e:
            evt = custom_events.wxStatusEvent(message='Error starting HTTPS proxy: %s' % e)
            wx.PostEvent(self.main_tab, evt)
            return

        self.proxy_master = PadMaster(proxy_server, self, region)
        thread.start_new_thread(self.proxy_master.run, ())
padherder_proxy.py 文件源码 项目:padherder_proxy 作者: jgoldshlag 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def is_out_of_date(main_tab):
    session = requests.Session()
    session.headers = { 'accept': 'application/vnd.github.v3+json',
                        'user-agent': 'jgoldshlag-padherder_sync_' + PH_PROXY_VERSION,
                      }

    session.mount('https://', requests.adapters.HTTPAdapter(pool_connections=1, pool_maxsize=1))
    try:
        r = session.get('https://api.github.com/repos/jgoldshlag/padherder_proxy/releases')
    except Exception as e:
        evt = custom_events.wxStatusEvent(message='Error checking for updates: %s' % e)
        wx.PostEvent(main_tab, evt)

    if r.status_code != requests.codes.ok:
        evt = custom_events.wxStatusEvent(message='Error checking for updates: %s %s' % (r.status_code, r.content))            
        wx.PostEvent(main_tab, evt)

    releases = json.loads(r.content)
    current_ver = LooseVersion(PH_PROXY_VERSION)
    for rel in releases:
        rel_version = LooseVersion(rel['tag_name'][1:])
        if rel_version > current_ver:
            return True

    return False
dnsproxy.py 文件源码 项目:padherder_proxy 作者: jgoldshlag 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def resolve(self,request,handler):
        reply = request.reply()
        qname = request.q.qname
        qtype = QTYPE[request.q.qtype]
        if qname.matchGlob("api-*padsv.gungho.jp."):
            config = wx.ConfigBase.Get()
            host = config.Read("host") or socket.gethostbyname(socket.gethostname())
            reply.add_answer(RR(qname,QTYPE.A,rdata=A(host)))
            evt = custom_events.wxStatusEvent(message="Got DNS Request")
            wx.PostEvent(self.status_ctrl,evt)
            evt = custom_events.wxDNSEvent(message=str(qname)[:-1])
            wx.PostEvent(self.main_frame,evt)
            time.sleep(0.5) # we need to sleep until the proxy is up, half a second should do it...
        # Otherwise proxy
        if not reply.rr:
            if handler.protocol == 'udp':
                proxy_r = request.send(self.address,self.port)
            else:
                proxy_r = request.send(self.address,self.port,tcp=True)
            reply = DNSRecord.parse(proxy_r)
        return reply
mobile_insight_gui.py 文件源码 项目:mobileinsight-core 作者: mobile-insight 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def OnReadComplete(self):
        evt = ResultEvent(self._log_analyzer.msg_logs)
        wx.PostEvent(wx.GetApp().frame, evt)
page.py 文件源码 项目:cebl 作者: idfah 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def onKeyUp(self, event):
        """Handle keypress events.
        """
        key = event.GetKeyCode()

        # check for F11 to start full screen mode
        if key == wx.WXK_F11:
            # post a an EVT_FULL_SCREEN event
            # the change should be handled by the parent
            wx.PostEvent(self, events.FullScreenEvent(id=wx.ID_ANY))
manager.py 文件源码 项目:cebl 作者: idfah 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def setSource(self, srcName):
        self.src.delBuffer() # buffer is only active for current source
        self.src = self.sources[srcName]
        self.src.initBuffer()

        self.updateSources()

        if self.statusPanel is not None:
            wx.PostEvent(self.statusPanel, events.UpdateStatusEvent(id=wx.ID_ANY))
manager.py 文件源码 项目:cebl 作者: idfah 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def addRunningPage(self, page):
        """Add a page and start current source if
        when number of running pages goes above zero.
        """
        if self.getNRunningPages() == 0:
            self.src.start()

        self.runningPages.append(page)

        if self.statusPanel is not None:
            wx.PostEvent(self.statusPanel, events.UpdateStatusEvent(id=wx.ID_ANY))
manager.py 文件源码 项目:cebl 作者: idfah 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def remRunningPage(self, page):
        """Remove a page and stop current source if
        number of running pages reaches zero.
        """
        self.runningPages.remove(page)

        if self.getNRunningPages() == 0:
            self.src.stop()

        if self.statusPanel is not None:
            wx.PostEvent(self.statusPanel, events.UpdateStatusEvent(id=wx.ID_ANY))
manager.py 文件源码 项目:cebl 作者: idfah 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def closeAllPages(self):
        # should probably be stopping sources instead of pages if this is only for cleanup?  This still hangs sometimes XXX - idfah
        if self.getNRunningPages() > 0:
            for pg in self.runningPages:
                pg.close()

            self.runningPages = []

            if self.statusPanel is not None:
                wx.PostEvent(self.statusPanel, events.UpdateStatusEvent(id=wx.ID_ANY))
notebook.py 文件源码 项目:cebl 作者: idfah 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, *args, **kwargs)
        #self.Bind(wx.EVT_KEY_UP, self.onKeyUp)
        self.Bind(events.EVT_FULLSCREEN, self.toggleFullScreen)

    #def onKeyUp(self, event):
    #    key = event.GetKeyCode()
    #    if key == wx.WXK_F11:
    #        wx.PostEvent(self, events.FullScreenEvent(id=wx.ID_ANY))
piemenu.py 文件源码 项目:cebl 作者: idfah 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def growBar(self, choice, amount, refresh=True):
        """Grow a selection bar toward a menu cell.

        Args:
            choice: String name of the menu cell to grow
                    the bar toward.

            amount: Floating point amount to grow the
                    bar.  Must be between 0.0 and 1.0
                    with 1.0 growing the bar all the
                    way to the cell and 0.0 not
                    growing the bar at all.

        Returns:
            True if the bar for choice meets or exceeds
            1.0 and False otherwise.

        Events:
            A PieMenuSelectEvent is posted if the bar
            length for choice meets or exceeds 1.0.
        """
        self.bars[choice] += amount

        if self.bars[choice] < 0.0:
            self.bars[choice] = 0.0

        if refresh:
            self.refresh()

        if np.isclose(self.bars[choice], 1.0) or self.bars[choice] > 1.0:
            self.bars[choice] = 1.0
            wx.PostEvent(self, PieMenuSelectEvent(choice=choice, id=wx.ID_ANY))
            return True
        else:
            return False
canvas_sample.py 文件源码 项目:dxf2gcode 作者: cnc-club 项目源码 文件源码 阅读 54 收藏 0 点赞 0 评论 0
def render(self):
        while self.running:
            if self.requests:
                request = self.requests.pop(0)
                # Make the CPU work
                for i in range(100000): pass
                self.counter += 1
                wx.PostEvent(self.parent.log,PrintEvent("%s\n"%self.counter))
            else:
                time.sleep(.01)
squaremap.py 文件源码 项目:squaremap3 作者: kawaiicthulhu 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def OnDoubleClick(self, event):
        """Double click on a given square in the map"""
        node = HotMapNavigator.findNodeAtPosition(self.hot_map, event.GetPosition())
        if node:
            wx.PostEvent( self, SquareActivationEvent( node=node, point=event.GetPosition(), map=self ) )
squaremap.py 文件源码 项目:squaremap3 作者: kawaiicthulhu 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def OnKeyUp(self, event):
        event.Skip()
        if not self.selectedNode or not self.hot_map:
            return

        if event.KeyCode == wx.WXK_HOME:
            self.SetSelected(HotMapNavigator.firstNode(self.hot_map))
            return
        elif event.KeyCode == wx.WXK_END:
            self.SetSelected(HotMapNavigator.lastNode(self.hot_map))
            return

        try:
            parent, children, index = HotMapNavigator.findNode(self.hot_map, self.selectedNode)
        except TypeError:
            log.info( 'Unable to find hot-map record for node %s', self.selectedNode )
        else:
            if event.KeyCode == wx.WXK_DOWN:
                self.SetSelected(HotMapNavigator.nextChild(children, index))
            elif event.KeyCode == wx.WXK_UP:
                self.SetSelected(HotMapNavigator.previousChild(children, index))
            elif event.KeyCode == wx.WXK_RIGHT:
                self.SetSelected(HotMapNavigator.firstChild(children, index))
            elif event.KeyCode == wx.WXK_LEFT and parent:
                self.SetSelected(parent)
            elif event.KeyCode == wx.WXK_RETURN:
                wx.PostEvent(self, SquareActivationEvent(node=self.selectedNode,
                                                         map=self))
squaremap.py 文件源码 项目:squaremap3 作者: kawaiicthulhu 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def SetSelected( self, node, point=None, propagate=True ):
        """Set the given node selected in the square-map"""
        if node == self.selectedNode:
            return
        self.selectedNode = node
        self.UpdateDrawing()
        if node:
            wx.PostEvent( self, SquareSelectionEvent( node=node, point=point, map=self ) )
squaremap.py 文件源码 项目:squaremap3 作者: kawaiicthulhu 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def SetHighlight( self, node, point=None, propagate=True ):
        """Set the currently-highlighted node"""
        if node == self.highlightedNode:
            return
        self.highlightedNode = node
        # TODO: restrict refresh to the squares for previous node and new node...
        self.UpdateDrawing()
        if node and propagate:
            wx.PostEvent( self, SquareHighlightEvent( node=node, point=point, map=self ) )
visuals.py 文件源码 项目:pyDataView 作者: edwardsmith999 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def post_string_event(self, eventtype, eventval, panel):
        """
            Triggers an event 
        """
        event = wx.PyCommandEvent(eventtype.typeId, panel.GetId())
        event.SetString(str(eventval))
        wx.PostEvent(self.GetEventHandler(),event)
sliders.py 文件源码 项目:pyDataView 作者: edwardsmith999 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def post_slide_event(self,eventval):
        """
            Updated positions triggers an
            event to let the parent know scroll 
            position has been changed 
        """
        event = wx.PyCommandEvent(wx.EVT_COMMAND_SCROLL_CHANGED.typeId, self.GetId())
        event.SetInt(eventval)
        wx.PostEvent(self.GetEventHandler(),event)
entitypicker.py 文件源码 项目:Turrican2Editor 作者: GitExl 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def set_template(self):
        template = self._entities[self._selected_index].template
        event = EntityPicker.PickEvent(template=template)
        wx.PostEvent(self.GetEventHandler(), event)
tileselector.py 文件源码 项目:Turrican2Editor 作者: GitExl 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def mouse_left_up(self, event):
        if not self._tilemap:
            return

        if not self._select_end:
            return

        x1, y1 = self._select_start
        x2, y2 = self._select_end

        if x2 < x1:
            x2, x1 = x1, x2
        if y2 < y1:
            y2, y1 = y1, y2

        width = x2 - x1 + 1
        height = y2 - y1 + 1

        self._select_start = None
        self._select_end = None

        self.Viewport.Refresh(False)

        if width and height:
            selection = Tilemap.from_tilemap(self._tilemap, x1, y1, x2 + 1, y2 + 1)
        else:
            selection = None

        event = TileSelector.SelectEvent(selection=selection)
        wx.PostEvent(self.GetEventHandler(), event)
dochtml.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def OnLinkClicked(self, linkinfo):
        wx.PostEvent(self, HtmlWindowUrlClick(linkinfo))
squaremap.py 文件源码 项目:BigBrotherBot-For-UrT43 作者: ptitbigorneau 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def OnDoubleClick(self, event):
        """Double click on a given square in the map"""
        node = HotMapNavigator.findNodeAtPosition(self.hot_map, event.GetPosition())
        if node:
            wx.PostEvent( self, SquareActivationEvent( node=node, point=event.GetPosition(), map=self ) )
squaremap.py 文件源码 项目:BigBrotherBot-For-UrT43 作者: ptitbigorneau 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def SetSelected( self, node, point=None, propagate=True ):
        """Set the given node selected in the square-map"""
        if node == self.selectedNode:
            return
        self.selectedNode = node 
        self.Refresh()
        if node:
            wx.PostEvent( self, SquareSelectionEvent( node=node, point=point, map=self ) )
squaremap.py 文件源码 项目:BigBrotherBot-For-UrT43 作者: ptitbigorneau 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def SetHighlight( self, node, point=None, propagate=True ):
        """Set the currently-highlighted node"""
        if node == self.highlightedNode:
            return
        self.highlightedNode = node 
        self.Refresh()
        if node and propagate:
            wx.PostEvent( self, SquareHighlightEvent( node=node, point=point, map=self ) )
runsnake.py 文件源码 项目:BigBrotherBot-For-UrT43 作者: ptitbigorneau 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def OnNodeActivated(self, event):
        """We have double-clicked for hit enter on a node refocus squaremap to this node"""
        try:
            node = self.sorted[event.GetIndex()]
        except IndexError, err:
            log.warn(_('Invalid index in node activated: %(index)s'),
                     index=event.GetIndex())
        else:
            wx.PostEvent(
                self,
                squaremap.SquareActivationEvent(node=node, point=None,
                                                map=None)
            )
runsnake.py 文件源码 项目:BigBrotherBot-For-UrT43 作者: ptitbigorneau 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def OnMouseMove(self, event):
        point = event.GetPosition()
        item, where = self.HitTest(point)
        if item > -1:
            try:
                node = self.sorted[item]
            except IndexError, err:
                log.warn(_('Invalid index in mouse move: %(index)s'),
                         index=event.GetIndex())
            else:
                wx.PostEvent(
                    self,
                    squaremap.SquareHighlightEvent(node=node, point=point,
                                                   map=None)
                )
post_event_example.py 文件源码 项目:wxpythoncookbookcode 作者: driscollis 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def run(self):
        """Run Worker Thread."""
        # This is the code executing in the new thread.
        for i in range(6):
            time.sleep(10)
            amtOfTime = (i + 1) * 10
            wx.PostEvent(self.wxObject, ResultEvent(amtOfTime))
        time.sleep(5)
        wx.PostEvent(self.wxObject, ResultEvent("Thread finished!"))
padherder_sync.py 文件源码 项目:padherder_proxy 作者: jgoldshlag 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def add_status_msg(msg, status_ctrl, simulate):
    if status_ctrl and not simulate:
        evt = custom_events.wxStatusEvent(message=msg)
        wx.PostEvent(status_ctrl, evt)
    else:
        print msg.encode('ascii', errors='ignore')
padherder_proxy.py 文件源码 项目:padherder_proxy 作者: jgoldshlag 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def handle_request(self, f):
        if f.client_conn.ssl_established:
            f.request.scheme = "https"
            sni = f.client_conn.connection.get_servername()
            port = 443
        else:
            f.request.scheme = "http"
            sni = None
            port = 80

        host_header = f.request.pretty_host
        m = parse_host_header.match(host_header)
        if m:
            host_header = m.group("host").strip("[]")
            if m.group("port"):
                port = int(m.group("port"))

        f.request.host = sni or host_header
        f.request.port = port

        evt = custom_events.wxStatusEvent(message="Got HTTPS request, forwarding")            
        wx.PostEvent(self.status_ctrl,evt)

        flow.FlowMaster.handle_request(self, f)
        if f:
            f.reply()
        return f


问题


面经


文章

微信
公众号

扫码关注公众号