Re: in need of some help...

2013-05-13 Thread Gregory Ewing

Dennis Lee Bieber wrote:

Is that the accepted group noun? I'd think a crisis of Chrises is
more alliterative...


A confusion of Chrises might be more appropriate
in this case.

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


Re: in need of some help regarding my rock paper scissors game

2013-05-13 Thread Denis McMahon
On Sun, 12 May 2013 20:33:44 +0100, Alex Norton wrote:

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

It looks to me as if bWater is an integer value and doesn't have 
a .clicked attribute.

Where is bWater assigned, and what is it assigned to?

If you have a clickable water widget of some sort in your gui, what is 
the click handler for that widget defined as?

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: in need of some help...

2013-05-12 Thread Chris “Kwpolska” Warrick
(slightly offtopic, sorry.)

On Sun, May 12, 2013 at 12:20 AM, Jens Thoms Toerring j...@toerring.de wrote:
 PS: If I may ask you a favor: consider refraining from using Google's
 completely broken interface to newsgroups - your post consists
 of nearly 200 lines of text containing all I wrote, with an empty
 line inserted between each of them, and a single line of text
 you wrote. It's rather annoying to have to sieve through that
 much of unrelated stuff just to find thar one line that's re-
 levant.

Gmail automatically hides long quotes.  This is helpful in situations
like this one.  More mail software should implement that
functionality.  Seriously: once you go Gmail, you never go back.

 And this Google groups crap seems to make it nearly
 impossible to do it any other way. If you don't believe me see
 e.g.

   http://wiki.python.org/moin/GoogleGroupsPython

 There are much better alternatives to Google groups,
 using a real usenet news server and a program that does
 not mess up content of news group postings. They've been
 developed with 30 years of experience with newsgroups.

