On 05/12/2013 03:33 PM, Alex Norton wrote:
im new to python and im in the middle of making a RPS game for a college
unit.

i have used PyQt to create the GUI and i have received help regarding
adding the code to the buttons.

I'm not at all familiar with PyQT, but I have used other GUIs, and I'm quite familiar with Python itself.


but its missing something as the error

'Traceback (most recent call last): File "C:\Users\Me\Desktop\testy.py",
line 174, in bWater.clicked.connect( water_clicked ) AttributeError: 'int'
object has no attribute 'clicked'' appears when i run the module.

You've defined two very different bWater objects. One is an instance attribute of the class Ui_MainWindow, while the other is an int at global scope. The latter is never usefully referenced, but it's there to cause a confusing error message. Those three calls through the clicked attrbute are evidently intended for the button object, which is inside the class instance. My guess is that those three lines should be inside the setupUI method, and should have self. prefix on each.

Next problem is that there's a comment at the beginning:

# Form implementation generated from reading ui file 'mygui.ui'
#
# Created: Fri May 10 20:27:13 2013
#      by: PyQt4 UI code generator 4.10.1
#
# WARNING! All changes made in this file will be lost!

which implies this file is a generated one. If you ever rerun that UI generator, you'll wipe out any changes you've made. Again, I'm not familiar with PyQT, so I don't know how likely that is.

Next problem is that you have no top-level code that calls main(), which is evidently the code that gets things moving. Generally, you want to put all the top-level code inside main(), in which case the call to main() would be the only top-level code left. But there are exceptions. imports should nearly always go to the top, at top level. And you conditional functions need to stay at top-level just as you have them (the two clauses with try/cath in them).

Final problem that I can spot is that if you DO need to reference those four functions from mainline code, you'll have to move them earlier in the file. But if you agreed with my earlier suggestion to move the three lines inside that method, then this wouldn't be a problem any more.


i was wondering if somebody could walk me through making the game complete
and to add the results of the game (win/lose/stalemate) to the loutcome
label


Once you get to the innards of PyQT, I'll be no help at all. But I hope I've given you a little push in the right direction.


--
DaveA
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to