예제 #1
0
 def _cleanup(self):
     """Clean up after hinting."""
     for elem in self._context.elems.values():
         try:
             elem.label.removeFromDocument()
         except webelem.IsNullError:
             pass
     for f in self._context.frames:
         log.hints.debug("Disconnecting frame {}".format(f))
         if objreg.get('args').debug:
             sip.dump(f)
         try:
             f.contentsSizeChanged.disconnect(self.on_contents_size_changed)
         except TypeError:
             # It seems we can get this here:
             #   TypeError: disconnect() failed between
             #   'contentsSizeChanged' and 'on_contents_size_changed'
             # See # https://github.com/The-Compiler/qutebrowser/issues/263
             pass
         log.hints.debug("Disconnected.")
     text = self.HINT_TEXTS[self._context.target]
     message_bridge = objreg.get('message-bridge', scope='window',
                                 window=self._win_id)
     message_bridge.maybe_reset_text(text)
     self._context = None
예제 #2
0
 def _cleanup(self):
     """Clean up after hinting."""
     for elem in self._context.elems.values():
         try:
             elem.label.removeFromDocument()
         except webelem.IsNullError:
             pass
     for f in self._context.frames:
         log.hints.debug("Disconnecting frame {}".format(f))
         if objreg.get('args').debug:
             sip.dump(f)
         try:
             f.contentsSizeChanged.disconnect(self.on_contents_size_changed)
         except TypeError:
             # It seems we can get this here:
             #   TypeError: disconnect() failed between
             #   'contentsSizeChanged' and 'on_contents_size_changed'
             # See # https://github.com/The-Compiler/qutebrowser/issues/263
             pass
         log.hints.debug("Disconnected.")
     text = self.HINT_TEXTS[self._context.target]
     message_bridge = objreg.get('message-bridge',
                                 scope='window',
                                 window=self._win_id)
     message_bridge.maybe_reset_text(text)
     self._context = None
예제 #3
0
파일: widgettest.py 프로젝트: ifwe/wxpy
 def onclose(e):
     print 'destroying frame', f
     print 'BEFORE: isdeleted?', sip.isdeleted(f)
     print sip.dump(f)
     f.Destroy()
     #sip.setdeleted(f)
     print 'AFTER: isdeleted?', sip.isdeleted(f)
     print sip.dump(f)
예제 #4
0
파일: widgettest.py 프로젝트: ifwe/wxpy
 def onclose(e):
     print 'destroying frame', f
     print 'BEFORE: isdeleted?', sip.isdeleted(f)
     print sip.dump(f)
     f.Destroy()
     #sip.setdeleted(f)
     print 'AFTER: isdeleted?', sip.isdeleted(f)
     print sip.dump(f)
예제 #5
0
파일: widgettest.py 프로젝트: ifwe/wxpy
def construct_layout(f):
    b  = wx.Button(f, -1, 'test')
    b2 = wx.Button(f, -1, 'test2')

    s = f.Sizer = wx.BoxSizer(wx.VERTICAL)
    
    item1 = s.Add(b)
    sip.dump(item1)
    item2 = s.Add(b2)

    s2 = f.Sizer = wx.BoxSizer(wx.VERTICAL)
    sip.dump(s)
예제 #6
0
파일: widgettest.py 프로젝트: ifwe/wxpy
def construct_layout(f):
    b = wx.Button(f, -1, 'test')
    b2 = wx.Button(f, -1, 'test2')

    s = f.Sizer = wx.BoxSizer(wx.VERTICAL)

    item1 = s.Add(b)
    sip.dump(item1)
    item2 = s.Add(b2)

    s2 = f.Sizer = wx.BoxSizer(wx.VERTICAL)
    sip.dump(s)
예제 #7
0
def checkLeaks():
    gc.collect()

    notDestroyedCount = 0
    for o in gc.get_objects():
        try:
            if not sip.isdeleted(o):
                sip.dump(o)
                notDestroyedCount += 1
        except TypeError:
            pass
    if notDestroyedCount:
        print("\n\n{}\nFound {} objects that weren't deleted.".format(
            '*' * 80, notDestroyedCount))
예제 #8
0
파일: future.py 프로젝트: freason/enki
def checkLeaks():
    gc.collect()

    notDestroyedCount = 0
    for o in gc.get_objects():
        try:
            if not sip.isdeleted(o):
                sip.dump(o)
                notDestroyedCount += 1
        except TypeError:
            pass
    if notDestroyedCount:
        print("\n\n{}\nFound {} objects that weren't deleted.".format('*'*80,
          notDestroyedCount))
