I am trying to draw an xkcd-style plot with matplotlib (ver. 1.4.2) under Python 3. When I try to run: It opens an empty window without any image and I get the error: I have Humor Sans installed. I checked it with fc-list | grep Humor. It can also be used within other programs, like Libre Office. I also have
Tag: python-3.x
How to convert Julian date to standard date?
I have a string as Julian date like “16152” meaning 152’nd day of 2016 or “15234” meaning 234’th day of 2015. How can I convert these Julian dates to format like 20/05/2016 using Python 3 standard library? I can get the year 2016 like this: date = 20 + julian[0:1], where julian is the string containing the Julian date, but
Python: search for a file in current directory and all it’s parents
Is there an inbuilt module to search for a file in the current directory, as well as all the super-directories? Without the module, I’ll have to list all the files in the current directory, search for the file in question, and recursively move up if the file isn’t present. Is there an easier way to do this? Answer Well this
putting file names in an array using os in python
I want to create a program that will use os to make an ls of a directory and then put the files in a array. However, ls does not list the names one by one, so I am kind of stuck, because there’s nothing constant by which I can tell when the next name starts. Here is the actual code:
Specify max and min in NumberInput widget
I have a form that is using NumberInput widget to accept a rating for a Song from the user. The number should be between 0-5. My Song model has a MaxValueValidator but I want the NumberInput widget to show options only from 0-5. Answer In your form you can add min and max value which atleast shows the user the
How can I debug Python 3 code in Visual Studio Code?
I want to debug a project written in Python 3 in Visual Studio Code, but I can’t seem to find any way of specifying interpreter or Python version in the launch.json file. It works great for Python 2, so the question is, how do I make it work for Python 3? Answer Python 3 debugging works well also. It is a little
How to close the Python turtle window after it does its code?
I’m working on a simple program in Python 3.5 that contains turtle graphics and I have a problem: after the turtle work is finished the user has to close the window manually. Is there any way to program the window to close after the turtle work is done? Answer turtle.bye(), aka turtle.Screen().bye(), closes a turtle graphics window. Usually, a lack
Python Convert any number to power of 10 (E-notation)
In my program big numbers is shown off and for this reason I want any number to be converted to power of 10 (E-notation). I tried an idea that came to my mind but I get an error that says: How I succeed that I want? Answer In Python floats are usually double-precision IEEE-754 floating point numbers; it has 11
How to set a tkinter window to a constant size
I’m programming a little game with tkinter and briefly, I’m stuck. I have a kind od starting menu, in which are two buttons and one label. If I just create the frame everything is fine, it has the size 500×500 pixels I want the background not to change when I create the buttons and the labe, but it adapts the
“Syntax error: Unterminated quoted string” error when calling a bash script from Python
I have a situation where, I need to call a bash script inside a python script which is in turn called inside another python script. download-output-files.py: watcher.py: copy_output_file.sh: When I run download-output-files.py , it calls watcher.py , which in turn calls copy_output_file.sh and below is the error I face: When I run the same commands in Python shell, it runs