Привет, ребята, я пытаюсь запустить скрипт Python независимо от выбранного файла, но он не меняет выбранный файл. У меня более трех файлов json, это мой код:
это мой код:
from tkinter import *
import os
import json
root = Tk()
root.configure(bg="#4a3b2c")
root.title("file open test ")
root.resizable(FALSE, FALSE)
folder = 'profiles'
profile_options = StringVar()
profile_options.set('test.json')
profile_menu = OptionMenu(root, profile_options, *[i for i in os.listdir(folder)])
profile_menu.place(x=135, y=400)
final = profile_options.trace_add('write', lambda *args: print(profile_options.get()))
# printing finale is working and print on selected file but it dosen't open it
profil_name = StringVar()
profil_name = profile_options.get()
# i want to change file selected to run it on option select
with open("profiles\\"+profil_name, "r") as file:
dict = json.load(file)
print(profile_options.get())
width = 1040 # Width
height = 850 # Height
screen_width = root.winfo_screenwidth() # Width of the screen
screen_height = root.winfo_screenheight() # Height of the screen
xwidth = (screen_width/2) - (width/2)
yheigh = (screen_height/2) - (height/2)
root.geometry('%dx%d+%d+%d' % (250, 460, xwidth, yheigh))
root.mainloop()
Подробнее здесь: https://stackoverflow.com/questions/792 ... ected-file
Как использовать Python с изменениями открытого файла в выбранном файле меню опций ⇐ Python
Программы на Python
1734535925
Anonymous
Привет, ребята, я пытаюсь запустить скрипт Python независимо от выбранного файла, но он не меняет выбранный файл. У меня более трех файлов json, это мой код:
это мой код:
from tkinter import *
import os
import json
root = Tk()
root.configure(bg="#4a3b2c")
root.title("file open test ")
root.resizable(FALSE, FALSE)
folder = 'profiles'
profile_options = StringVar()
profile_options.set('test.json')
profile_menu = OptionMenu(root, profile_options, *[i for i in os.listdir(folder)])
profile_menu.place(x=135, y=400)
final = profile_options.trace_add('write', lambda *args: print(profile_options.get()))
# printing finale is working and print on selected file but it dosen't open it
profil_name = StringVar()
profil_name = profile_options.get()
# i want to change file selected to run it on option select
with open("profiles\\"+profil_name, "r") as file:
dict = json.load(file)
print(profile_options.get())
width = 1040 # Width
height = 850 # Height
screen_width = root.winfo_screenwidth() # Width of the screen
screen_height = root.winfo_screenheight() # Height of the screen
xwidth = (screen_width/2) - (width/2)
yheigh = (screen_height/2) - (height/2)
root.geometry('%dx%d+%d+%d' % (250, 460, xwidth, yheigh))
root.mainloop()
Подробнее здесь: [url]https://stackoverflow.com/questions/79291654/how-to-use-python-with-open-file-changes-on-option-menu-selected-file[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия