Project development

Hi guys!
I have learned python for a year through my school classes and now I’m asked to develop a project.
I’ve planned to develop some games like Ludo. But the problem is that I haven’t been taught about modules and functions.
For me, the topic is on tkinter module. Further random, os, math modules can be used.
So I tried to get some source code for this Ludo game through internet, hoping I can understand and learn from it and make out my project; most of the results were from GitHub and were very complex to understand.

Please can anybody help me with this.
I just need the board, 4 Buttons on 4 corners outside board with the text “Roll the die”, Die result (Random no between 1 and 6) shold be displayed under it in a box, 4 coins (No need for design or shape just black box labeled a,b,c,d for each player) and another box where player can chose which coin to move.
I don’t need to make it complex with die roll gifs or separate designs for coins or safe spots where coin doesn’t cut each other. No selection of number of players is needed, always 4 players

Please help me as I’m in need to submit it ASAP
I’ll be thankful to you :slightly_smiling_face:

Being asked to “develop a project” is a very broad and open ended statement. If you’ve yet to learn about modules and functions, then it seems to me, you’re setting your goal too high right now.

What have you learned so far? We’ll some indication of your knowledge.

They have taught us only basics like core datatypes and their functions. Currently, they are teaching on def().
Due to the covid pandemic, we had a syllabus reduction the previous year
But this year the project topics are from those deleted syllabi too and that’s where we students are facing difficulty.:worried:
One of my classmate said that someone in this forum helped him complete his project and so I’m in need of help too.
I’m learning from yt videos and few sites about tkinter module and tried my best to develop the lodo board. I’ve come up with track alone and planed to do start and end points now. :slightly_smiling_face:


from tkinter import *
import random

ws = Tk()
ws.title('PythonGuides')
ws.geometry('1080x800')
ws.config(bg='Black')

def roll():
    a=random.randint(0,7)
    return a

frame = Frame(ws, bg='Black')

Button(frame, text="   ", bg="White" ).grid(row=0, column=6)
Button(frame, text="   ", bg="White").grid(row=0, column=7)
Button(frame, text="   ", bg="White").grid(row=0, column=8)
Button(frame, text="   ", bg="White").grid(row=1, column=6)
Button(frame, text="   ", bg="Red").grid(row=1, column=7)
Button(frame, text="   ", bg="Red").grid(row=1, column=8)
Button(frame, text="   ", bg="White" ).grid(row=2, column=6)
Button(frame, text="   ", bg="Red").grid(row=2, column=7)
Button(frame, text="   ", bg="White").grid(row=2, column=8)
Button(frame, text="   ", bg="White" ).grid(row=3, column=6)
Button(frame, text="   ", bg="Red").grid(row=3, column=7)
Button(frame, text="   ", bg="White").grid(row=3, column=8)
Button(frame, text="   ", bg="White" ).grid(row=4, column=6)
Button(frame, text="   ", bg="Red").grid(row=4, column=7)
Button(frame, text="   ", bg="White").grid(row=4, column=8)
Button(frame, text="   ", bg="White" ).grid(row=5, column=6)
Button(frame, text="   ", bg="Red").grid(row=5, column=7)
Button(frame, text="   ", bg="White").grid(row=5, column=8)
Button(frame, text="   ", bg="White" ).grid(row=6, column=0)
Button(frame, text="   ", bg="Blue").grid(row=6, column=1)
Button(frame, text="   ", bg="White").grid(row=6, column=2)
Button(frame, text="   ", bg="White").grid(row=6, column=3)
Button(frame, text="   ", bg="White").grid(row=6, column=4)
Button(frame, text="   ", bg="White").grid(row=6, column=5)
Button(frame, text="   ", bg="White" ).grid(row=7, column=0)
Button(frame, text="   ", bg="Blue").grid(row=7, column=1)
Button(frame, text="   ", bg="Blue").grid(row=7, column=2)
Button(frame, text="   ", bg="Blue").grid(row=7, column=3)
Button(frame, text="   ", bg="Blue").grid(row=7, column=4)
Button(frame, text="   ", bg="Blue").grid(row=7, column=5)
Button(frame, text="   ", bg="White").grid(row=8, column=0)
Button(frame, text="   ", bg="White").grid(row=8, column=1)
Button(frame, text="   ", bg="White").grid(row=8, column=2)
Button(frame, text="   ", bg="White").grid(row=8, column=3)
Button(frame, text="   ", bg="White").grid(row=8, column=4)
Button(frame, text="   ", bg="White").grid(row=8, column=5)

