Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Скриптовые языки программирования > Python
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 19.10.2021, 08:09   #1
evachka17
Новичок
Джуниор
 
Регистрация: 19.10.2021
Сообщений: 2
Вопрос Как открыть проводник Windows через кнопку программы, написанной на Python \ TKINTER?

У меня есть код, написанный на Питоне с помощью ткинтера. В программе, которую он запускает есть путь из кнопок MONDAY > REGISTRATION. Как сделать так, чтобы при нажатии на кнопку REGISTRATION открывался проводник с определенной директорией, а не еще одно окно?

Код:
from tkinter import *
from tkinter import messagebox
import json
from tkinter.filedialog import asksaveasfile

root = Tk()
root.title("Organaizer")
root.resizable(0, 0)
root.configure(bg='black')
root.geometry('750x600')

def reg1():
	#os.system("start C:/Users/evamo/Documents/")
	monregles = Toplevel()
	#monregles.title("REGISTRATION")
	#monregles.resizable(0, 0)
	#monregles.configure(bg='black')
	#monregles.geometry('750x600')

	#monreg1notes = Frame(monregles, width=750, height=400, bg='white')
	#monreg1notes.grid(row=0, column=0)
	#monreg1view = Frame(monregles, width=750, height=200, bg='black')
	#monreg1view.grid(row=1, column=0)

	#notemonreg1 = Entry(monreg1notes, bg='yellow')
	#notemonreg1.pack()

def mondays():
	monles = Toplevel(root)
	monles.title("MONDAY")
	monles.resizable(0, 0)
	monles.configure(bg='black')
	monles.geometry('750x600')

	
	#def rl1():
	#	noterl1.pack()

	#def itgs1():
	#	noteitgs1.pack()

	#def maths1():
	#	notemaths1.pack()


	lesson = Frame(monles, width=750, height=600, bg='black')
	lesson.grid(row=0, column=0, padx=1, pady=1)


	registration = Button(lesson, text="Registration", fg='black', bg='white', font=20, width=85, height=6, command=reg1)
	registration.grid(row=0, column=0, sticky=S)

	literature = Button(lesson, text="Russian LIterature", fg='black', bg='white', font=20, width=85, height=6)
	literature.grid(row=1, column=0, sticky=S)

	itgs = Button(lesson, text="ITGS", fg='black', bg='white', font=20, width=85, height=6)
	itgs.grid(row=2, column=0, sticky=S)

	maths = Button(lesson, text="Maths", fg='black', bg='white', font=20, width=85, height=6)
	maths.grid(row=3, column=0, sticky=S)

	#notereg1 = Entry(notes, width=375, height=300, bg='white')
	#notereg1.pack()

	#noterl1 = Entry(notes, width=375, height=300, bg='white')
	#notereg1.pack()

	#noteitgs1 = Entry(notes, width=375, height=300, bg='white')
	#notereg1.pack()

	#notemath1 = Entry(notes, width=375, height=300, bg='white')
	#notereg1.pack()




lu = Frame(root, width=250, height=200, bg='white')
lu.grid(row=0, column=0, padx=1, pady=1, sticky=N)

tp = Frame(root, width=250, height=200, bg='white')
tp.grid(row=0, column=1, padx=1, pady=1, sticky=N)

ru = Frame(root, width=250, height=200, bg='white')
ru.grid(row=0, column=2, padx=1, pady=1, sticky=N)

lt = Frame(root, width=250, height=200, bg='white')
lt.grid(row=1, column=0, padx=1, pady=1, sticky=N)

md = Frame(root, width=250, height=200, bg='white')
md.grid(row=1, column=1, padx=1, pady=1, sticky=N)

rt = Frame(root, width=250, height=200, bg='white')
rt.grid(row=1, column=2, padx=1, pady=1, sticky=N)

bt = Frame(root, 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)
tday.pack()

wday = Button(ru, text="WEDNESDAY", fg='black', bg='white', font=150, width=27, height=10)
wday.pack()

thday = Button(lt, text="THURSDAY", fg='black', bg='white', font=150, width=27, height=10)
thday.pack()

fday = Button(md, text="FRIDAY", fg='black', bg='white', font=150, width=27, height=10)
fday.pack()

saday = Button(rt, text="SATURDAY", fg='black', bg='white', font=150, width=27, height=10)
saday.pack()

sday = Button(bt, text="SUNDAY", fg='black', bg='white', font=150, width=27, height=10)
sday.pack()


root.mainloop()
evachka17 вне форума Ответить с цитированием
Старый 19.10.2021, 11:24   #2
Ципихович Эндрю
Старожил
 
Регистрация: 24.01.2011
Сообщений: 3,039
По умолчанию

наверное, что-то из этой оперы))
Код:
import tkinter.filedialog as fd
f_name = fd.askopenfilename(title='Выберете файл с расширением html', initialdir='d:/', filetypes=(('HTML-файлы', '*.html'),))
Ципихович Эндрю на форуме Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Помогите с tkinter как же убрать анимацию нажатия кнопки? версия python 3.7.5 semen901 Python 4 17.11.2020 19:14
Функция y=sin(x) в Python (Tkinter) klyukina2901 Python 0 18.03.2019 13:40
Windows Forms c++ как через кнопку вызвать PictureBox diga666 Windows Forms 1 27.05.2013 14:51
Как вызвать скрипты powershell из программы, написанной на с++ maximus83 C/C++ Сетевое программирование 1 19.01.2012 10:08
Как через командную строку (Windows XP) открыть файл в программе WordPad? ivan.tiran Windows 1 13.11.2011 15:06