简体   繁体   中英

How to create desktop python game application in Ubuntu 16.04?

I have written a python game using pygame module. It runs fine from terminal.

I have a game directory (let's call it myGame) which contain all the resources(images and sounds) and all the python scripts which use those.

When I run the game through terminal (let's say python3 mainPythonModule.py), the game runs fine.

I tried to create a game.desktop file. But when I click it, a black window appears and crashes almost instantly.

I am using Ubuntu 16.04 LTS. And my game is written in python3.5 and uses pygame module.

My game.desktop file looks like this

I don't want the solution answered for this question because I still have to type in terminal.

I would like to create a desktop applcation, such that by clicking on the icon, the game would start. Just like when we download any game, after installation, we just click on the game icon and it runs, I want something like that. How can I do that?

Edit : I don't think this question is a possible duplicate of this question . I want to know how to develop a desktop application in Ubuntu 16.04, such that by clicking on some icon, the game would start.

Final Edit : First of all, I would like to thank everyone who responded. I really am sorry for wasting your precious time.

The issue is resolved. The problem was all the resource (images and sounds) were loaded via relative path and not through absolute path. Now the game.desktop file runs fine.

I think what are you trying to do is some kind of launcher.

Here you have my repo, it contains a Tkinter GUI with a PyGame call on a button.

Feel free to study/use it as you want, look at the file desktop_application.py and if you don`t care about the coin part you can just skip that and take what you need.

https://github.com/FilippoLeone/PyGameLauncher

And you can compile everything as an executable with PyInstaller.

Install PyInstaller from PyPI:

pip install pyinstaller

Go to your program's directory and run:

pyinstaller yourprogram.py

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM