woooee 814 Nearly a Posting Maven

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

woooee 814 Nearly a Posting Maven

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

woooee 814 Nearly a Posting Maven

You would use hide() instead. If you want to keep track of separate dialogs, then you will have to store each one in a list, or somewhere, so you can access them individually. I have no time at the present to look at it further but running this example from the PyQt docs might help as I think it does what you are trying to do.

"""PyQt4 port of the dialogs/simplewizard example from Qt v4.x"""

import sys
from PyQt4 import QtCore, QtGui


class SimpleWizard(QtGui.QDialog):
    def __init__(self, parent=None):
        QtGui.QDialog.__init__(self, parent)

        self.history = []
        self.numPages = 0
        
        self.cancelButton = QtGui.QPushButton(self.tr("Cancel"))
        self.backButton = QtGui.QPushButton(self.tr("< &Back"))
        self.nextButton = QtGui.QPushButton(self.tr("Next >"))
        self.finishButton = QtGui.QPushButton(self.tr("&Finish"))
    
        self.connect(self.cancelButton, QtCore.SIGNAL("clicked()"), self, QtCore.SLOT("reject()"))
        self.connect(self.backButton, QtCore.SIGNAL("clicked()"), self.backButtonClicked)
        self.connect(self.nextButton, QtCore.SIGNAL("clicked()"), self.nextButtonClicked)
        self.connect(self.finishButton, QtCore.SIGNAL("clicked()"), self, QtCore.SLOT("accept()"))
    
        buttonLayout = QtGui.QHBoxLayout()
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(self.cancelButton)
        buttonLayout.addWidget(self.backButton)
        buttonLayout.addWidget(self.nextButton)
        buttonLayout.addWidget(self.finishButton)
    
        self.mainLayout = QtGui.QVBoxLayout()
        self.mainLayout.addLayout(buttonLayout)
        self.setLayout(self.mainLayout)

    def setButtonEnabled(self, enable):
        if len(self.history) == self.numPages:
            self.finishButton.setEnabled(enable)
        else:
            self.nextButton.setEnabled(enable)

    def setNumPages(self, n):
        self.numPages = n
        self.history.append(self.createPage(0))
        self.switchPage(0)

    def backButtonClicked(self):
        self.nextButton.setEnabled(True)
        self.finishButton.setEnabled(True)
    
        oldPage = self.history.pop()
        self.switchPage(oldPage)
        del oldPage

    def nextButtonClicked(self):
        self.nextButton.setEnabled(True)
        self.finishButton.setEnabled(len(self.history) == self.numPages - 1)
    
        oldPage = self.history[-1]
        self.history.append(self.createPage(len(self.history)))
        self.switchPage(oldPage)

    def switchPage(self, oldPage):
        if oldPage:
            oldPage.hide()
            self.mainLayout.removeWidget(oldPage)

        newPage = self.history[-1]
        self.mainLayout.insertWidget(0, newPage)
        newPage.show()
        newPage.setFocus()
    
        self.backButton.setEnabled(len(self.history) != 1)
        if len(self.history) == self.numPages:
            self.nextButton.setEnabled(False)
            self.finishButton.setDefault(True)
        else:
            self.nextButton.setDefault(True)
            self.finishButton.setEnabled(False)

        self.setWindowTitle(self.tr("Simple Wizard - Step %1 of %2")
                                    .arg(len(self.history)).arg(self.numPages))
                       

class ClassWizard(SimpleWizard):
    def __init__(self, parent=None):
        SimpleWizard.__init__(self, parent)

        self.setNumPages(3)

    def createPage(self, index):
        if index == 0:
            self.firstPage = FirstPage(self)
            return self.firstPage
        elif index == 1:
            self.secondPage = SecondPage(self)
            return self.secondPage
        elif index == 2:
            self.thirdPage = ThirdPage(self)
            return self.thirdPage …
woooee 814 Nearly a Posting Maven

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 found last.

test_dict = {}
test_dict['Arts'] = 'person1'
test_dict['Book'] = 'person2'
test_dict['Learning'] = 'person3'
if system == 'Conferences':
    person = ""
    for key in test_dict:
        if key in communities:
            person = test_dict[key]
    if len(person):     ## something was found
        assignedtomatrix[system]['Third'] = person
woooee 814 Nearly a Posting Maven

I would just add a self.close(), but that seems too easy so I guess that I still don't understand.

from PyQt4 import QtCore, QtGui
 
class Ui_Login(QtGui.QDialog):
 
    def __init__(self,parent=None):
        QtGui.QDialog.__init__(self,parent)
        self.setObjectName("Login")
        self.resize(550, 340)
        self.button=QtGui.QPushButton(self)
        self.button.setGeometry(250,170,70,25)
        self.button.setText("Press Me")
 
        self.show()
        QtCore.QObject.connect(self.button,QtCore.SIGNAL('clicked()'),self.showNextDlg)
        QtCore.QMetaObject.connectSlotsByName(self)
 
    def closeEvent(self,event):
        print('Inside Close Event of Parent Window')        
 
    def showNextDlg(self):
        ## ----------  added
        self.close()
        self.newAccCreation=QtGui.QDialog(self)
        self.newAccCreation.setObjectName("Dialog")
        self.newAccCreation.resize(550, 340)
        self.newAccCreation.show()
 
if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    loginScreen = Ui_Login()
    sys.exit(app.exec_())
woooee 814 Nearly a Posting Maven

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.

def Marks(*score):
    print score, type(score)
    marks0 = 0
    marks1 = 0
    marks2 = 0
    marks3 = 0
    marks4 = 0
    marks5 = 0

    if score == 0:
        marks0 = marks0+1
    elif score == 1:
        marks1 = marks1+1
    elif score == 2:
        marks2 = marks2+1
    elif score == 3:
        marks3 = marks3+1
    elif score == 4:
        marks4 = marks4+1
    elif score == 5:
        marks5 = marks5+1

    print "0 marks scored by", marks0 , "people."
    print "1 mark scored by", marks1 , "people."
    print "2 marks scored by", marks2 , "people."
    print "3 marks scored by", marks3 , "people."
    print "4 marks scored by", marks4 , "people."
    print "5 marks scored by", marks5 , "people."

Marks(1)

Also you can use a list instead of 6 variables.

def Marks(*score_input):
    marks_list = [0, 0, 0, 0, 0, 0]
    for score in score_input:
        if score < 6:
            marks_list[score] += 1
        else:
            print "Bogus score entered ----->", score

    for score in range(6):
        print "%s marks scored by %d people." % \
                 (score, marks_list[score])

Marks(1, 3, 3, 7, 5)
vegaseat commented: very helpful +10
woooee 814 Nearly a Posting Maven

The return statement is still in the wrong place. You return from the function after the first flip. See Vegaseat's or my previous post.

woooee 814 Nearly a Posting Maven

I tried that but it didnt work out..

Post the code that you are using.

woooee 814 Nearly a Posting Maven

After navigating to dialog2 if i press close button in Dialog2, Dialog2 is closed but Dialog1 is displayed.

You should be able to close everything, otherwise you have to close dialog1 and close dialog2 within the same function.

## to close everything
    self.connect(self.pushButton, QtCore.SIGNAL('clicked()'), self.button_clicked)

    def button_clicked(self):
        print "close the window"
        self.close()

You'll have to post some example code for anything more specific.

woooee 814 Nearly a Posting Maven

i mean that if there isnt enough elements to delete in data_list that process should wait until there is enough elements

Can you just compare the length of data_list to the number of random elements you wish to delete?

woooee 814 Nearly a Posting Maven

This function returns on the first pass through the loop.

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

Also you have to convert to a float when dividing
print (float(heads)/times*100), "Heads Probability."
and pass "times" to the function displayResults.

woooee 814 Nearly a Posting Maven

the problem is that import queue and import Queue dont work

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.

from Queue import Queue   ##<----- imports fine
def main():
 
   ##=========================================================
   ## line 19 (here) is the problem
    q = Queue.Queue()....

Traceback (most recent call last):
File "D:\Python26\test.py", line 166, in <module>
main()
##=========================================================
## line 19 (here) is the problem
File "D:\Python26\test.py", line 19, in main
q = Queue.Queue()
AttributeError: class Queue has no attribute 'Queue'
woooee 814 Nearly a Posting Maven

The Earth is now considered to be somewhere around 5 billion years old, and inhabited by people for around 200,000 years. It would be interesting to know when the Earth is considered to be the Earth and not a bunch of stuff being pulled together.

woooee 814 Nearly a Posting Maven

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

woooee 814 Nearly a Posting Maven

Good to hear. Please mark the post as solved. If you have more problems, start a new thread.

woooee 814 Nearly a Posting Maven

I dont want to remove the old data in the file just add new data to it?

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.

import random
testfil=file("testfil.txt","r")      ## opened for reading once only
fp_out = open('testfil.new', "a")
n = 10
for rad in testfil:
    if  n >= 0:
        x = random.randrange(0,100,1)
        print rad, x
        fp_out.write("%d\n" % (x))
        n = n-1
       
## file closed once only, not once for every loop
testfil.close()
fp_out.close()
woooee 814 Nearly a Posting Maven

Works fine for me as well. I get 7 entries at the end.

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 List <<<"
      print (stud.age,"-",stud.name,"-",stud.mark)

def AppendStudent(age,name,mark):
   global studRoll
   a = int(age)
   n = "" + name
   m = int(mark)
   s = stud(a,n,m)
   print "---------------B4", a, n, m
   ShowRoll()
   studRoll.append(s)
##   s = None
   print "after" + "/" *30
   ShowRoll()

def AppendStudentObject(s):
   global studRoll
   studRoll.append(s)


print "****************** START OF RUN *******************"

ShowRoll()

AppendStudent (1,"A",2)
AppendStudent (2,"b",4)
AppendStudent (3,"c",6)

studage=50
studname="kathleen"
studmark=90
AppendStudent (studage,studname,studmark)

s1=stud(4,"44",4)
s2=stud(5,"55",5)
s3=stud(6,"66",6)

AppendStudentObject(s1)
AppendStudentObject(s2)
AppendStudentObject(s3)

ShowRoll()

print "="*60
print "length =", len(studRoll)
woooee 814 Nearly a Posting Maven

I forgot, the reset button has to reset all, exept for one label that cuntes victories.

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)

woooee 814 Nearly a Posting Maven

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 e.coord[1] == object.coord[1])]

You will add one and subtract one from the first number, and do the same for the second, giving you the four neighbors (if you don't want up or down = 6 directions). And are you sure that you want +2 instead of +1? Again, if North is (5,5) and you are looking for (5,7), what is (5,6)? Finally, if all else fails, store the neighbors coordinates in another dictionary so you can look up the original coordinate, and it will point to a list of the coordinates of all neighbors.

woooee 814 Nearly a Posting Maven

Here is what I WANT to echo to a file:
[ $(date +\%d) -eq $(echo $(cal) | awk '{print $NF}') ] &&

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 $NF}" + "') ] &&"
or you may have to get ridiculous with something like the following as braces can be some sort of substitution; again I don't remember the particulars.
mes = "$(date +\%d) -eq $(echo $(cal) | awk '" + "{" + "print $NF" + "}" + "') ] &&"
would work. Also try a double brace, "}}" to see what happens as it appears to work as it should on my machine, Python 2.6.3 on Slackware64.

woooee 814 Nearly a Posting Maven

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 you want to print it, as each printing mechanism has it's own, different way of displaying text. So far, you are just wasting everyone's time.

woooee 814 Nearly a Posting Maven

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.

woooee 814 Nearly a Posting Maven

Replace this

