988 Posted Topics
![]() | Re: I have to applaud your teacher for teaching Python rather than the usual "ugly syntax stuff" like C, C++ or Java. Colleges with their all too often ultra conservative teachers are just warming up to Python. So you and your teacher are way ahead! I will be playing around with … |
Re: As far as I know only wxPython has a password option, the Tkinter Entry widget does not. An easy way to get around this, is to give the password entry widget a bg="yellow" and fg="white". This will be very hard to see for a bystander, as you type in the … | |
Re: There is a a Hardware section under DaniWeb TechTalk, that's were the experts are for this project of yours! | |
Re: [QUOTE=~s.o.s~;262041]@ slake Why stick to Borland ??? If you are thinking about compiler migration better go for the free Visual Studio 2005 free edition or for GCC mingw compiler which nowadays most of the people use.[/QUOTE] Why stick to Borland ??? Right on ~s.o.s~! Borland is a sinking ship! The … | |
Re: Works nicely, welcome to GUI programmig! You seemed to have learned quite a bit! Now, you can do a few cosmetic improvements, like making all the buttons the same sice and introducing some color. Just a matter of taste, but I would have lined up all the buttons on top … | |
Re: If you want to use Tkinter to draw some shapes see: [url]http://www.daniweb.com/techtalkforums/post261377-80.html[/url] If you want to display a GIF image with Tkinter see: (for other image formats PIL works with Tkinter) [url]http://www.daniweb.com/code/snippet296.html[/url] If you want to plot a math function you can use VPython: [url]http://www.daniweb.com/code/snippet376.html[/url] | |
Re: Only guys? Using a urinal was part of sorority pledge week! BTW, the guy I worked for during my summer job could in no way see what he was doing! | |
Re: The rules of the Game of Life are wonderfully explained at: [url]http://www.math.com/students/wonders/life/life.html[/url] | |
I don't know how it is in your country, but in the good old USA election time is coming up. I will go to the voting place and look at the slate of sh*t, and whomever I vote for will be, you guess what. Any idea how to change things … | |
Re: How about a database of your senior class. Something you can search for names, phone numbers, addresses, hobbies, aspirations, favorite music and moviestar and so on. Do it right, and you could be a popular person. You could hand it out on graduation day to anyone that contributed. Hope your … | |
Re: In the case of: [code]import random random.randint(5) [/code]random is a module, and you are using the namespace random. Note that random is not a class! To find out if an object is a class use something like this: [code]import inspect if inspect.isclass(object_name): print "object_name is a class" [/code] Generally, Python … | |
Re: The major difference between C++ and Python is that Python compiles source code to byte code and then interprets the byte code. There are programs that combine the byte code with the interpreter and package to an executable for distribution. More and more computers have Python already installed, so you … | |
Re: The integer is the smallest number in Python. [QUOTE]For the purpose of shift and mask operations, integers are assumed to have a binary, 2's complement notation using 32 or more bits, and hiding no bits from the user (i.e., all 4294967296 different bit patterns correspond to different values). [/QUOTE] | |
Re: What do you mean with reversing a hex string? | |
Re: I think we just had a discussion related to the same issue at: [url]http://www.daniweb.com/techtalkforums/thread55436.html[/url] | |
Re: Thanks Jeff, good observation! To bad the Python help never mentions that! If you insist on using fromkeys() you could use a tuple, adding two tuples forms a new tuple and there is no problem: [code]d = dict().fromkeys(range(1,10), ()) print d # {1: (), 2: (), 3: (), 4: (), … | |
Re: I use the DrPython IDE and that one allows me to set arguments like they would come from the command line. Take a look at: [url]http://www.daniweb.com/techtalkforums/post193207-50.html[/url] I have used a default argument under the else, particular for testing a program. | |
Re: Its me, Ene, note that each button ends up executing a function defined in the program. The button uses the command=function statement. The function is activated via its object (ie. just function rng), and not the usual function call (ie. would be rng() ). Also note that rng is not … | |
Re: I enjoyed the flow of this discussion, learned a lot! | |
Re: Take a look at this Python code snippet at: [url]http://www.daniweb.com/code/snippet360.html[/url] It uses a bitwise shift right operator to get the binary representation of an integer. Editor's note: I think we lost the reference when snippets were folded into the regular forum. Looks like Ene refers to ... [code]def denary2binary(n): '''convert … | |
Re: Some C++ books like Deitel&Deitel are full with practice projects of this kind. You might want to post this question on the "C and C++" forum here. Some of the folks there are very helpful! | |
Re: You need to give us more of your code, otherwise this will be an exercise in mind reading! | |
Re: I took the liberty to modify vegaseat's previous example code to show you how buttons would work: [code]from Tkinter import * root = Tk() root.title("Press Button!") def show_image2(): canvas1.create_image(x, y, image=photo2) def show_image3(): canvas1.create_image(x, y, image=photo3) # pick three GIF image files you have in your working directory # image1 … | |
Re: I guess I must be a geek, since I would rather use my computer to write programs and surf the net than watch TV. | |
Re: I agree, Python is fun! Take a look at: [url]http://www.daniweb.com/techtalkforums/post225611-64.html[/url] You can modify this to fit your needs. | |
Re: This seems to work too: [code]a = unichr(88).encode('utf8') b = unichr(257).encode('utf8') c = unichr(109).encode('utf8') d = unichr(258).encode('utf8') print a,b,c,d e = a+b+c+d print e print for c in e: print c print for i in e.decode('utf8'): print ord(i) [/code] | |
Re: Your or statements weren't written correctly. In this case it's simpler to see if the word is in a tuple (or list) of choices: [code]#1337 to Human dictionary: leet = { "1337": "l-EET/nReally Awesome", "noob": "(n00b) nOOb/nPerson who can't accept that s/he's wrong", "-xxors": "Suffix, pron: zors.\nUsed to accent an … | |
Re: Nice code so far! It would be easier on the user, if you only ask the user numbers to be entered once and then run the computer numbers against that! I like your compare, but there is a flaw. Lists [1,2,3,4,5,6] and [1,3,4,5,6,7] should have 5 matches, your compare would … | |
Re: I think bash is a script language on Linux computers. I don't use Linux (yet), so I can't test it, but the program flow is easy to follow. The first part is a menu from which you select, and the second part is a case statement that activates a slected … | |
Re: To make this song challenging you could change part of it: [code]def print_charlieVerse(): print "Charlie was a pidgeon, a pidgeon, a pidgeon." print "Charlie was a pidgeon, a pidgeon that flew." print "He flew in the morning, he flew in the night." print "And when he came home he was … | |
Re: Several problems with your program, I corrected some of them: [code]from Tkinter import * root = Tk() def hello(): print "Hello!" # removed unneeded arguments (metre,cm) def metres_to_centimetres(): metre = input("Put in a distance in metres: ") cm = metre*100 print "Distance in Centimetres = ",cm menubar = Menu(root) filemenu … | |
Re: I think vegaseat meant "Projects for the Beginner" to be for the beginning programmer who understood the basics of Python and wanted to do something with that knowledge. It was probably not meant to be a tutorial, just projects with a few hints thrown in. You are right, why not … | |
| |
Re: Just a few observations, hope you don't mind: 1) Python has True = 1 and False = 0 builtin 2) define your functions outside of the conditional if, or Python will redefine your functions whenever you take a test. This would slow down the program. The memory manager cleans up … | |
Re: See [url]http://www.daniweb.com/techtalkforums/post249267-10.html[/url] | |
Re: Lint Filters give warnings that are not always sensible. Using elif instead of all if is faster, since Python has to evaluate all the if, but stops at the first true elif condition. In your case it doesn't make much difference since you have a return statement, which will stop … | |
Re: You can use function sys.exc_info() to fetch the error created by my_program.py: [code]# save as my_file.py # executes a file my_program.py which has an error from Tkinter import* import sys root=Tk() text=Text() text.pack() try: execfile('my_program.py') except: error = "%s --> %s in file my_program.py"% (sys.exc_info()[0], sys.exc_info()[1]) # put error msg … | |
What is a closure? I keep reading this word in programming, but never got a good explanation. | |
Re: Thanks for thinking out loud, I found it interesting! | |
Re: Once you go to GUI programming, your approach has to change past just making labels. User actions are initiated by clicking on buttons, data is entered in an entry widget, results and messages can be displayed in labels. Get used to callback functions. Also, you might as well start a … | |
Re: Which web framework are you using? Any listed on: [url]http://wiki.python.org/moin/WebFrameworks[/url] | |
Re: I think your trouble comes from the fact that Python itself actually has a module Queue. Rename your module MyQueue.py and it works just fine. This small code shows you all the modules Python has installed: [code]help("modules") [/code] To avoid conflicts give your own modules a prefix like "my"or "My". | |
Re: The answer is: execfile("myfile.py") | |
Re: Wow! Your code is hard to read! See Dani's remarks at: [url]http://www.daniweb.com/techtalkforums/announcement114-3.html[/url] The common way to save data each time you use a program is to save it to a data file. Then bring in the latest saved data each time the program is run. If you want to save … | |
Does anyone have a good example of a wx.FlexGridSizer() application. | |
Is there a way to verify an exit, if you click on the exit symbol on a wxPython frame? | |
Re: You mean something like that: [code]# write out each text containing line # (other than '\n') to a separate file str1 = """sentence one sentence two sentence three """ # write str1 to the test file fout = open("test.txt", "w") fout.write(str1) fout.close() # read the test file as a list … | |
Re: Is that the endangered feline with the short tail? | |
Does Python have a module to display when a file has been last modified? Also, how do you get the file length? | |
Re: I have been in Las Vegas with some friends on the weekend, and the beer or shots are free as long as you play the penny slots. Of course, these folks want you to loosen up and waste your money on their machines or the tables. |
The End.