Packing Buttons In Tkinter | Python Tkinter GUI Tutorial In Hindi #9

Packing Buttons In Tkinter | Python Tkinter GUI Tutorial In Hindi #9

CodeWithHarry

5 лет назад

102,633 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@Mrinal_Devnath
@Mrinal_Devnath - 29.11.2023 20:04

from tkinter import *
def three():
print(3)
def plus():
print("+")
def fout():
print(4)
def cal():
print(3 + 4)
root = Tk()
root.geometry("400x400")
root.title("Simple calculator")
root.minsize(200, 200)
frame = Frame(root, border=2, bg="Blue", relief=SUNKEN)
frame.pack(side=LEFT, anchor="nw")
b1 = Button(frame, fg="red", text="3", command=hi).pack(side=LEFT, anchor="nw")
b2 = Button(frame, fg="red", text="+", command=plus).pack(side=LEFT, anchor="nw", padx=5)
b3 = Button(frame, fg="red", text="4", command=fout).pack(side=LEFT, anchor="nw", padx=5)
b4 = Button(frame, fg="red", text="=", command=cal).pack(side=LEFT, anchor="nw", padx=5)


root.mainloop()

Ответить
@neharajput8353
@neharajput8353 - 07.11.2023 19:04

Your video is really very helpful to understand this GUI TKINTER.

Ответить
@navneetgupta6240
@navneetgupta6240 - 13.10.2023 11:01

Exercise code:

from tkinter import *

root = Tk()
root.geometry("444x444")
frame = Frame(root, bg="white", relief=SUNKEN)
frame.pack(side=LEFT, anchor=NW)
def name():
print("Vijval")
def clas():
print("7th")
def section():
print("E")
def roll():
print(49)

b = Button(frame, fg="black", text="NAME", bg="white", relief=SUNKEN, command=name)
b.pack(side="left")

c = Button(frame, fg="black", text="CLASS", bg="white", relief=SUNKEN, command=clas)
c.pack(side="left")

d = Button(frame, fg="black", text="SECTION", bg="white", relief=SUNKEN, command=section)
d.pack(side="left")

e = Button(frame, fg="black", text="ROLL NO.", bg="white", relief=SUNKEN, command=roll)
e.pack(side="left")

root.title("Exercise 1")
root.configure(bg="black")

root.mainloop()

Ответить
@ishusharma9653
@ishusharma9653 - 06.10.2023 16:38

harry bhai me apna project bana rha hu cs ka and usme mujhe chahiye ki button pe click karu to ek alag tkinter window open ho jaha mera main code ka logic run ho but vo kese karu samajh nhi aa rha plz help

Ответить
@zeeshanali4502
@zeeshanali4502 - 02.10.2023 10:25

heres the solution from tkinter import *
root = Tk()
root.geometry("666x433")
root.title("Learning tkinter")
topr=Frame(root,borderwidth=5,relief=GROOVE,bg="red")
title = Label(topr,text="This is inside frame " , padx=5,pady=10 , font="times 13 bold" ,fg="white" ,bg="red")
title.pack()
topr.pack(side="top",fill=X)

def getName():
print("Zeeshan")
for widget in op.winfo_children():
widget.destroy()
ti=Label(op,text="Name = Zeeshan ")
ti.pack()

def getDob():
print("Nahi bataunga")
for widget in op.winfo_children():
widget.destroy()

ti=Label(op,text="DOB = Nahi bataunga ")
ti.pack()
def getAdd():
print("up, India")
for widget in op.winfo_children():
widget.destroy()
ti=Label(op,text="Add = Up,India ")
ti.pack()
def getLang():
print("Python")
for widget in op.winfo_children():
widget.destroy()
ti=Label(op,text="Language = Python ")
ti.pack()
f2=Frame(root,bg="grey",pady=10)
namebtn=Button( f2,text="Get Name" ,command=getName)
namebtn.pack(side=LEFT,padx=10)
dobbtn=Button( f2,text="Get Dob" ,command=getDob)
dobbtn.pack(side=LEFT,padx=10)
addbtn=Button( f2,text="Get Address" ,command=getAdd)
addbtn.pack(side=LEFT,padx=10)
langbtn=Button( f2,text="Get Lang" ,command=getLang)
langbtn.pack(side=LEFT,padx=10)
f2.pack()

op = Frame(root,bg="grey" ,padx=10,pady=20)

op.pack(side=TOP)
root.mainloop()

Ответить
@akhileshkumarsharma2405
@akhileshkumarsharma2405 - 30.09.2023 11:40

from tkinter import *

root=Tk()
def btn1():
print('My Name is Bobby')
def btn2():
print('I am a Python Developer')
def btn3():
print('I have 2 years of experience of Python, Go and MySQL')
def btn4():
print('I am from Gorakhpur')
root.geometry("750x550")
f1= Frame(root, borderwidth=6)
f1.pack(side='left', anchor='nw')