Button(frame, text="   ", bg="White" ).grid(row=6, column=9)
Button(frame, text="   ", bg="White").grid(row=6, column=10)
Button(frame, text="   ", bg="White").grid(row=6, column=11)
Button(frame, text="   ", bg="White").grid(row=6, column=12)
Button(frame, text="   ", bg="White").grid(row=6, column=13)
Button(frame, text="   ", bg="White").grid(row=6, column=14)
Button(frame, text="   ", bg="Green" ).grid(row=7, column=9)
Button(frame, text="   ", bg="Green").grid(row=7, column=10)
Button(frame, text="   ", bg="Green").grid(row=7, column=11)
Button(frame, text="   ", bg="Green").grid(row=7, column=12)
Button(frame, text="   ", bg="Green").grid(row=7, column=13)
Button(frame, text="   ", bg="White").grid(row=7, column=14)
Button(frame, text="   ", bg="White").grid(row=8, column=9)
Button(frame, text="   ", bg="White").grid(row=8, column=10)
Button(frame, text="   ", bg="White").grid(row=8, column=11)
Button(frame, text="   ", bg="White").grid(row=8, column=12)
Button(frame, text="   ", bg="Green").grid(row=8, column=13)
Button(frame, text="   ", bg="White").grid(row=8, column=14)
Button(frame, text="   ", bg="White" ).grid(row=9, column=6)
Button(frame, text="   ", bg="Yellow").grid(row=9, column=7)
Button(frame, text="   ", bg="White").grid(row=9, column=8)
Button(frame, text="   ", bg="White").grid(row=10, column=6)
Button(frame, text="   ", bg="Yellow").grid(row=10, column=7)
Button(frame, text="   ", bg="White").grid(row=10, column=8)
Button(frame, text="   ", bg="White" ).grid(row=11, column=6)
Button(frame, text="   ", bg="Yellow").grid(row=11, column=7)
Button(frame, text="   ", bg="White").grid(row=11, column=8)
Button(frame, text="   ", bg="White" ).grid(row=12, column=6)
Button(frame, text="   ", bg="Yellow").grid(row=12, column=7)
Button(frame, text="   ", bg="White").grid(row=12, column=8)
Button(frame, text="   ", bg="Yellow" ).grid(row=13, column=6)
Button(frame, text="   ", bg="Yellow").grid(row=13, column=7)
Button(frame, text="   ", bg="White").grid(row=13, column=8)
Button(frame, text="   ", bg="White" ).grid(row=14, column=6)
Button(frame, text="   ", bg="White").grid(row=14, column=7)
Button(frame, text="   ", bg="White").grid(row=14, column=8)

frame.pack(expand=True) 

ws.mainloop()

For die, I thought I can use randint()
But I’ve got no idea on how to make the coin (Differently colored boxed) move.
I know this is way above what I’ve learned But I’ve got no other goes as it’s for my high school. In India, the Education system is badly hit by the Covid pandemic.
I’ll be thankful if someone can help me in this ! :slight_smile:

If you’ve only been taught the basics, how can you be expected to come up with a GUI based game?

I don’t know where that code has come from, but it’s not how I would code.

It sounds to me like you’re in a panic right now. If you’re not able to understand what you need to do and how to go about it, then you need to contact your tutor: having someone else complete your project for you will not teach you a thing.

2 Likes

The basics…

Data Types:
Do you know about:

  • Dictionary
  • List
  • Set
  • Tuple

