Как использовать Python с изменениями открытого файла в выбранном файле меню опцийPython

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Как использовать Python с изменениями открытого файла в выбранном файле меню опций

Сообщение 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()


Подробнее здесь: https://stackoverflow.com/questions/792 ... ected-file
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»