예제 #9
0
파일: events.py 프로젝트: ifwe/wxpy
def main():
    a = wx.PySimpleApp()
    f = wx.Frame(None, -1, 'test', size = (300, 500))
    sip.dump(f)

    f.Title = str(f.Handle)

    f.Bind(wx.EVT_SIZE, lambda e: p(f.Size))
    f.Bind(wx.EVT_MOVE, lambda e: p(f.Position))

    f.Sizer = sizer = wx.BoxSizer(wx.VERTICAL)

    N = 5
    ids = {}
    buttons = []
    for x in xrange(N):
        ids[x] = wx.NewId()
        b = wx.Button(f, ids[x], 'button %d' % x)
        b.Bind(wx.EVT_BUTTON, lambda e: p(e.EventObject.Label))
        buttons.append(b)
        sizer.Add(b)

    timer_button = wx.Button(f, -1, 'timer')

    f.i=0
    def foo(e):
        f.i += 1
        c = f.i
        f.t = wx.PyTimer(lambda: p('hello world', c))
        import gc; gc.collect()
        f.t.Start(1000)

    f.Bind(wx.EVT_BUTTON, foo, id = timer_button.Id)
    sizer.Add(timer_button)

    sizer.Layout()
    f.Show()

    for x in xrange(N):
        button = buttons[x]
        print button, button.Position

    f.Bind(wx.EVT_CLOSE, lambda e: wx.GetApp().ExitMainLoop())

    wx.GetApp().MainLoop()
예제 #10
0
파일: hints.py 프로젝트: pyrho/qutebrowser
 def _cleanup(self):
     """Clean up after hinting."""
     for elem in self._context.elems.values():
         try:
             elem.label.removeFromDocument()
         except webelem.IsNullError:
             pass
     for f in self._context.frames:
         log.hints.debug("Disconnecting frame {}".format(f))
         if objreg.get('args').debug:
             sip.dump(f)
         f.contentsSizeChanged.disconnect(self.on_contents_size_changed)
         log.hints.debug("Disconnected.")
     text = self.HINT_TEXTS[self._context.target]
     message_bridge = objreg.get('message-bridge', scope='window',
                                 window=self._win_id)
     message_bridge.maybe_reset_text(text)
     self._context = None
예제 #11
0
 def _cleanup(self):
     """Clean up after hinting."""
     for elem in self._context.elems.values():
         try:
             elem.label.removeFromDocument()
         except webelem.IsNullError:
             pass
     for f in self._context.frames:
         log.hints.debug("Disconnecting frame {}".format(f))
         if objreg.get('args').debug:
             sip.dump(f)
         f.contentsSizeChanged.disconnect(self.on_contents_size_changed)
         log.hints.debug("Disconnected.")
     text = self.HINT_TEXTS[self._context.target]
     message_bridge = objreg.get('message-bridge',
                                 scope='window',
                                 window=self._win_id)
     message_bridge.maybe_reset_text(text)
     self._context = None
예제 #12
0
	def transformation(self):
		import sip
		sip.dump(self.transf)
		print("plouf transformation")
		return self.transf
예제 #13
0
파일: widgettest.py 프로젝트: ifwe/wxpy
def main2():
      a = wx.PySimpleApp()

      f = wx.Frame(None, -1, u'wxpy frame', (40, 40), (400, 300))
      p = wx.Panel(f)
      p.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)

      f.Bind(wx.EVT_ACTIVATE, lambda e: prnt('frame activate:', f.IsActive()))

      def onclose(e):
          print 'destroying frame', f
          print 'BEFORE: isdeleted?', sip.isdeleted(f)
          print sip.dump(f)
          f.Destroy()
          #sip.setdeleted(f)
          print 'AFTER: isdeleted?', sip.isdeleted(f)
          print sip.dump(f)

      f = wx.Frame(None, -1, u'wxpy frame', (40, 40), (400, 300))
      f.Bind(wx.EVT_CLOSE, onclose)
      f.Bind(wx.EVT_ACTIVATE, lambda e: p('frame activate:', f.IsActive()))

      s = wx.BoxSizer(wx.VERTICAL)

      def show_modal(e):
          diag = wx.Dialog(f, -1, 'test modal dialog', size = (400, 300))
          try:
              diag.ShowModal()
          finally:
              diag.Destroy()
          import gc
          print 'collect', gc.collect()

      button = wx.Button(p, -1, 'Show Modal Dialog')
      button.Bind(wx.EVT_BUTTON, show_modal)

      print 'button id is', id(button)

      def on_paint(e):
          dc = wx.AutoBufferedPaintDC(p)

          dc.SetBrush(wx.WHITE_BRUSH)
          dc.SetPen(wx.TRANSPARENT_PEN)
          dc.DrawRectangleRect(p.GetClientRect())

          dc.SetBrush(wx.Brush(wx.Colour(255, 0, 0)))
          rect = wx.Rect(20, 20, 60, 70)

          if dc.IsOk():
              font = dc.GetFont()
              font.SetPointSize(20)
              font.SetWeight(wx.FONTWEIGHT_BOLD)
              dc.SetFont(font)

              dc.DrawText("hello, world!", 130, 100)

              b = wx.Brush(wx.Colour(255, 0, 0))
              dc.SetBrush(b)
              b = dc.GetBrush()

              dc.DrawRectangle(140, 130, 60, 30)
          else:
              print 'not ok!'

      #f.Connect(-1, -1, 10090, on_paint)
      f.Bind(wx.EVT_PAINT, on_paint)

      static_text = wx.StaticText(p, -1, 'Static Text')
      checkbox = wx.CheckBox(p, -1, 'Checkbox')

      def print_top(e):
          print wx.GetTopLevelWindows()

      checkbox.Bind(wx.EVT_CHECKBOX, print_top)

      s.Add(static_text, 0, wx.ALL, 6)
      s.Add(button, 0, wx.ALL, 6)
      s.Add(checkbox, 0, wx.ALL, 6)

      s.Add(wx.TextCtrl(p, -1, 'Text Control', name = 'Username'))

      p.SetSizer(s)

      a.Bind(wx.EVT_MENU, lambda e: a.ExitMainLoop(), id = wx.ID_EXIT)


      a.SetTopWindow(f)
      f.Show()

      #
      # sys.a=a

      print '--> calling MainLoop'
      import sip
      sip.dump(wx.GetApp())
      a.MainLoop()
      print '--> MainLoop returned'
