Python Game using pyGame with Window Menu elements - python

Here's the deal. I'm trying to write an arkanoid clone game and the thing is that I need a window menu like you get in pyGTK. For example File->(Open/Save/Exit) .. something like that and opening an "about" context where the author should be written.
I'm already using pyGame for writting the game logic. I've tried pgu to write the GUI but that doesn't help me, altough it has those menu elements I'm taking about, you can't include the screen of the game in it's container.
Does anybody know how to include such window menus with the usage of pyGame ?

wxPython allows you to integrate a Pygame window inside of a "normal" wxPython window - check out their wiki entry for how to do it. This should allow you to have a normal window (with File/Help/etc.) menus, but have a Pygame surface to which you can draw for your game.

Related

How to make a only 1 window GUI in python?

I am trying to make a GUI in python that only consists of 1 window. I think this is better explained with examples. If you have say the settings app open on the computer when you click an option a new window doesn't pop up, the original window changes the a new layout. Is there a way to do this without deleting everything in the window and then adding new stuff, and when going back doing the same process.
If you're using a QT based gui framework like PyQT or PySimpleGUI, you can accomplish this task using a Tab object. Here is a link to a sample program with using Tabs in PySimpleGUI
PySimpleGUI is a really good option for getting your feet wet with GUI development in Python. You can get a lot done with very little code and learn about how GUI's work.

Making a game overlay in python

So I am trying to make a python script that when I do a certain hotkey combination, It shows a text box as an overlay like what "Geforce Experience" and "Windows Gamebar" do.
the problem is that in the game when I interact with the text-area loses focus and goes minimized as opposed to the 2 programs I spoke about before, for example windows game bar allows you interact with a lot of options while the game is still on foreground and you close the bar you are left with whatever you were with before...
I'm using tkinter for now, and if there are solution not including tkinter it is Ok as long as it achives the goal.
As far as I understand what you are trying to do is create a overlay for a game and the overlay should be created using tkinter object. Here is a library that can do that, however as far as I remember you needed to change something in it's python file, however this might have already been fixed.

How to take a screenshot of a Wxpython GUI program when menu drops down on menubar

Is it possible to capture a screenshot of a wxpython GUI program when the program menu on the menu bar drops down?. I attempted to do this by pressing the print screen key on my keyboard but it didn't work.
Nevertheless, the print screen function key works fine when the menu on the menubar does NOT drop down.
I noticed I can take screenshots of other GUI programs on my system when their menu options are seen .
If this is possible, what codes can I place in my program to facilitate a successful screenshot when any menu is showing?
I just tried "Shift-prt scr" on my Windows 8.1 to capture a screen with a menu shown (used the wxPython demo) and it worked for me.
You can also use a screen capture utility, e.g. I often use IrfanView, to do this, with it I set a timer to capture things which go away when the window looses focus.
With Ubuntu using Mate under Applications--> Accessories there is a Take Screen shot option.
The actual command is mate-screenshot --interactive
this allows you Full screen, Current window or Selected area, with a "Grab delay", I found it particularly useful documenting wxpython, although you will have to drag the window to a size to accommodate the full menu or you end up with it cut off.
Note: gnome-screenshot --interactive, is another alternative.
Edit:
Have you checked out pyscreenshot?
https://pypi.python.org/pypi/pyscreenshot
It claims the following usage:
Example:
import pyscreenshot as ImageGrab
# fullscreen
im=ImageGrab.grab()
im.show()
# part of the screen
im=ImageGrab.grab(bbox=(10,10,510,510)) # X1,Y1,X2,Y2
im.show()

drawing transparent and click through text on top of all windows

I am creating a Lyrics display app in Tkinter and python for Ubuntu. It works fine in displaying lyrics in a window. but I want to create a on screen presentation of lyrics lines like it happens in MiniLyrics. So I want to draw over all windows and that should with click through and have transparent background.
what strategy I should use to achieve this task.
You cannot use tkinter to do what you want. Tkinter can only affect the windows it creates.

How to focus on a window with pygame?

I made a Python game using Pygame. I try to make it so when it starts, it loads the shell, and entering a raw input would display the pygame window and start the game so that I can make the game playable without having to close the shell. It works, however, the window starts minimized. The game is a simple "dodge the object" and has no pause what so ever. The game still runs in the background, possibly having the player hit multiple projectiles before the user realizes it. Is there a way to focus on the window?
For anyone in the future who stumbles across this question:
As of 2022, pygame v2.1.2 has an experimental module ._sdl2 where: Window.focus() is used to make a window to be moved at the top and set focus. Windows.focus() supports optional input_only bool parameter for whenever the window should be moved at the top (False), or just collect input (True).
As I understood you, you don't want the game to start, before the window is in fullscreen-mode, right?
When I try you attempt (starting through rawinput), my display is fullscreen from the start. Have you set everything correctly?
I suggest that you stop the game until there is an actual key-input (whatever controls you have set). Like this the player has the time to arrange everything to his liking before starting the game. Because, even if you figure out how to analyse the focus-issue: When the game starts, the window HAS focus, therefore this approach wouldn't work anyway.

Categories

Resources