I need to make a score table function which keeps a track of the points. the first player to reach 11 points wins, however the game must be won by aleast a 2 point margin.

the players points should be displayed on two halves of the graphic window. for example:
http://img413.imageshack.us/i/boxz.jpg/

the player should clicj on there side of the window to increase the point. after the players wins, a wins message should be displayed under the winner. the next click should close the window

def main():

I am not sure how to start the code, any help would be great

Start by asking the player(s) for a name and store it in a dictionary that will also keep track of their score. Then, open one graphic window that will simply display the name and score of the player(s). Worry about the multiple windows and clicking on each at a latter time. The design will be both easier and better if you use a class structure for this. Post the code here and ask for help for any glitches.

Start by asking the player(s) for a name and store it in a dictionary that will also keep track of their score. Then, open one graphic window that will simply display the name and score of the player(s). Worry about the multiple windows and clicking on each at a latter time. The design will be both easier and better if you use a class structure for this. Post the code here and ask for help for any glitches.

wouldn't get be easier to use the getX and getY code. I haven't coverd class struture yet

Isnt it possible that you could just have two large buttons side to side? When you click them you can set the label (if you are using wxPython) via wx.Button.SetLabel("Label Here") Then you can bind it to an event so every time the user click a button it updates the label on the button.

I cant see the exact image you want, im at school.. so its blocked. But if you're not using wxPython and using Tkinter, then im sorry, i cant help with that :P

ok,
here's one ( not very good way of doing it ) but it'll give you some idea I hope. Since you haven't done classes I'll use functions and a dictionary for the players:

from Tkinter import *

root = Tk(); root.geometry( "180x190+400+200" )
root[ "bg" ] = "white"

players = { 1:0, 2:0 }
close = False

def increaseScore1():
    global players, b2, close
    if close:
        root.destroy()
    players[ 1 ] += 1
    if players[ 1 ] == 11:
        b1[ "text" ] = str( players[ 1 ] ) + "\nWIN"
        close = True
    else:
        b1[ "text" ] = players[ 1 ]

def increaseScore2():
    global players, b2, close
    if close:
        root.destroy()
    players[ 2 ] += 1
    if players[ 2 ] == 11:
        b2[ "text" ] = str( players[ 2 ] ) + "\nWIN"
        close = True
    else:
        b2[ "text" ] = players[ 2 ]
    
b1 = Button( root, text = "0", height = 14, width = 13, command = increaseScore1 ); b1.place( relx = 1, x = -180, y = 0 ) 
b2 = Button( root, text = "0", height = 14, width = 13, command = increaseScore2 ); b2.place( relx = 1, x = -88, y = 0 )

mainloop()

P.S I'm not sure whether this is what you mean. That is how I understand the problem :)

hope this helps :)

sorry for the double post :)

here's another way by using radiobuttons instead:

from Tkinter import *

root = Tk(); root.geometry( "180x190+400+200" )
root[ "bg" ] = "white"

players = { 1:0, 2:0 }
close = False

def increaseScore():
    global players, close, buttons
    if close:
        root.destroy()
    
    v = var.get()
    players[ v ] += 1
    if players[ 1 ] == 11:
        b1[ "text" ] = str( players[ v ] ) + "\nWIN"
        close = True
    elif players[ 2 ] == 11:
        b2[ "text" ] = str( players[ 2 ] ) + "\nWIN"
        close = True
    else:
        buttons[ v ][ "text" ] = players[ v ]

var = IntVar( root, 0 )
b1 = Radiobutton( root, text = "0", indicatoron = 0, height = 14, width = 13, variable = var, value = 1, command = increaseScore ); b1.place( relx = 1, x = -180, y = 0 ) 
b2 = Radiobutton( root, text = "0", indicatoron = 0, height = 14, width = 13, variable = var, value = 2, command = increaseScore ); b2.place( relx = 1, x = -88, y = 0 )

buttons = { 1:b1, 2:b2 }

mainloop()

see if you could implement the algorithm for a two point win :)
post your code if you're stuck at some point :)

Edited 7 Years Ago by masterofpuppets: n/a

You should not speend much time on outdate mouduls like graphics.py.
Think it was written in 2005 by John M. Zelle as and easy intro to graphics for beginner.

The only way to do this is to learn a gui toolkit like Tkinter-wxpython-pyqt.
I like wxpython and use that to almost all i do with gui.

Edited 7 Years Ago by snippsat: n/a

You should not speend much time on outdate mouduls like graphics.py.
Think it was written in 2005 by John M. Zelle as and easy intro to graphics for beginner.

The only way to do this is to learn a gui toolkit like Tkinter-wxpython-pyqt.
I like wxpython and use that to almost all i do with gui.

Can the above code be simplified and change to graphic.py not TK

I don't think that anyone here is going to give you code that you can take to another forum, claim it is yours, and ask them to finish it for you. Let this thread die.

I don't think that anyone here is going to give you code that you can take to another forum, claim it is yours, and ask them to finish it for you. Let this thread die.

I asked a question, read carefully

Can the above code be simplified and change to graphic.py not TK

Maybe,but i wont speend any tïme at all on an outdatet module like graphics.py.
It was just made as an intro to graphic,you much forget this module if you want to make something ourself.

Look at code by masterofpuppets,it not hard at all to understand tkinter.

This question has already been answered. Start a new discussion instead.