def show(comp_board):
    print """_____________________________________________
|===|_0_|_1_|_2_|_3_|_4_|_5_|_6_|_7_|_8_|_9_|
|_A_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|""" %(comp_board[0][0], comp_board[0][1], comp_board[0][2], comp_board[0][3], comp_board[0][4], comp_board[0][5], comp_board[0][6], comp_board[0][7], comp_board[0][8], comp_board[0][9])
    print "|_B_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|" %(comp_board[1][0], comp_board[1][1], comp_board[1][2], comp_board[1][3], comp_board[1][4], comp_board[1][5], comp_board[1][6], comp_board[1][7], comp_board[1][8], comp_board[1][9])
    print "|_C_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|" %(comp_board[2][0], comp_board[2][1], comp_board[2][2], comp_board[2][3], comp_board[2][4], comp_board[2][5], comp_board[2][6], comp_board[2][7], comp_board[2][8], comp_board[2][9])
    print "|_D_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|" %(comp_board[3][0], comp_board[3][1], comp_board[3][2], comp_board[3][3], comp_board[3][4], comp_board[3][5], comp_board[3][6], comp_board[3][7], comp_board[3][8], comp_board[3][9])
    print "|_E_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|" %(comp_board[4][0], comp_board[4][1], comp_board[4][2], comp_board[4][3], comp_board[4][4], comp_board[4][5], comp_board[4][6], comp_board[4][7], comp_board[4][8], comp_board[4][9])
    print "|_F_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|" %(comp_board[5][0], comp_board[5][1], comp_board[5][2], comp_board[5][3], comp_board[5][4], comp_board[5][5], comp_board[5][6], comp_board[5][7], comp_board[5][8], comp_board[5][9])
    print "|_G_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|" %(comp_board[6][0], comp_board[6][1], comp_board[6][2], comp_board[6][3], comp_board[6][4], comp_board[6][5], comp_board[6][6], comp_board[6][7], comp_board[6][8], comp_board[6][9])
    print "|_H_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|" %(comp_board[7][0], comp_board[7][1], comp_board[7][2], comp_board[7][3], comp_board[7][4], comp_board[7][5], comp_board[7][6], comp_board[7][7], comp_board[7][8], comp_board[7][9])
    print "|_I_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|" %(comp_board[8][0], comp_board[8][1], comp_board[8][2], comp_board[8][3], comp_board[8][4], comp_board[8][5], comp_board[8][6], comp_board[8][7], comp_board[8][8], comp_board[8][9])
    print "|_J_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|_%s_|" %(comp_board[9][0], comp_board[9][1], comp_board[9][2], comp_board[9][3], comp_board[9][4], comp_board[9][5], comp_board[9][6], comp_board[9][7], comp_board[9][8], comp_board[9][9])

with

letters = [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J' ]
print "_____________________________________________"
print "|===|_0_|_1_|_2_|_3_|_4_|_5_|_6_|_7_|_8_|_9_|"
for x in range(0, 10):
    str_print = "|_%s_|" % (letters[x])
    for y in range(0, 10):
        str_print += "_%s_|" % (comp_board[x][y])
    print str_print

And similiarly

def comp_place2():
    a = 0
    while a == 0:
        comp_placement2(patrol)
        if comp_placement2.a == 1:
            a = 1
        if comp_placement2.a == 0:
            a = 0
    a = 0
    while a == 0:
        comp_placement2(sub)
        if comp_placement2.a == 1:
            a = 1
        if comp_placement2.a == 0:
            a = 0
    a = 0
    while a == 0:
        comp_placement2(destroyer)
        if comp_placement2.a == 1:
            a = 1
        if comp_placement2.a == 0:
            a = 0
    a = 0
    while a == 0:
        comp_placement2(battle)
        if comp_placement2.a …
woooee 814 Nearly a Posting Maven

Spamming is often combined with 'plotting' scams, where areas are divided up into plots. It became popular with the stock market boom in the 20s but is still going strong today. With plotting, an area is divided up into plots, with half of the areas being sent spam saying that the price of gold, or whatever, will go up in the next X days or weeks. The other half gets spam that says the price of gold will go down. At the end of the alloted time, the winning half from the first spamming is divided into two, with one half being sent spam saying the price of silver will go up. The other half of course are told the price of silver will go down. The remaining quarter of the people which received spam that actually proved to be true are then solicited for expensive investment letters based on the success of these 'advisories'.

woooee 814 Nearly a Posting Maven

If you want to source .bash_profile for example, it should work fine. Try it for yourself, but be sure to use shell=True, as it should be done through the shell.

woooee 814 Nearly a Posting Maven

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 should know the solution, so I'll look some more tonight, and perhaps someone else has ideas as well.

Edit: Apparently it has to be an xbm image. I used ImageMagick's convert (convert ./fname.gif ./fname.xbm or do a 'man convert') to change a gif to an xbm an it worked fine with the '@' in front of the file name.

woooee 814 Nearly a Posting Maven

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.

## 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", 
        "_symmetry_space_group_name_H-M ", "_cell_length_a","_cell_length_b", "_cell_length_c", "_cell_angle_alpha",
        "_cell_angle_beta", "_cell_angle_gamma", "_cell_volume", "_cell_formula_units_Z", "_cell_measurement_temperature",
        "_cell_measurement_theta_min", "_cell_measurement_theta_max", "_exptl_absorpt_coefficient_mu", "_diffrn_radiation_type", 
        "_refine_ls_R_factor_all", "_refine_ls_R_factor_gt", "_refine_ls_wR_factor_ref", "_refine_ls_wR_factor_gt", "_refine_ls_goodness_of_fit_ref"]

    for rec_num, rec in enumerate(fin):
        rec = rec.strip()
        start = 0
        for phrase in pos1:
          while 1:
            pos = rec.find(phrase, start)
            if  pos < 0:
              break

            print rec_num, phrase, pos  #print a number of line for each keyword
            print rec
            start = pos + len(phrase)