btn= Button(f1, text= 'File', command=btn1)
btn.pack(side='left')

btn= Button(f1, text= 'Edit', command=btn2)
btn.pack(side='left')

btn= Button(f1, text= 'Format', command=btn3)
btn.pack(side='left')

btn= Button(f1, text= 'Help', command=btn4)
btn.pack(side='left')

root.mainloop()

Ответить
@manoranjansahu1680
@manoranjansahu1680 - 12.09.2023 13:44

from tkinter import *
root = Tk()
root.geometry("500x400")

def f1():
print("Button 1 Pressed")
def f2():
print("Button 2 Pressed")
def f3():
print("Button 3 Pressed")
def f4():
print("Button 4 Pressed")

frame = Frame(root, bg = "grey", borderwidth = 2, relief = SUNKEN)
frame.pack(side = LEFT, anchor = 'nw')
b1 = Button(frame, fg = 'red', text = 'Button 1', command = f1)
b1.pack(side = LEFT, padx = 23)

b2 = Button(frame, fg = 'red', text = 'Button 2', command = f2)
b2.pack(side = LEFT, padx = 23)

b3 = Button(frame, fg = 'red', text = 'Button 3', command = f3)
b3.pack(side = LEFT, padx = 23)

b4 = Button(frame, fg = 'red', text = 'Button 4', command = f4)
b4.pack(side = LEFT, padx = 23)
root.mainloop()

Ответить
@psrapidogaming1721
@psrapidogaming1721 - 07.09.2023 19:44

here is the code buddy ....

from tkinter import *
root = Tk()
root.geometry("500x300")
root.title("buttons tutorial")
root.minsize(500,400)
def hello():
print("hay welcome")
def name():
print("my name is harry")
def code():
print("python")
def bye():
print("ok bye")


f1=Frame(root, bg="gray", borderwidth=8,relief=SUNKEN)
f1.pack(side =LEFT ,anchor="nw" ,fill = "x")
b1 =Button(f1,text="click" ,bg="silver", borderwidth=8,relief=SUNKEN, padx=5,pady=5,command =hello)
b1.pack(side =LEFT ,padx=10,pady=10)
b2 =Button(f1,text="click" ,bg="silver", borderwidth=8,relief=SUNKEN, padx=5,pady=5,command =name)
b2.pack(side =LEFT,padx=10,pady=10)
b3=Button(f1,text="click" ,bg="silver", borderwidth=8,relief=SUNKEN, padx=5,pady=5,command =code)
b3.pack(side =LEFT,padx=10,pady=10)
b4=Button(f1,text="click" ,bg="silver", borderwidth=8,relief=SUNKEN, padx=5,pady=5,command =bye)
b4.pack(side =LEFT,padx=10,pady=10)

root.mainloop()

Ответить
@psrapidogaming1721
@psrapidogaming1721 - 07.09.2023 18:28

i accept the challange brother

code is coming soon

Ответить
@ultranoobm319
@ultranoobm319 - 26.08.2023 19:44

from tkinter import *
root = Tk()

def fun1():
print("button 1 clicked")

def fun2():
print("button 2 clicked")

def fun3():
print("button 3 clicked")

def fun4():
print("button 4 clicked")

root.geometry("1000x600")

f1 = Frame(root, borderwidth=5, background="black", relief="groove")
f1.pack(side="left", anchor="nw")

b1 = Button(f1, foreground="gold", background="black", text="button 1", command=fun1)
b1.pack(padx=1, pady=1)

b2 = Button(f1, foreground="gold", background="black", text="button 2", command=fun2)
b2.pack(padx=1, pady=1)

b3 = Button(f1, foreground="gold", background="black", text="button 3", command=fun3)
b3.pack(padx=1, pady=1)

b4 = Button(f1, foreground="gold", background="black", text="button 4", command=fun4)
b4.pack(padx=1, pady=1)

root.mainloop()

Ответить
@manizlegent5275
@manizlegent5275 - 25.08.2023 16:57

how to make button open another window

Ответить
@user-oh7iw8wq4x
@user-oh7iw8wq4x - 18.08.2023 17:06

from tkinter import*

root = Tk()
root.geometry('500x400')
root.minsize(400,100)
root.title("Button")

def Red():
print("RED")

def Green():
print("GREEN")

def Blue():
print("BLUE")

def Yellow():
print("YELLOW")

f1 = Frame(root,borderwidth=6,relief=SUNKEN,bg='gray')
f1.pack(side='left',anchor='nw')

b1 = Button(f1,fg='red',text='RED', command=Red)
b1.pack(side='left',padx=10)

b2 = Button(f1, fg='green',text='GREEN',command=Green)
b2.pack(side='left',padx=10)

b3 = Button(f1, fg='blue',text="BLUE",command=Blue)
b3.pack(side='left',padx=10)

b4 = Button(f1,fg='yellow', text="YELLOW", command=Yellow)
b4.pack(side='left',padx=10)
root.mainloop()