Flow Control:
Do you know about:

  • For loops
  • While loops
  • If branches
  • Else conditions

With those building blocks, one can put together very complex text based apps. Such apps can then be developed into GUI apps. That’s the road you need to be looking at, IMHO

Yes, they have taught us about non-GUI programs, shell interactive ones.
But never did they teach us about GUI based ones nor about tkinter module :frowning:
And our tutor is like “Learn them yourself from internet”

I’ve completed making the board myself
Could you please help me from here

from tkinter import *
import random

ws = Tk()
ws.title('Ludo')
ws.geometry('1080x800')
ws.config(bg='Black')
frame = Frame(ws, bg='Black')

Button(frame, text="", bg="White",height=2,width=3).grid(row=0, column=6)
Button(frame, text="", bg="White",height=2,width=3).grid(row=0, column=7)
Button(frame, text="", bg="White",height=2,width=3).grid(row=0, column=8)
Button(frame, text="", bg="White",height=2,width=3).grid(row=1, column=6)
Button(frame, text="", bg="Red",height=2,width=3).grid(row=1, column=7)
Button(frame, text="", bg="Red",height=2,width=3).grid(row=1, column=8)
Button(frame, text="", bg="White",height=2,width=3).grid(row=2, column=6)
Button(frame, text="", bg="Red",height=2,width=3).grid(row=2, column=7)
Button(frame, text="", bg="White",height=2,width=3).grid(row=2, column=8)
Button(frame, text="", bg="White",height=2,width=3).grid(row=3, column=6)
Button(frame, text="", bg="Red",height=2,width=3).grid(row=3, column=7)
Button(frame, text="", bg="White",height=2,width=3).grid(row=3, column=8)
Button(frame, text="", bg="White",height=2,width=3).grid(row=4, column=6)
Button(frame, text="", bg="Red",height=2,width=3).grid(row=4, column=7)
Button(frame, text="", bg="White",height=2,width=3).grid(row=4, column=8)
Button(frame, text="", bg="White",height=2,width=3).grid(row=5, column=6)
Button(frame, text="", bg="Red",height=2,width=3).grid(row=5, column=7)
Button(frame, text="", bg="White",height=2,width=3).grid(row=5, column=8)
Button(frame, text="", bg="White",height=2,width=3).grid(row=6, column=0)
Button(frame, text="", bg="Blue",height=2,width=3).grid(row=6, column=1)
Button(frame, text="", bg="White",height=2,width=3).grid(row=6, column=2)
Button(frame, text="", bg="White",height=2,width=3).grid(row=6, column=3)
Button(frame, text="", bg="White",height=2,width=3).grid(row=6, column=4)
Button(frame, text="", bg="White",height=2,width=3).grid(row=6, column=5)
Button(frame, text="", bg="White",height=2,width=3).grid(row=7, column=0)
Button(frame, text="", bg="Blue",height=2,width=3).grid(row=7, column=1)
Button(frame, text="", bg="Blue",height=2,width=3).grid(row=7, column=2)
Button(frame, text="", bg="Blue",height=2,width=3).grid(row=7, column=3)
Button(frame, text="", bg="Blue",height=2,width=3).grid(row=7, column=4)
Button(frame, text="", bg="Blue",height=2,width=3).grid(row=7, column=5)
Button(frame, text="", bg="White",height=2,width=3).grid(row=8, column=0)
Button(frame, text="", bg="White",height=2,width=3).grid(row=8, column=1)
Button(frame, text="", bg="White",height=2,width=3).grid(row=8, column=2)
Button(frame, text="", bg="White",height=2,width=3).grid(row=8, column=3)
Button(frame, text="", bg="White",height=2,width=3).grid(row=8, column=4)
Button(frame, text="", bg="White",height=2,width=3).grid(row=8, column=5)
Button(frame, text="", bg="White",height=2,width=3).grid(row=6, column=9)
Button(frame, text="", bg="White",height=2,width=3).grid(row=6, column=10)
Button(frame, text="", bg="White",height=2,width=3).grid(row=6, column=11)
Button(frame, text="", bg="White",height=2,width=3).grid(row=6, column=12)
Button(frame, text="", bg="White",height=2,width=3).grid(row=6, column=13)
Button(frame, text="", bg="White",height=2,width=3).grid(row=6, column=14)
Button(frame, text="", bg="Green",height=2,width=3).grid(row=7, column=9)
Button(frame, text="", bg="Green",height=2,width=3).grid(row=7, column=10)
Button(frame, text="", bg="Green",height=2,width=3).grid(row=7, column=11)
Button(frame, text="", bg="Green",height=2,width=3).grid(row=7, column=12)
Button(frame, text="", bg="Green",height=2,width=3).grid(row=7, column=13)
Button(frame, text="", bg="White",height=2,width=3).grid(row=7, column=14)
Button(frame, text="", bg="White",height=2,width=3).grid(row=8, column=9)
Button(frame, text="", bg="White",height=2,width=3).grid(row=8, column=10)
Button(frame, text="", bg="White",height=2,width=3).grid(row=8, column=11)
Button(frame, text="", bg="White",height=2,width=3).grid(row=8, column=12)
Button(frame, text="", bg="Green",height=2,width=3).grid(row=8, column=13)
Button(frame, text="", bg="White",height=2,width=3).grid(row=8, column=14)
Button(frame, text="", bg="White",height=2,width=3).grid(row=9, column=6)
Button(frame, text="", bg="#9932cc",height=2,width=3).grid(row=9, column=7)
Button(frame, text="", bg="White",height=2,width=3).grid(row=9, column=8)
Button(frame, text="", bg="White",height=2,width=3).grid(row=10, column=6)
Button(frame, text="", bg="#9932cc",height=2,width=3).grid(row=10, column=7)
Button(frame, text="", bg="White",height=2,width=3).grid(row=10, column=8)
Button(frame, text="", bg="White",height=2,width=3).grid(row=11, column=6)
Button(frame, text="", bg="#9932cc",height=2,width=3).grid(row=11, column=7)
Button(frame, text="", bg="White",height=2,width=3).grid(row=11, column=8)
Button(frame, text="", bg="White",height=2,width=3).grid(row=12, column=6)
Button(frame, text="", bg="#9932cc",height=2,width=3).grid(row=12, column=7)
Button(frame, text="", bg="White",height=2,width=3).grid(row=12, column=8)
Button(frame, text="", bg="#9932cc",height=2,width=3).grid(row=13, column=6)
Button(frame, text="", bg="#9932cc",height=2,width=3).grid(row=13, column=7)
Button(frame, text="", bg="White",height=2,width=3).grid(row=13, column=8)
Button(frame, text="", bg="White",height=2,width=3).grid(row=14, column=6)
Button(frame, text="", bg="White",height=2,width=3).grid(row=14, column=7)
Button(frame, text="", bg="White",height=2,width=3).grid(row=14, column=8)