예제 #14
0
파일: widgettest.py 프로젝트: ifwe/wxpy
def main2():
    a = wx.PySimpleApp()

    f = wx.Frame(None, -1, u'wxpy frame', (40, 40), (400, 300))
    p = wx.Panel(f)
    p.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)

    f.Bind(wx.EVT_ACTIVATE, lambda e: prnt('frame activate:', f.IsActive()))

    def onclose(e):
        print 'destroying frame', f
        print 'BEFORE: isdeleted?', sip.isdeleted(f)
        print sip.dump(f)
        f.Destroy()
        #sip.setdeleted(f)
        print 'AFTER: isdeleted?', sip.isdeleted(f)
        print sip.dump(f)

    f = wx.Frame(None, -1, u'wxpy frame', (40, 40), (400, 300))
    f.Bind(wx.EVT_CLOSE, onclose)
    f.Bind(wx.EVT_ACTIVATE, lambda e: p('frame activate:', f.IsActive()))

    s = wx.BoxSizer(wx.VERTICAL)

    def show_modal(e):
        diag = wx.Dialog(f, -1, 'test modal dialog', size=(400, 300))
        try:
            diag.ShowModal()
        finally:
            diag.Destroy()
        import gc
        print 'collect', gc.collect()

    button = wx.Button(p, -1, 'Show Modal Dialog')
    button.Bind(wx.EVT_BUTTON, show_modal)

    print 'button id is', id(button)

    def on_paint(e):
        dc = wx.AutoBufferedPaintDC(p)

        dc.SetBrush(wx.WHITE_BRUSH)
        dc.SetPen(wx.TRANSPARENT_PEN)
        dc.DrawRectangleRect(p.GetClientRect())

        dc.SetBrush(wx.Brush(wx.Colour(255, 0, 0)))
        rect = wx.Rect(20, 20, 60, 70)

        if dc.IsOk():
            font = dc.GetFont()
            font.SetPointSize(20)
            font.SetWeight(wx.FONTWEIGHT_BOLD)
            dc.SetFont(font)

            dc.DrawText("hello, world!", 130, 100)

            b = wx.Brush(wx.Colour(255, 0, 0))
            dc.SetBrush(b)
            b = dc.GetBrush()

            dc.DrawRectangle(140, 130, 60, 30)
        else:
            print 'not ok!'

    #f.Connect(-1, -1, 10090, on_paint)
    f.Bind(wx.EVT_PAINT, on_paint)

    static_text = wx.StaticText(p, -1, 'Static Text')
    checkbox = wx.CheckBox(p, -1, 'Checkbox')

    def print_top(e):
        print wx.GetTopLevelWindows()

    checkbox.Bind(wx.EVT_CHECKBOX, print_top)

    s.Add(static_text, 0, wx.ALL, 6)
    s.Add(button, 0, wx.ALL, 6)
    s.Add(checkbox, 0, wx.ALL, 6)

    s.Add(wx.TextCtrl(p, -1, 'Text Control', name='Username'))

    p.SetSizer(s)

    a.Bind(wx.EVT_MENU, lambda e: a.ExitMainLoop(), id=wx.ID_EXIT)

    a.SetTopWindow(f)
    f.Show()

    #
    # sys.a=a

    print '--> calling MainLoop'
    import sip
    sip.dump(wx.GetApp())
    a.MainLoop()
    print '--> MainLoop returned'