2,190 Posted Topics

Member Avatar for computerfreak97

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]

Member Avatar for Gribouillis
0
119
Member Avatar for rajivgupta1107

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 …

Member Avatar for woooee
0
103
Member Avatar for eggowaffles

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 …

Member Avatar for mrnutty
0
148
Member Avatar for nickcampbell

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 …

Member Avatar for woooee
0
2K
Member Avatar for mn_kthompson

[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 …

Member Avatar for vegaseat
0
275
Member Avatar for EAnder

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]

Member Avatar for vegaseat
0
821
Member Avatar for hydrobat

[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.

Member Avatar for hydrobat
0
1K
Member Avatar for leegeorg07

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.

Member Avatar for woooee
0
118
Member Avatar for zachabesh

"=" 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 …

Member Avatar for zachabesh
0
102
Member Avatar for mattlew62

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]

Member Avatar for woooee
0
158
Member Avatar for sab786

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] …

Member Avatar for willygstyle
0
147
Member Avatar for pluring

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.

Member Avatar for pluring
0
144
Member Avatar for utefan001

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 …

Member Avatar for vegaseat
0
275
Member Avatar for pynoc

Try here for a comprehensive list [url]http://wiki.python.org/moin/IntegratedDevelopmentEnvironments[/url]

Member Avatar for woooee
0
133
Member Avatar for darangho

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.

Member Avatar for woooee
0
99
Member Avatar for sab786

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 …

Member Avatar for woooee
0
96
Member Avatar for nessa203

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 …

Member Avatar for woooee
0
464
Member Avatar for SoulMazer

[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 …

Member Avatar for SoulMazer
0
4K
Member Avatar for nondecorum

[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 …

Member Avatar for woooee
0
345
Member Avatar for iamthwee

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"

Member Avatar for miesnerd
0
1K
Member Avatar for miesnerd

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.

Member Avatar for Mathhax0r
0
245
Member Avatar for blah32

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 = …

Member Avatar for Gribouillis
0
127
Member Avatar for Mathhax0r

[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 …

Member Avatar for woooee
0
115
Member Avatar for alex-VX

You'll have to post the Tkinter part of the code. There is no root.mainloop() in the code you posted.

Member Avatar for woooee
0
87
Member Avatar for chrischavez

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 …

Member Avatar for woooee
0
201
Member Avatar for romes87

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) …

Member Avatar for romes87
0
3K
Member Avatar for SoulMazer

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 …

Member Avatar for SoulMazer
0
156
Member Avatar for willygstyle

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") …

Member Avatar for willygstyle
0
114
Member Avatar for catcit

[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 …

Member Avatar for woooee
0
240
Member Avatar for Lingson

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]

Member Avatar for Lingson
0
143
Member Avatar for Stefano Mtangoo
Member Avatar for miac09

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 …

Member Avatar for willygstyle
0
159
Member Avatar for sravan953

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.

Member Avatar for woooee
0
94
Member Avatar for sab786

[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 …

Member Avatar for woooee
0
310
Member Avatar for fleem

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 …

Member Avatar for vegaseat
0
129
Member Avatar for shaun.b

[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 …

Member Avatar for woooee
0
449
Member Avatar for ms_kichu

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 …

Member Avatar for woooee
0
115
Member Avatar for sleign

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 …

Member Avatar for woooee
0
387
Member Avatar for atqamar

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 …

Member Avatar for atqamar
0
140
Member Avatar for DrakeMagi

[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 …

Member Avatar for DrakeMagi
0
116
Member Avatar for gertblue

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 …

Member Avatar for woooee
0
164
Member Avatar for meyer7

[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 …

Member Avatar for woooee
0
147
Member Avatar for tomtetlaw

[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 …

Member Avatar for Clueless86
0
174
Member Avatar for hughesadam_87

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, …

Member Avatar for jlm699
0
157
Member Avatar for sab786

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 …

Member Avatar for gnujohn
0
89
Member Avatar for Clueless86

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 …

Member Avatar for shadwickman
0
315
Member Avatar for sriramaam

[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 …

Member Avatar for sriramaam
0
136
Member Avatar for MediocreGopher

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. …

Member Avatar for MediocreGopher
0
83
Member Avatar for sab786

[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 …

Member Avatar for woooee
0
85
Member Avatar for foosion

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 …

Member Avatar for foosion
0
203

The End.