Привет, ребята, я пытаюсь запустить скрипт 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
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Меню настройки основного меню не обновляется в меню «Настройки» меню паузы
Anonymous » » в форуме C# - 0 Ответы
- 19 Просмотры
-
Последнее сообщение Anonymous
-