4,305 Posted Topics
Re: You have quite a few mistakes. This will work, look at it closely ... import random # optional, make string input work with Python2 or Python3 try: input = raw_input except: pass dice = random.randrange(1,5) dice2 = random.randrange(1,7) dice3 = random.randrange(1,13) info = ''' Which sided dice would you like … | |
Re: Take a look at ... itertools.permutations(iterable, sample_size) in the Python manual. | |
Re: Right now they are trying to improve the response time. As far as I can figure out there is an insurance market place that lets you pick an insurance company and plan for your needs. However, everyone has to have maternity care and drug rehab in their plan. That's when … | |
This is an example of a singly linked list allowing you to enter a number of names and associated ages. The twist is that the names are inserted into the list in ascending order. When the list is displayed, it is already sorted by name. Note: This is not an … | |
The PySide (PyQT) GUI toolkit can be used to play wave sound files. | |
Re: I took vegaseat because everything else was already taken. Las Vegas, great place to eat top notch fine food. | |
Re: One way to do this that looks a lot more like C++ code ... // circle_calc101.cpp // ask for radius of a circle and show area and circumference #include <iostream> #include <string> #include <sstream> int main(void) { std::string response; float radius; float pi = 355.0/113; // good approximation of pi … | |
PySide's QWebView can load a given url and display the web page associated with it with just a few lines of code. | |
Re: Even a blind chicked will find a piece of corn every now and then. | |
Re: This might help ... http://pytools.codeplex.com/wikipage?title=NumPy%20and%20SciPy%20for%20.Net | |
Re: This might help ... ''' datetime_add_time101.py add 1 second to a time near midnight some time format specifiers ... %a Locale's abbreviated weekday name %A Locale's full weekday name %b Locale's abbreviated month name %B Locale's full month name %c Locale's appropriate date and time representation %d Day of the … | |
Re: Python3 is the best way to go at this point in your development. For a GUI toolkit that also allows some scripting look at PySide (PyQT). For example: [url]http://www.daniweb.com/software-development/python/threads/191210/1597999#post1597999[/url] Something to play with: [code]# PySide is the official LGPL-licensed version of PyQT # You can download and use the Windows … | |
Shows you how to get a Python object's memory size. Notice that there can be a difference between Python versions. | |
If you decorate a function, then some of the information is lost during the debugging process. Python supplies another decorator @wraps to help out. A decorator for a decorator, very interesting. | |
![]() | |
Re: Did you by accident create a file tkinter.py in your working directory (where your program code is)? It would be imported first. | |
Re: You could bind the event to pass certain arguments ... # Tkinter, show the text of the button that has been clicked # for Python3 use tkinter import Tkinter as tk def click(event): s = "clicked: " + event.widget.cget("text") root.title(s) root = tk.Tk() root.geometry("300x50+30+30") b1 = tk.Button(root, text="button1") b1.bind("<Button-1>", click) … | |
![]() | Re: I go to one of the sandwich shops about once a week. This includes Panera Bread, Jimmy John's, Port of Subs etc. |
Re: I have to admire the folks that help on the C++ forum. The language can be tough for beginners and the questions are endless. So, I am hiding out on the Python forum, where programming can be downright fun. If I remember it correctly, I got my Hypocrite Medal during … ![]() | |
| |
Re: Well, I went to Best Buy to get one of those fancy Sony Soundbars with a wireless woofer. Discounted at 30% off, not bad, and on Friday afternoon the only problem I had was parking. The problem at home was that my little terrier barks at the woofer. I have … | |
Re: You got to give us more detsails. Not everyone is familiar with this game. | |
Re: What version are you using? QVariant() hasn't been around for ages! | |
Re: Am I going blind? I can't see a while loop in your code. Also, you can add a few "test prints" to help you debug this. | |
Re: You can put in a few test prints (also use type()) to help you debug your code. | |
Re: With time.sleep() you need to tell Tkinter to update the root/label ... ''' display a GIF image on a Tkinter label at random positions ''' import time import random as rn try: # Python2 import Tkinter as tk except ImportError: # Python3 import tkinter as tk mainGUI = tk.Tk() width2= … | |
Re: You can also take a quick look at ... http://www.daniweb.com/software-development/python/code/468841/tkinter-image-slide-show-python | |
Re: Actually Python2 has an input() function, but it is supposed to be for numeric input only. Python3 has changed that to string input and done away with raw_input(). | |
Re: Welcome to DaniWeb and the interesting world of Python coding! The Quiz.dat file is just a text file containing 6 lines per question. The first line is the correct answer code for the four possible answers (A, B, C, D), followed by the question and the four possible answers. For … | |
Re: Not quite ZZ Top but it's a start! The Windows Api has a little thing called Beep(), try it ... [code]// simple sounds via Beep(frequency_hrz, duration_ms) #include <iostream> #include <windows.h> // WinApi header file using namespace std; int main(int argc, char *argv[]) { Beep(523.2511,500); // 523.2511 hertz (C5) for 500 … | |
Re: I have needed this for many years. | |
Re: Who are you? venkaaaaat, vankaat or venkaat? | |
![]() | |
Re: See also ... http://www.daniweb.com/software-development/python/code/468072/a-button_namebutton_object-dictionary-tkinter | |
| |
Re: The matplot libray is the work horse for any type of plotting with Python ... ''' mp_barchart_vertical2.py make a simple vertical bar chart downloaded Windows installer (Python 3.3 version) matplotlib-1.2.0.win32-py3.3.exe from http://matplotlib.org/downloads.html tested with Python33 ''' from pylab import * # names of sales persons persons = ['Tom', 'Jean', 'Paul', … | |
Re: Maybe something along this line ... dd = "{'a':1,'b':2}" print(type(dd)) # <type 'str'> d = eval(dd) print(type(d)) # <type 'dict'> print(d) # {'a': 1, 'b': 2} | |
Re: I thought that startword and endword have to be four letter words? | |
Re: Indian narcotic cop arrests racially competent erotic recluse after triple escape woolworth | |
| |
Shows you how to create multiple Tkinter buttons in a loop, each with its own name, label and command response. | |
The code sample shows how to get an image from the internet and show it in a Tkinter label widget. | |
Re: To break out of a nested loop put it into a function and use return instead of break. | |
Re: Put in a few test printf() and find out where it gets stuck. | |
Re: Another option ... mylist = [('cat', 'meow'), ('dog', 'ruff')] for tup in mylist: print(" ".join(tup)) # use "" for no space | |
Re: Hint ... import sys # check if there is a commandline if len(sys.argv) > 1: mylist = [] # sys.argv[0] is the program filename, slice it off for element in sys.argv[1:]: mylist.append(element) else: print("usage {} element1 element2 [element3 ...]".format(sys.argv[0])) sys.exit(1) # if the arguments were 1 2 3 4 5 … | |
Re: I think we better consider the original problem solved | |
Re: Just as an exercise, a mild modification of woooee's code ... ''' bubble_sort_details.py count the number of tuple swaps performed ''' import random def bubble_sort(mylist): '''mylist is sorted in place''' swaps_ctr = 0 while True: swap_flag = False for ctr in range(0, len(mylist)-1): if mylist[ctr] > mylist[ctr+1]: # do a … | |
![]() | Re: Scooters are not as fatal as the "crotch rockets" most teens around here drive. ![]() |
The End.