iiYO Community

Full Version: WebStory Engine GTK Container
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
Hey all, I'm working on my own little container program for WebStory using python and the pygtk, SimpleHTTPServer and pywebkitgtk. Hopefully it will provide a nice little way to run WebStory games locally on GTK based systems, which with the already existing WebStory Engine LC, should get us to cover all Linux Desktop Environments.

I do plan to eventually pack it as a single binary using pyinstaller with a ini file so you can change settings (like stage size, start full screen, name, etc) related to it. I also want to try porting it to Windows.

I have run into a few issues but most of the fun is in figuring them out, right? Tongue


Hi @Trixar_za,

I look forward to seeing your first release. By the way, it's not really a problem on Linux systems whether you use GTK or Qt anymore. I personally prefer using Unity, but I also use some KDE apps like Kate (which is imho much better than gedit). So if you get something working on Windows also, I don't really see the point in continuing my version of the Local Container, especially when yours has more features, an installer etc.

Do you have a GitHub repo for your project?

Well, if you have troubles related to the engine you can always ask here, too.

If you haven't done so yet, I guess it would be a good idea to have a look at the HOST object of the WebStory Engine LC to see what's already supported by the engine.

#container #wse #gtk #python #linux #windows


The problem seem related to my webkit version (or one of it's dependancy) since I get the same error in midori and tazweb. So far it just pops up with the default demo when it prompts for the user's name. The input box shows for a second and then the program crashes with a very informative 'Instruction Error'. It doesn't show up when I test it with the basic effects demo on the site or even the More than Forever game.

Considering I broke my package manager Monday, it's probably a great time to switch to the unstable but more up to date version of my distro.

I do have a github account under the username Trixarian, but haven't uploaded the project yet since I have to properly thread it and make it actually close the program when you close the window. I'll probably get to that today.

Edit: The previous bug disappeared, but now it gets stuck at the 'loading assets' screen and throws an error about Audio. Removing the audio tags from the game.xml makes it work without any problems.


That sounds like your WebKit version is extremely ancient. If it doesn't support the HTML5 Audio element, it is much too old to run the engine. I mean... what sense does a game engine without sound make? But that's just my interpretation of what you wrote, I can't really tell without more information. Maybe it's even something else entirely?

Which versions of WebKit and GTK do you use? Which Linux distro?


I'm using SliTaz 4 running Gtk 2.24.10 and libwebkit 1.16.1, but it seems webkit's media functions have been split into libwebkit-video.

I'll admit that I've always been bad at threading applications, hence my current struggle of integrating the web server with the client. Slowly getting to a coherent client and enjoying the challenge it provides.

As to why I'm putting in so much effort: WebStory Engine, even with a container, will be incredibly lightweight compared to Ren'py. I love lightweight applications, especially if it's web based. All my sites use lightweight and SQL free technology.


Well, threading is kinda hard, isn't it? That's why node.js is awesome. Wink

I wouldn't call a JS app with 300 kb sources lightweight compared to other JS projects, but compared to Ren'Py, I guess that's probably true.

So, did installing the video package solve the problem with Audio?

Anyway, just wanted to let you know that I put together a diagram that shows a simplified overview of WSE's structure. Maybe that helps should you need to change something in it or write an extension?

[Image: wiki:wse-structure.jpg]


Installing libwebkit-video did help, but the game.xml had an error in it. It was looking for something called wslegends.mp3/ogg in /Desktop. I changed it to assets/audio/birds.mp3/ogg with a loop and I'm now enjoying the sounds of birds in my demo Smile

I figure I'll use the subprocess module to run SimpleHTTPServer in the background and kill it when the program closes. Saves me having to figure out Threading and I get to work on the client instead. It's not an ideal solution because this won't work well with PyInstaller and not at all with systems that doesn't have python on it and not on Windows at all. I'll crash course a few threading tutorials and see if something clicks in my brain. If all else fails, I'll ask on freenode, but I can already hear #python's answer: Use twisted and/or pyxml. But that's their solution to absolutely EVERYTHING Internet based.

Development wise it's getting pretty interesting. I realized I could read the game.xml to figure out the stage's dimensions and wrap the window around it perfectly. I also want to write in a way to fullscreen the client by using either Alt+Enter or F11 and save it all to a configuration file (which I named settings.ini), so the program remembers the user's preferences while using the program. I'll create a proper github repository tomorrow and upload what I got.

But for now the obligatory screenshot:
[Image: demo.jpg]


Well, leaving the MP3 on the desktop was intentional, because it was copyrighted so I didn't want to accidentally commit it. But I should've taken it out, that's right. Wink

I don't know about WebKitGTK, but QtWebKit can quite easily be manipulated to allow things operating on a local file that aren't normally possible without a server. So, you don't really need to run a webserver if it gives you headaches. In the Local Container, I let the HOST object load the XML, and the HOST object talks to Python methods that do all the "server" stuff. Also, I used the HOST object to resize the window so that I did not need to parse the XML twice. It can also toggle fullscreen. Another thing I did was stopping WebKit from opening non-local connections and so that links inside the WebStory will instead be opened in the default browser. Things like that are really easy in Qt because you can just extend the network class or whatever it's called and use that with WebKit instead of the original.

Another idea I had for the LC was to enable the WebStory developer to compile in all the assets and the game.xml as binary resources so that they don't have to worry about the things being stolen when they release commercial games. I'm not really sure though if there's any way doing that without requiring the developer to worry about the hairy compiling stuff.

Do you know what license you will be using for your container app? It would be nice if it were a permissive license like BSD or MIT to be compatible with WSE's license.


As I understand it, you can use PyInstaller to package the files used with the program into a single file or even include it with the binary to be extracted when needed. I know Ren'Py does something similar. I'll have a look into it more when I make the container (named pywse for now) more compatible with PyInstaller.

Subprocess has a minor pain. Starting SimpleHTTPServer takes about 1.5 seconds to do, which means the container program starts too fast for the web server to be available. I did a dirty fix for this by making the program sleep for that 1.5 seconds before continueing. I really need to integrate the module into the main program because the slower start-up time should disappear.

I'm just going to release it under Creative Common Zero. Don't really care if I get credit for the code or not or what people do with it. I'm doing it more for the challenge than anything else. Speaking of which, it's now online @ https://github.com/Trixarian/pywse in all it's horrible glory.


I've been reading up about allowing js to execute in webkit using local file browsing. If I could implement something like this, then the need for a webserver would be gone and the program should run lighter too. I'm also going to enable cacheing like you did in WSE LC. Things are looking good for a pyinstaller port Big Grin

EDIT: OK, that was a no-go. I got it to work, but WSE couldn't load the XML file... Sad
The attempt is saved under the filename pywse-fb. I did figure out how to speed up the load time of web server to about 1 second (yay). I'm now attempting to add the the requirements to a stand-alone lib folder for easy packaging. So far I got pywebkitgtk working on my system using this method so please somebody test if it works on yours.
Pages: 1 2 3 4