Button(frame, text=" a ",bg="#00bfff",height=2,width=3).grid(row=1,column=1)
Button(frame, text=" b ",bg="#00bfff",height=2,width=3).grid(row=1,column=4)
Button(frame, text=" c ",bg="#00bfff",height=2,width=3).grid(row=4,column=1)
Button(frame, text=" d ",bg="#00bfff",height=2,width=3).grid(row=4,column=4)
Button(frame, text=" a ",bg="#ff355e",height=2,width=3).grid(row=1,column=10)
Button(frame, text=" b ",bg="#ff355e",height=2,width=3).grid(row=1,column=13)
Button(frame, text=" c ",bg="#ff355e",height=2,width=3).grid(row=4,column=10)
Button(frame, text=" d ",bg="#ff355e",height=2,width=3).grid(row=4,column=13)
Button(frame, text=" a ",bg="#dda0dd",height=2,width=3).grid(row=10,column=1)
Button(frame, text=" b ",bg="#dda0dd",height=2,width=3).grid(row=10,column=4)
Button(frame, text=" c ",bg="#dda0dd",height=2,width=3).grid(row=13,column=1)
Button(frame, text=" d ",bg="#dda0dd",height=2,width=3).grid(row=13,column=4)
Button(frame, text=" a ",bg="#39ff14",height=2,width=3).grid(row=10,column=10)
Button(frame, text=" b ",bg="#39ff14",height=2,width=3).grid(row=10,column=13)
Button(frame, text=" c ",bg="#39ff14",height=2,width=3).grid(row=13,column=10)
Button(frame, text=" d ",bg="#39ff14",height=2,width=3).grid(row=13,column=13)

Button(frame,height=2,width=3,bg='yellow').grid(row=6,column=6)
Button(frame,height=2,width=3,bg='yellow').grid(row=7,column=6)
Button(frame,height=2,width=3,bg='yellow').grid(row=8,column=6)
Button(frame,height=2,width=3,bg='yellow').grid(row=6,column=7)
Button(frame,text="Win",bg='orange',height=2,width=3).grid(row=7,column=7)
Button(frame,height=2,width=3,bg='yellow').grid(row=8,column=7)
Button(frame,height=2,width=3,bg='yellow').grid(row=6,column=8)
Button(frame,height=2,width=3,bg='yellow').grid(row=7,column=8)
Button(frame,height=2,width=3,bg='yellow').grid(row=8,column=8)

Button(frame,height=2,width=3,bg='yellow').grid(row=0,column=0)
Button(frame,height=2,width=3,bg='yellow').grid(row=0,column=1)
Button(frame,height=2,width=3,bg='yellow').grid(row=0,column=2)
Button(frame,height=2,width=3,bg='yellow').grid(row=0,column=3)
Button(frame,height=2,width=3,bg='yellow').grid(row=0,column=4)
Button(frame,height=2,width=3,bg='yellow').grid(row=0,column=5)
Button(frame,height=2,width=3,bg='yellow').grid(row=1,column=0)
Button(frame,height=2,width=3,bg='yellow').grid(row=1,column=2)
Button(frame,height=2,width=3,bg='yellow').grid(row=1,column=3)
Button(frame,height=2,width=3,bg='yellow').grid(row=1,column=5)
Button(frame,height=2,width=3,bg='yellow').grid(row=2,column=0)
Button(frame,height=2,width=3,bg='yellow').grid(row=2,column=1)
Button(frame,height=2,width=3,bg='yellow').grid(row=2,column=2)
Button(frame,height=2,width=3,bg='yellow').grid(row=2,column=3)
Button(frame,height=2,width=3,bg='yellow').grid(row=2,column=4)
Button(frame,height=2,width=3,bg='yellow').grid(row=2,column=5)
Button(frame,height=2,width=3,bg='yellow').grid(row=3,column=0)
Button(frame,height=2,width=3,bg='yellow').grid(row=3,column=1)
Button(frame,height=2,width=3,bg='yellow').grid(row=3,column=2)
Button(frame,height=2,width=3,bg='yellow').grid(row=3,column=3)
Button(frame,height=2,width=3,bg='yellow').grid(row=3,column=4)
Button(frame,height=2,width=3,bg='yellow').grid(row=3,column=5)
Button(frame,height=2,width=3,bg='yellow').grid(row=4,column=0)
Button(frame,height=2,width=3,bg='yellow').grid(row=4,column=2)
Button(frame,height=2,width=3,bg='yellow').grid(row=4,column=3)
Button(frame,height=2,width=3,bg='yellow').grid(row=4,column=5)
Button(frame,height=2,width=3,bg='yellow').grid(row=5,column=0)
Button(frame,height=2,width=3,bg='yellow').grid(row=5,column=1)
Button(frame,height=2,width=3,bg='yellow').grid(row=5,column=2)
Button(frame,height=2,width=3,bg='yellow').grid(row=5,column=3)
Button(frame,height=2,width=3,bg='yellow').grid(row=5,column=4)
Button(frame,height=2,width=3,bg='yellow').grid(row=5,column=5)
Button(frame,height=2,width=3,bg='yellow').grid(row=0,column=9)
Button(frame,height=2,width=3,bg='yellow').grid(row=0,column=10)
Button(frame,height=2,width=3,bg='yellow').grid(row=0,column=11)
Button(frame,height=2,width=3,bg='yellow').grid(row=0,column=12)
Button(frame,height=2,width=3,bg='yellow').grid(row=0,column=13)
Button(frame,height=2,width=3,bg='yellow').grid(row=0,column=14)
Button(frame,height=2,width=3,bg='yellow').grid(row=1,column=9)
Button(frame,height=2,width=3,bg='yellow').grid(row=1,column=11)
Button(frame,height=2,width=3,bg='yellow').grid(row=1,column=12)
Button(frame,height=2,width=3,bg='yellow').grid(row=1,column=14)
Button(frame,height=2,width=3,bg='yellow').grid(row=2,column=9)
Button(frame,height=2,width=3,bg='yellow').grid(row=2,column=10)
Button(frame,height=2,width=3,bg='yellow').grid(row=2,column=11)
Button(frame,height=2,width=3,bg='yellow').grid(row=2,column=12)
Button(frame,height=2,width=3,bg='yellow').grid(row=2,column=13)
Button(frame,height=2,width=3,bg='yellow').grid(row=2,column=14)
Button(frame,height=2,width=3,bg='yellow').grid(row=3,column=9)
Button(frame,height=2,width=3,bg='yellow').grid(row=3,column=10)
Button(frame,height=2,width=3,bg='yellow').grid(row=3,column=11)
Button(frame,height=2,width=3,bg='yellow').grid(row=3,column=12)
Button(frame,height=2,width=3,bg='yellow').grid(row=3,column=13)
Button(frame,height=2,width=3,bg='yellow').grid(row=3,column=14)
Button(frame,height=2,width=3,bg='yellow').grid(row=4,column=9)
Button(frame,height=2,width=3,bg='yellow').grid(row=4,column=11)
Button(frame,height=2,width=3,bg='yellow').grid(row=4,column=12)
Button(frame,height=2,width=3,bg='yellow').grid(row=4,column=14)
Button(frame,height=2,width=3,bg='yellow').grid(row=5,column=9)
Button(frame,height=2,width=3,bg='yellow').grid(row=5,column=10)
Button(frame,height=2,width=3,bg='yellow').grid(row=5,column=11)
Button(frame,height=2,width=3,bg='yellow').grid(row=5,column=12)
Button(frame,height=2,width=3,bg='yellow').grid(row=5,column=13)
Button(frame,height=2,width=3,bg='yellow').grid(row=5,column=14)
Button(frame,height=2,width=3,bg='yellow').grid(row=9,column=0)
Button(frame,height=2,width=3,bg='yellow').grid(row=9,column=1)
Button(frame,height=2,width=3,bg='yellow').grid(row=9,column=2)
Button(frame,height=2,width=3,bg='yellow').grid(row=9,column=3)
Button(frame,height=2,width=3,bg='yellow').grid(row=9,column=4)
Button(frame,height=2,width=3,bg='yellow').grid(row=9,column=5)
Button(frame,height=2,width=3,bg='yellow').grid(row=10,column=0)
Button(frame,height=2,width=3,bg='yellow').grid(row=10,column=2)
Button(frame,height=2,width=3,bg='yellow').grid(row=10,column=3)
Button(frame,height=2,width=3,bg='yellow').grid(row=10,column=5)
Button(frame,height=2,width=3,bg='yellow').grid(row=11,column=0)
Button(frame,height=2,width=3,bg='yellow').grid(row=11,column=1)
Button(frame,height=2,width=3,bg='yellow').grid(row=11,column=2)
Button(frame,height=2,width=3,bg='yellow').grid(row=11,column=3)
Button(frame,height=2,width=3,bg='yellow').grid(row=11,column=4)
Button(frame,height=2,width=3,bg='yellow').grid(row=11,column=5)
Button(frame,height=2,width=3,bg='yellow').grid(row=12,column=0)
Button(frame,height=2,width=3,bg='yellow').grid(row=12,column=1)
Button(frame,height=2,width=3,bg='yellow').grid(row=12,column=2)
Button(frame,height=2,width=3,bg='yellow').grid(row=12,column=3)
Button(frame,height=2,width=3,bg='yellow').grid(row=12,column=4)
Button(frame,height=2,width=3,bg='yellow').grid(row=12,column=5)
Button(frame,height=2,width=3,bg='yellow').grid(row=13,column=0)
Button(frame,height=2,width=3,bg='yellow').grid(row=13,column=2)
Button(frame,height=2,width=3,bg='yellow').grid(row=13,column=3)
Button(frame,height=2,width=3,bg='yellow').grid(row=13,column=5)
Button(frame,height=2,width=3,bg='yellow').grid(row=14,column=0)
Button(frame,height=2,width=3,bg='yellow').grid(row=14,column=1)
Button(frame,height=2,width=3,bg='yellow').grid(row=14,column=2)
Button(frame,height=2,width=3,bg='yellow').grid(row=14,column=3)
Button(frame,height=2,width=3,bg='yellow').grid(row=14,column=4)
Button(frame,height=2,width=3,bg='yellow').grid(row=14,column=5)
Button(frame,height=2,width=3,bg='yellow').grid(row=9,column=9)
Button(frame,height=2,width=3,bg='yellow').grid(row=9,column=10)
Button(frame,height=2,width=3,bg='yellow').grid(row=9,column=11)
Button(frame,height=2,width=3,bg='yellow').grid(row=9,column=12)
Button(frame,height=2,width=3,bg='yellow').grid(row=9,column=13)
Button(frame,height=2,width=3,bg='yellow').grid(row=9,column=14)
Button(frame,height=2,width=3,bg='yellow').grid(row=10,column=9)
Button(frame,height=2,width=3,bg='yellow').grid(row=10,column=11)
Button(frame,height=2,width=3,bg='yellow').grid(row=10,column=12)
Button(frame,height=2,width=3,bg='yellow').grid(row=10,column=14)
Button(frame,height=2,width=3,bg='yellow').grid(row=11,column=9)
Button(frame,height=2,width=3,bg='yellow').grid(row=11,column=10)
Button(frame,height=2,width=3,bg='yellow').grid(row=11,column=11)
Button(frame,height=2,width=3,bg='yellow').grid(row=11,column=12)
Button(frame,height=2,width=3,bg='yellow').grid(row=11,column=13)
Button(frame,height=2,width=3,bg='yellow').grid(row=11,column=14)
Button(frame,height=2,width=3,bg='yellow').grid(row=12,column=9)
Button(frame,height=2,width=3,bg='yellow').grid(row=12,column=10)
Button(frame,height=2,width=3,bg='yellow').grid(row=12,column=11)
Button(frame,height=2,width=3,bg='yellow').grid(row=12,column=12)
Button(frame,height=2,width=3,bg='yellow').grid(row=12,column=13)
Button(frame,height=2,width=3,bg='yellow').grid(row=12,column=14)
Button(frame,height=2,width=3,bg='yellow').grid(row=13,column=9)
Button(frame,height=2,width=3,bg='yellow').grid(row=13,column=11)
Button(frame,height=2,width=3,bg='yellow').grid(row=13,column=12)
Button(frame,height=2,width=3,bg='yellow').grid(row=13,column=14)
Button(frame,height=2,width=3,bg='yellow').grid(row=14,column=9)
Button(frame,height=2,width=3,bg='yellow').grid(row=14,column=10)
Button(frame,height=2,width=3,bg='yellow').grid(row=14,column=11)
Button(frame,height=2,width=3,bg='yellow').grid(row=14,column=12)
Button(frame,height=2,width=3,bg='yellow').grid(row=14,column=13)
Button(frame,height=2,width=3,bg='yellow').grid(row=14,column=14)

