Skip to content

Tag: python

Get legend as a separate picture in Matplotlib

I’m developing a Web application and want to display a figure and its legend in different locations on the page. Which means I need to save the legend as a separate png file. Is this possible in Matplotlib in a more or less straightforward way? Answer This could work:

Python virtualenv questions

I’m using VirtualEnv on Windows XP. I’m wondering if I have my brain wrapped around it correctly: I ran virtualenv ENV and it created C:WINDOWSsystem32ENV. I then changed my PATH variable to include C:WINDOWSsystem32ENVScripts instead of C:Python27Scripts. Then, I checked out Django into C:WINDOWS…

Check if module exists, if not install it

I want to check if a module exists, if it doesn’t I want to install it. How should I do this? So far I have this code which correctly prints f if the module doesn’t exist. Answer Here is how it should be done, and if I am wrong, please correct me. However, Noufal seems to confirm it in another

PyQt: removing QTreeView columns

I am using QTreeView with QFileSystemModel. It displays columns like Size, Type, Modification Date, which I don’t need. How can I remove them from the view? I can’t find any removeColumn in model or in view. Answer Get the QHeaderView of your TreeView by calling header() on it, the headerview know…

light weight template engine for python

Which is the simplest and light weight html templating engine in Python which I can use to generate customized email newsletters. Answer For a really minor templating task, Python itself isn’t that bad. Example: In this sense, you can use string formatting in Python for simple templating. That’s a…