Ответить
@solankidaksh9725
@solankidaksh9725 - 16.08.2023 09:48

from tkinter import*
a = Tk()
a.geometry("456x344")
a.title("Task 2")

def Name():
print("My name is Daksh")

def age():
print("My age is 18")

def crickter():
print("My favriout is Virat kohli")

def colour():
print("My skin colour is brown")

b = Button(a,text="Print Name",bg="red",fg="Black",borderwidth=6,font="arial,10,bold",relief="solid",command=Name)
b.pack(side="left",pady=23,anchor="nw")

b = Button(a,text="Print age",bg="red",fg="Black",borderwidth=6,font="arial,10,bold",relief="solid",command=age)
b.pack(side="left",pady=23,anchor="nw")

b = Button(a,text="Print colour",bg="red",fg="Black",borderwidth=6,font="arial,10,bold",relief="solid",command=colour)
b.pack(side="left",pady=23,anchor="nw")

b = Button(a,text="Print cricketer",bg="red",fg="Black",borderwidth=6,font="arial,10,bold",relief="solid",command=crickter)
b.pack(side="left",pady=23,anchor="nw")

a.mainloop()

Ответить
@Titanium_Gopal
@Titanium_Gopal - 06.08.2023 10:08

from tkinter import *
from tkinter import messagebox
from PIL import Image, ImageTk
import subprocess
import platform

root = Tk()
root.geometry("655x333")

def greet():
print("Good Morning Sir!")

def wish():
fruit = input('What is your Favorite fruit: ')
print("Check GUI")
if fruit.lower() == 'banana':
image_path = 'F/banana.jpg'
elif fruit.lower() == 'apple':
image_path = 'F/apple.jpg'
elif fruit.lower() == 'orange':
image_path = 'F/orange.jpg'
elif fruit.lower() == 'watermelon':
image_path = 'F/wl.jpg'
else:
print(f"Sorry, we only have images of a banana, apple, orange, and wl.")
return

load = Image.open(image_path)
render = ImageTk.PhotoImage(load)
img = Label(image=render)
img.image = render
img.place(x=50, y=50)

def text():
system = platform.system()
if system == 'Windows':
subprocess.run(["notepad.exe"])
elif system == 'Darwin': # macOS
subprocess.run(["open", "-a", "TextEdit"])
else:
print("Unsupported operating system. Could not open the text editor.")

def greetl():
message = "Have a great day!\nBye!"
print(message)
messagebox.showinfo("Greetings", message)

frame = Frame(root, borderwidth=6, bg="blue", relief=SUNKEN)
frame.pack(side=LEFT, anchor="nw")

b1 = Button(frame, fg="blue", text="Click Me", command=greet)
b1.pack(side=LEFT, padx=23)

b2 = Button(frame, fg="blue", text="Wish Me", command=wish)
b2.pack(side=LEFT, padx=23)

b3 = Button(frame, fg="blue", text="Text Here", command=text)
b3.pack(side=LEFT, padx=23)

b4 = Button(frame, fg="blue", text="Please Click It", command=greetl)
b4.pack(side=LEFT, padx=23)

root.mainloop()

Ответить
@user-dt9ud1el1l
@user-dt9ud1el1l - 28.07.2023 07:40

my code:


from tkinter import *

window = Tk()
window.title("Buttons")

window.geometry("400x400")

label = Label(text="Buttons", fg="darkblue", font=("Arial", 20, "bold"))
label.pack(pady=10)

def name():
print("Hello, my Name is Harsimran Kaur")

def age():
print("Hello, my Age is 17 Years")

def course():
print("Hello, my Course is Btech-Cse")

def hobby():
print("Hello, my Hobby is Reading Books, Listening Music and Coding")

button = Button(window, text="Show Name", command=name, border=10)
button.pack(pady=10)

button = Button(window, text="Show Age", command=age, border=10)
button.pack(pady=10)

button = Button(window, text="Show Course", command=course, border=10)
button.pack(pady=10)

button = Button(window, text="Show Hobby", command=hobby, border=10)
button.pack(pady=10)

Ответить
@softech9617
@softech9617 - 17.07.2023 11:58

from tkinter import *
root = Tk()
def hello():
print("Hello ")
def hi():
print("hi ")
def hey():
print("hey ")
def halo():
print("halo ")
root.geometry("500x500")
f1 = Frame(root,bg="grey",borderwidth=10, relief=SUNKEN)
f1.pack(side = LEFT,fill="y")

b1 = Button(f1,fg= "black", text = "Print Now",command=hello)
b1.pack()

f2 = Frame(root,bg="grey",borderwidth=10, relief=SUNKEN)
f2.pack(side = LEFT,fill="y")

b2 = Button(f2,fg= "black", text = "Print Now",command=hi)
b2.pack()

f3 = Frame(root,bg="grey",borderwidth=10, relief=SUNKEN)
f3.pack(side = LEFT,fill="y")

b3 = Button(f3,fg= "black", text = "Print Now",command=hey)
b3.pack()

f4 = Frame(root,bg="grey",borderwidth=10, relief=SUNKEN)
f4.pack(side = LEFT,fill="y")

b4 = Button(f4,fg= "black", text = "Print Now",command=halo)
b4.pack()

root.mainloop()

Ответить
@sanketbhute5341
@sanketbhute5341 - 15.07.2023 12:51

from tkinter import*

root=Tk()
root.geometry("655x333")

def hello():
print("hello sanket")

def name():
print("My name is sanket")

def clg():
print("priyadarshni clg of engineering")

def distric():
print("nagpur")


f1= Frame (root, bg="gray",borderwidth=6, relief="sunken")
f1.pack(side=LEFT,anchor="ne")

b1=Button(f1,fg="red", text="say hello", command=hello)
b1.pack(side=LEFT,padx=23)

b2=Button(f1,fg="red", text="tell me name",command=name)
b2.pack(side=LEFT,padx=23)

b3=Button(f1,fg="red", text="print clg", command=clg)
b3.pack(side=LEFT,padx=23)

b4=Button(f1,fg="red", text="print distric", command=distric)
b4.pack(side=LEFT,padx=23)


root.mainloop()

Ответить
@royalwinnerz8481
@royalwinnerz8481 - 09.07.2023 09:49

Challenge Accepted

from tkinter import *
from PIL import Image, ImageTk
import os


root = Tk()
root.geometry('500x400')
def bu1():
print("Hello 1")
def bu2():
print("Hello 2")
def bu3():
print("Hello 3")
def bu4():
print("Hello 4")
frame = Frame(root, bg = 'grey')
frame.pack(side=TOP, anchor = 'nw')
b1 = Button(frame, text = 'Button 1', command = bu1)
b1.pack(side = LEFT)
b2 = Button(frame, text = 'Button 2', command = bu2)
b2.pack(side = LEFT)
b3 = Button(frame, text = 'Button 3', command = bu3)
b3.pack(side = LEFT)
b4 = Button(frame, text = 'Button 4', command = bu4)
b4.pack(side = LEFT)
root.mainloop()

Ответить
@vlogboikhan
@vlogboikhan - 03.07.2023 17:32

i have done the exercise and i have added extra features and also here is the solution :-

from tkinter import *

root = Tk()

root.geometry("1920x1080")

f1 = Frame(root, bg="grey", borderwidth=3, relief=RIDGE, pady = 100)
f1.pack(side=LEFT, fill=Y)

def PrintLollipop():
print("lolipop")
def PrintHW():
print("Hello world")
def PrintHSP():
print("Hello shit peoplez")

def WhenOpenSideBarFunc():
f2 = Frame(root, bg="grey", borderwidth=3, relief=RIDGE)
f2.pack(side = RIGHT, fill=Y)
l1 = Label(f2, text="Here are all the buttons you can press:-", bg="white", fg = "black", font = "comicsansms 7 bold", borderwidth=3, relief=RAISED)
l1.pack(padx=34, pady = 10)

button1 = Button(f2, text="print(\"lolipop\")", bg="white", fg = "black", font = "comicsansms 10 ", command=PrintLollipop)
button1.pack(pady=10)

button2 = Button(f2, text="print(\"Hello world\")", bg="white", fg = "black", font = "comicsansms 10 ", command=PrintHW)
button2.pack(pady=10)

button3 = Button(f2, text="print(\"Hello shit peoplez\")", bg="white", fg = "black", font = "comicsansms 10 ", command=PrintHSP)
button3.pack(pady=10)


buttonToOpenSideBar = Button(f1, text="<", bg="white", fg="black", command=WhenOpenSideBarFunc)
buttonToOpenSideBar.pack(anchor="ne", side=TOP)

l1 = Label(f1, text="press the buttons on the side bar to print things", bg="white", fg = "black", font = "comicsansms 20 bold", borderwidth=3, relief=SUNKEN)
l1.pack(pady=300, fill= BOTH, padx = 500)


root.mainloop()

Ответить
@Desicraft07
@Desicraft07 - 30.06.2023 08:52

I Accept the challenge

Ответить
@Helly04
@Helly04 - 29.06.2023 12:29

I accept the challenge 🤩

from tkinter import *
root=Tk()
root.geometry("500x400")
def first():
print("Johny Johny...yes papa")

def second():
print("Eating sugar...No papa")

def third():
print("Telling a lie...No papa")

def fourth():
print("Open ur mouth...Hahaha")


f1=Frame(root,borderwidth=100,bg="black",relief=RIDGE)
f1.pack(anchor="center")


b1=Button(f1,bg="orange",fg="white",borderwidth=6,padx=20,relief=RAISED,text="1st",command=first)

b1.pack(side=LEFT)

b2=Button(f1,bg="white",fg="blue",borderwidth=6,padx=20,relief=RAISED,text="2nd",command=second)

b2.pack(side=LEFT)


b3=Button(f1,bg="green",fg="white",borderwidth=6,padx=2,relief=RAISED,text="3rd",command=third)

b3.pack(side=LEFT)

b4=Button(f1,bg="grey",fg="white",borderwidth=6,padx=20,relief=RAISED,text="4th",command=fourth)

b4.pack(side=LEFT)
root.mainloop()

Ответить
@manishasaini3012
@manishasaini3012 - 09.06.2023 21:21

what is bad geometry specifier sir..

Ответить
@3LineOfCode
@3LineOfCode - 07.06.2023 22:44

I accept the challenge.

Ответить
@ManishKumar-zk5or
@ManishKumar-zk5or - 23.05.2023 12:51

from tkinter import *

root = Tk()
root.geometry("500x400")

def hello():
print("never give up")
def name():
print("my name is hulk")
def age():
print("my age 19")
def male():
print("i am man")

Frame = Frame(root,borderwidth=6,bg="grey",relief=SUNKEN)
Frame.pack(side=LEFT,anchor="nw")

b1 = Button(Frame,fg="red",text="print now",command=hello)
b1.pack(side=LEFT,padx=23)

b2 = Button(Frame,fg="red",text="what is your name",command=name)
b2.pack(side=LEFT,padx=23)

b3 = Button(Frame,fg="red",text="age",command=age)
b3.pack(side=LEFT,padx=23)

b4 = Button(Frame,fg="red",text="gender",command=male)
b4.pack(side=LEFT,padx=23)

mainloop()

Ответить
@sarv4265
@sarv4265 - 22.05.2023 09:52

from tkinter import *

root = Tk()
root.geometry("800x500")

# button frame
f1 = Frame(root, bg="white", borderwidth=2, relief=GROOVE)
f1.pack(side="top", fill=X)

# button functions
def file():
print("This option is to open a file")

def save():
print("This is to save you work as a file")

def help():
print("This is a notepad")

def about():
print("Harry bhai bahut ache hai!")

# button
b1 = Button(f1, text="File", bg="white", fg="black", font="Helvetica 10", command=file)
b1.pack(side=LEFT, padx=5, pady=2)

b2 = Button(f1, text="Save", bg="white", fg="black", font="Helvetica 10", command=save)
b2.pack(side=LEFT, padx=5, pady=2)

b3 = Button(f1, text="Help", bg="white", fg="black", font="Helvetica 10", command=help)
b3.pack(side=LEFT, padx=5, pady=2)

b4 = Button(f1, text="About", bg="white", fg="black", font="Helvetica 10", command=about)
b4.pack(side=LEFT, padx=5, pady=2)

root.mainloop()

Ответить
@saym7502
@saym7502 - 20.05.2023 06:46

from tkinter import *

root = Tk()
root.geometry('655x333')


def hello():
print("hello tkinter button")


frame = Frame(root, borderwidth=6, bg='grey', relief=SUNKEN)
frame.pack(side=LEFT, anchor='nw')

b1 = Button(frame, fg='red', text='print now', command=hello)
b1.pack(side=LEFT, padx=23)

b1 = Button(frame, fg='red', text='print now', command=hello)
b1.pack(side=LEFT, padx=23)

b1 = Button(frame, fg='red', text='print now', command=hello)
b1.pack(side=LEFT, padx=23)

b1 = Button(frame, fg='red', text='print now', command=hello)
b1.pack(side=LEFT, padx=23)

b1 = Button(frame, fg='red', text='print now', command=hello)
b1.pack(side=LEFT, padx=23)

root.mainloop()

Ответить
@ankitanand1046
@ankitanand1046 - 08.05.2023 01:12

from tkinter import *

root = Tk()

root.title('Buttons and Functions')
root.geometry('700x350')

def f1():
print('F1')

def f2():
print('F2')

def f3():
print('F3')

def f4():
print('F4')

frame_1 = Frame(root, borderwidth = 5, bg = 'White')
frame_2 = Frame(root, borderwidth = 5, bg = 'White')
frame_3 = Frame(root, borderwidth = 5, bg = 'White')
frame_4 = Frame(root, borderwidth = 5, bg = 'White')

frame_1.pack(side = 'left'); frame_2.pack(side = 'left'); frame_3.pack(side = 'left'); frame_4.pack(side = 'left');

button_1 = Button(frame_1,text = 'F1', command = f1)
button_2 = Button(frame_2,text = 'F2', command = f2)
button_3 = Button(frame_3,text = 'F3', command = f3)
button_4 = Button(frame_4,text = 'F4', command = f4)

button_1.pack(); button_2.pack(); button_3.pack(); button_4.pack();

root.mainloop()

Ответить
@akashlikhitkar9000
@akashlikhitkar9000 - 05.05.2023 13:05

from tkinter import *
root = Tk()
def name1():
print("Sachin")

def name2():
print("Rahul")

def name3():
print("Gaurav")

def name4():
print("Yas")

root.geometry("900x150")

fram = Frame(root,borderwidth=6,relief=RIDGE,background="red")
fram.pack()

b1 = Button(fram,text="Akash Likhitkar 1",foreground="green",font="comicsansms 16 bold",command=name1)
b1.pack(side=LEFT,padx=6,pady=2)


b2 = Button(fram,text="Akash Likhitkar 2",foreground="green",font="comicsansms 16 bold",command=name2)
b2.pack(side=LEFT,padx=6,pady=2)

b3 = Button(fram,text="Akash Likhitkar 3",foreground="green",font="comicsansms 16 bold",command=name3)
b3.pack(side=LEFT,padx=6,pady=2)

b4 = Button(fram,text="Akash Likhitkar 4",foreground="green",font="comicsansms 16 bold",command=name4)
b4.pack(side=LEFT,padx=6,pady=2)

root.mainloop()

Ответить
@akashlikhitkar9000
@akashlikhitkar9000 - 05.05.2023 12:15

I accept the challenge

Ответить
@veethecomputerlad
@veethecomputerlad - 21.04.2023 13:15

here's the answer:-
from tkinter import *
import random as r

root = Tk()

def random():
list=["smart","genious","cretive","awesome"]
print(r.choice(list))

f = Frame(root,borderwidth=7)
f.pack(side=LEFT)

b1 = Button(f,text="1",fg="cyan",command=random)
b1.pack(side=LEFT,padx=10)

b2 = Button(f,text="2",fg="cyan",command=random)
b2.pack(side=LEFT)

b3 = Button(f,text="3",fg="cyan",command=random)
b3.pack(side=LEFT)

b4 = Button(f,text="4",fg="cyan",command=random)
b4.pack(side=LEFT)

b5 = Button(f,text="5",fg="cyan",command=random)
b5.pack(side=LEFT)

root.mainloop()

Ответить
@harpreetkaur291
@harpreetkaur291 - 20.04.2023 15:26

May you please solve one of my query.. I am trying to make a GUI(the richest persons in India) and when i am inserting image of one person and defining some message about them. Its okay.... But as soon as I am inserting another image.. the first image is disappearing.. even their sides and anchor are different..

Ответить
@Anilkumar-vz9qm
@Anilkumar-vz9qm - 02.04.2023 09:12

from tkinter import *
root = Tk()
root.geometry("623x536")
def himachal():
print("hello you are choosing the Himachal pradesh door/n WELCOME HIMACHAL PRADESH")
def chandigrah():
print("hello you are choosing the Chandigrah door/n WELCOME TO CHANDIGRAH")
def bihar():
print("hello you are choosing the Bihar door/n WELCOME TO BIHAR")
def usa():
print("hello you are choosing the USA door/n WELCOME TO USA")
f= Label(text="We have a type of door which are using for life exploring", font="comicsansms 14 bold", bg="blue")
f.pack(pady=4, fill=X)
f1 = Frame(root, bg="red", borderwidth=32, relief=SUNKEN)
f1.pack(side=LEFT, fill=Y )
b = Button(f1, fg="black", text="HIMACHAL", borderwidth=22, bg="blue", relief=SUNKEN, font= "comicsansms 17 bold", command=himachal)
b.pack(side=LEFT, padx=55)
f2 = Frame(root, bg="blue", borderwidth=32, relief=SUNKEN)
f2.pack(side=LEFT, fill=Y )
b = Button(f2, fg="black", text="CHANDIGARH", borderwidth=22, bg="red", relief=SUNKEN, font= "comicsansms 17 bold", command=chandigrah)
b.pack(side=LEFT, padx=55)
f3 = Frame(root, bg="yellow", borderwidth=32, relief=SUNKEN)
f3.pack(side=LEFT, fill=Y )
b = Button(f3, fg="black", text="BIHAR", borderwidth=22, bg="green", relief=SUNKEN, font= "comicsansms 17 bold", command=bihar)
b.pack(side=LEFT, padx=55)
f4 = Frame(root, bg="green", borderwidth=32, relief=SUNKEN)
f4.pack(side=LEFT, fill=Y )
b = Button(f4, fg="black", text="USA", borderwidth=22, bg="yellow", relief=SUNKEN, font= "comicsansms 17 bold", command=usa)
b.pack(side=LEFT, padx=70)

root.mainloop()

Ответить
@and-zw5re
@and-zw5re - 31.03.2023 12:59

Hi Harry, I accept your challenge. Here's the code =)

from tkinter import *

Button_root = Tk()

Button_root.geometry("1000x500")


def teacher():
print("My python teachers name is Harry.")


def resize():
Button_root.geometry("600x500")


def size_default():
Button_root.geometry("1000x500")


def end():
quit()

