Результаты поиска
Почему не запускается программа? Python + TKINTER
import os
from tkinter import *
import subprocess
from tkinter import ttk
path = "C:/Program Files/Organaizer"
m1 = "C:/Program Files/Organaizer/Monday/Registration"
m2 = "C:/Program Files/Organaizer/Monday/Literature"
m3 = "C:/Program Files/Organaizer/Monday/ITGS"
m4 = "C:/Program Files/Organaizer/Monday/Maths"
t1 = "C:/Program Files/Organaizer/Tuesday/Registration"
t2 = "C:/Program Files/Organaizer/Tuesday/English"
t3 = "C:/Program Files/Organaizer/Tuesday/Literature"
t4 = "C:/Program Files/Organaizer/Tuesday/CS"
t5 = "C:/Program Files/Organaizer/Tuesday/PE"
w1 = "C:/Program Files/Organaizer/Wednesday/Registration"
w2 = "C:/Program Files/Organaizer/Wednesday/CS"
w3 = "C:/Program Files/Organaizer/Wednesday/Psychology"
w4 = "C:/Program Files/Organaizer/Wednesday/English"
h1 = "C:/Program Files/Organaizer/Thursday/Registration"
h2 = "C:/Program Files/Organaizer/Thursday/English"
h3 = "C:/Program Files/Organaizer/Thursday/Maths"
h4 = "C:/Program Files/Organaizer/Thursday/Literature"
h5 = "C:/Program Files/Organaizer/Thursday/ITGS"
f1 = "C:/Program Files/Organaizer/Friday/Registration"
f2 = "C:/Program Files/Organaizer/Friday/CS"
f3 = "C:/Program Files/Organaizer/Friday/Psychology"
f4 = "C:/Program Files/Organaizer/Friday/Grorootg Minds"
try:
os.makedirs(path)
except OSError:
print ("The %s directory could not be created" % path)
else:
print ("The %s directory was successfully created" % path)
try:
os.makedirs(m1)
except OSError:
print ("The %s directory could not be created" % m1)
else:
print ("The %s directory was successfully created" % m1)
try:
os.makedirs(m2)
except OSError:
print ("The %s directory could not be created" % m2)
else:
print ("The %s directory was successfully created" % m2)
try:
os.makedirs(m3)
except OSError:
print ("The %s directory could not be created" % m3)
else:
print ("The %s directory was successfully created" % m3)
try:
os.makedirs(m4)
except OSError:
print ("The %s directory could not be created" % m4)
else:
print ("The %s directory was successfully created" % m4)
try:
os.makedirs(t1)
except OSError:
print ("The %s directory could not be created" % t1)
else:
print ("The %s directory was successfully created" % t1)
try:
os.makedirs(t2)
except OSError:
print ("The %s directory could not be created" % t2)
else:
print ("The %s directory was successfully created" % t2)
try:
os.makedirs(t3)
except OSError:
print ("The %s directory could not be created" % t3)
else:
print ("The %s directory was successfully created" % t3)
try:
os.makedirs(t4)
except OSError:
print ("The %s directory could not be created" % t4)
else:
print ("The %s directory was successfully created" % t4)
try:
os.makedirs(t5)
except OSError:
print ("The %s directory could not be created" % t5)
else:
print ("The %s directory was successfully created" % t5)
try:
os.makedirs(w1)
except OSError:
print ("The %s directory could not be created" % w1)
else:
print ("The %s directory was successfully created" % w1)
try:
os.makedirs(w2)
except OSError:
print ("The %s directory could not be created" % w2)
else:
print ("The %s directory was successfully created" % w2)
try:
os.makedirs(w3)
except OSError:
print ("The %s directory could not be created" % w3)
else:
print ("The %s directory was successfully created" % w3)
try:
os.makedirs(w4)
except OSError:
print ("The %s directory could not be created" % w4)
else:
print ("The %s directory was successfully created" % w4)
try:
os.makedirs(h1)
except OSError:
print ("The %s directory could not be created" % h1)
else:
print ("The %s directory was successfully created" % h1)
try:
os.makedirs(h2)
except OSError:
print ("The %s directory could not be created" % h2)
else:
print ("The %s directory was successfully created" % h2)
try:
os.makedirs(h3)
except OSError:
print ("The %s directory could not be created" % h3)
else:
print ("The %s directory was successfully created" % h3)
try:
os.makedirs(h4)
except OSError:
print ("The %s directory could not be created" % h4)
else:
print ("The %s directory was successfully created" % h4)
try:
os.makedirs(h5)
except OSError:
print ("The %s directory could not be created" % h5)
else:
print ("The %s directory was successfully created" % h5)
try:
os.makedirs(f1)
except OSError:
print ("The %s directory could not be created" % f1)
else:
print ("The %s directory was successfully created" % f1)
try:
os.makedirs(f2)
except OSError:
print ("The %s directory could not be created" % f2)
else:
print ("The %s directory was successfully created" % f2)
try:
os.makedirs(f3)
except OSError:
print ("The %s directory could not be created" % f3)
else:
print ("The %s directory was successfully created" % f3)
try:
os.makedirs(f4)
except OSError:
print ("The %s directory could not be created" % f4)
else:
print ("The %s directory was successfully created" % f4)
root = Tk()
root.title("Login")
root.resizable(0, 0)
root.configure(bg='black')
root.geometry("910x740")
attempts=0
correctpassword="1234"
entrypass = Entry(root, width=25, textvariable=password, show="*")
entrypass.pack()
def start():
while attempts<3:
if entrypass==correctpassword:
print('Correct.')
altroot = Toplevel(root)
altroot.title("Organaizer")
altroot.resizable(0, 0)
altroot.configure(bg='black')
altroot.geometry('910x740')
def monviewcom():
subprocess.Popen(r'explorer /select,"C:\Program Files\Organaizer\Monday\Registration"')
def tuviewcom():
subprocess.Popen(r'explorer /select,"C:\Program Files\Organaizer\Tuesday\Registration"')
def wedviewcom():
subprocess.Popen(r'explorer /select,"C:\Program Files\Organaizer\Wednesday\Registration"')
def huviewcom():
subprocess.Popen(r'explorer /select,"C:\Program Files\Organaizer\Thursday\Registration"')
def frviewcom():
subprocess.Popen(r'explorer /select,"C:\Program Files\Organaizer\Friday\Registration"')
def mondays():
monles = Toplevel(root)
monles.title("MONDAY")
monles.resizable(0, 0)
monles.configure(bg='black')
monles.geometry('910x740')
monlesson = Frame(monles, width=750, height=600, bg='black')
monlesson.grid(row=0, column=0, padx=1, pady=1)
monregistration = Label(monlesson, text="Registration || 8:20 - 8:40", fg='white', bg='black', font=200, width=85, height=6)
monregistration.grid(row=0, column=0, sticky=S, padx=1, pady=1)
monliterature = Label(monlesson, text="Russian Literature || 10:20 - 11:40", fg='white', bg='black', font=200, width=85, height=6)
monliterature.grid(row=1, column=0, sticky=S, padx=1, pady=1)
monitgs = Label(monlesson, text="ITGS || 11:40 - 12:20 / 13:20 - 14:00", fg='white', bg='black', font=200, width=85, height=6)
monitgs.grid(row=2, column=0, sticky=S, padx=1, pady=1)
monmaths = Label(monlesson, text="Maths || 14:00 - 15:20", fg='white', bg='black', font=200, width=85, height=6)
monmaths.grid(row=3, column=0, sticky=S, padx=1, pady=1)
monview = Button(monlesson, text="View", fg='black', bg='white', font=300, width=85, height=6, command=monviewcom)
monview.grid(row=4, column=0, sticky=S, padx=1, pady=1)
def tuesdays():
tules = Toplevel(root)
tules.title("TUESDAY")
tules.resizable(0, 0)
tules.configure(bg='black')
tules.geometry('910x740')
tulesson = Frame(tules, width=750, height=600, bg='black')
tulesson.grid(row=0, column=0, padx=1, pady=1)
turegistration = Label(tulesson, text="Registration || 8:20 - 8:40", fg='white', bg='black', font=200, width=85, height=5)
turegistration.grid(row=0, column=0, sticky=S, padx=1, pady=1)
tuenglish = Label(tulesson, text="English || 8:40 - 10:00", fg='white', bg='black', font=200, width=85, height=5)
tuenglish.grid(row=1, column=0, sticky=S, padx=1, pady=1)
tuliterature = Label(tulesson, text="Literature || 10:20 - 11:40", fg='white', bg='black', font=200, width=85, height=5)
tuliterature.grid(row=2, column=0, sticky=S, padx=1, pady=1)
tucs = Label(tulesson, text="CS || 11:40 - 12:20 / 13:20 - 14:00", fg='white', bg='black', font=200, width=85, height=5)
tucs.grid(row=3, column=0, sticky=S, padx=1, pady=1)
tupe = Label(tulesson, text="PE || 14:00 - 15:20", fg='white', bg='black', font=200, width=85, height=5)
tupe.grid(row=4, column=0, sticky=S, padx=1, pady=1)
tuview = Button(tulesson, text="View", fg='black', bg='white', font=300, width=85, height=5, command=tuviewcom)
tuview.grid(row=5, column=0, sticky=S, padx=1, pady=1)
def wednesdays():
wedles = Toplevel(root)
wedles.title("WEDNESDAY")
wedles.resizable(0, 0)
wedles.configure(bg='black')
wedles.geometry('910x740')
wedlesson = Frame(wedles, width=750, height=600, bg='black')
wedlesson.grid(row=0, column=0, padx=1, pady=1)
wedregistration = Label(wedlesson, text="Registration || 8:20 - 8:40", fg='white', bg='black', font=200, width=85, height=6)
wedregistration.grid(row=0, column=0, sticky=S, padx=1, pady=1)
wedliterature = Label(wedlesson, text="CS || 8:40 - 10:00", fg='white', bg='black', font=200, width=85, height=6)
wedliterature.grid(row=1, column=0, sticky=S, padx=1, pady=1)
weditgs = Label(wedlesson, text="Psychology || 11:40 - 12:20 / 13:20 - 14:00", fg='white', bg='black', font=200, width=85, height=6)
weditgs.grid(row=2, column=0, sticky=S, padx=1, pady=1)
wedmaths = Label(wedlesson, text="English || 14:00 - 15:20", fg='white', bg='black', font=200, width=85, height=6)
wedmaths.grid(row=3, column=0, sticky=S, padx=1, pady=1)
wedview = Button(wedlesson, text="View", fg='black', bg='white', font=300, width=85, height=6, command=wedviewcom)
wedview.grid(row=4, column=0, sticky=S, padx=1, pady=1)
def thursdays():
hules = Toplevel(root)
hules.title("THURSDAY")
hules.resizable(0, 0)
hules.configure(bg='black')
hules.geometry('910x740')
hulesson = Frame(hules, width=750, height=600, bg='black')
hulesson.grid(row=0, column=0, padx=1, pady=1)
huregistration = Label(hulesson, text="Registration || 8:20 - 8:40", fg='white', bg='black', font=200, width=85, height=5)
huregistration.grid(row=0, column=0, sticky=S, padx=1, pady=1)
huenglish = Label(hulesson, text="English || 8:40 - 10:00", fg='white', bg='black', font=200, width=85, height=5)
huenglish.grid(row=1, column=0, sticky=S, padx=1, pady=1)
humaths = Label(hulesson, text="Maths || 10:20 - 11:40", fg='white', bg='black', font=200, width=85, height=5)
humaths.grid(row=2, column=0, sticky=S, padx=1, pady=1)
huliterature = Label(hulesson, text="Literature || 11:40 - 12:20 / 13:20 - 14:00", fg='white', bg='black', font=200, width=85, height=5)
huliterature.grid(row=3, column=0, sticky=S, padx=1, pady=1)
huitgs = Label(hulesson, text="ITGS || 14:00 - 15:20", fg='white', bg='black', font=200, width=85, height=5)
huitgs.grid(row=4, column=0, sticky=S, padx=1, pady=1)
huview = Button(hulesson, text="View", fg='black', bg='white', font=300, width=85, height=5, command=huviewcom)
huview.grid(row=5, column=0, sticky=S, padx=1, pady=1)
def fridays():
frles = Toplevel(root)
frles.title("FRIDAY")
frles.resizable(0, 0)
frles.configure(bg='black')
frles.geometry('910x740')
frlesson = Frame(frles, width=750, height=600, bg='black')
frlesson.grid(row=0, column=0, padx=1, pady=1)
frregistration = Label(frlesson, text="Registration || 8:20 - 8:40", fg='white', bg='black', font=200, width=85, height=6)
frregistration.grid(row=0, column=0, sticky=S, padx=1, pady=1)
frcs = Label(frlesson, text="CS|| 8:40 - 10:00", fg='white', bg='black', font=200, width=85, height=6)
frcs.grid(row=1, column=0, sticky=S, padx=1, pady=1)
frpsychology = Label(frlesson, text="Psychology || 10:20 - 11:40", fg='white', bg='black', font=200, width=85, height=6)
frpsychology.grid(row=2, column=0, sticky=S, padx=1, pady=1)
frgm = Label(frlesson, text="GM || 14:00 - 15:20", fg='white', bg='black', font=200, width=85, height=6)
frgm.grid(row=3, column=0, sticky=S, padx=1, pady=1)
frview = Button(frlesson, text="View", fg='black', bg='white', font=300, width=85, height=6, command=frviewcom)
frview.grid(row=4, column=0, sticky=S, padx=1, pady=1)
lu = Frame(altroot, width=250, height=200, bg='white')
lu.grid(row=0, column=0, padx=1, pady=1, sticky=N)
tp = Frame(altroot, width=250, height=200, bg='white')
tp.grid(row=0, column=1, padx=1, pady=1, sticky=N)
ru = Frame(altroot, width=250, height=200, bg='white')
ru.grid(row=0, column=2, padx=1, pady=1, sticky=N)
lt = Frame(altroot, width=250, height=200, bg='white')
lt.grid(row=1, column=0, padx=1, pady=1, sticky=N)
md = Frame(altroot, width=250, height=200, bg='white')
md.grid(row=1, column=1, padx=1, pady=1, sticky=N)
rt = Frame(altroot, width=250, height=200, bg='white')
rt.grid(row=1, column=2, padx=1, pady=1, sticky=N)
bt = Frame(altroot, width=250, height=200, bg='white')
bt.grid(row=2, column=1, padx=1, pady=1, sticky=N)
mday = Button(lu, text="MONDAY", fg='black', bg='white', font=150, width=27, height=10, command=mondays)
mday.pack()
tday = Button(tp, text="TUESDAY", fg='black', bg='white', font=150, width=27, height=10, command=tuesdays)
tday.pack()
wday = Button(ru, text="WEDNESDAY", fg='black', bg='white', font=150, width=27, height=10, command=wednesdays)
wday.pack()
thday = Button(lt, text="THURSDAY", fg='black', bg='white', font=150, width=27, height=10, command=thursdays)
thday.pack()
fday = Button(md, text="FRIDAY", fg='black', bg='white', font=150, width=27, height=10, command=fridays)
fday.pack()
saday = Label(rt, text="SATURDAY", fg='black', bg='white', font=150, width=27, height=10)
saday.pack()
sday = Label(bt, text="SUNDAY", fg='black', bg='white', font=150, width=27, height=10)
sday.pack()
altroot.mainloop()
else:
attempts+=1
print('incorrect!')
if attempts==3:
print('too many attempts')
ttt = Button(root, text="Enter", command=start).pack()
root.mainloop()
Как в tkinter из поля ввода Entry получить значение в одну переменную и обновить строку кнопкой, затем получить ещё одно введённое значение и затем сложить их. Ниже пример кода
from tkinter import *
from tkinter import ttk
def plus(): #беру текст из строки и записываю в переменную, и удаляю всё из строки
number1=entry.get()
entry.delete(0, END)
return()
def result(): #беру ещё одно значение и складываю, затем вывожу в шелле число, но программа выдаёт ошибку
number2=entry.get()
res=int(number1)+int(number2)
print(res)
return()
window = Tk()
window.title('Example')
window.geometry('300x250')
entry =ttk.Entry()
butplus=ttk.Button(text='+', command = plus)
butresult=ttk.Button(text='result', command=result)
entry.pack(fill=X)
butplus.pack()
butresult.pack()
window.mainloop()