Skip to content

Tag: python

Display/Update score on python using tkinter

I’m making an arcade game using tkinter GUI, that as most arcades, needs a score display on screen that updates every time the user kills an enemy (obviously). I am doing it by creating a text on a canvas, and calling a function that creates another one, but this time with the score value (Which is a gl…

How to convert webpage into PDF by using Python

I was finding solution to print webpage into local file PDF, using Python. one of the good solution is to use Qt, found here, https://bharatikunal.wordpress.com/2010/01/. It didn’t work at the beginning as I had problem with the installation of PyQt4 because it gave error messages such as ‘ImportE…

Curl works but urllib doesn’t [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself. Closed 8 years …

Asking the user for input until they give a valid response

I am writing a program that accepts user input. The program works as expected as long as the the user enters meaningful data. But it fails if the user enters invalid data: Instead of crashing, I would like the program to ask for the input again. Like this: How do I ask for valid input instead of crashing or a…

Overriding __dict__() on python class

I have a class where I want to get the object back as a dictionary, so I implemented this in the __dict__(). Is this correct? I figured once I did that, I could then use the dict (custom object), and get back the object as a dictionary, but that does not work. Should you override __dict__()? How can you make

Move and resize legends-box in matplotlib

I’m creating plots using Matplotlib that I save as SVG, export to .pdf + .pdf_tex using Inkscape, and include the .pdf_tex-file in a LaTeX document. This means that I can input LaTeX-commands in titles, legends etc., giving an image like this which renders like this when I use it in my LaTeX document. N…

Interface between networkx and igraph

I’ve been working with networkx for quite some time now and it’s been serving my purposes quite well with minimal tweaks until recently when I started looking into community detection. In comparison, the igraph Python package seems to have a much wider implementations of community detection method…