The following code works perfect on a Windows OS though does not work on the raspberry pi. I'm looking for information as to why this is, I have scoured the web for a solution but cannot find one.
from distutils.command.config import config
import logging
from logging.handlers import RotatingFileHandler
import os
from logging import root
import tkinter
import tkinter as tk
import tkinter.messagebox
import customtkinter
from threading import Thread
from tkinter import Label
from random import *
from itertools import count, cycle
from tkinter import *
from tkinter import ttk, Scrollbar
import platform
import pygame
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
tabview = customtkinter.CTkTabview(self, height=500, width=500)
tabview.place(x=-5, y=-50, anchor=tkinter.NW)
tabview.add("tab_main")
tabview.set("tab_main")
try:
pygame_width = 400
pygame_height = 400
embed_pygame = tk.Frame(tabview.tab("tab_main"), width=pygame_width, height=pygame_height)
embed_pygame.place(x=10, y=10)
self.update()
os.environ['SDL_WINDOWID'] = str(embed_pygame.winfo_id())
system = platform.system()
if system == "Windows":
os.environ['SDL_VIDEODRIVER'] = 'windib'
elif system == "Linux":
os.environ['SDL_VIDEODRIVER'] = 'x11'
display_surface = pygame.display.set_mode((pygame_width, pygame_height))
display_surface.fill((0, 50, 0))
pygame.init()
background_surface = pygame.Surface((pygame_width, pygame_height))
clock = pygame.time.Clock()
def handle_tkinter_events():
self.update_idletasks()
self.update()
while True:
handle_tkinter_events()
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
elif event.type == pygame.MOUSEBUTTONDOWN:
print('Clicked on image')
display_surface.blit(background_surface, (0, 0))
pygame.display.update()
clock.tick(60)
except Exception as e:
logging.critical("An exception occurred: {}".format(e))
print("An exception occurred: {}".format(e))
if __name__ == "__main__":
app = App()
app.mainloop()