0

How to force Pygame frame to be placed on top of tkinter frame?

I found the feature wm_attributes('-topmost', 1) for tkinter frame and that it works for setting Tkinter on Top. But I need this feature for Pygame Frame.

I found a post that using windll SetWindowPos(pygame.display.get_wm_info()['window'], -1, x, y, 0, 0, 0x0001)

Unfortunately this did not work for me because I am using Raspberry Pi and this package was not compatible with it.

H_PMD
  • 1
  • Linux should have own methods to put (overlay) one window on other window. But frankly I don't like idea to mix two different frameworks - tkinter and pygame - so I never tried to do this. – furas Jan 04 '21 at 12:28
  • at this moment the only idea: in every loop get Pygame `screen`, convert to image and put on `tkinter.Label` or `tkinter.Canvas`. I think I was doing something like this with stream from webcam on Linux (maybe even on Raspberry Pi) – furas Jan 04 '21 at 12:36
  • 1
    Is [this](https://stackoverflow.com/questions/23319059/embedding-a-pygame-window-into-a-tkinter-or-wxpython-frame) what you want? – acw1668 Jan 04 '21 at 13:10
  • @acw1668 I was thinking about something like in your link :) – furas Jan 04 '21 at 14:18
  • No! My main program consists of a number of frames made with Tkinter. In one of these frames I have two start and stop buttons at the bottom of the Frame. Pressing the start button opens Angry birds game (Pygame). The Pygame program is placed on the Tkinter and It's Correct. But when the mouse pointer is touched on the Tkinter Frame, Pygame moves down and this is my problem. I want the program to be closed just by pressing the stop button on the Tkinter. – H_PMD Jan 04 '21 at 14:34
  • Did you try embedding the pygame display into a tkinter window and then use `wm_attributes("-topmost", 1)` on the tkinter window? – acw1668 Jan 05 '21 at 04:06
  • I try embedding the pygame display into a tkinter window and It is ok. The Pygame takes up part of the tkinter frame and It is ok. I need when I touch other parts of the Tkinter Frame that are not occupied by the Pygame, The pygame don't move to the back. I don't use wm_attributes("-topmost", 1). I need a attribute similar to this for pygame frame. – H_PMD Jan 05 '21 at 09:52

0 Answers0