2,190 Posted Topics
![]() | Re: TkSnack is one of the simpliest [url]http://www.daniweb.com/code/snippet414.html[/url] Also, try the Python Music wiki [url]http://wiki.python.org/moin/PythonInMusic[/url] |
Re: You can use "lsof" (list open files) but that gives a huge amount of data since it will list any and all system files, etc. as well. [QUOTE]The application cannot generate any indication of completion of the process.[/QUOTE]Why not? That is the standard way of doing things. Processes are meant … | |
Re: I didn't spend a lot of time on the code, but best move should be similiar to legal move. IMHO this should be implemented as a class. That would avoid the gobal variables and make the code cleaner. But you may not have gotten into creating classes yet. Also, the … | |
Re: Doing this in memory is definitely the way to go. It could be 1000 times faster. Putting 17,000 records into memory is not a big deal in today's world. If each of the records is 100 bytes long, then you have 1,700,000 bytes. If your computer has 2 gig of … | |
Re: [QUOTE] if you want to make a super amazingly quick program and it had to be in python then maybe this could even matter (i doubt it)[/QUOTE]I doubt it as well. I view the "function calls are expensive" as someone trying to impress with how much they know. Function calls … | |
Re: Tix, additional widgets for tkinter, has a notebook that may or may not help. The code is available from here [url]http://tix.sourceforge.net/dist/current/man/html/TixCmd/TixIntro.htm#M28[/url] | |
Re: [QUOTE]I thought old_leader was assigned in the constructor?[/QUOTE]Look again. You declared self.old_leader, so what is the difference in a class structure between self.old_leader and just old_leader. | |
![]() | Re: Please post the error message to avoid this type of "looking for 'not in' as bad syntax when it is really a colon" errors. Same thing for "not in" is a bad descriptor. The error message probably has other info which possibly points to "never_save.readlines()" as the real problem. |
Re: "=" means they are equal, i.e. the same memory address, so when you change one, you change the memory that they both point to. You can instead use: a = [1,2,3] b = a[:] ## copy all of the elements in "a" to a new block of memory Also, there … | |
Re: I think you are looking for subprocess.call() if you just want to run the program "tasklist.exe", instead of using "print". See here [url]http://blog.doughellmann.com/2007/07/pymotw-subprocess.html[/url] | |
Re: Store the record number in the dictionary, (this code was not tested)[CODE]match={} for rec_num, values in enumerate(lines): truple=(values[0], values[2], values[3]) if not match.has_key(truple): match[truple] =[] match[truple].append(rec_num) for key in match.keys(): if len(match[key]) > 1: print "more than one record found for", match[key] for rec_num in match[key]: print " ", lines[rec_num] … | |
Re: I would suggest using lsusb, but this will list all usb devices, so if you have a printer or mouse, or possibly an sda drive, you will have to weed them out. | |
Re: You could try cypes and convert via C, which should be a lot faster. Also note the surprising difference when using the decimal class below.[CODE]import decimal import datetime #**setup part** j = 0 myint = 1 while j < 100000: j = j + 1 myint = myint * 10 … | |
Re: Try here for a comprehensive list [url]http://wiki.python.org/moin/IntegratedDevelopmentEnvironments[/url] | |
Re: According to effbot, you can use wrap=NONE [url]http://www.google.com/search?client=opera&rls=en&q=tkinter+wrap+text&sourceid=opera&ie=utf-8&oe=utf-8[/url] I've never used it though. | |
Re: Please don't double post. Stick with one thread and mark the other "Closed" or "Solved". And a title like "someone please help!!!!!!!!!!" will get less responses not more. It does not state a specific problem and indicates someone who is looking for someone to write free programs for them. The … | |
Re: The problem is here rows = [0] * x run the following code and see what you get[CODE]rows = [0] * x for row in rows: print id(row) ## ## you should see that all of the memory addresses are the same ## meaning that you have the same object … | |
Re: [QUOTE]is there a way to make a scrollbar widget automatically scroll to the bottom?[/QUOTE]Use scrollbar.config () scrollbar.config( command = listbox_widget.yview ) listbox_widget.see(listbox_widget.size()) I think it is something like this for a text widget Text.see(Text.END) [QUOTE]in a Text widget, how would I be able to make everything...colored[/QUOTE]Most all of Tkinter's widget's … | |
Re: [QUOTE]I have a log which keeps IP of the visitors of my blog[/QUOTE]Start with file open and readlines to get the file into memory. Then decide how you are going to identify an IP address. If it is the only thing on the line that has digits, or is always … | |
![]() | Re: Off-topic, how can I join the F-ugly code club? Whenever someone touts a program written in "pure python" I wonder if that means that my programs are in impure python. Maybe a support group would help: "Hello, my name is Joe and I write ugly code" |
Re: See the last post in this thread [url]http://www.daniweb.com/forums/thread210760.html[/url] It has links to reading files and online starter books for Python. | |
Re: What is in entry_list, class instances? The simple solution is to create a list of lists with each sub-list containing [field_to_sort, class_instance] and just use the built in sort method. [QUOTE]sorted_ent_list = entry_list.sort(key=entry_T.get_word())[/QUOTE]If entry_list is a list of class instances, then you would have to use something like sorted_ent_list = … | |
Re: [QUOTE](like green, or hasPerson) that I'd like to be able to filter the list with.[/QUOTE]Use a dictionary of lists, with the key being "green" or whatever, pointing to those pictures. You can then send all of the lists in the dictionary, or just the list for one key, to the … | |
Re: You'll have to post the Tkinter part of the code. There is no root.mainloop() in the code you posted. | |
Re: Computers are faster than serial ports, so you are probably getting several reads (and processing) the same data more than once, and reading and trying to process the null between each piece of data. For serial reads you want to do something like this pseudo code: [CODE]port_read = False data … | |
Re: There is no difference, as far a calling a function goes, between calling a function within or without a program. The following works for me with the calc() function contained in the same program file.[CODE]from Tkinter import * def calc(one, two, result): def addition(): add = one + 1 print(add) … | |
Re: It;s just personal preference, but I prefer multiprocessing to threading (If you are using Python2.5 or lower, then you will have to download pyprocessing and substitute "processing" for "multiprocessing" in the code below). [url]http://pyprocessing.berlios.de/[/url] This is just something used to test a dictionary and a list as a way to … | |
Re: Run this piece of code and then take a look at where you can add some print statements to your code so you will know what is actually happening.[CODE]item = "third = 1" if item.find("third"): print "item found at position", item.find("third") else: print "item NOT found, value returned =", item.find("third") … | |
Re: [QUOTE]2. Is there any way to convert it to read only? Normally the user is able to modify the text but I want it to be read only.[/QUOTE]Use the codebox "Display some text in a monospaced font, with no line wrapping. This function is suitable for displaying code and text … | |
Re: You can use the decimal module if you want very, very precise results [url]http://docs.python.org/library/decimal.html#quick-start-tutorial[/url] One of the hits from a search on this forum [url]http://www.daniweb.com/forums/thread95473.html[/url] | |
Re: You have to commit self.conn.commit() after the adds | |
Re: There are two problems while True: x=f.readlines() You read the entire file on every loop, so you willl always get the first rec of the newly read list. if not x: break x.next() This may exit if you have any blank lines in the file. Instead, you want to loop … | |
![]() | Re: You should state what you are trying to accomplish and perhaps someone will help with that. We are not your personal answering machine. Please don't waste everyone's time. |
Re: [QUOTE]please has anyone got any suggestions im still stuck[/QUOTE]Suggestions about what? If you want 100 random samples, then you can select the dictionary's keys randomly.[CODE]import random ##--- create dictionary with 1000 keys test_data_d = {} for j in range(1001, 2001): test_data_d[j] = "data for key %d" % (j) ##--- keys_list … | |
Re: I tried last night (about 12 hours ago) and it was down then. It is still down this morning. It is hosted in the Netherlands, so I doubt it's connected to the Twitter/Facebook stuff. I also Googled for mirrors, but Python doesn't host mirrors anymore. Too bad. Of course this … | |
Re: [QUOTE]the next job is to create a search function which would allow someone to search for flights which fly on a certain day, and then it would bring up all the corresponding flights and thier details (e.g flight times etc)[/QUOTE]How are you going to do this? You have a list … | |
Re: Break the file into groups that start with the "define host" record So, you want to append each record to a list, but first: If "define host" is found in the record then send the list to a function to process it (test for 'nod3001' and/or the IP address, and … | |
Re: You haven't recieved many answers, and probably won't because your examples are incomplete. You are obviously doing something in the code that is not posted that alters the result. Take a look at the following code that is a complete program that can be run. It shows that your contention … | |
Re: This may or may not help. First you want to find out if 2 circles do intersect. You can find the distance from the center of circle A to the center of circle B by constructing a right triangle. If (radius_A + radius_B) is greater than the distance you have … | |
Re: [QUOTE]3. For Linux . What the difference between ( #! = user/bin/python , #! = user/bin/env python) ?[/QUOTE]"/usr/bin/python' looks for the python executable in /usr/bin "/usr/bin/env python" searches the environment ($PATH) for the python executable[QUOTE]2. How to make path for Linux ? using user ?[/QUOTE]Do you mean you want add … | |
Re: You can use readlines() to read the entire file into a list and then access it any way you want.[CODE]input_data = open(file_name, "r").readlines() stop = len(input_data) for ctr in range(0, stop): print "This record is", ctr, input_data[ctr] if ctr+1 < stop: print "Next record is", ctr+1, input_data[ctr+1], "\n"[/CODE]Note that you … | |
Re: [QUOTE]These exist in /usr/local/lib/Python2.5 and /usr/local/lib/Python2.6 Also in /usr/local/lib exists Tcl8.5 and Tk8.5[/QUOTE]/uar/local/lib is not always in $PATH (enter $PATH in the terminal and see what prints). You can key in export PATH=$PATH:/usr/lib/:/usr/local/lib:/usr/local/bin or whatever you want to add, and also add that line to the ~/.bashrc file so it … | |
Re: [QUOTE] File "E:\Tom's Personal Project\src\gamemain.py", line 44, in attack ****************************************************** menus.combat_menu(enemy, player, self) ****************************************************** TypeError: combat_menu() takes exactly 5 arguments (4 given[/QUOTE]combat_menu is defined as def combat_menu(self, enemy, player, actions, menus): The error message says that you only sent it 3 args (+ the class's self) and only two of … | |
Re: Not that I know of. You would have to use a dictionary with the integer as a key, with the value being a counter integer that you would increment each time. There is a count function for lists that would return the number of times something occurs in a list, … | |
Re: This is pretty straight forward and done quite often. It assumes, of course, that the file is already in a sorted order. First, declare an empty list to store the records in. Read the file one record at a time and extract the two fields you want to compare. If … | |
Re: Whne do you declare x and what happens if it is the first time through and x is empty (it will never process no matter how many times you run it because of "if x:"). Generally "gold" is passed as an iteger to the function and returned. This example subtracts … | |
Re: [QUOTE]Did you ever thought of doing your work yourself? I could find the recipe from active state[/QUOTE]Obviously not (something like "This is __not__ freeprograms.com" should be displayed prominently on the website). I try to follow the rule that when a question is asked with words, I respond with words. And … | |
Re: I would suggest declaring the variable in the main class and passing that class's instance to the other classes so they have access to it, or using a separate class for variables and then passing that instance to it, which is essentially the same thing. See the second example below. … | |
Re: [QUOTE]and so on until the last line is my fully sorted data[/QUOTE]No way to tell without any code. For example, what is "sort_ouput"? It appears to be a function, but then it would be "sort_output()". It also appears that you are printing the record and then adding it to the … | |
Re: You use a Tkinter.StringVar(). This is not what you are doing, but a program I have lying around. The string variable is attached to both the entry box and the label, so they change as the StringVar changes.[CODE]import Tkinter class EntryTest: def __init__(self): self.top = Tkinter.Tk() self.str_1 = Tkinter.StringVar() label_lit … |
The End.