woooee 814 Nearly a Posting Maven

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

Have you tried something like
program.bash > program.py
where the output of the shell is the input to the Python program. If you want to use popen, take a look at "Reading Output of Another Command" here http://blog.doughellmann.com/2007/07/pymotw-subprocess.html Note that subprocess has replaced os.open.

woooee 814 Nearly a Posting Maven

Does nobody read my posts? \b matches the word boundary. A regexp '\bnf\b' does exactly what the OP wants.

We do read the original post.

also re.sub('\bnf\b', '1.0', str) does not work either as 'nf' can be anywhere in the string.

And as we do not know the before string, or whether or not there is always a "+" associated with it, we have to make assumptions.

woooee 814 Nearly a Posting Maven

Rather tedious, but one more way.

nf_str = 'nf+nfpermult+nf+nf'
ctr = 0
index = -1

go_on = True
while go_on:
   print nf_str
   before = False
   after = False

   index = nf_str.find('nf', index+1)
   if index > -1:
      ## check character before
      if (index == 0) or (not nf_str[index-1].isalpha()):
         before = True

      ## check character after
      if (index+2 >= len(nf_str)) or \
         (not nf_str[index+2].isalpha()):
         after = True

      if before and after:   ## neither is alpha
         nf_str = nf_str[:index] + "1.0" + nf_str[index+2:]

   else:          ## 'nf' not found
      go_on = False
   ctr += 1

print nf_str 

"""  my results
nf+nfpermult+nf+nf
1.0+nfpermult+nf+nf
1.0+nfpermult+nf+nf
1.0+nfpermult+1.0+nf
1.0+nfpermult+1.0+1.0
1.0+nfpermult+1.0+1.0
"""
woooee 814 Nearly a Posting Maven

string.replace(" nf ","1.0")?

Your question is not clear because you show the after but not the before.

woooee 814 Nearly a Posting Maven

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

if self.moveUp:
    if self.moveRight:      ## moveUp and moveRight
        print "MOVE UPRIGHT"
    elif self.moveLeft:     ## moveUp and moveLeft
        print "MOVE UPLEFT"
    else:                 ## moveRight and moveLeft both = False
        print "MOVE UP"

And I would use a dictionary to contain everything, which would also show errors, if up and down were both true for example, which your original code would not catch as an error. In the example below, the self.moveRIght, etc. fields are kept for illustration only. You would probably use a tuple, as in the down+right test, and eliminate all of the self.moveLeft, etc. as they would be redundant.

