4,305 Posted Topics
Re: One of the zillion rules of Kivy: Kivy looks for a .kv file with the same name as your App class in lowercase (minus “App” if it ends with ‘App’. eg. TutorialApp -> tutorial.kv) Compared to Python syntax, Kivy syntax really sucks. I would only use it if you have … | |
Re: The U.S. government is creating a new agency to monitor cybersecurity threats. Let's hope these experts will take care of the abuse of the social media by Islamic State. Actually pastebin itself is abused by these folks. | |
Re: abs(x) where x is an argument for the function abs() For example ... x = -123 print(x) print(abs(x)) From the manual ... abs(x) Return the absolute value of a number. The argument may be a plain or long integer or a floating point number. If the argument is a complex … | |
Re: Sooner or later you will use the pygame module anyway ... ''' pg_playmp3f.py play MP3 music files using Python module pygame pygame is free from: http://www.pygame.org (does not create a GUI frame in this case) ''' import pygame as pg def play_music(music_file, volume=0.8): ''' stream music with mixer.music module in … | |
![]() | Re: The SharpDevelop IDE is a drag and drop GUI builder that writes most of the code for you either in C# or IronPython. With Mono it should work on Linux too? ![]() |
Re: To create the layout you want use frames ... ''' tk_frame_pack101.py use Tkinter frames for different pack() layouts ''' # for Python3 change Tkinter to tkinter import Tkinter as tk root = tk.Tk() frame1 = tk.Frame() frame2 = tk.Frame() frame1.pack(side='top') # side='top' is default frame2.pack(side='top') # these widgets go into … | |
Re: Well, I am glad we solved this beginner problem. | |
Re: I used to go to the Milwaukee Brewers games and they had German Brats and Leinenkugel beer, a real gourmet feast. For the Superbowl I will go to a friend's house for barbecue (ribs and stuff). My friend is a Seahawks fan, so I better cheer for them. Should be … | |
![]() | Re: Generally you use the PyGame module to play sound and movies with Tkinter. See ... http://www.pygame.org/docs/ref/movie.html ![]() |
I used csv data readily available from http://www.weatherdatadepot.com/ to create a multiline plot of the average monthly temperatures of a given location. | |
![]() | Re: Another possibility (finds all occurrences of search) ... import numpy as np a = np.array([[1,2,1],[3,4,2],[6,5,3],[7,8,4]]) print(a) ''' [[1 2 1] [3 4 2] [6 5 3] [7 8 4]] ''' search = 2 for col, column in enumerate(np.transpose(a)): print(col, column) row = 0 for item in column: if item == … ![]() |
Re: Plenty of good solutions, pick one that fits your level. | |
Re: PySide is the official LGPL-licensed version of PyQT. | |
Two third party Python modules imageio and visvis make it easy to load and view images. The modules come with the pyzo scientific package or can be downloaded separately. Module imageio can read many image file formats as shown in http://imageio.readthedocs.org/en/latest/formats.html You could also replace your image file name directly … | |
Re: C++ and Python complement each other, so you should have a good knowledge of those two languages. Once you are learning C++ then Java isn't far off. Unless you are a genius, it will take a lot of coding and exploring to get to know Python thoroughly enough to pass … | |
Re: ttk is included with Python27 on Debian Linux. What is your exact traceback error message? | |
With just about everybody snooping around your emails today with the excuse of hunting the bad guys, coding to keep some resemblance of privacy is getting important. I will start out with some simple encryption examples to get this started. You are invited to give us your thoughts and codes. … | |
Re: The sun, as it dies, will expand and engulf the Earth. So we can stay put and wait. | |
Re: Module pickle is made for this ... ''' pickle_list101.py use module pickle to dump and load a list object use binary file modes "wb" and "rb" to make it work with Python2 and Python3 ''' import pickle mylist = [ 'Frank', 'Paul', 'Mary'] fname = "list101.pkl" # pickle dump the … | |
Re: Since you are using the Windows OS see ... https://www.daniweb.com/software-development/python/code/490440/copy-to-and-from-the-clipboard-windows | |
Re: `favorite_movies = pickle.load( open("films.db", "rb"))` will give you a Python object like a list or dictionary, whatever you saved. You would have to process it to give you a meaningfull string you can display with `label['text'] = favorite_movies_string` | |
Knowing the longitude and latitude coordinates of two cities you can calculate the distance between them. Use the code in https://www.daniweb.com/software-development/python/code/490561/postal-code-zips-and-location-python to find the coordinates. | |
Using http://download.geonames.org/export/zip/ you can get postal information for most countries in the world. The raw data string can be transformed into a Python list of lists that can be searched for zip codes, locations, longitude and latitude coordinates. | |
Re: You can study up on list comprehension ... mylist = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18] size = 3 newlist = [mylist[n : n + size] for n in range(0, len(mylist), size)] print(newlist) ''' result ... [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11], [12, 13, 14], [15, 16, 17], [18]] … | |
Re: snippsat's latest re approach is actually quite speedy. | |
Using the Python win32 extensions it is relatively simple to copy to and from the clipboard. Sorry. the Windows OS is a requirement. | |
Just a small mildly optimized function to check if an integer is a prime number. For very large numbers use the Miller-Rabin primality test. There have been questions why I used `not n & 1` to check for even integer n. The more tradional` n % 2 == 0` is … | |
Re: On Windows 8.1 it pastes into Google Chrome alright. | |
Re: No, there is no "do ... while" loop in Python. A properly constructed while loop can do the same. If you have any problems, give us a simplified idea of what you want to accomplish. We will be glad to help! | |
Re: @L7Sqr In all fairness SneeKula answered the original question. Sometimes it is fun to experiment a little to get to know the language better. Yes, I would rather use the tested `tolower()` and `toupper()` functions. Some instructors give these kind of problems to their students to make them think. | |
A dictionary in Python is an unordered set of key:value pairs. I show you how to initialize, create, load, display, search, copy and otherwise manipulate this interesting container. Like the name says, it is the closest thing to a dictionary. | |
Python's double ended queue module makes Caesar's cipher easy. | |
Re: One of the simpler Caesar ciphers can be done using Python's double-ended queue rotation. | |
Re: Something like this ... fname_in = "names_nocaps.txt" # write a test data file data = '''\ frank heidi karl ''' with open(fname_in, 'w') as fout: for name in data: fout.write(name) fname_out = "names_caps.txt" # read the file back in and write the modified data back out with open(fname_in, 'r') as … | |
Re: Potential freeloaders are all over the place. Nearly 50% of the US population now receives government handouts in one form or another. Food stamps/cards are a modern day soupkitchen in the USA. Great for those who are desperately down on their luck, but there is some abuse. Luckily in commerce, … ![]() | |
Re: It is my understanding that pillow has basicly taken over the further development of PIL. | |
Google Drive, Dropbox, iCloud, and OneDrive are all available to try for free (with limited storage). So far I have used Dropbox and OneDrieve and like Dropbox since it handles better on the PC and my iPad. OneDrive is improving and I have used iCloud on my iPad mostly for … | |
Re: Trusting a Twitter feed? Absurd notion! | |
Re: For an example see: [url]http://www.daniweb.com/software-development/python/threads/191210/1556772#post1556772[/url] Note: Programs like py2exe and cxfreeze simply package/combine necessary things (like code and interpreter) together and then unpackage it later to run on the users machine. | |
Re: If you have plenty of electric energy and airconditioned buildings, then heat above body temperature is not too bad. Do your outdoor activities in the morning when it is usually a little cooler. | |
Use the PySide (PyQT) GUI toolkit to play animated gif files. | |
Re: A home water fall might help, add a little vinegar to the water. Nicotine is a base. We used to have carbon monoxide and cyanide detectors in the lab. They would go of if someone smoked nearby. | |
| |
Re: GUI toolkits like Tkinter can be used to draw strange three dimensional objects. Just play with it ... ''' tk_canvas_multi_circles101.py draw a series of circles to form 3D objects ''' try: # Python2 import Tkinter as tk except ImportError: # Python3 import tkinter as tk def draw_circle(x, y, radius, color): … | |
If you draw a series of close spaced shapes your eyes get fooled to see Moire patterns. Here is one example of this. | |
Re: https://www.daniweb.com/software-development/python/threads/489298/new-idle | |
Re: Can you give us an example what the plate should look like? | |
![]() | Re: Doing this with a low level language like C could most assuredly be a challenge. If you use a higher level language like Java or even Python, then this project might be much easier, for a Python example see ... https://www.daniweb.com/software-development/python/code/487171/google-translate-api-python Check out the Google translate API, I am sure … |
Re: C++ has the Standard Template Library (STL) that makes your life so much easier when it comes to strings and vectors/arrays. See ... https://www.sgi.com/tech/stl/stl_introduction.html Also take a wiff of ... https://www.daniweb.com/software-development/cpp/code/216400/an-array-can-use-stl-functions Introduce yourself to classical OOP gradually, C++ allows this. A language that complements C++ very well is Python. | |
Re: Hint ... // dirlist.c // display information about files // works with Pelles C and CodeBlocks #include <stdio.h> #include <io.h> // _findfirst() #include <time.h> // ctime() char *get_month(char *time_created); int main(int argc, char **argv) { // uses working directory if no args given char *spec = (argc > 1) ? … |
The End.