2,190 Posted Topics

Member Avatar for sindhujavenkat

You don't actually split a widget, you use 2 widgets and pass whatever data back and forth. The following code is not exactly what you want but does show how to pass data from one widget to another. When you click on the 'Edit' button the item you selected is …

Member Avatar for sindhujavenkat
0
180
Member Avatar for jpslayug

First, don't use "file" as a variable name as it is a reserved word. I would guess that the problem may be with counter equal or not equal to one, or not stripping spaces from the name or term. There were some punctuation errors in the code you posted as …

Member Avatar for jpslayug
0
224
Member Avatar for sindhujavenkat

A "How To" is generally sample code on how you do something, so anyone who doesn't want to know how to do this will not even look at the thread. Try a new thread with a more specific title and some sample code. For example, "How would I link two …

Member Avatar for sindhujavenkat
0
146
Member Avatar for Her-o

letters_used and wrong are never incremented. You should be able to tell that from the print letters_used statement. Also, you define letters_used=() (a tuple) and not zero.

Member Avatar for jwenting
0
247
Member Avatar for MacUsers

You have to declare the encoding somewhere. The following works for me on python 3.x. Note that printing to screen is a different matter as some characters will not print depending on the encoding and font for the system. [CODE]#!/usr/bin/python3 # -*- coding: latin-1 -*- y = 'abcdef' + chr(128) …

Member Avatar for Pupo
0
722
Member Avatar for Stubaan

Take a look at any of these [url]http://code.activestate.com/recipes/52250/[/url] [url]http://www.daniweb.com/forums/thread255278.html[/url] [url]http://www.daniweb.com/code/snippet216636.html[/url] [url]http://www.daniweb.com/forums/thread70426.html[/url] [url]http://www.daniweb.com/forums/thread143165.html[/url]

Member Avatar for Stubaan
0
5K
Member Avatar for punter999
Member Avatar for anishakaul

I've only done this once and used html2ps and then ps2png. I am pretty sure that convert within Imagemagick (located here in most distros [URL]file://localhost/usr/share/doc/ImageMagick-6.5.6/www/convert.html[/URL] ) will do it in one step from the command line but you may have to supply additional paramenters like layers, etc.

Member Avatar for anishakaul
0
3K
Member Avatar for ariel.goldstien

We can't help without knowing what encoding your program uses (obviously not the right one). It appears to work fine with the universal utf-8 encoding, see here [url]http://effbot.org/pyfaq/what-does-unicodeerror-ascii-decoding-encoding-error-ordinal-not-in-range-128-mean.htm[/url] [CODE]a = unicode('\u05d0', "utf-8") print a [/CODE]

Member Avatar for ariel.goldstien
0
366
Member Avatar for garyinspringhil

I have this example from somewhere on the web that changes based on the slider value. You are interested in the moveSlider and valueChanged functions. Sorry, I didn't note where i came from. Edit: Just noticed that you are using Qt3, so try this program instead. I don't have Qt3 …

Member Avatar for woooee
0
154
Member Avatar for nomemory

