DEV Community

fawlid
fawlid

Posted on

Python Dumb Finder๐Ÿ

Hello Guys!๐Ÿคž๐Ÿผ

After a while, I wrote a dumb finder program that written by Python just for FUN!!๐Ÿ˜‚

What is your idea to improve our Dumb finder program?๐Ÿค”

`#------------ * Start coding * -----------
from tkinter import *
from tkinter import messagebox
from random import randint

Importing needed packages

my_window = Tk()

Create an instance of window

my_window.geometry("350x200")

Set the geometry of the window

my_window.title("Dumb Finder")

Window title

text = Label(my_window, text="Are You Dumb?" , font=("Hobo Std",14,"bold")).pack(pady=50)

define a label(text)

def no_changer():
random_x = randint(0,150)
#gives random x for no button
random_y = randint(0,150)
#gives random y for no button
no_btn.place(x=random_x, y=random_y)
#place no button by random-generated x , y

def yes_alert():
messagebox.showinfo("Dumb Founded!", "I KNOW <3")
#show message
my_window.quit()
#close window after clicking Ok

no_btn = Button(my_window, text= "No" , width=5 , font=30, command=no_changer)

define No button and send to no_changer function

no_btn.place(x=100, y=100)

place no button in x=100 , y=100

yes_btn = Button(my_window, text= "Yes" , width=5 , font=30, command=yes_alert)

define Yes button and send to yes_alert function

yes_btn.place(x=200, y=100)

place Yes button in x = 200 , y=100

my_window.mainloop()

stay on my_window until manually close program

------------- * End of code * -----------

------------- ** Code by @fawlid ** -----`

Top comments (4)

Collapse
 
pramon18 profile image
pramon18

I think your code is missing some quotation marks.

### Should it look like this?
print("Hello World")
Enter fullscreen mode Exit fullscreen mode
Collapse
 
fawlid profile image
fawlid

where?

Collapse
 
pramon18 profile image
pramon18 • Edited

Sorry. I think i misunderstood your post. I thought the whole block starting on the "Start coding" was supposed to be formatted as code.
Like this ->

#------------ * Start coding * -----------
from tkinter import *
from tkinter import messagebox
from random import randint

Importing needed packages
my_window = Tk()

Create an instance of window
my_window.geometry("350x200")

Set the geometry of the window
my_window.title("Dumb Finder")

Window title
text = Label(my_window, text="Are You Dumb?" , font=("Hobo Std",14,"bold")).pack(pady=50)

define a label(text)
def no_changer():
random_x = randint(0,150)
#gives random x for no button
random_y = randint(0,150)
#gives random y for no button
no_btn.place(x=random_x, y=random_y)
#place no button by random-generated x , y

def yes_alert():
messagebox.showinfo("Dumb Founded!", "I KNOW <3")
#show message
my_window.quit()
#close window after clicking Ok

no_btn = Button(my_window, text= "No" , width=5 , font=30, command=no_changer)

define No button and send to no_changer function
no_btn.place(x=100, y=100)

place no button in x=100 , y=100
yes_btn = Button(my_window, text= "Yes" , width=5 , font=30, command=yes_alert)

define Yes button and send to yes_alert function
yes_btn.place(x=200, y=100)

place Yes button in x = 200 , y=100
my_window.mainloop()

stay on my_window until manually close program
------------- * End of code * -----------
------------- ** Code by @fawlid ** -----

Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
fawlid profile image
fawlid

pay more attention about code that you copied! there are more comments that you missed their #. if you want help, it is my pleasure to help you!