frame2 = Frame(Button_root, bg="red", relief=GROOVE)
frame2.pack(side=TOP, fill="x", pady=20)

frame1 = Frame(Button_root, borderwidth=5, bg="light blue", relief=SUNKEN)
frame1.pack(side=TOP, fill="x")

frame3 = Frame(Button_root, bg="red", relief=GROOVE)
frame3.pack(side=TOP, fill="x", pady=20)

frame4 = Frame(Button_root, bg="red", relief=GROOVE)
frame4.pack(side=RIGHT, fill="y", padx=20)

frame5 = Frame(Button_root, bg="red", relief=GROOVE)
frame5.pack(side=LEFT, fill="y", padx=20)

b1 = Button(frame1, text="My python teacher", font=20, command=teacher)
b1.pack()

b2 = Button(frame1, text="Resize GUI to 600x500",font=20, command=resize)
b2.pack()

b3 = Button(frame1, text="resize GUI to default (1000x500)",font=20, command=size_default)
b3.pack()

b4 = Button(frame1, text="End this programme",font=20, command=end)
b4.pack()

Button_root.mainloop()

Ответить
@IAMVEGETA420
@IAMVEGETA420 - 25.03.2023 13:02

i didnt made that question but here is my code -
from tkinter import *
tk = Tk()
tk.geometry("450x450")

frame = Frame(tk,bg="grey",borderwidth=5,relief=SUNKEN)
frame.pack(side=LEFT,anchor=NW)

def count():
for i in range(100):
i+=1
print(i)

b1 = Button(frame,text="i_can_count_to_hundred",fg="red",command=count)
b1.pack()

tk.mainloop()

Ответить
@ag_youtube
@ag_youtube - 17.03.2023 17:37

I accept the challenge

Ответить
@vipulkumarjain9839
@vipulkumarjain9839 - 08.03.2023 13:30

from tkinter import *

root = Tk()

# GUI Logic

root.title('Buttons in Tkinter')
root.geometry('1280x720')
root.minsize(640, 480)
root.maxsize(1919, 1080)

frame = Frame(root, bg="grey", borderwidth=6, relief=GROOVE)
frame.pack(side=LEFT, anchor="nw")

def hello():
print("yellow")
def hello1():
print("yellow1")
def hello2():
print("yellow2")
def hello3():
print("yellow3")

b1 = Button(frame,fg="red",text="print now",bg="white",highlightbackground="green",highlightthickness=2,command=hello,)
b1.pack(side=LEFT,padx=23)
b2 = Button(frame,fg="red",text="print now",bg="white",command=hello1)
b2.pack(side=LEFT,padx=23)
b3 = Button(frame,fg="red",text="print now",bg="white",command=hello2)
b3.pack(side=LEFT,padx=23)
b4 = Button(frame,fg="red",text="print now",bg="white",command=hello3)
b4.pack(side=LEFT,padx=23)

root.mainloop()

Ответить
@Uploader12
@Uploader12 - 02.03.2023 23:04

this is the code sir whats u need more HUKAM

Ответить
@glow.x.editzzz25
@glow.x.editzzz25 - 21.02.2023 08:19

I accept the challenge

Ответить
@raviupadhyay2368
@raviupadhyay2368 - 06.02.2023 20:10

from tkinter import *
root=Tk()
root.title("my butons")
root.geometry("500x400")
def hello():
print("Hello thinter buttons")
def ravi():
print("mango with sameer")
def yellow():
print("yello color is mine")
frame=Frame(root,border=6,bg="red",relief=SUNKEN)
frame.pack(side="left",anchor="nw")
b1=Button(frame,fg="black",text="print ",command=hello)
b1.pack(side="left")

b2=Button(frame,fg="black",text="print ",command=ravi)
b2.pack(side="left")
b3=Button(frame,fg="black",text="print ",command=yellow)
b3.pack(side="left")

root.mainloop()

Ответить
@vishweshrai3126
@vishweshrai3126 - 04.02.2023 15:29

what to do if we want the result after clicking the button on the gui window ??

Ответить
@rakeshsuwasiya3150
@rakeshsuwasiya3150 - 22.01.2023 12:17

from tkinter import*
root=Tk()
root.title("RAKESH GUI")
root.geometry("500x500")
def hello():
print("hello start from here")
def name():
print("my name is Tkinter")
def intro():
print("i am from bomboy-71")
def qut():
print("lif is all about the next step")
frame=Frame(root,borderwidth=6,bg="black",relief=SUNKEN)
frame.pack(side=LEFT,anchor="nw")
btn1=Button(frame,fg="red",text="click here",command=hello)
btn1.pack(side=LEFT)
btn2=Button(frame,fg="red",text="click here",command=name)
btn2.pack(side=LEFT)
btn3=Button(frame,fg="red",text="click here",command=intro)
btn3.pack(side=LEFT)
btn4=Button(frame,fg="red",text="click here",command=qut)
btn4.pack(side=LEFT)
root.mainloop()