Works fine for me (using the following stripped down version). You should include the actual error when posting; it is not always what you think it means. [CODE]class Card(): SUIT = { 'C':'Clubs', 'D':'Diamonds', 'H':'Hearts', 'S':'Spades' } VALUES = { '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9, \ '10':10, …

Member Avatar for nomemory
0
400
Member Avatar for axa121

I think you want to use new_sentence (and is one of the positive results of posting code). [CODE]def wordFrequences(new_sentence): wordFreq = {} ## new_sentence was not defined split_sentence = new_sentence.split() for word in split_sentence: wordFreq[word] = wordFreq.get(word,0) + 1 wordFreq.items() print wordFreq sentence = "The first test of the function" …

Member Avatar for woooee
0
3K
Member Avatar for d8m9

Use startswith() on each record to test for <HEADLINE and the string find function to locate the double quotation marks.

Member Avatar for snippsat
0
139
Member Avatar for bharatk

[QUOTE]if I could do something like sort all values[/QUOTE]Try a normal list sort and then print it to see if it is in the order you want. You can then go through the list item by item, and if the first letter of this word is different from the first …

Member Avatar for woooee
0
145
Member Avatar for evilweasel_47
Member Avatar for woooee
0
109
Member Avatar for Cjreynol

[QUOTE]print "\n\t", board[0], "|", board[1], "|", board[2] IndexError: list index out of range[/QUOTE]Add a print len(board) as the first statement in the function to see if your list contains 9 items (and of course it doesn't, but this will tell you how many items it does contain).

Member Avatar for woooee
0
79
Member Avatar for ELBUF

print score(0,-9) will trigger the last return in this block of code, because x=0. Note that the "y" portion of the code will never be reached, because any value of x will result in a return from the function. [CODE] if x>15 or x<-15: print "Out of Bounds, No Points" …

Member Avatar for ELBUF
0
5K
Member Avatar for yemu

A second for the use of SQLite, then you can select where sex=='Male', etc. If you want to keep your original structure, a dictionary of lists might work better, with each position in the list holding a specitic data value. exp_dict[Exp#] = [sex, age_band, type_of treatment] Otherwise, you would want …

Member Avatar for vegaseat
1
125
Member Avatar for ds2000

[QUOTE]TypeError: __add__ nor __radd__ defined for these operands [/QUOTE]The error could be here because of backticks print "Adding strTest to Array " + `unDepSuccess` Also, you can not concatenate a string and a list (I'm assuming it is a list because you append to it). print "Printing unDepSuccess " + …

Member Avatar for woooee
0
226
Member Avatar for eva yang

t.play(toy) doesn't have a return, which means it returns None, so print 'Yip! ' + str(t.play(toy)) prints "Yip!None" Try [CODE]print 'Yip!', t.play(toy) # # or class Toy(object): def play(self, toy, lit): '''Print squeak''' print lit+'Squeak!' t.play(toy, 'YIP!') ## note that 'toy' is not used anywhere # # or class Toy(object): …

Member Avatar for eva yang
0
92
Member Avatar for fuston05

spell = [] defines an empty list on every pass through the loop. You want it before the while(). Also, your code is an infinite loop, i.e. there is no exit.

Member Avatar for fuston05
0
111
Member Avatar for kadvar

I am not a user (of regex's) so would do something like the following. You might prefer to find the first "&" and slice from there instead of using split and join. [CODE]test_data = ["sometext herekeywords=walter&keywords=scott", "keywords=john&sometexthere", "keywords=james&keywords=john& keywords=brian&"] delim = 'keywords=' found_list = [] for rec in test_data: ## …

Member Avatar for woooee
0
90
Member Avatar for voolvif

Not using a regex, it would be [CODE]mystring = "00:00:11 192.168.21.44 GET /images/help.gif - 200 Mozilla/4.0+(compatible;+MSIE+5.0;+Windows+98;+DigExt) ASPSESSIONIDGGGGGQEG=CLDIHIJBJAPFAGBFIOMCFGGA;+PRO%5FOnline=SEARCHQUERY=%09%3Cinput+type%3Dhidden+name%3D%27HrowColumns%27+ID%3D%27HrowColumns%27++value%3D%271%3B6%27%3E%0D%0A%09%3Cinput+type%3Dhidden+name%3D%27txtScopeData10%27+ID%3D%27txtScopeData10%27++value%3D%27catherine%27%3E%0D%0A%09%3Cinput+type%3Dhidden+name%3D%27txtScopeData30%27+ID%3D%27txtScopeData30%27++value%3D%27porter%27%3E%0D%0A%09%3Cinput+type%3Dhidden+name%3D%27txtScopeData50%27+ID%3D%27txtScopeData50%27++value%3D%27%27%3E%0D%0A%09%3Cinput+type%3Dhidden+name%3D%27txtScopeData11%27+ID%3D%27txtScopeData11%27++value%3D%27%27%3E%0D%0A%09%3Cinput+type%3Dhidden+name%3D%27txtScopeData31%27+ID%3D%27txtScopeData31%27++value%3D%27%27%3E%0D%0A%09%3Cinput+type%3Dhidden+name%3D%27txtScopeData51%27+ID%3D%27txtScopeData51%27++value%3D%27%27%3E%0D%0A%09%3Cinput+type%3Dhidden+name%3D%27HCollection%5Fid%27+ID%3D%27HCollection%5Fid%27++value%3D%271%27%3E%0D%0A%09%3Cinput+type%3Dhidden+name%3D%27Submit1%2Ex%27+ID%3D%27Submit1%2Ex%27++value%3D%2736%27%3E%0D%0A%09%3Cinput+type%3Dhidden+name%3D%27Submit1%2Ey%27+ID%3D%27Submit1%2Ey%27++value%3D%2718%27%3E%0D%0A http://www.foo-bar.com/SearchResult.asp" substrs = mystring.split('++value%3D%27') for s in substrs: if s[0].isalpha(): print s.split("%27") [/CODE]

Member Avatar for bvdet
0
190
Member Avatar for iamai

Bookmark the Python wiki as it is a good place to start for anything Python [url]http://wiki.python.org/moin/[/url]

Member Avatar for vegaseat
0
114
Member Avatar for Zetlin

There are many ways to flatten a list. Here are two. I'm sure a Google would come up with many more. [CODE]a = [[1,2,3], [4,5,6], [7,8,9]] b = [num for sublist in a for num in sublist] print b import itertools c = itertools.chain(*a) print list(c) [/CODE]

Member Avatar for vegaseat
0
115
Member Avatar for TheNational22

Generally, you would use mutiprocessing or threading, with a separate class instance/window running in a separate process or thread.

Member Avatar for woooee
0
175
Member Avatar for shrikant.rails

And you can use a dictionary as a container for all of this, so if you want to change anything, you just add, change, or delete from the dictionary. Your code assumes that just one hit will be found. If there is more than one, "person" will be whatever was …

Member Avatar for shrikant.rails
0
142
Member Avatar for charlottetemp

See if adding this print statement clears things up. You have to compare the same type of variables, i.e. an integer to an integer, etc. [CODE]def Marks(*score): print score, type(score) marks0 = 0 marks1 = 0 marks2 = 0 marks3 = 0 marks4 = 0 marks5 = 0 if score …

Member Avatar for charlottetemp
0
106
Member Avatar for Godflesh

[QUOTE]i mean that if there isnt enough elements to delete in data_list that process should wait until there is enough elements[/QUOTE]Can you just compare the length of data_list to the number of random elements you wish to delete?

Member Avatar for Godflesh
0
315
Member Avatar for gangster88

This function returns on the first pass through the loop. [CODE]def simulateFlips(times): import random heads = 0 tails = 0 for i in range(times): if random.randint(1,2) == 1: heads += 1 else: tails += 1 return (heads, tails) ## it should be return heads, tails [/CODE]Also you have to convert …

Member Avatar for charlottetemp
0
1K
Member Avatar for Godflesh

[QUOTE]the problem is that import queue and import Queue dont work[/QUOTE]In your original example, Queue imported fine. It was the statement calling Queue that was the problem. Try the first two lines of redyugi's example and see what you get.[CODE]from Queue import Queue ##<----- imports fine def main(): ##========================================================= ## …

Member Avatar for Godflesh
0
16K
Member Avatar for lewashby

You have to define glob. Try a google for one of the online books like: "dive into python" glob

Member Avatar for Firewolf
0
842
Member Avatar for Godflesh

[QUOTE] I dont want to remove the old data in the file just add new data to it?[/QUOTE]Opening a file in write mode creates new file. You want to open in append mode. A Google for 'Python file append' will give all the info you want to know. [CODE]import random …

Member Avatar for Godflesh
0
85
Member Avatar for digitaldust

Do you have to find up and down as well? If North is (5,5), and you are using a dictionary, you can easily look up (5,7) etc. instead of the list comprehension. print coord_dict[(5,7)] instead of East = [e.color for e in objectList if (e.coord[0] == object.coord[0] + 2 and …

Member Avatar for woooee
0
145
Member Avatar for greatkraw

Works fine for me as well. I get 7 entries at the end. [CODE]studRoll = [] def GetInteger(i): try: return int(i) except: return 0 class stud: def __init__(self, a, n, m): self.age = a self.name = n self.mark = m def ShowRoll(): for stud in studRoll: print "\n\n\n>>>> Student Roll …

Member Avatar for woooee
0
109
Member Avatar for zrin

[QUOTE]I forgot, the reset button has to reset all, exept for one label that cuntes victories.[/QUOTE]You can delete all items from the listbox and then re-insert the victory counter. listbox.delete(0, END) ## deletes all items listbox.insert(END, newitem)

Member Avatar for zrin
0
111
Member Avatar for bryancan

[QUOTE]Here is what I WANT to echo to a file: [ $(date +\%d) -eq $(echo $(cal) | awk '{print $NF}') ] &&[/QUOTE]The brace, "}", is some kind of an escape character but I don't remember the particulars. Perhaps something like mes = "$(date +\%d) -eq $(echo $(cal) | awk '{print …

Member Avatar for woooee
0
108
Member Avatar for deonis

As Namibnat has already stated, it depends on what you are using to print it. Obviously, if you are printing in the terminal you are limited to ASCII characters and can not do it, as you stated yourself, so you will have to be more specific than just stating that …

Member Avatar for deonis
0
13K
Member Avatar for Techwriter10

The same kind of thing was said when Proctor and Gamble introduced Oxydol in the late 1920s. It competed with Tide, which was then the market leader. Sure enough, Oxydol reduced Tide's market share but the combined market share was greater than Tide's alone.

Member Avatar for maddoghall
0
774
Member Avatar for kc0arf

[QUOTE=jbennet;410507]i like eating and coking favourite things: scones homemade tablet haggis with parsnips and potatoes (mashed) shortbread[/QUOTE]Coking? I though a spell checker would kick that out, but it turns out that coking is the process of making coke while distilling coal. Look at the length of this topic. Perhaps we …

Member Avatar for pogson
0
2K
Member Avatar for SoulMazer

In Linux you have to use an "@" sign in front of the filename, but root.wm_iconbitmap('@'+fname) yields an "error reading bitmap file". I opened it in GIMP and it is fine, and tried ico, gif, and bmp with the same results. This is something that is not critical but we …

Member Avatar for SoulMazer
0
24K
Member Avatar for johnyboy82

For something simple like "ls", use subprocess.call('ls -l /home', shell=True) Doug Hellmann's examples are a good place to start [url]http://blog.doughellmann.com/2007/07/pymotw-subprocess.html[/url]

Member Avatar for woooee
0
132
Member Avatar for Ash_Pokemaster

[QUOTE] Inside this Class, there is another Class[/QUOTE]Why is this necessary. Everything should be in functions inside a single class, or two classes with one calling an instance of the other. [QUOTE]TclError: image "pyimage8" doesn't exist[/QUOTE]You are probably looking in the wrong directory. Use the absolute directory + file name …

Member Avatar for Ash_Pokemaster
0
2K
Member Avatar for deonis

If I understand correctly, you should read a record, look for one of the strings, and print the line. Something like the following should be close to what you want. [CODE]## pass "fin" to the function and avoid the use of globals def CifT(self, fin): pos1 = ["_chemical_formula_moiety", "_chemical_formula_weight", "_symmetry_cell_setting", …

Member Avatar for deonis
0
272
Member Avatar for kbalamuk

string.replace(" nf ","1.0")? Your question is not clear because you show the after but not the before.

Member Avatar for vegaseat
-1
6K
Member Avatar for rehber344

[QUOTE]. how can ı make ı read from command shel (like ı wıll poınt my txt file from the shell and ıt wıll command and read thıs fıle) [/QUOTE] Have you tried something like program.bash > program.py where the output of the shell is the input to the Python program. …

Member Avatar for woooee
0
188
Member Avatar for BlackPhoenix

You want to group the moveUp under one if statement, and the same for moveDown, otherwise moveUp also prints for (moveUp and moveLeft) or (moveUp and moveRight).[COde]if self.moveUp: if self.moveRight: ## moveUp and moveRight print "MOVE UPRIGHT" elif self.moveLeft: ## moveUp and moveLeft print "MOVE UPLEFT" else: ## moveRight and …

Member Avatar for JugglerDrummer
0
308
Member Avatar for El Duke

What type of objects does the query return? You may have to convert to a list to access it in this way. [CODE]query = db.GqlQuery("SELECT *" .....etc. print type(query) ctr = 0 for q in query: if ctr < 2: print type(q) ctr += 1 [/CODE]

Member Avatar for vegaseat
0
139
Member Avatar for gzm_e

Use getpass [QUOTE]Can you help meee???? pleaseeeee=(((( [/QUOTE] Don't know about anyone else, but I ignore any posts with this type of plea, especially when nothing has been tried.

Member Avatar for Stefano Mtangoo
0
76
Member Avatar for pyguy420

Add some print statements so you know what is going on. [CODE]def colourpicker(): print "pick four different colours from; red, green, blue, yellow, orange, pink, brown" colourList = ["red", "green", "blue", "yellow", "orange", "pink", "brown"] coloursPicked = [] while True: colour1 = raw_input("pick first colour: ") print "colour1 picked =", …

Member Avatar for woooee
0
114

The End.