Or something even better: a mailing list.
http://mail.python.org/mailman/listinfo/python-list is where you can
find it.  Much friendlier than Usenet, and the software itself is
developed by the FLUFL.

 If I'd be conspiracy theorist I would conclude that Google
 is up to something bad in trying to make using newsgroups
 nearly impossible by their badly broken stuff (and, to add
 credibility to such a claim, their complete disregard for
 all the criticism they got over the years, actually making
 each version of Google groups even worse), but it's rather
 likely just another case of pure incompetence (or a why
 should we care attitude:-(

They shouldn’t care because Usenet users often yell “Get off my
lawn!”.  Young people don’t use newsgroups.  They don’t even know what
Usenet is.

--
Kwpolska http://kwpolska.tk | GPG KEY: 5EAAEA16
stop html mail| always bottom-post
http://asciiribbon.org| http://caliburn.nl/topposting.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: in need of some help...

2013-05-12 Thread Chris Angelico
On Mon, May 13, 2013 at 1:59 AM, Chris “Kwpolska” Warrick
kwpol...@gmail.com wrote:
 On Sun, May 12, 2013 at 12:20 AM, Jens Thoms Toerring j...@toerring.de 
 wrote:
 PS: If I may ask you a favor: consider refraining from using Google's
 completely broken interface to newsgroups - your post consists
 of nearly 200 lines of text containing all I wrote, with an empty
 line inserted between each of them, and a single line of text
 you wrote. It's rather annoying to have to sieve through that
 much of unrelated stuff just to find thar one line that's re-
 levant.

 Gmail automatically hides long quotes.  This is helpful in situations
 like this one.  More mail software should implement that
 functionality.  Seriously: once you go Gmail, you never go back.

I use Gmail, but the automated hiding of long quotes is *disrupted* by
the double-spacing. So it's no less important to avoid breaking
protocol.

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


in need of some help regarding my rock paper scissors game

2013-05-12 Thread Alex Norton
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.

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.

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

 attached is the game file.


testy.py
Description: Binary data
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: in need of some help...

2013-05-12 Thread Alex Norton
On Saturday, 11 May 2013 23:20:13 UTC+1, Jens Thoms Toerring  wrote:
 Alex Norton ayjayn1...@gmail.com wrote:
 
  On Wednesday, 1 May 2013 13:15:28 UTC+1, Jens Thoms Toerring  wrote:
 
   Of course, it might be nicer to have a result label some-
 
   where in the graphical interface which you set to the text
 
   instead of printing it out to the console. And you also will
 
   probably add some Quit button to end the game.
 
 
 
  how would i go about adding print outcomes of all options  to a label ?
 
 
 
 If you have a QLabel you can set its text to anything you want
 
 using its setText() method.
 
  Regaeds, Jens
 
 
 
 PS: If I may ask you a favor: consider refraining from using Google's
 
 completely broken interface to newsgroups - your post consists
 
 of nearly 200 lines of text containing all I wrote, with an empty
 
 line inserted between each of them, and a single line of text
 
 you wrote. It's rather annoying to have to sieve through that
 
 much of unrelated stuff just to find thar one line that's re-
 
 levant. And this Google groups crap seems to make it nearly
 
 impossible to do it any other way. If you don't believe me see
 
 e.g.
 
 
 
   http://wiki.python.org/moin/GoogleGroupsPython
 
 
 
 There are much better alternatives to Google groups,
 
 using a real usenet news server and a program that does
 
 not mess up content of news group postings. They've been
 
 developed with 30 years of experience with newsgroups.
 
 
 
 If I'd be conspiracy theorist I would conclude that Google
 
 is up to something bad in trying to make using newsgroups
 
 nearly impossible by their badly broken stuff (and, to add
 
 credibility to such a claim, their complete disregard for
 
 all the criticism they got over the years, actually making
 
 each version of Google groups even worse), but it's rather
 
 likely just another case of pure incompetence (or a why
 
 should we care attitude:-(
 
 -- 
 
   \   Jens Thoms Toerring  ___  j...@toerring.de
 
\__  http://toerring.de

i have taken your advice and have messaged the mailing group about the issues i 
have
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: in need of some help regarding my rock paper scissors game

2013-05-12 Thread Benjamin Kaplan
On Sun, May 12, 2013 at 12:33 PM, Alex Norton ayjayn1...@gmail.com 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.

 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.

 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

  attached is the game file.

 --

bWater is an int. Integers don't have a clicked attribute. So
bWater.clicked.connect(water_clicked) looks for the clicked attribute
of the integer bWater, can't find it, and throws an error. Also,
Python scripts are executed line by line- at the time you make that
call, the water_clicked function doesn't exist yet, so even if that
was the correct call, it wouldn't work here.

I haven't used PyQT before so I can't say what the correct way to set
this up would be, but that's at least what's causing this error.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: in need of some help...

2013-05-12 Thread Jens Thoms Toerring
Chris “Kwpolska” Warrick kwpol...@gmail.com wrote:
 (slightly offtopic, sorry.)

 On Sun, May 12, 2013 at 12:20 AM, Jens Thoms Toerring j...@toerring.de 
 wrote:
  PS: If I may ask you a favor: consider refraining from using Google's
  completely broken interface to newsgroups - your post consists
  of nearly 200 lines of text containing all I wrote, with an empty
  line inserted between each of them, and a single line of text
  you wrote. It's rather annoying to have to sieve through that
  much of unrelated stuff just to find thar one line that's re-
  levant.

 Gmail automatically hides long quotes.  This is helpful in situations
 like this one.  More mail software should implement that
 functionality.  Seriously: once you go Gmail, you never go back.

i giess you mean Gougle groups and not Gmail, which I can't comment
on since I don't use it.

You still have to un-hide the message when you want to under-
stand what the other person is respoding to. And then you're back
to square one (and the double-spacing issue seems to remain). That
is why it has been a good tradition to remove everything when
you reply that isn't relevant to what you're replying to. Of
course, with the sorry excuse for an editor you habe in a web
based form that's more difficult to do than with a real editor.
That's one of the reasons I would advice to use a specialized
program that can be made to use the editor of your choice.

Another extremly annoying thing when reading via Google groups is
that there's no reasonable threading, i.e. it's not immediately
obvious what is meant as a reply to a specific post. That makes
Google groups basically useless for longer discussions.

And then Google groups overflow with spam messages that any
self-respecting news server would discard, so you never get
to see them.

  And this Google groups crap seems to make it nearly
  impossible to do it any other way. If you don't believe me see
  e.g.
 
http://wiki.python.org/moin/GoogleGroupsPython
 
  There are much better alternatives to Google groups,
  using a real usenet news server and a program that does
  not mess up content of news group postings. They've been
  developed with 30 years of experience with newsgroups.

 Or something even better: a mailing list.
 http://mail.python.org/mailman/listinfo/python-list is where you can
 find it.  Much friendlier than Usenet, and the software itself is
 developed by the FLUFL.

Mailing lists are quite fine and I'm on quite a number of them.
But I don't want many more to further fill up my inbox. And there
you again have the problem that there's no reasonable threading
of messages when these messages arrive in your mail folder.

  If I'd be conspiracy theorist I would conclude that Google
  is up to something bad in trying to make using newsgroups
  nearly impossible by their badly broken stuff (and, to add
  credibility to such a claim, their complete disregard for
  all the criticism they got over the years, actually making
  each version of Google groups even worse), but it's rather
  likely just another case of pure incompetence (or a why
  should we care attitude:-(

 They shouldn’t care because Usenet users often yell “Get off my
 lawn!”.  Young people don’t use newsgroups.  They don’t even know what
 Usenet is.

Well, it's a pity when younger people don't use newsgroups (no
idea if this is true, though) since they can be extremely useful
for all kinds of purposes - I e.g. learned a huge amount from
just lurking. And while some groups may be nicer than others,
that's no excuse for Google at all to actively trying to destroy
them. I'd rather prefer Google to simply get rid of Google groups
and put the long time archives they obtained from DajaNews into
better hands that do care.
   Regards, Jens
-- 
  \   Jens Thoms Toerring  ___  j...@toerring.de
   \__  http://toerring.de
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: in need of some help...

2013-05-12 Thread Chris Angelico
On Mon, May 13, 2013 at 7:56 AM, Jens Thoms Toerring j...@toerring.de wrote:
 Chris “Kwpolska” Warrick kwpol...@gmail.com wrote:
 Gmail automatically hides long quotes.  This is helpful in situations
 like this one.  More mail software should implement that
 functionality.  Seriously: once you go Gmail, you never go back.

 i giess you mean Gougle groups and not Gmail, which I can't comment
 on since I don't use it.


No, Chris (not me, the other Chris... *an*other Chris okay, one of
the chorus of Chrises of this list!) did mean Gmail, the Google
webmail client. It does threading (and does it better than
SquirrelMail does), and it does the hiding of long quotes, long
signatures, etc.

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


Re: in need of some help...

2013-05-12 Thread Jens Thoms Toerring
Chris Angelico ros...@gmail.com wrote:
 On Mon, May 13, 2013 at 7:56 AM, Jens Thoms Toerring j...@toerring.de wrote:
  Chris “Kwpolska” Warrick kwpol...@gmail.com wrote:
  Gmail automatically hides long quotes.  This is helpful in situations
  like this one.  More mail software should implement that
  functionality.  Seriously: once you go Gmail, you never go back.
 
  i giess you mean Gougle groups and not Gmail, which I can't comment
  on since I don't use it.

 No, Chris (not me, the other Chris... *an*other Chris okay, one of
 the chorus of Chrises of this list!) did mean Gmail, the Google
 webmail client. It does threading (and does it better than
 SquirrelMail does), and it does the hiding of long quotes, long
 signatures, etc.

Ok, sorry then about that - as I said I never have used Gmail
(and don't plan using it for other reasons than usability - and
then I would hardly consider anything with a web interface for a
text medium to be very usable;-). But, as far as I understand,
Gmail is about email, so I'm a bit at a loss to understand what
got this to do with news groups and Google groups (were the post
I originally was responing to according to the header seemed to
be coming from) that I intended this to be about?

  Best regards, Jens
-- 
  \   Jens Thoms Toerring  ___  j...@toerring.de
   \__  http://toerring.de
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: in need of some help regarding my rock paper scissors game

2013-05-12 Thread Dave Angel

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


Re: in need of some help...

2013-05-12 Thread Chris Angelico
On Mon, May 13, 2013 at 8:58 AM, Jens Thoms Toerring j...@toerring.de wrote:
 Chris Angelico ros...@gmail.com wrote:
 On Mon, May 13, 2013 at 7:56 AM, Jens Thoms Toerring j...@toerring.de 
 wrote:
  Chris “Kwpolska” Warrick kwpol...@gmail.com wrote:
  Gmail automatically hides long quotes.  This is helpful in situations
  like this one.  More mail software should implement that
  functionality.  Seriously: once you go Gmail, you never go back.
 
  i giess you mean Gougle groups and not Gmail, which I can't comment
  on since I don't use it.

 No, Chris (not me, the other Chris... *an*other Chris okay, one of
 the chorus of Chrises of this list!) did mean Gmail, the Google
 webmail client. It does threading (and does it better than
 SquirrelMail does), and it does the hiding of long quotes, long
 signatures, etc.

 Ok, sorry then about that - as I said I never have used Gmail
 (and don't plan using it for other reasons than usability - and
 then I would hardly consider anything with a web interface for a
 text medium to be very usable;-). But, as far as I understand,
 Gmail is about email, so I'm a bit at a loss to understand what
 got this to do with news groups and Google groups (were the post
 I originally was responing to according to the header seemed to
 be coming from) that I intended this to be about?

Since you can subscribe to the mailing list python-list@python.org and
get all of comp.lang.python (sans a pile of spam), you can read it as
a threaded mailing list instead of a newsgroup. It comes to pretty
much the same thing, so effectively you get your choice of technology.

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


Re: in need of some help...

2013-05-12 Thread Chris Angelico
On Mon, May 13, 2013 at 9:47 AM, Dennis Lee Bieber
wlfr...@ix.netcom.com wrote:
 On Mon, 13 May 2013 08:18:05 +1000, Chris Angelico ros...@gmail.com
 declaimed the following in gmane.comp.python.general:


 No, Chris (not me, the other Chris... *an*other Chris okay, one of
 the chorus of Chrises of this list!) did mean Gmail, the Google

 Is that the accepted group noun? I'd think a crisis of Chrises is
 more alliterative...

That works too! I automatically went for chorus since I work in
theatre, but I like your version. What do the other Chrises think?

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


Re: in need of some help...

2013-05-11 Thread Jens Thoms Toerring
Alex Norton ayjayn1...@gmail.com wrote:
 On Wednesday, 1 May 2013 13:15:28 UTC+1, Jens Thoms Toerring  wrote:
  Of course, it might be nicer to have a result label some-
  where in the graphical interface which you set to the text
  instead of printing it out to the console. And you also will
  probably add some Quit button to end the game.

 how would i go about adding print outcomes of all options  to a label ?

If you have a QLabel you can set its text to anything you want
using its setText() method.
 Regaeds, Jens

PS: If I may ask you a favor: consider refraining from using Google's
completely broken interface to newsgroups - your post consists
of nearly 200 lines of text containing all I wrote, with an empty
line inserted between each of them, and a single line of text
you wrote. It's rather annoying to have to sieve through that
much of unrelated stuff just to find thar one line that's re-
levant. And this Google groups crap seems to make it nearly
impossible to do it any other way. If you don't believe me see
e.g.

  http://wiki.python.org/moin/GoogleGroupsPython

There are much better alternatives to Google groups,
using a real usenet news server and a program that does
not mess up content of news group postings. They've been
developed with 30 years of experience with newsgroups.

If I'd be conspiracy theorist I would conclude that Google
is up to something bad in trying to make using newsgroups
nearly impossible by their badly broken stuff (and, to add
credibility to such a claim, their complete disregard for
all the criticism they got over the years, actually making
each version of Google groups even worse), but it's rather
likely just another case of pure incompetence (or a why
should we care attitude:-(
-- 
  \   Jens Thoms Toerring  ___  j...@toerring.de
   \__  http://toerring.de
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: in need of some help...

2013-05-10 Thread Alex Norton
On Wednesday, 1 May 2013 13:15:28 UTC+1, Jens Thoms Toerring  wrote:
 Alex Norton ayjayn1...@gmail.com wrote:
 
  thanks... ill take a look at the Qt event handling
 
 
 
 It's rather simple: instead of the program running through a
 
 sequence of steps, the program normally is basically doing
 
 nothing. It just reacts to events that normally come from
 
 the user, i.e. the user clicks on some icon or widget, or
 
 (s)he enters something via the keyboard. You etermine which
 
 of all the possible events to which widget are relevant to
 
 you, write handler functions for them and tell the widget
 
 to call some function when an event happens. The simplest
 
 case is a button: you want to react to it, so you write a
 
 function for what's to be done when it's clicked on and
 
 then tell Qt to call that function once it gets clicked
 
 (there are different events even for a simple push button,
 
 it can be clicked, just pushed, released etc.). And if you
 
 have set up everything for that you tell Qt to start waiting
 
 for events.
 
 
 
 So the steps are:
 
 
 
   1. Tell Qt that this is a program using it
 
 
 
  app = QtGui.QApplication( sys.argv )
 
 
 
   2. Create your graphical interface (what you seem to
 
  have done more or less)
 
 
 
   3. Connect desired events (what's called signals in
 
  Qt lingo) for a certain widget to the function to be
 
  called with something like
 
 
 
  your_widget.clicked.connect( your_function )
 
 
 
  (replace 'clicked' with e.g. 'pushed' or 'released'
 
  when interested in a push or release signal instead)
 
 
 
   4. Start the event loop (i.e. have Qt wait for the user
 
  to do something and call one of your functions if the
 
  user did something you're interested in) with
 
 
 
  app.exec_( )
 
 
 
  When this returns the game is over.
 
 
 
 So you don't wait for keyboard input with input() like in
 
 your original program but instead tell Qt to do the waiting
 
 for you and call the appropriate function you defined when
 
 something interesting happens.
 
 
 
 What you probably will have to change about the graphical
 
 interface is that instead of using QLabel widgets for 'Air',
 
 'Earth', 'Fire', 'Water' to use e.g. QPushButtons since
 
 QLabels are rather static objects - they don't receive any
 
 click events and it's rather likely some kind of event
 
 like this is what you're going to want to react to. And for
 
 that QPushButtons seem to be the simplest choice to start
 
 with.
 
 
 
 So have an 'Air' button (let's call it 'bAir' and then do
 
 
 
bAir.clicked.connect( air_clicked )
 
 
 
 after defining a function air_clicked() in which you deal
 
 with that case. that might be as simple as
 
 
 
 def air_clicked( ) :
 
   # Randomly pick one of 'air', 'fire', 'water' or 'earth'
 
 
 
 z = [ 'air', 'fire', 'water', earth' ][ random.randrange( 4 ) ]
 
 
 
   if z == 'air' :
 
 print( 'Stalemate' )
 
 elif z == 'water' :
 
 print( 'Air removes Water, you win!' )
 
 ...
 
 
 
 Now, when during the game the 'Air' button is clicked this
 
 function will get called.
 
 
 
 Of course, it might be nicer to have a result label some-
 
 where in the graphical interface which you set to the text
 
 instead of printing it out to the console. And you also will
 
 probably add some Quit button to end the game.
 
 
 
   Regards, Jens
 
 -- 
 
   \   Jens Thoms Toerring  ___  j...@toerring.de
 
\__  http://toerring.de

how would i go about adding print outcomes of all options  to a label ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: in need of some help...

2013-05-01 Thread Alex Norton
On Wednesday, 1 May 2013 05:37:34 UTC+1, Chris Angelico  wrote:
 On Wed, May 1, 2013 at 9:20 AM, Alex Norton ayjayn1...@gmail.com wrote:
 
  the teacher actually cant teach anything, he as the knowledge of Vb but his 
  teaching methods are abysmal and severely lacking, but he said we can use 
  any language we feel more comfortable in. some are using VB others PHP and 
  some in C ++.
 
 
 
 Quit the course and go study someplace else... I wouldn't want to be
 
 in any course where people use VB and PHP to build GUIs!
 
 
 
 ChrisA

its a college course (Uk college btw) and its the last unit... im just gonna 
stick with it

python is quite easy ot understand (reading wise) that the teacher can attempt 
to read it with my comments
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: in need of some help...

2013-05-01 Thread Jens Thoms Toerring
Alex Norton ayjayn1...@gmail.com wrote:
 thanks... ill take a look at the Qt event handling

It's rather simple: instead of the program running through a
sequence of steps, the program normally is basically doing
nothing. It just reacts to events that normally come from
the user, i.e. the user clicks on some icon or widget, or
(s)he enters something via the keyboard. You etermine which
of all the possible events to which widget are relevant to
you, write handler functions for them and tell the widget
to call some function when an event happens. The simplest
case is a button: you want to react to it, so you write a
function for what's to be done when it's clicked on and
then tell Qt to call that function once it gets clicked
(there are different events even for a simple push button,
it can be clicked, just pushed, released etc.). And if you
have set up everything for that you tell Qt to start waiting
for events.

So the steps are:

  1. Tell Qt that this is a program using it

 app = QtGui.QApplication( sys.argv )

  2. Create your graphical interface (what you seem to
 have done more or less)

  3. Connect desired events (what's called signals in
 Qt lingo) for a certain widget to the function to be
 called with something like

 your_widget.clicked.connect( your_function )

 (replace 'clicked' with e.g. 'pushed' or 'released'
 when interested in a push or release signal instead)

  4. Start the event loop (i.e. have Qt wait for the user
 to do something and call one of your functions if the
 user did something you're interested in) with

 app.exec_( )

 When this returns the game is over.

So you don't wait for keyboard input with input() like in
your original program but instead tell Qt to do the waiting
for you and call the appropriate function you defined when
something interesting happens.

What you probably will have to change about the graphical
interface is that instead of using QLabel widgets for 'Air',
'Earth', 'Fire', 'Water' to use e.g. QPushButtons since
QLabels are rather static objects - they don't receive any
click events and it's rather likely some kind of event
like this is what you're going to want to react to. And for
that QPushButtons seem to be the simplest choice to start
with.

So have an 'Air' button (let's call it 'bAir' and then do

   bAir.clicked.connect( air_clicked )

after defining a function air_clicked() in which you deal
with that case. that might be as simple as

def air_clicked( ) :
# Randomly pick one of 'air', 'fire', 'water' or 'earth'

z = [ 'air', 'fire', 'water', earth' ][ random.randrange( 4 ) ]

if z == 'air' :
print( 'Stalemate' )
elif z == 'water' :
print( 'Air removes Water, you win!' )
...

Now, when during the game the 'Air' button is clicked this
function will get called.

Of course, it might be nicer to have a result label some-
where in the graphical interface which you set to the text
instead of printing it out to the console. And you also will
probably add some Quit button to end the game.

  Regards, Jens
-- 
  \   Jens Thoms Toerring  ___  j...@toerring.de
   \__  http://toerring.de
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: in need of some help...

2013-05-01 Thread Alex Norton
Thank you very much for the specific detail. I have already done the signal for 
the finish button so that the app closes when clicked
-- 
http://mail.python.org/mailman/listinfo/python-list


in need of some help...

2013-04-30 Thread Alex Norton

hi, 

i am currently trying to make a rock paper scissors game based on a game.

the code for the game itself works fine, it does what i need it to do

the issue i am having is that i haven't a clue how to combine the game code i 
have with the QT GUI code i have. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: in need of some help...

2013-04-30 Thread Chris Angelico
On Wed, May 1, 2013 at 8:06 AM, Alex Norton ayjayn1...@gmail.com wrote:

 hi,

 i am currently trying to make a rock paper scissors game based on a game.

 the code for the game itself works fine, it does what i need it to do

 the issue i am having is that i haven't a clue how to combine the game code i 
 have with the QT GUI code i have.

Poke around with some QT examples, or play with Tkinter (which comes
with Python). Get a hello, world going, then expand on it. If you
get stuck, come back to the list with a bit more information and,
preferably, code; at the moment, your request is so vague that all I
can offer is highly general advice.

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


Re: in need of some help...

2013-04-30 Thread Alex Norton
On Tuesday, April 30, 2013 11:13:24 PM UTC+1, Chris Angelico wrote:
 On Wed, May 1, 2013 at 8:06 AM, Alex Norton ayjayn1...@gmail.com wrote:
 
 
 
  hi,
 
 
 
  i am currently trying to make a rock paper scissors game based on a game.
 
 
 
  the code for the game itself works fine, it does what i need it to do
 
 
 
  the issue i am having is that i haven't a clue how to combine the game code 
  i have with the QT GUI code i have.
 
 
 
 Poke around with some QT examples, or play with Tkinter (which comes
 
 with Python). Get a hello, world going, then expand on it. If you
 
 get stuck, come back to the list with a bit more information and,
 
 preferably, code; at the moment, your request is so vague that all I
 
 can offer is highly general advice.
 
 
 
 ChrisA

thanks... i have made the Tkinter hello world before and thats simple

below is the RPS game coding 


import pygame, sys

from pygame.locals import * 


import random


#


#game message
print
print
print
print('Welcome to the Elements game')
print('Water, Earth, Fire, and Air')
print('Type quit to exit the game')
print


#variables for the elements
water = 1

earth = 2

fire = 3

air = 4

#game core mechanic
while 1:

#Z is the computer, the randint is to allow the randomisation of the 
integers the computer will choose
z = random.randint (1, 4)

#A is the you, this is to allow you to enter an integer yourself and 
not a randomisation.
a = int (input ('Water, Earth, Fire, Air :-'))

#the choices you make and the results
if a ==  z :
print ('Stalemate')

if a == water and z == earth:
print ('Water smashes against Earth and Does nothing, 
Stalemate')

if a == water and z == fire:
print (' Water hits fire and douses the flames, you win!')

if a == water and z == air:
print (' Water misses the Air, you lose')

if a == earth and z == water:
print (' Earth hits Water and does nothing, Stalemate')

if a == earth and z == fire:
print('Earth is sorched by Fire, you lose')

if a == earth and z == air:
print('Earth snuffs the Air, you win!')

if a == fire and z == water:
print('fire is doused by Water, you lose')

if a == fire and z == earth:
print ('fire sorches Earth, you win!')

if a == fire and z == air:
print('Fire misses Air, Stalemate')

if a == air  and z == water:
print('Air removes Water, you win!')

if a == air and z == earth:
print(' Air is dispatched by Earth, you lose')

if a == air and z == fire:
print('Air  shakes fire but does nothing, Stalemate')

if a == quit:
break


print('Thank you for playing the Elements game')

oh FYI its for my college course.. i didnt really want to use Visual Basic so 
the teacher cannot help

below is the QT GUI Code

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'GUI.ui'
#
# Created: Tue Apr 30 22:36:27 2013
#  by: PyQt4 UI code generator 4.10.1
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui

try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s

try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)

class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8(MainWindow))
MainWindow.resize(762, 578)
MainWindow.setMinimumSize(QtCore.QSize(762, 578))
MainWindow.setMaximumSize(QtCore.QSize(762, 578))
MainWindow.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(_fromUtf8(../../../../Users/Alex 
Norton/Desktop/Avatar-The-Last-Airbender.ico)), QtGui.QIcon.Normal, 
QtGui.QIcon.Off)
MainWindow.setWindowIcon(icon)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8(centralwidget))
self.widget = QtGui.QWidget(self.centralwidget)
self.widget.setGeometry(QtCore.QRect(30, 21, 701, 521))
self.widget.setObjectName(_fromUtf8(widget))
self.verticalLayout_4 = QtGui.QVBoxLayout(self.widget)
self.verticalLayout_4.setMargin(0)

Re: in need of some help...

2013-04-30 Thread Ian Kelly
On Tue, Apr 30, 2013 at 4:30 PM, Alex Norton ayjayn1...@gmail.com wrote:
 oh FYI its for my college course.. i didnt really want to use Visual Basic so 
 the teacher cannot help

If the course is being taught in Visual Basic then that would probably
be the best thing to use.  I'm surprised that the teacher is allowing
you to complete the assignment in Python if he/she doesn't know the
language.

 basically i want to have it so that the element images in the GUI are linked 
 with their corresponding variable(water with lblWater) and in the background 
 the computer selects their own random integer and the results are displayed 
 in the lblOutput.

I'm not all that familiar with PyQt specifically, but I can tell you
that GUI programs are typically event-based rather than simply
procedural like your RPS game.  That means that the while 1 loop
that you have will be replaced with the Qt event loop.  You will also
need to write event handlers for each of the four element labels, so
that when a user clicks on one of them, the game will go through the
logic of receiving the player's choice (based on which one was
clicked), determining the result of the match, and finally updating
the output label accordingly.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: in need of some help...

2013-04-30 Thread Alex Norton
On Wednesday, 1 May 2013 00:02:51 UTC+1, Ian  wrote:
 On Tue, Apr 30, 2013 at 4:30 PM, Alex Norton ayjayn1...@gmail.com wrote:
 
  oh FYI its for my college course.. i didnt really want to use Visual Basic 
  so the teacher cannot help
 
 
 
 If the course is being taught in Visual Basic then that would probably
 
 be the best thing to use.  I'm surprised that the teacher is allowing
 
 you to complete the assignment in Python if he/she doesn't know the
 
 language.
 
 
 
  basically i want to have it so that the element images in the GUI are 
  linked with their corresponding variable(water with lblWater) and in the 
  background the computer selects their own random integer and the results 
  are displayed in the lblOutput.
 
 
 
 I'm not all that familiar with PyQt specifically, but I can tell you
 
 that GUI programs are typically event-based rather than simply
 
 procedural like your RPS game.  That means that the while 1 loop
 
 that you have will be replaced with the Qt event loop.  You will also
 
 need to write event handlers for each of the four element labels, so
 
 that when a user clicks on one of them, the game will go through the
 
 logic of receiving the player's choice (based on which one was
 
 clicked), determining the result of the match, and finally updating
 
 the output label accordingly.

thanks... ill take a look at the Qt event handling

the teacher actually cant teach anything, he as the knowledge of Vb but his 
teaching methods are abysmal and severely lacking, but he said we can use any 
language we feel more comfortable in. some are using VB others PHP and some in 
C ++.
 the reason i chose python was because i could understand it ( simple python) 
better than any worksheet or notes he made
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: in need of some help...

2013-04-30 Thread Chris Angelico
On Wed, May 1, 2013 at 9:20 AM, Alex Norton ayjayn1...@gmail.com wrote:
 the teacher actually cant teach anything, he as the knowledge of Vb but his 
 teaching methods are abysmal and severely lacking, but he said we can use any 
 language we feel more comfortable in. some are using VB others PHP and some 
 in C ++.

Quit the course and go study someplace else... I wouldn't want to be
in any course where people use VB and PHP to build GUIs!

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