Re: Question:Programming a game grid ...

Discussion in 'Python' started by MRAB, Jun 28, 2012.

  1. MRAB

    MRAB Guest

    On 27/06/2012 23:21, iconoclast011 wrote:
    > Fairly new to Python ... Is there a way to efficiently (different from my brute
    > force code shown below) to set up a game grid of buttons (ie with pygame)
    > responding to mouse clicks ? I would want to vary the size of the grid ...
    >

    [code snipped]

    Something based around this, perhaps:


    buttons = {}

    for row in range(10):
    for column in range(9):
    b = Button(f3, text = "{0}{1}".format(row, column), bg = "white")
    b.grid(row=0, column=0)
    b.bind('<Button-1>', leftclick) # bind left mouse click
    b.bind('<Button-3>', rightclick) # bind left mouse click

    buttons['{0}{1}'.format(row, column)] = b
     
    MRAB, Jun 28, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. BlackHawke
    Replies:
    12
    Views:
    1,623
    Andrew Thompson
    Jan 26, 2004
  2. Max Kubierschky
    Replies:
    10
    Views:
    1,907
    pabloreda
    Mar 31, 2007
  3. David
    Replies:
    7
    Views:
    248
    Steven D'Aprano
    Jun 28, 2012
  4. alex23
    Replies:
    0
    Views:
    212
    alex23
    Jun 28, 2012
  5. Rick Johnson

    Re: Question:Programming a game grid ...

    Rick Johnson, Jun 28, 2012, in forum: Python
    Replies:
    0
    Views:
    224
    Rick Johnson
    Jun 28, 2012
Loading...

Share This Page