class TestMove:
    def __init__(self):
        self.initialize_test_dict()

        ## test left
        self.initialize_to_false()
        self.moveLeft = True
        self.print_result()

        ## test left, up
        self.initialize_to_false()
        self.moveLeft = True
        self.moveUp = True
        self.print_result()

        self.initialize_to_false()

        ## test down, right
        test_tuple = (False, True, False, True)
        self.dictionary_lookup(test_tuple)

    def dictionary_lookup(self, test_tuple):
        if test_tuple in self.test_dict:
            print self.test_dict[test_tuple]
        else:
            print test_tuple, "is not a legal move"


    def initialize_to_false(self):
        self.moveUp = False
        self.moveDown = False
        self.moveRight = False
        self.moveLeft = False


    def initialize_test_dict(self):
        """ A dictionary of tuples
            each tupe = (Up, Down, Left, Right)
        """
        self.test_dict = {}
        self.test_dict[(True, False, False, False)] = 'MOVE UP'
        self.test_dict[(True, False, True, False)]  = 'MOVE UPLEFT'
        self.test_dict[(True, False, False, True)]  = 'MOVE UPRIGHT'
        self.test_dict[(False, False, False, True)] = 'MOVE RIGHT'
        self.test_dict[(False, False, True, False)] = 'MOVE LEFT' …
woooee 814 Nearly a Posting Maven

Use getpass

