چنل پایتون | جنگو | برنامه نویسی وب سایت | HTML & CSS & JS
Photo
خروجی این کد چیست ؟
import tkinter as tk
from tkcalendar import Calendar
import datetime
root = tk.Tk()
root.title("My calendar")
root.geometry("600x400")
events = {'2022-09-28': ('Tehran', 'meeting'),
'2022-08-15': ('Mashhad', 'meeting'),
'2022-07-30': ('Isfahan', 'meeting')}
cal = Calendar(root, selectmode='day', year=2022, month=8)
for k in events.keys():
date = datetime.datetime.strptime(k, '%Y-%m-%d').date()
cal.calevent_create(date, events[k][0], events[k][1])
cal.tag_config('meeting', background='violet red', foreground='white')
cal.pack(fill='both', expand=True)
root.mainloop()
❤4
چنل پایتون | جنگو | برنامه نویسی وب سایت | HTML & CSS & JS
Photo
خروجی این کد چیست؟
# The following line should be used for most modules that rely on Tkinter, but for turtle there is an exception
# We added it anyway to demostrate how Pydroid run modes work
#Pydroid run tkinter
import turtle
l1 = [[0.0, -238.0], [92.6, -219.3], [168.3, -168.3], [219.3, -92.6], [238.0, 0.0], [219.3, 92.6], [168.3, 168.3], [92.6, 219.3], [0.0, 238.0], [-92.6, 219.3], [-168.3, 168.3], [-219.3, 92.6], [-238.0, 0.0], [-219.3, -92.6], [-168.3, -168.3], [-92.6, -219.3], [0.0, -238.0], [0.0, -256.0], [-99.6, -235.9], [-181.0, -181.0], [-235.9, -99.6], [-256.0, 0.0], [-235.9, 99.6], [-181.0, 181.0], [-99.6, 235.9], [0.0, 256.0], [99.6, 235.9], [181.0, 181.0], [235.9, 99.6], [256.0, 0.0], [235.9, -99.6], [181.0, -181.0], [99.6, -235.9], [0.0, -256.0], [0.0, -256.0], [0.0, -256.0], [0.0, -256.0], [0.0, -256.0], [0.0, -256.0]]
l2 = [[-83.1, 17.3], [-64.3, 16.4], [-13.81, 32.1], [3.2, 70.7], [-18.9, 115.4], [-70.5, 130.1], [-76.5, 129.9], [-82.7, 129.3], [-82.7, 128.7], [-82.7, 128.1], [-93.8, 128.1], [-104.9, 128.1], [-104.9, 127.5], [-104.9, -128.6], [-82.7, -126.9], [-104.9, -128.6], [-104.8, 20.4]]
l3 = [[-82.7, 110.4], [-75.9, 111.0], [-69.7, 111.2], [-34.8, 101.6], [-20.8, 73.4], [-32.0, 46.1], [-63.8, 35.8], [-72.2, 36.1], [-82.7, 37.2], [-82.7, 38.3], [-82.7, -126.9], [-82.7, 110.4]]
l4 = [[81.7, -76.9], [58.9, -114.2], [25.0, -134.9], [21.13, -125.4], [17.2, -115.9], [42.5, -101.7], [58.0, -79.0], [33.8, -13.4], [9.63, 52.2], [22.3, 52.2], [35.0, 52.2], [52.6, -1.8], [70.2, -55.8], [87.9, -1.8], [105.6, 52.2], [117.6, 52.2], [129.6, 52.2], [105.7, -12.3], [81.7, -76.9], [81.7, -76.9]]
l5 = [[220.5, 96], [168.9, 96], [117.3, 96], [90.5, 107.1], [79.3, 134], [79.3, 180.7], [79.3, 227.5], [88.3, 227.5], [97.3, 227.5], [97.3, 180.7], [97.3, 134], [103.2, 119.9], [117.3, 114], [168.9, 114], [220.5, 114], [220.5, 105], [220.5, 96]]
def drawseg(l):
turtle.pu()
turtle.goto(l[0][0], l[0][1])
turtle.pd()
for a, b in l[1:]:
turtle.goto(a, b)
drawseg(l1)
drawseg(l2)
drawseg(l3)
drawseg(l4)
drawseg(l5)
turtle.mainloop()
import tkinter as tk
from tkinter import ttk
import time
def start():
GB = 100
download = 0
bar['value'] = 0
speed = 1
while(download < GB):
time.sleep(0.05)
bar['value'] += (speed/GB)*100
download += speed
percent.set(str(int((download/GB)*100))+"%")
text.set(str(download)+"/"+str(GB)+" GB completed")
root.update_idletasks()
root = tk.Tk()
root.geometry('350x120')
root.title('Progress Bar Demo')
percent = tk.StringVar()
text = tk.StringVar()
style = ttk.Style()
color = "purple1"
style.theme_use('default')
style.configure(f"{color}.Horizontal.TProgressbar",
foreground=color, background=color)
bar = ttk.Progressbar(root, style=f"{color}.Horizontal.TProgressbar",
orient=tk.HORIZONTAL, length=300)
bar.pack(pady=10)
percentLabel = tk.Label(root, textvariable=percent).pack()
taskLabel = tk.Label(root, textvariable=text).pack()
button = tk.Button(root, text="download", command=start).pack()
root.mainloop()
😁2👍1🤣1
چنل پایتون | جنگو | برنامه نویسی وب سایت | HTML & CSS & JS
import tkinter as tk from tkinter import ttk import time def start(): GB = 100 download = 0 bar['value'] = 0 speed = 1 while(download < GB): time.sleep(0.05) bar['value'] += (speed/GB)*100 download += speed …
دانلود فایل تستی ۱۰۰ گیگی با پایتون گرافیکی
import webbrowser
from tkinter import *
root = Tk()
root.title("WebBrowser")
root.geometry("380x200")
def google():
webbrowser.open("https://www.google.com")
mygoogle = Button(root, text="open Google", command=google).pack (pady=20)
root.mainloop()
🔥2👍1
منتظر آموزش مقدماتی تا پیشرفته Tkinter باشید🙂
❤1😁1
آموزش Tkinter از مقدماتی تا پیشرفته
اول از همه باید یک صفحه اصلی برای برنامه خود ایجاد کنیم که به صورت زیر است:
# Import library
import tkinter as tk
# main the window
win = tk.Tk()
win.mainloop()
حالا میتونیم کار های خود را روی این صفحه انجام بدیم
اولین کار برچسب ها هستند که Label نام دارن
مثلا هر متنی میخوایم رو توی این صفحه قرار میدیم
مثلا من میخوام Hello python world رو بزارم
باید به صورت زیر بنویسیم:
مثلا من میخوام Hello python world رو بزارم
باید به صورت زیر بنویسیم:
import tkinter as tk
win = tk.Tk()
my_label = tk.Label(win, text="Hello python world", font=("Arial", 20))
my_label.pack()
win.mainloop()