Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #44571

Re: in need of some help...

Newsgroups comp.lang.python
Date 2013-04-30 15:30 -0700
References <1bdc367a-4187-440b-85a8-de69360bc71d@googlegroups.com> <mailman.1201.1367360008.3114.python-list@python.org>
Message-ID <001fe0f1-9124-4cbb-bc84-1b58ee7b8138@googlegroups.com> (permalink)
Subject Re: in need of some help...
From Alex Norton <ayjayn1101@gmail.com>

Show all headers | View raw


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 <ayjayn1101@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)
        self.verticalLayout_4.setObjectName(_fromUtf8("verticalLayout_4"))
        self.lblTitle = QtGui.QLabel(self.widget)
        font = QtGui.QFont()
        font.setFamily(_fromUtf8("Viner Hand ITC"))
        font.setPointSize(24)
        font.setBold(True)
        font.setWeight(75)
        self.lblTitle.setFont(font)
        self.lblTitle.setObjectName(_fromUtf8("lblTitle"))
        self.verticalLayout_4.addWidget(self.lblTitle)
        self.verticalLayout_3 = QtGui.QVBoxLayout()
        self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3"))
        self.horizontalLayout_2 = QtGui.QHBoxLayout()
        self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
        self.verticalLayout = QtGui.QVBoxLayout()
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.lblWater = QtGui.QLabel(self.widget)
        self.lblWater.setMinimumSize(QtCore.QSize(200, 175))
        self.lblWater.setMaximumSize(QtCore.QSize(200, 175))
        self.lblWater.setText(_fromUtf8(""))
        self.lblWater.setPixmap(QtGui.QPixmap(_fromUtf8(":/imagery/Water.png")))
        self.lblWater.setObjectName(_fromUtf8("lblWater"))
        self.verticalLayout.addWidget(self.lblWater)
        self.lblFire = QtGui.QLabel(self.widget)
        self.lblFire.setMinimumSize(QtCore.QSize(200, 175))
        self.lblFire.setMaximumSize(QtCore.QSize(200, 175))
        self.lblFire.setText(_fromUtf8(""))
        self.lblFire.setPixmap(QtGui.QPixmap(_fromUtf8(":/imagery/Fire.png")))
        self.lblFire.setObjectName(_fromUtf8("lblFire"))
        self.verticalLayout.addWidget(self.lblFire)
        self.horizontalLayout_2.addLayout(self.verticalLayout)
        self.verticalLayout_2 = QtGui.QVBoxLayout()
        self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
        self.lblEarth = QtGui.QLabel(self.widget)
        self.lblEarth.setMinimumSize(QtCore.QSize(200, 175))
        self.lblEarth.setMaximumSize(QtCore.QSize(200, 175))
        self.lblEarth.setText(_fromUtf8(""))
        self.lblEarth.setPixmap(QtGui.QPixmap(_fromUtf8(":/imagery/Earth.png")))
        self.lblEarth.setObjectName(_fromUtf8("lblEarth"))
        self.verticalLayout_2.addWidget(self.lblEarth)
        self.lblAir = QtGui.QLabel(self.widget)
        self.lblAir.setMinimumSize(QtCore.QSize(200, 175))
        self.lblAir.setMaximumSize(QtCore.QSize(200, 175))
        self.lblAir.setText(_fromUtf8(""))
        self.lblAir.setPixmap(QtGui.QPixmap(_fromUtf8(":/imagery/Air.png")))
        self.lblAir.setObjectName(_fromUtf8("lblAir"))
        self.verticalLayout_2.addWidget(self.lblAir)
        self.horizontalLayout_2.addLayout(self.verticalLayout_2)
        self.verticalLayout_3.addLayout(self.horizontalLayout_2)
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
        self.lblOutput = QtGui.QLabel(self.widget)
        self.lblOutput.setText(_fromUtf8(""))
        self.lblOutput.setObjectName(_fromUtf8("lblOutput"))
        self.horizontalLayout.addWidget(self.lblOutput)
        self.btnFinish = QtGui.QPushButton(self.widget)
        font = QtGui.QFont()
        font.setFamily(_fromUtf8("Viner Hand ITC"))
        font.setPointSize(12)
        font.setBold(True)
        font.setWeight(75)
        self.btnFinish.setFont(font)
        self.btnFinish.setObjectName(_fromUtf8("btnFinish"))
        self.horizontalLayout.addWidget(self.btnFinish)
        self.verticalLayout_3.addLayout(self.horizontalLayout)
        self.verticalLayout_4.addLayout(self.verticalLayout_3)
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QObject.connect(self.btnFinish, QtCore.SIGNAL(_fromUtf8("pressed()")), MainWindow.close)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(_translate("MainWindow", "Avatar: The Last Airbender", None))
        self.lblTitle.setText(_translate("MainWindow", "Avatar: The Last Airbender Elements Game", None))
        self.btnFinish.setText(_translate("MainWindow", "Finish", None))

import elements_rc



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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

in need of some help... Alex Norton <ayjayn1101@gmail.com> - 2013-04-30 15:06 -0700
  Re: in need of some help... Chris Angelico <rosuav@gmail.com> - 2013-05-01 08:13 +1000
    Re: in need of some help... Alex Norton <ayjayn1101@gmail.com> - 2013-04-30 15:30 -0700
      Re: in need of some help... Ian Kelly <ian.g.kelly@gmail.com> - 2013-04-30 17:02 -0600
        Re: in need of some help... Alex Norton <ayjayn1101@gmail.com> - 2013-04-30 16:20 -0700
          Re: in need of some help... Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-05-01 00:01 -0400
          Re: in need of some help... Chris Angelico <rosuav@gmail.com> - 2013-05-01 14:37 +1000
            Re: in need of some help... Alex Norton <ayjayn1101@gmail.com> - 2013-05-01 03:27 -0700
          Re: in need of some help... jt@toerring.de (Jens Thoms Toerring) - 2013-05-01 12:15 +0000
            Re: in need of some help... Alex Norton <ayjayn1101@gmail.com> - 2013-05-01 16:24 -0700
            Re: in need of some help... Alex Norton <ayjayn1101@gmail.com> - 2013-05-10 01:23 -0700
              Re: in need of some help... jt@toerring.de (Jens Thoms Toerring) - 2013-05-11 22:20 +0000
                Re: in need of some help... Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-05-12 17:59 +0200
                Re: in need of some help... jt@toerring.de (Jens Thoms Toerring) - 2013-05-12 21:56 +0000
                Re: in need of some help... Chris Angelico <rosuav@gmail.com> - 2013-05-13 08:18 +1000
                Re: in need of some help... jt@toerring.de (Jens Thoms Toerring) - 2013-05-12 22:58 +0000
                Re: in need of some help... Chris Angelico <rosuav@gmail.com> - 2013-05-13 09:08 +1000
                Re: in need of some help... Chris Angelico <rosuav@gmail.com> - 2013-05-13 10:51 +1000
                Re: in need of some help... Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-05-12 19:47 -0400
                Re: in need of some help... Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-05-13 20:10 +1200
                Re: in need of some help... Chris Angelico <rosuav@gmail.com> - 2013-05-13 02:08 +1000
                Re: in need of some help... Alex Norton <ayjayn1101@gmail.com> - 2013-05-12 12:34 -0700

csiph-web