I’m making a game and I’m now using tkinter for settings.
It works good while using Windows, but in Linux, the GUI appears but i can’t do anything with it.
GUI appears but can’t be interacted
i dont know if it would be any help but here the init() of my setting
class SettingsWindow(tk.Tk):
def __init__(self, createSaveFile, loadSaveFile):
tk.Tk.__init__(self)
# Set the initial theme
self.tk.call("source", "assets/azure.tcl")
self.tk.call("set_theme", "dark")
# self.geometry('700x400')
self.title('Settings')
self.createSaveFile = createSaveFile
self.loadSaveFile = loadSaveFile
self.constantsVars = {}
self.initMainNotebook()
self.addFeaturesFrame()
self.addConstantsFrame()
self.addLoadSaveFrame()
self.addShortcutsFrame()
self.mainloop()
I asked ChatGPT and he told me to assure the existence of the files, and check permissions. I did all of them but still cant solve anything.
I’ve already tried to run the settingWindows separately, and it’s totally fine, but when i put again into the game, it still cant be interected, so i think it might be my game loop who has the problem
in game loop i put in the events handling:
while self.running:
# handle events
self.events()
and there if the menu is on, it will display menu:
def events(self):
"""
Handle events
Currently handles:
- Quitting the game (by pressing the cross or escape)
- Pausing the game (by pressing p)
- Rendering the game (by pressing r)
- Moving the map (by clicking and dragging)
- Zooming the map (by scrolling)
"""
for event in pygame.event.get():
# Quitting the game (cross)
if event.type == pygame.QUIT:
self.running = False
if event.type == pygame.KEYDOWN:
# Pausing the game and displaying the pause menu (escape)
if event.key == pygame.K_ESCAPE:
if self.editorMode:
self.gui.displayPauseMenu = not self.gui.displayPauseMenu
else:
self.paused = not self.paused
self.gui.displayPauseMenu = self.paused
And in thie GUI i will have the buttons Options, to run the settingWindows
self.button(buttonX, buttonY + buttonHeight + 10, pauseMenuOffset, buttonWidth, buttonHeight, "Options", pauseMenu, lambda : SettingsWindow(self.game.createSaveFile, self.game.loadSaveFile))
Still cant figure out how it can run on Windows but not Ubuntu
dumbfloppa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.