Can you help meee???? pleaseeeee=((((

Don't know about anyone else, but I ignore any posts with this type of plea, especially when nothing has been tried.

woooee 814 Nearly a Posting Maven

What type of objects does the query return? You may have to convert to a list to access it in this way.

query = db.GqlQuery("SELECT *" .....etc.
print type(query)
ctr = 0
for q in query:
    if ctr < 2:
        print type(q)
    ctr += 1
woooee 814 Nearly a Posting Maven

This is a more or less standard way of entering data. Use a function, and return from the function only if a correct value is entered.

def colour_picker():
    colourList = ["red", "green", "blue", "yellow", "orange", "pink", "brown"]
    print "pick four different colours from;",
    print ",".join(colourList)

    while True:
            colourPicked = raw_input("pick a colour: ")
            if colourPicked in colourList:
                return colourPicked
            print "not in list, pick again: "


chosenColours = []
for x in range(4):
        colour_returned = colour_picker()
        chosenColours.append(colour_returned)
print chosenColours
woooee 814 Nearly a Posting Maven

what do these two strings have to do with the A & c in RANKS & SUITS?

One is a class instance and one is a class attribute. See here http://diveintopython.org/object_oriented_framework/class_attributes.html

woooee 814 Nearly a Posting Maven

Add some print statements so you know what is going on.

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 =", colour1

        if colour1 in colourList:

            print "colour1 in colourList"
            break
        colour1 = raw_input("not in list, pick agin: ")
    coloursPicked.append(colour1)

    print "returning", coloursPicked
    return coloursPicked

    ##  etc. 
    ## consider using one function and calling it 4 times for the colors
woooee 814 Nearly a Posting Maven

Inside this Class, there is another Class

Why is this necessary. Everything should be in functions inside a single class, or two classes with one calling an instance of the other.

TclError: image "pyimage8" doesn't exist

You are probably looking in the wrong directory. Use the absolute directory + file name for the image = /path/to/images/choose.gif

## missing a quote on the following line
photocho = PhotoImage(file=choose.gif")
                self.labelcho = Button(framebu, image= photocho)
                self.labelcho.image = photocho

                ##---------------------------------------------------------------
                ## you can not use grid and pack.  Pick one only
                self.labelcho.pack()
                self.labelcho.grid(row=2, column=0)

Effbot's Photoimage page http://effbot.org/tkinterbook/photoimage.htm

For any more help you will have to post some code.

Ash_Pokemaster commented: Thanks man +0
woooee 814 Nearly a Posting Maven

The same code with a call back to show which button was pressed. Hopefully you will use a class structure for this as that eliminates shared variable problems.

from Tkinter import*

def cb_handler(event, cb_number ):
    print "cb_handler - button number pressed =", cb_number

root = Tk()
frame = Frame(root)

frames = []
buttons=[]
for i in range(24):
    f = Frame(frame)
    frames.append(f)
    for j in range(25):
        n = 25 * i + j
        b = Button(f, text= "%03d" % n)
        buttons.append(b)
        b.pack(side="left")

        def handler ( event, button_num=n ):
            return cb_handler( event, button_num )
        b.bind ( "<Button-1>", handler )

    f.pack(side="top")
frame.pack(side="top")

root.mainloop()

It's all personal preference, but I prefer a grid.

from Tkinter import*

def cb_handler(event, cb_number ):
    print "cb_handler - button number pressed =", cb_number

root = Tk()
frame = Frame(root)

buttons=[]
b_row=1
b_col=0
for j in range(1, 601):
         b = Button(frame, text = "%3d" % (j))
         buttons.append(b)
         b.grid(row=b_row, column=b_col)

         def handler ( event, button_num=j ):
                return cb_handler( event, button_num )
         b.bind ( "<Button-1>", handler )

        ## you can also use 2 for() loops as Gribouillis did
         b_col += 1
         if b_col > 24:
            b_col = 0
            b_row += 1

frame.grid(row=0, column=1)
root.mainloop()
woooee 814 Nearly a Posting Maven

pie=3.14159265358979323846264338327950288

I think the standard computer's floating point will only use something between
3.14159265359 and
3.1415926535897931
If you want more significant digits than that you will have to use Python's decimal module. http://docs.python.org/library/decimal.html

woooee 814 Nearly a Posting Maven

My aim is to call a method in pyqt from a python thread

And how do you propose to do this without some sort of communication? If you want to update a label, as an example, then one way to do it is to update some common variable. Otherwise, you have to have the class and the function in two, separate threads. Otherwise, the threaded function would not run until the qt class is exited, or vice-versa depending on how they are called.

woooee 814 Nearly a Posting Maven

i want to receive messages from the threads running in other python modules and display or process in my pyqt application.

You would have to communicate between the threads. I use multiprocessing instead of threading and so would communicate through a manager list or dictionary. This is an example of multiprocessing. Note that the function sleeps for 1/2 second, and the __main__() sleeps for 3/4 second so they won't be in sync. "multiprocessing" in included in Python versions greater than 2.5, otherwise you will have to install pyprocessing (same thing) http://pyprocessing.berlios.de/

import time
from multiprocessing import Process, Manager

def test_f(test_d):
   while not test_d["QUIT"]:
      ## change the counter's value
      test_d["ctr"] += 1
      time.sleep(0.5)


if __name__ == '__main__':
   ## define the dictionary to be used as a counter
   manager = Manager()
   test_d = manager.dict()
   test_d["ctr"] = 0
   test_d["QUIT"] = False

   ## start the process
   p = Process(target=test_f, args=(test_d,))
   p.start()

   for x in range(7):
       print test_d["ctr"]
       time.sleep(0.75)

   ## exit the process/function
   test_d["QUIT"] = True
   print "\ntest_d dictionary changed to terminate loop"

   p.terminate()
woooee 814 Nearly a Posting Maven

This may or may not be the problem but should be fixed.

if option<>1 or option<>2 or option<>3:
        ondamenu()
        ## should be (otherwise option never changes)
        option = ondamenu()

Then run the following code to see why you should code it as:
if option not in (1, 2, 3):

option = 1
if option<>1 or option<>2 or option<>3:
   print "ondamenu()"
else:
   print "not if"

if option =1 then it is not equal to 2, etc. You could code it as
if option<>1 and option<>2 and option<>3 also.

woooee 814 Nearly a Posting Maven

I don't use regex as a rule and it is not necessary in this case.

found = False
fp = open(fname, 'r')
for num, line in enumerate(fp):
    line = line.strip()
    if line.startswith(search_term):
        found = True
    if found:
        print num, line
fp.close()

and a number of lines before and after the search term

To do this, you will have to process the file twice, the first time to count the total number of records (so you can print the number of recs after the search term), and process a second time and print the info.

woooee 814 Nearly a Posting Maven

The problem might be the double "input" on the previous line. You did not state that there was an error in the first post, and to get any more help you will have to post the exact error message as well.

if option==1:
        whatsdaradius(input(input("enter a circumference: "))
    if option==2:
        radius2pie(input("enter a radius (ie.half diametre): "))
woooee 814 Nearly a Posting Maven

One thing, you can not open a directory, so you should test that it is a file.

import os
a = []
a = os.listdir('.')
for t in a:
    if os.path.isfile(t):
        f = open(t,'r')
        print t, "opened"
        f.close()
    else:
        print "     ", t, "not a file"

Also, if you are not using Idle for writing code, http://www.annedawson.net/Python_Editor_IDLE.htm that is the editor/IDE that you want to start with. You can choose from several other options once you know what you want in an IDE.

woooee 814 Nearly a Posting Maven
if option==3:
        active<>"on"

This will print "True" if active != 'on' and print "False" otherwise. <> has been deprecated so use "!=" instead. I think you want

if option==3:
        active = "off"

Also you can simplify the following code.

if option<>1 or option<>2 or option<>3:
        ondamenu()
##
## can also be written as
    if option not in (1, 2, 3):
        ondamenu()
woooee 814 Nearly a Posting Maven

First you want to check that the word ends up as an even number, otherwise you can't divide it in two. Tiger = 59 so is not a good choice.

import string


def number_equiv(word):
    ## I prefer a list over string.find  (so sue me)
    letters_list = [ ltr for ltr in string.lowercase ]
    total = 0
    for ltr in word:
        num = letters_list.index(ltr) + 1
        print ltr, num
        total += num
    print total

number_equiv("tiger")
number_equiv("tigers")

Next, I would think that you would want to start with the largest number since it is the most inflexible. For "tigers" that would be t=20. Since "tigers" adds up to 78, one-half would be 39. 39 -"t"(20) = 19 which is "s" which you have, so "tigers" = "ts" and "iger". In this case, I think that is the only solution.

woooee 814 Nearly a Posting Maven

It's personal preference, but I would use a dictionary in the players() function.

def player(self, choice, Com):
        win_d = { 'rock':'Scissors', 'paper':'Rock',
                       'scissors':'paper'}
        if choice.lower() == Com.lower():
            return 'Tie!'
        elif win_d[choice] == Com:
            return 'You won!'
        else:
            return 'You lost!'

Also, you can create all four buttons with one function, and use one function as the call-back if you pass the button number to that function. Note that this is from memory so if there are problems or you don't understand something, post back.

def __init__(self, root):
        self.root = root
        self.create_button('Rock', 7, 0, 1)
        self.create_button('Paper', 7, 1, 2)
        self.create_button('Scissors', 7, 2, 3)
        self.create_button('Reset', 12, 1, 4)

    ##-------------------------------------------------------------------
    def create_button(self, text_in, row_in, col_in, num_in):
        ret_button =  Button(self.root, text=text_in,
                              bg='Blue',
                              fg='white',
                              padx=10, pady=5)
        ret_button.grid(row=row_in, column=col_in, rowspan=2)

        def handler(event, self=self, button_num=num_in):
            return self.cb_handler(event, button_num)
        ret_button.bind("<Button-1>", handler)

    ##-------------------------------------------------------------------
    def cb_handler(self, event, button_num):
        button_dict = { 1:'Rock', 2:'Paper', 3:'Scissors' }
        if button_num in button_dict:
            choice = button_dict[button_num]
            self.message1.config(text= 'You choose ' + choice)
            Com = ComputerChoice()
            self.message2.config(text= 'Computer has chosen %s.' % Com)
            choice = choice.lower()
            self.message3.config(text = winner(choice, Com))
            numWin(self,choice, Com)
        else:     ## 4 is the only other button option
            self.message1.config(text= '')
            self.message2.config(text= '')
            self.message3.config(text= '')
            self.numComWin = 0
            self.numPlayerWin = 0
            numWin(self,0, 0)
            self.message4.config(text = '')
            self.message5.config(text = '')

Finally, it you are going to be coding in python you want to read and follow the style guide here http://www.python.org/dev/peps/pep-0008/ variable names are all lower case with underscores for example.

woooee 814 Nearly a Posting Maven

You aren't converting to a float. Try this code to emphasize the point.

h_list = [ 1, 2, 3 ]
k_list = [ 2, 3, 4 ]
for h in h_list:
   for k in k_list:
      print h,k, (h/k) * 100, "----->", float(h)/k