frame.pack(expand=True) 

ws.mainloop()

You’ve not planned this at all. By not doing any planing, you’re simply developing this on-the-fly, which means that there’s a very good chance that you’re going to hit a design floor. At that point, you’re going to have to start over.

You don’t need 200 lines of code to do what you’ve done: that’s what ‘loops’ are for.

Example:

for row in range(15):
    if row < 6 or row > 8:
        Button(frame,height=2,width=3,bg='yellow').grid(row=row,column=0)
    else:
        Button(frame,height=2,width=3,bg='white'). grid(row=row,column=0)

That loop replaces 15 lines of your code, although at this stage, I don’t even know why you’re using Buttons. Do you plan on having a command for each Button?

If I were you, I would use something like:

# This Code Creates a 5X5 Table Of Buttons (With Colored Cells)
board = {}
for button_no in range(25):# 5**2 = 25
    board["btn"+str(button_no)] = Button(frame, text="", bg="White",height=2,width=3) # board["btn1"] = Button() etc.
    button_no += 1
        
blue_btns = [1,2,3,4]
for i in blue_btns:
    board["btn"+str(i)].configure( bg="Blue" )
#red_btns=[]
#for i in red_btns ...
#yellow_btns=[]
#for i in yellow_btns ...
#BLA BLA
button_no = 0
for row in range(5):
    for column in range(5):
        board["btn"+str(button_no)].grid(row=row,column=column)
        button_no += 1