Ответить
@harshitkumar9312
@harshitkumar9312 - 19.01.2023 12:23

from tkinter import*
root=Tk()
def but1():
print("This is Button 1")
def but2():
print("This si Button 2")
def but3():
print("This is Button 3")
def but4():
print("This is Button 4")
def frame1():
frame1=Frame(borderwidth=10,bg="black",relief=SUNKEN)
frame1.pack(fill=X)
b1=Button(frame1,text="1",fg="red",bg="grey",font=("conmicsansms",20,"bold"),command=but1)
b1.pack(side=LEFT,padx=10,pady=10)
b2=Button(frame1,text="2",fg="red",bg="grey",font=("conmicsansms",20,"bold"),command=but2)
b2.pack(side=LEFT,padx=10,pady=10)
b3=Button(frame1,text="3",fg="red",bg="grey",font=("conmicsansms",20,"bold"),command=but3)
b3.pack(side=LEFT,padx=10,pady=10)
b4=Button(frame1,text="4",fg="red",bg="grey",font=("conmicsansms",20,"bold"),command=but4)
b4.pack(side=LEFT,padx=10,pady=10)
frame1()
root.mainloop()

Ответить
@gamingprime989
@gamingprime989 - 12.01.2023 17:22

Answer of the question:

# Importing module:
import tkinter

def Press1():
print("Button1 is clicked!")

def Press2():
print("Button2 is clicked!")

def Press3():
print("Button3 is clicked!")

def Press4():
print("Button4 is clicked!")


# Declaring root variable:
root = tkinter.Tk()

# Program title:
root.title("Challenge accepted.")

# Screen size:
root.geometry("700x500")

# Frames:
frame1 = tkinter.Frame(root, bg="blue", relief="sunken", padx=50, borderwidth=5)
frame1.pack(side="top", anchor="nw")

# Creating buttons:
button1 = tkinter.Button(frame1, text="Button1", command=Press1)
button1.pack(padx=2, side="left")
button2 = tkinter.Button(frame1, text="Button2", command=Press2)
button2.pack(padx=2, side="left")
button3 = tkinter.Button(frame1, text="Button3", command=Press3)
button3.pack(padx=2, side="left")
button4 = tkinter.Button(frame1, text="Button4", command=Press4)
button4.pack(padx=2, side="left")

# Looping the program:
root.mainloop()

Ответить
@vinayshakya3906
@vinayshakya3906 - 07.01.2023 16:16

from tkinter import *
root = Tk()
root.geometry("450x350")

def Name():
print("My name is Vinay Shakya")

def Address():
print("I am from Uttar Predesh dist. Mainpuri.")

def Age():
print("My age is 30 years old.")

def Job():
print("I am a Data Scientist")

f = Frame(root, borderwidth=4, bg="Grey")
f.pack(side=TOP, padx=50, fill=X)

b1 = Button(f,fg="Blue", text="Name", command= Name)
b1.pack(side=LEFT)

b2 = Button(f,fg="Blue", text="Address", command= Address)
b2.pack(side=LEFT)

b3 = Button(f,fg="Blue", text="Age", command= Age)
b3.pack(side=LEFT)

b4 = Button(f,fg="Blue", text="Job", command= Job)
b4.pack(side=LEFT)

root.mainloop()

Ответить
@mastergreen9793
@mastergreen9793 - 02.01.2023 12:08

Challenge Accepted😠😠😠😠😠😠😠

from tkinter import *

root = Tk()
root.geometry("400x300")
root.title("Exercise")

def open():
print("File Opened")
def open_folder():
print("Folder Opened")
def save():
print("File Saved")
def about():
print("Hello, I'm Tkinter\nA Python GUI Framework")


f1 = Frame(root, border=2, relief="sunken")
f1.pack(side="left", anchor="nw")

b1 = Button(f1, text="Open", command=open)
b1.pack(side="left", padx=10, pady=10)

b2 = Button(f1, text="Open Folder", command=open_folder)
b2.pack(side="left", padx=10, pady=10)

b3 = Button(f1, text="Save", command=save)
b3.pack(side="left", padx=10, pady=10)

b4 = Button(f1, text="About", command=about)
b4.pack(side="left", padx=10, pady=10)


root.mainloop()

Ответить
@mohammedilyasilyas1118
@mohammedilyasilyas1118 - 13.12.2022 13:51

from tkinter import *
root=Tk()
root.geometry("333 x444")
def hello():
Print("hello 😁😁")
def hi():
Print("hi👍👍🙃")
def good():
Print("bye")
F=Frame(root,borderwith=24,relief=SOLID).pack()

B=Button(root,text="ok",command=hello).pack(side=RIGHT,padx=12)
B1=Button(root,text="ok",command=hi).pack(side=RIGHT,padx=12)
B2=Button(root,text="ok",command=good).pack(side=RIGHT,padx=12)
root.mainloop()

Ответить