Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7869303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:16:41+00:00 2026-06-03T01:16:41+00:00

I have a visualizer for network traffic in Python. It uses Twisted for networking

  • 0

I have a visualizer for network traffic in Python. It uses Twisted for networking and calls run() it also has matplotlib for plotting and calls show(). Neither of these functions seem to return yet I need to call both of them to start the networking, then show the plot and ultimately update the plot as things happen on the network. Any solutions? Do I need threads?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T01:16:44+00:00Added an answer on June 3, 2026 at 1:16 am

    matplotlib is a layer on top of some GUI toolkit. Which GUI toolkit depends a bit – on per-user configuration, on site-wide configuration, on the particulars of the matplotlib code you have.

    Twisted has specific support for integrating with some GUI toolkits. So, for example, you can run matplotlib with its Gtk backend and use Twisted’s Gtk integration and then everything will play nicely together.

    Here’s a 5 minute hack I threw together, based on what I know about integrating the various mainloops, and on a little bit of inspection of the matplotlib source code:

    if __name__ == '__main__':
        from mpl import main
        raise SystemExit(main())
    
    from matplotlib import use
    use('GTK')
    from matplotlib import pyplot
    
    from matplotlib.backends import backend_gtk
    
    from twisted.internet import gtk2reactor
    gtk2reactor.install()
    
    from twisted.internet import reactor, task
    
    class TwistedGtkShow(backend_gtk.Show):
        running = False
        def mainloop(self):
            if not self.running:
                self.running = True
                reactor.run()
    
    def main():
        pyplot.plot([1,2,3,4])
        pyplot.ylabel('some numbers')
    
        def proof():
            print 'Twisted!'
        task.LoopingCall(proof).start(3)
    
        TwistedGtkShow()()
    

    Notice:

    • This is in a file named mpl.py (hence the mpl import up top)
    • I forced matplotlib to use Gtk with the use('GTK') call before importing pyplot
    • I forced Twisted to use Gtk with the gtk2reactor.install() call before importing reactor
    • I replaced the call to pyplot.show() with a call to my own Show subclass with a mainloop method starts the Gtk mainloop and the Twisted mainloop (both via reactor.run())

    This example seems to work fairly well. I haven’t explored this very much, so if there are problems that only crop up under more advanced usage, I don’t know about them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one debugger visualizer for seeing list of class object in the form
For a project I have to create a music visualizer in java (I've decided
In my app, I have an equalizer with a visualizer behind it. The equalizer
I have a social network similar to myspace/facebook. In my code you are either
I have an audio visualizer applet I created with processing and minim using fft
I'm writing a pathfinding visualizer in python and Pygame. I intend to write a
I've made a pathfinding visualizer using python and pygame. As of now, it can
I have created a debugger visualizer in VS2008. There are two classes i've made,
I have an application that visualize network data structure as visual graph of nodes
I have tried to install the linq visualizer debugger, but it doesn't seems to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.