Answer the question
In order to leave comments, you need to log in
How to change windows in PySimleGui depending on what is selected in sg.Combo?
I need to create a GUI for a program that translates mods for a game. The translator has several modes and input variables are also different. I want the interface to change depending on what is selected in sg.Combo. I wrote this code:
(Class with layouts)
list_commands = [COMMANDS.ADDITIONAL_ENGLISH, COMMANDS.ADDITIONAL_RUSSIAN, COMMANDS.TRANSFER_FILE,
COMMANDS.ALL_TRANSLATE_DIRECTRY, COMMANDS.TRANSLATE_FILE, COMMANDS.ALL_TRANSFER_DIRECTORY,
COMMANDS.STREAMLINE_FILE, COMMANDS.STREAMLINE_DIRECTORY, COMMANDS.SEARCH_UPDATE_STRING_FILE,
COMMANDS.SEARCH_UNTRANS_STRING_FILE]
class INTERFACE:
ADD_FILE_ENG =
ADD_FILE_RU =
def change_interfase(self, mode):
if mode == COMMANDS.ADDITIONAL_ENGLISH:
window = sg.Window('LTA (localization translator assistant)', INTERFACE.ADD_FILE_ENG)
elif mode == COMMANDS.ADDITIONAL_RUSSIAN:
window = sg.Window('LTA (localization translator assistant)', INTERFACE.ADD_FILE_RU)
def get_default_interface(self):
return sg.Window('LTA (localization translator assistant)', INTERFACE.DEFAULT, size=(700, 100))
interface = work_with_interface.get_default_interface()
while True:
try:
event, values = interface.read()
#print(event, values) #debug
if event in (None, 'Exit', 'Cancel'):
break
elif event =='MODE':
interface.Close()
interface = work_with_interface.change_interfase(values['MODE'])
Answer the question
In order to leave comments, you need to log in
The point was that I initialized the ayouts once, but it is necessary for each new switching to the mode in the ComboBox. For this, INTERFACE has been redesigned as follows:
class Interfaces:
def get_add_file_eng(self):
return
def get_add_file_ru(self):
return
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question