4,305 Posted Topics

Member Avatar for vegaseat

Do I have to spell it out for you? This short C code will do just that. It will spell out an integer number in English words. The banks do that on large checks, and it would be nice to get one of those every now and then.

Member Avatar for soulcandra44
1
525
Member Avatar for lewashby

[QUOTE=Garrett85;1298807]... In the above code, what on earth is the little underscore doing in that for loop? for _ ...[/QUOTE]The underscore is a variable name Python uses internally. Someone is trying to be a show-off! IMHO, those things lead to unnecessary confusion. BTW, where are you copying this dated pygame …

Member Avatar for vegaseat
0
260
Member Avatar for onauc

My advice, learn C++ When you learn C++ you also learn C, Java and C# to a fair extent, since they are so closely related. Sort of like classical English at Harvard and street English in certain parts of LA. C# is the new kid on the block (2000) and …

Member Avatar for PHANEENDAR06
0
149
Member Avatar for rhodi

If you run your Python code from the shell, you will most likely not be in the same directory as your file word.txt Give this a try to show the current working directory the shell looks at ... [code]>>> import os; os.getcwd() 'C:\\Python26' >>> [/code]Also, if you use Unix, file …

Member Avatar for vegaseat
0
87
Member Avatar for terence193

I went to a fight the other night and a hockey game broke out. (one of Rodney Dangerfield's lines)

Member Avatar for vegaseat
0
885
Member Avatar for Archenemie

Here is an example that works ... [code]# create a frame class containing two panel classes import wx class MyFrame(wx.Frame): def __init__(self, parent, mytitle, mysize): wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize) self.panel1 = MyPanel1(self) self.panel2 = MyPanel2(self) sizer = wx.BoxSizer() sizer.Add(self.panel1, proportion=1, flag=wx.EXPAND) sizer.Add(self.panel2, proportion=1, flag=wx.EXPAND) self.SetSizer(sizer) class MyPanel1(wx.Panel): def __init__(self, …

Member Avatar for vegaseat
0
114
Member Avatar for vaultdweller123

1) I believe if a deal sounds too good, it is most likely a scam. 2) Full moon nights bring out the crazies. 3) There is no such thing as an honest politician. 4) When you die you lose your senses.

Member Avatar for dellie
0
309
Member Avatar for d and d addict
Member Avatar for Agilemind
1
121
Member Avatar for lionaneesh

Input the two numbers as a string split the string into a two item list check if each item is a valid number then use the index to get at each numeric item convert each number with float() Here is a little function to check if a string is numeric …

Member Avatar for TrustyTony
0
798
Member Avatar for IT cllge stdnt
Member Avatar for vegaseat
0
52
Member Avatar for Peter_TARAS

Some more insight ... [code]import copy import pprint def funk(): """ wrote class inside function to keep local dictionary vars() clean """ class C: pass bob = C() joe = C() pprint.pprint(vars()) print('-'*50) # make a copy of vars() to freeze it vars_frozen = copy.copy(vars()) for key in vars_frozen: if …

Member Avatar for vegaseat
0
17K
Member Avatar for Archenemie

Lines read from a text file are strings, so even something as simple as this will work ... [code]# a simple wxPython template for testing widgets '''-->my_file.txt x a b ''' import wx app = wx.App(0) frame = wx.Frame(None, wx.ID_ANY, size=(300, 200)) panel = wx.Panel(frame, wx.ID_ANY, size=(300, 200)) #text_label = …

Member Avatar for Archenemie
0
115
Member Avatar for technocratic

Not quite as arduous if you use a template approach, then you only need to customize a few things to fit your task. Here is an example of a general Tkinter template that ask for two numbers (tk.Entry), processes them and displays the result (tk.Label) ... [code]# a general Tkinter …

Member Avatar for technocratic
0
2K
Member Avatar for student_

You can accomplish your module task by first creating the file commonModules.py [code]# save as commonModules.py def makeName(): name = raw_input("Please enter your name: ") return name def makeAge(): year = input("What is the current year? ") byear = input("What year were you born in? ") age = year - …

Member Avatar for student_
0
83
Member Avatar for technocratic

You do it simply along the line of this calculator key pad example ... [code]# create a calculator key pad with Tkinter # tested with Python 3.1.2 and Python 2.6.5 # vegaseat try: # Python2 import Tkinter as tk except ImportError: # Python3 import tkinter as tk # needs Python25 …

Member Avatar for vegaseat
0
5K
Member Avatar for lewashby

Your problem is not with app.destroy(), but with track.stop() self.track is an instance name (instance of pygame Sound class) in class SoundPanel and needs to be associated with the proper instance of class SoundPanel like panel1.track.stop(), panel2.track.stop() etc. I took the liberty to play around with your previous program (nice …

Member Avatar for vegaseat
0
2K
Member Avatar for linuxoidoz

Most GUI toolkits have a keyboard option for a button, implemented by the '&' character. So, if your button label is "E&xit", only "Exit" shows on the button. However pressing alt/x on the keyboard will activate the button too. You may not be able to display the '&' on a …

Member Avatar for -ordi-
0
2K
Member Avatar for vulcano224

You are making your life too complicated! You are almost there actually ... [code]def convertToSeconds(hours, minutes, seconds): "Convert time to seconds." return hours * 3600 + minutes * 60 + seconds # give time as a (hours, minutes, seconds) tuple time1 = (8, 30, 0) time2 = (9, 36, 40) …

Member Avatar for vegaseat
0
206
Member Avatar for vulcano224

The problem with Python when you come from C++ is that Python code is just mind-numbingly simple ... [code]def make_square(side): for k in range(side): print('*' * side) make_square(4) [/code]

Member Avatar for vegaseat
-3
182
Member Avatar for lewashby

One error I can see in line 19 of the module ... [B]to 1.0,[/B] should be [B]to = 1.0,[/B]

Member Avatar for vegaseat
0
190
Member Avatar for ITGeEk2020
Member Avatar for Tommymac501

[B]value_list = ['12345'][/B] Here you have a list of one item, you want the item at index zero [B]value_str = value_list[0][/B]

Member Avatar for woooee
0
4K
Member Avatar for rajwant51

Just some advice: When you ask for help you got to be humble. You can't force it! Show us some effort! While you are waiting for an answer, google. There are a lot of these screensaver codes out there.

Member Avatar for karthik_udt
0
258
Member Avatar for lllllIllIlllI

I downloaded PyQt-Py2.5-gpl-4.4.2-1.exe from [url]http://www.riverbankcomputing.co.uk/software/pyqt/download[/url] This binary Windows installer installs well on Windows XP and contains everything you need to use the PyQt GUI toolkit. I downloaded and tried the Eric IDE with it, and it seems to work by simply double clicking on the file Eric.pyw However, I am …

Member Avatar for Tommymac501
0
821
Member Avatar for vegaseat

The code is shamefully short, but here it is. Now you can listen to the many sound files in wave (.wav) format and boing, chirp, chime, bark, booh, laugh and mooh at the people around you.

Member Avatar for jbronen
3
1K
Member Avatar for almostbob
Member Avatar for Ancient Dragon

[QUOTE=Ancient Dragon;1159987][url]http://www.youtube.com/watch?v=LCAdotyM-Eo[/url] Warning: contains GF violence.[/QUOTE]Well, she must have some other redeeming features. Maybe she can cook!

Member Avatar for IT cllge stdnt
2
152
Member Avatar for abhijat

You may also want to look at Henri Bumsfeld's Prime Number Function Improvements (Python) at: [url]http://www.daniweb.com/code/snippet216871.html[/url]

Member Avatar for TrustyTony
0
1K
Member Avatar for lewashby

The pygame.mixer is a required argument in function [B]create_gui(app, mixer, sound_file)[/B] where it is used in code line [B]track = mixer.Sound(sound_file)[/B]

Member Avatar for vegaseat
0
134
Member Avatar for KV305
Member Avatar for vegaseat
0
103
Member Avatar for SgtMe

You are better off using a list of class instances. Python arrays, like C arrays are meant to hold only very limited basic types.

Member Avatar for SgtMe
0
176
Member Avatar for timrichardson
Member Avatar for vegaseat
0
314
Member Avatar for murjam

The first thing that sticks out like a sore thumb is that you are using tabs for indentations. It makes for ugly and troublesome code. Use the standard 4 spaces for indents like most people do.

Member Avatar for TrustyTony
0
157
Member Avatar for abcdr

[QUOTE=abcdr;1285819]nevermind. I got it. here's what I did: [code] def wordReverse(word): acum = "" for ch in word: acum= ((ch)+"\n") + acum print acum [/code][/QUOTE]Great, very nice solution! You can use Python built-in functions to simplify it a little ... [code]def wordReverse(word): for ch in reversed(word): print ch wordReverse("python") [/code]

Member Avatar for TrustyTony
0
196
Member Avatar for kate2mba

[QUOTE=kate2mba;1285854]... My exercise says: Write a function wordPop that accepts a text and a length N and returns the list of all the words that are N letters long, sorted by their length. ... [/QUOTE]According to this, the function has to return only words with the length N, so what …

Member Avatar for kate2mba
0
187
Member Avatar for juzzy

Here would be simple example ... [code]# explore wxPython wx.Frame with # a wx.TextCtrl to enter some text # a wx.Button to start process action # a wx.StaticText to display the result import wx class MyFrame(wx.Frame): def __init__(self, parent, mytitle): wx.Frame.__init__(self, parent, -1, mytitle) self.SetBackgroundColour("yellow") # create some widgets self.edit …

Member Avatar for vegaseat
0
140
Member Avatar for need help!

Hide the root window with: root.withdraw() Bring the root window back up with: root.update() root.deiconify() Remove root window border and title bar with: root.overrideredirect(True) Bring the border and title bar back after 5000 milliseconds: root.after(5000, root.overrideredirect, False)

Member Avatar for hayathms
0
11K
Member Avatar for timrichardson

Python31 includes the Tkinter Tile extension module ttk. Ttk comes with 17 widgets, 11 of which already exist in Tkinter: Button, Checkbutton, Entry, Frame, Label, LabelFrame, Menubutton, PanedWindow, Radiobutton, Scale and Scrollbar The 6 new widget classes are: Combobox, Notebook, Progressbar, Separator, Sizegrip and Treeview You have to do some …

Member Avatar for vegaseat
0
1K
Member Avatar for Tommymac501

Python2 seems to take care of empty lines Python3 needs newline='\n', for instance ... [B]reader = csv.reader(open("some.csv", newline='\n'))[/B]

Member Avatar for Tommymac501
0
2K
Member Avatar for mrnutty

It is simply the effect of entropy on humanity as a whole. Or you might say: [QUOTE]God loves dumb people because He mad so many of them![/QUOTE]

Member Avatar for mrnutty
-1
107
Member Avatar for wolfeater017

There is a slightly more advanced example here: [url]http://www.daniweb.com/forums/post1282201.html#post1282201[/url]

Member Avatar for vegaseat
0
2K
Member Avatar for wolfeater017
Member Avatar for tbone2sk
0
218
Member Avatar for bpatt22

[QUOTE=tonyjv;1273744]Like this seems to work, but I do not know if it is easiest. If you use Python 3, surely there must be cleaner alternative using dictionary comprehensions. [CODE]import operator d1 = dict() d1[0] = 1 d1[1] = 2 d1[2] = 2 maxValue = max(d1) print [key for key in …

Member Avatar for TrustyTony
0
8K
Member Avatar for lewashby

Tkinter is remarkably tolerant, you can use or leave off app in the Scale or Checkbutton widgets. Since there is only one parent, Tkinter figures it out. It is a good habit to put the parent in, just in case there is more than one.

Member Avatar for vegaseat
0
276
Member Avatar for job2

Here is one way to do this using a list of lists ... [code]# example data string obtained from open('test.txt', 'r').read() data_str = """\ My name is x. I am 45 years old. My girlfriends name is y. She is way too old for me. y wears weird clothes. Good …

Member Avatar for TrustyTony
0
140
Member Avatar for Anteater7171

You have to use PIL and Tkinter together. See this blog on the PIL transparency: [url]http://nadiana.com/pil-tutorial-how-create-button-generator[/url]

Member Avatar for ultimatebuster
0
74
Member Avatar for wolfeater017

Maybe this shows you how to package a console program ... [code]""" con_setup.exe Using cx_freeze with Python31 to package a console program to an executable file (.exe in Windows OS). Might want to put a console-wait-line in at the end of your program. Put this setup program and your console …

Member Avatar for wolfeater017
0
1K
Member Avatar for jazzvibes

My hunch, do not install the 64bit version of Python, use the 32bit version. Otherwise, many external modules will not install properly.

Member Avatar for jazzvibes
0
409
Member Avatar for Dragazarth

Just some quick observations: 1) replace recursion with a while loop 2) the way you calculate blah, it will always be that last calculated line [B]blah = cos(radians(x)*9)[/B] 3) don't use math for a function name since it is a module name in Python this will bite you sooner or …

Member Avatar for Dragazarth
0
163
Member Avatar for wolfeater017

If you write a program that needs to load an image file, it is easiest to simply stick a copy of the image file into the same folder that the program works out of.

Member Avatar for vegaseat
0
138

The End.