This seems to be more dynamic(easily changeable) and easier to understand.

PS: In your code, you have lots of button objects which weren’t assigned to variables. Since you are making a ludo game, you should “move” them, but it seems too hard - at least to me- to do that without variables. Dictionary “board” -in my code above- may help you at this point.-A list may even be better. Instead of doing board["btn1"], to access 1. button, you would be able to access it via board[1] -

1 Like

First of all thanks Rob for trying to guid me :smiley:
And I didn’t know that this can also be done through loop
I just did copy past the line 15*15 = 225 times and formated the grid points.
Also I’m not sure what else to use rather than buttons.
I just thought that I’ll load the config of blank button to a variable and Pice(Coloured button with text ‘a’/‘b’/‘c’/‘d’) to another from there I thought I can use some mathamatical functions and format the particular button at needed grid points.
Kindly let me know if you got any better ideas please. Thank you !

I’m not sure if I can format a button by assigning arguments to a variable.
If this is not possible, I’ll be having to start over :worried:
Please let me know if this will work too

Oh ok I understood! This can create the whole board!

from tkinter import *
ws=Tk()
ws.title('Ludo')
ws.geometry('1080x800')
frame=Frame(ws,bg='black')

for i in range(15):
    for j in range(15):
        Button(frame,height=2,width=3,bg='yellow').grid(row=i,column=j)
        
frame.pack(expand=True)
ws.mainloop()

Thankyou ! :smiley:

You’re very welcome.

Now you’re getting it; well done.

I think that @sandraC could be on to something with her approach.

I’ve never codded a game, but I have done some design work with Tkinter, but not much. I’d use Label rather than Button for what you’re doing, unless you need something that is ‘clickable’.

Can I format lables with bg ? simillar to buttons ?

Yes, you can

Also, checkout this guy: Python Tkinter GUI 🐍【𝙁𝙧𝙚𝙚】 - YouTube

1 Like

I am also not a tkinter expert, unfortunately. But this discussion says yes:

I think, it is impossible to make a “movement” without generators or callable classes. -And you say that you haven’t got a knowledge about these kind of things.-
I want to hear others’ thoughts about simplifying this, if possible.

Will I be able to configure a button after assigning configurations to a variable. If so please let me know how to do it

Yes I’m too interested in knowing of ways to simplifying my code.
I tried to get some source code from GitHub but those too were complex with high end GUI and multiple .py files which I didn’t understand how they work.
I just need this to be simple
always 4 player
I common dice next to board
4 unique buttons for each players.
Config of there button to be loaded into a variable so there variable will be used to config the button where the coin should move to and the old place to be config with configuration of blank button