hali hazırda bir tkinter kodum var fakat farklı sayfalar arasında butonla geçiş yapıyorum her seferinde başka bir cmd penceresi açıp orda otomatik kod çalışıp bana butonuna bastığım sayfaya götürüyor ama her buton basışımda farklı cmd açtığından bi kaç kez sekme değiştirirsen onlarca pencere açık kalıyor kodla nasıl bunları kapatabilirim?
Niye farklı bir uygulama çalıştırıyorsunuz, direkt buton basıldığı vakit bir fonksiyon çalıştırın. Ana programdan ayırmayın diğer sayfayı.
her sayfanın fonsuyonu aynı ama bunu görsel olarak görmekte istiyorum internet tarayıcısı gibi bir şey oluşturdum programımda, sayfa 2 ye geçtiğimde sayfa 1 kapanıyor sayfa 2 açılıyor ama cmd yi kapatamadığımdan sayfa 1 in cmdsi kalıyor buda yük olur diye düşünüyorum, aynı cmd içine alsamda bu sefer üst üste biniyor sayfalar herhangi birini kapattığımda hepsi kapanıyor
.py uzantılı dosyanızı .pyw olarak kayıt ederseniz bu sorunu çözmüş olursunuz. Bununla birlikte pyinstaller kullandığınız zaman noconcole yazarak program çalışırken terminal ekranı ile sıkıntı yaşamazsınız.
Ufacık bir tavsiye, frame’leri kullanırsanız eğer tek bir pencere içerisinde yeni pencereler açılmasına gerek kalmadan kullanabilirsiniz. İhtiyacınızı karşılar ile daha güzel bir çözüm olabilir bu.
yanıt ve tavsiye için teşekkürler iyi çalışmalar
SAYFA 1
from fileinput import close
from tkinter import *
import os
from time import sleep
def amazon_git():
os.system("start cmd /k python.exe amazon_veri_kazma_arayüz.pyw")
tk.destroy()
def Ali_git():
pass
def banggood_git():
os.system("start cmd /k python.exe banggood_veri_kazma_arayüz.pyw")
tk.destroy()
metin_listesi = ["Program Başlatılıyor..."]
tk = Tk()
tk.title("*********** | ***********")
tk.configure(background="#1c1c1c")
tk.geometry("400x600+957+105")
frame_geçis_buton = Frame(tk,width="350",height="25",bg="#1c1c1c")
frame_geçis_buton.pack()
frame_üst = Label(tk,text="***********",font="impact 15",fg="#FF7600",width="250",height="2",bg="#1c1c1c")
frame_üst.pack()
frame_bosluk = Frame(tk,bg="#000000",width="350",height="5")
frame_bosluk.pack()
frame_bosluk_altı_label = Label(tk,text="***********",font="Arial 10 bold",fg="#ffffff",bg="#1c1c1c",width="350",height="2")
frame_bosluk_altı_label.pack()
radiobuton1_F = Frame(tk,bg="#1c1c1c",width=400,height=50)
radiobuton1_F.pack()
frame_checkbox1 = Frame(tk,bg="#1c1c1c",width=400,height=50)
frame_checkbox1.pack()
frame_checkbox2 = Frame(tk,bg="#1c1c1c",width=400,height=50)
frame_checkbox2.pack()
frame_checkbox3 = Frame(tk,bg="#1c1c1c",width=400,height=25)
frame_checkbox3.pack()
frame_bosluk1 = Frame(tk,bg="#000000",width="350",height="210")
frame_bosluk1.pack()
frame_yazi = LabelFrame(tk,text="Yazı Paneli",fg="#ffffff",bg="#1c1c1c",width=400,height=100,border=2)
frame_yazi.pack()
frame_bosluk2 = Frame(tk,bg="#000000",width="350",height="25")
frame_bosluk2.pack()
frame_uyg_butonu = Frame(tk,bg="#ffffff",width="350",height="50")
frame_uyg_butonu.pack()
gecis = Button(frame_geçis_buton,text="Amazon",width="20",bg="#1c1c1c",fg="#ffffff",command=amazon_git)
gecis.pack(side=LEFT)
gecis1 = Label(frame_geçis_buton,text="AliExpress",width="20",bg="#1c1c1c",fg="#ffffff")
gecis1.pack(side=LEFT)
gecis2 = Button(frame_geçis_buton,text="Banggood",width="20",bg="#1c1c1c",fg="#ffffff",command=banggood_git)
gecis2.pack(side=LEFT)
ara_frames = Label(radiobuton1_F,text="============================================",bg="#1c1c1c",fg="#ffffff")
ara_frames.pack()
CheckBox1 = Checkbutton(frame_checkbox1,text="istenilen kriter1",bg="#1c1c1c",fg="#C5C6F5",activebackground="#1c1c1c",activeforeground="#ffffff",state=ACTIVE)
CheckBox1.pack(side=LEFT)
CheckBox1_1 = Checkbutton(frame_checkbox1,text="istenilen kriter2",bg="#1c1c1c",fg="#ffffff")
CheckBox1_1.pack(side=LEFT)
CheckBox1_1_1 = Checkbutton(frame_checkbox1,text="istenilen kriter3",bg="#1c1c1c",fg="#ffffff")
CheckBox1_1_1.pack(side=LEFT)
CheckBox2 = Checkbutton(frame_checkbox2,text="istenilen kriter4",bg="#1c1c1c",fg="#ffffff")
CheckBox2.pack(side=LEFT)
CheckBox2_2 = Checkbutton(frame_checkbox2,text="istenilen kriter5",bg="#1c1c1c",fg="#ffffff")
CheckBox2_2.pack(side=LEFT)
program_metni = Label(frame_yazi,bg="#1c1c1c",fg="#ffffff",text=metin_listesi)
program_metni.pack(padx=50,pady=20)
program_butonu = Button(frame_uyg_butonu,width="34",text="Uygulama Başlat",font="impact 15",bg="#1c1c1c",fg="#FF7600",border=3)
program_butonu.pack()
tk.mainloop()
SAYFA 2
from tkinter import *
import os
from time import sleep
def amazon_git():
os.system("start cmd /k python.exe amazon_veri_kazma_arayüz.py")
tk.destroy()
def Ali_git():
pass
def banggood_git():
os.system("start cmd /k python.exe banggood_veri_kazma_arayüz.py")
tk.destroy()
metin_listesi = ["Program Başlatılıyor..."]
tk = Tk()
tk.title("*********** | ***********")
tk.configure(background="#1c1c1c")
tk.geometry("400x600+957+105")
frame_geçis_buton = Frame(tk,width="350",height="25",bg="#1c1c1c")
frame_geçis_buton.pack()
frame_üst = Label(tk,text="***********",font="impact 15",fg="#FF7600",width="250",height="2",bg="#1c1c1c")
frame_üst.pack()
frame_bosluk = Frame(tk,bg="#000000",width="350",height="5")
frame_bosluk.pack()
frame_bosluk_altı_label = Label(tk,text="***********",font="Arial 10 bold",fg="#ffffff",bg="#1c1c1c",width="350",height="2")
frame_bosluk_altı_label.pack()
radiobuton1_F = Frame(tk,bg="#1c1c1c",width=400,height=50)
radiobuton1_F.pack()
frame_checkbox1 = Frame(tk,bg="#1c1c1c",width=400,height=50)
frame_checkbox1.pack()
frame_checkbox2 = Frame(tk,bg="#1c1c1c",width=400,height=50)
frame_checkbox2.pack()
frame_checkbox3 = Frame(tk,bg="#1c1c1c",width=400,height=25)
frame_checkbox3.pack()
frame_bosluk1 = Frame(tk,bg="#000000",width="350",height="210")
frame_bosluk1.pack()
frame_yazi = LabelFrame(tk,text="Yazı Paneli",fg="#ffffff",bg="#1c1c1c",width=400,height=100,border=2)
frame_yazi.pack()
frame_bosluk2 = Frame(tk,bg="#000000",width="350",height="25")
frame_bosluk2.pack()
frame_uyg_butonu = Frame(tk,bg="#ffffff",width="350",height="50")
frame_uyg_butonu.pack()
gecis = Button(frame_geçis_buton,text="Amazon",width="20",bg="#1c1c1c",fg="#ffffff",command=amazon_git)
gecis.pack(side=LEFT)
gecis1 = Label(frame_geçis_buton,text="AliExpress",width="20",bg="#1c1c1c",fg="#ffffff")
gecis1.pack(side=LEFT)
gecis2 = Button(frame_geçis_buton,text="Banggood",width="20",bg="#1c1c1c",fg="#ffffff",command=banggood_git)
gecis2.pack(side=LEFT)
ara_frames = Label(radiobuton1_F,text="============================================",bg="#1c1c1c",fg="#ffffff")
ara_frames.pack()
CheckBox1 = Checkbutton(frame_checkbox1,text="istenilen kriter1",bg="#1c1c1c",fg="#C5C6F5",activebackground="#1c1c1c",activeforeground="#ffffff",state=ACTIVE)
CheckBox1.pack(side=LEFT)
CheckBox1_1 = Checkbutton(frame_checkbox1,text="istenilen kriter2",bg="#1c1c1c",fg="#ffffff")
CheckBox1_1.pack(side=LEFT)
CheckBox1_1_1 = Checkbutton(frame_checkbox1,text="istenilen kriter3",bg="#1c1c1c",fg="#ffffff")
CheckBox1_1_1.pack(side=LEFT)
CheckBox2 = Checkbutton(frame_checkbox2,text="istenilen kriter4",bg="#1c1c1c",fg="#ffffff")
CheckBox2.pack(side=LEFT)
CheckBox2_2 = Checkbutton(frame_checkbox2,text="istenilen kriter5",bg="#1c1c1c",fg="#ffffff")
CheckBox2_2.pack(side=LEFT)
program_metni = Label(frame_yazi,bg="#1c1c1c",fg="#ffffff",text=metin_listesi)
program_metni.pack(padx=50,pady=20)
program_butonu = Button(frame_uyg_butonu,width="34",text="Uygulama Başlat",font="impact 15",bg="#1c1c1c",fg="#FF7600",border=3)
program_butonu.pack()
tk.mainloop()
SAYFA 3
from tkinter import *
import os
from time import sleep
def amazon_git():
os.system("start cmd /k python.exe amazon_veri_kazma_arayüz.py")
tk.destroy()
def Ali_git():
os.system("start cmd /k python.exe aliexpress_veri_kazma_arayüz.py")
tk.destroy()
def banggood_git():
pass
metin_listesi = ["Program Başlatılıyor..."]
tk = Tk()
tk.title("*********** | ***********")
tk.configure(background="#1c1c1c")
tk.geometry("400x600+957+105")
frame_geçis_buton = Frame(tk,width="350",height="25",bg="#1c1c1c")
frame_geçis_buton.pack()
frame_üst = Label(tk,text="***********",font="impact 15",fg="#FF7600",width="250",height="2",bg="#1c1c1c")
frame_üst.pack()
frame_bosluk = Frame(tk,bg="#000000",width="350",height="5")
frame_bosluk.pack()
frame_bosluk_altı_label = Label(tk,text="***********",font="Arial 10 bold",fg="#ffffff",bg="#1c1c1c",width="350",height="2")
frame_bosluk_altı_label.pack()
radiobuton1_F = Frame(tk,bg="#1c1c1c",width=400,height=50)
radiobuton1_F.pack()
frame_checkbox1 = Frame(tk,bg="#1c1c1c",width=400,height=50)
frame_checkbox1.pack()
frame_checkbox2 = Frame(tk,bg="#1c1c1c",width=400,height=50)
frame_checkbox2.pack()
frame_checkbox3 = Frame(tk,bg="#1c1c1c",width=400,height=25)
frame_checkbox3.pack()
frame_bosluk1 = Frame(tk,bg="#000000",width="350",height="210")
frame_bosluk1.pack()
frame_yazi = LabelFrame(tk,text="Yazı Paneli",fg="#ffffff",bg="#1c1c1c",width=400,height=100,border=2)
frame_yazi.pack()
frame_bosluk2 = Frame(tk,bg="#000000",width="350",height="25")
frame_bosluk2.pack()
frame_uyg_butonu = Frame(tk,bg="#ffffff",width="350",height="50")
frame_uyg_butonu.pack()
gecis = Button(frame_geçis_buton,text="Amazon",width="20",bg="#1c1c1c",fg="#ffffff",command=amazon_git)
gecis.pack(side=LEFT)
gecis1 = Button(frame_geçis_buton,text="AliExpress",width="20",bg="#1c1c1c",fg="#ffffff",command=Ali_git)
gecis1.pack(side=LEFT)
gecis2 = Label(frame_geçis_buton,text="Banggood",width="20",bg="#1c1c1c",fg="#ffffff")
gecis2.pack(side=LEFT)
ara_frames = Label(radiobuton1_F,text="============================================",bg="#1c1c1c",fg="#ffffff")
ara_frames.pack()
CheckBox1 = Checkbutton(frame_checkbox1,text="istenilen kriter1",bg="#1c1c1c",fg="#C5C6F5",activebackground="#1c1c1c",activeforeground="#ffffff",state=ACTIVE)
CheckBox1.pack(side=LEFT)
CheckBox1_1 = Checkbutton(frame_checkbox1,text="istenilen kriter2",bg="#1c1c1c",fg="#ffffff")
CheckBox1_1.pack(side=LEFT)
CheckBox1_1_1 = Checkbutton(frame_checkbox1,text="istenilen kriter3",bg="#1c1c1c",fg="#ffffff")
CheckBox1_1_1.pack(side=LEFT)
CheckBox2 = Checkbutton(frame_checkbox2,text="istenilen kriter4",bg="#1c1c1c",fg="#ffffff")
CheckBox2.pack(side=LEFT)
CheckBox2_2 = Checkbutton(frame_checkbox2,text="istenilen kriter5",bg="#1c1c1c",fg="#ffffff")
CheckBox2_2.pack(side=LEFT)
program_metni = Label(frame_yazi,bg="#1c1c1c",fg="#ffffff",text=metin_listesi)
program_metni.pack(padx=50,pady=20)
program_butonu = Button(frame_uyg_butonu,width="34",text="Uygulama Başlat",font="impact 15",bg="#1c1c1c",fg="#FF7600",border=3)
program_butonu.pack()
tk.mainloop()
Niye cmd açıyorsunuz ki? os.system cmd açmasanız da cmd komutlarını çalıştırır zaten.
os.system("python file.py")
problem şu ki dediğinizde her sayfayı cmd açmazsam üst üste biniyor ve herhangi birini kapatırsam cmdde çalışan kodu kapattığım için diğer sayfalarda kapanıyor ayrı ayrı açıldığında sayfa geçişlerinde önceki sayfanın penceresini kapatabiliyorum
Cmd yi ( galiba terminal/konsol işletim sistemi komut istemcilerinden bahsediyorsunuz) çağırırken,
subprocess kullanırsanız. Pid ( process id) de alabilirsiniz. Bu id ile açtığınız process i sonlandırabilirsiniz.
python - How to determine pid of process started via os.system - Stack Overflow
Ben bu şekilde yapmam koduma uymaz derseniz.
EnumWindows
EnumWindows function (winuser.h) - Win32 apps | Microsoft Docs
EnumProcess gibi
Process Enumeration - Win32 apps | Microsoft Docs
Windows (kullandığınız işletim sistemini belirtmemişsiniz) gibi işletim sistemlerinde, tüm pencereleri listeletip pid lerini alıp istediğinizi kapatabilirsiniz.
Aslında programı tkinter notebook ile dizayn edebilirsin. Sekmeleri oluşturup her sekme için farklı arayüz oluşturabilirsin.