Member Avatar for CobRalf

Hello everybody!
a few days ago, i read this post in the Advanced and Intermediate Projects -Thread:

Create an operating system prototype/emulator in Python. You might research into various operating systems to get an idea for what to implement.

Things you can implement: A login. A shell system. A explorer system (If done well enough, you can disable your own explorer process at startup and execute your own.) A desktop window. A web browser. (A project in and of itself.) A plain text editor. (Another individual project.) A control panel/system configuration set of utilities.

...and I thought it would be fun to realize a such project.
It should not be a real OS, only a python script that is launchable on every pc having a python interpreter.
It should have a task bar, an explorer, a desktop, etc... (as lrh9 already posted)

What I've done 'til now:
I decided to code it in pygame, it already has a sort of multithreading and is very flexible in design.
I now already have a window-class, which is used for displaying windows (SURPRISE!=)
'til now, you can move the windows around, close them and open new ones.
all the windows are based on pygame.sprite.Sprite, the window.update() function simply sets the position of the window if it is dragged.
at the end of the mainloop, every sprite (window) is redrawn with allwindows.update()
(-> nothing special....)
I have a taskbar (where the open windows will show up in some hours=), a start-button, that opens up a small menu where you can select the windows you want to display, and a "shutdown"-button that exits the script.

...but I've a few problems, perhaps you can help me fixing them?when the titlebars of two windows overlap and i start moving one of them, the other one moves too... the window's title bar is a rect...
same problem if two window's close-buttons overlap: both are closed...
-> how can i give a "topmost"-attribute to a rect? (or something like that...)
input: how can i make an input-box?? eg. for making a text-editor... have i got to make a big loop where pygame checks for every key press and blits it to the screen?or is there an easier way?

thank you for any suggestion!!


Recommended Answers

All 5 Replies

Your project is unique and complex in design, and I fully understand the problems you have right now.
I don't have any knowledge of PyGame, so I can't really help you with the top-most concept (which is what problems #1-3 are related to)
Perhaps, after the window.update() method is called, you can check if there are any overlapping title bars, and draw invisible rectangles indicating the overlapping segments, and mark those rectangles with the windowid that is on top (usually that is the window that was just dragged to cause the overlap)

When those invisible rectangles detect a click, you can only cause the top-window to close or move.

Also, when that invisible rectangle detects a click, it should check if those two windows are still overlapping.

Hopefully that makes some sense. It's a complex problem.
Good luck.

I don't know pyGame, but I think it would be better off using GUI oriented Toolkits, something like wxWidgets or QT or GTK. I'm not sure if pyGame is that much capable.

PyGame is actually a great choice, because you have a single game window with the OS inside. Sprites for windows can be useful.
Of course, using a GUI library will also work, but PyGame is definitely capable.

Member Avatar for CobRalf

First, thanx for your replies!

@tonyjv: wow=) ...It's only a small change in my would be amazing if it works!

@jcao219: thank you for your long post. This is a way that takes some more time to code...but it will work!

@evstevemd: I also code loads of things in pyQT, and its much more powerful than pyGame. But the main thing of my "OS" is, that it really creates the illusion of being an OS. If I use pyQT, it would only be a pack of (stand-alone) tools, with the Windows Taskbar as control unit, Windows window moving, closing and resizing would have a smaller effect than a completely different interface, and it would be "relatively" easy to make. (making a text editor for example). [of course, you have nearly unlimited possibilities to improve your pyQT or wx text-editor, so it could compete against word etc...=) ]

I'll inform you about the changes I will make if i have a little more time...if you want=)



because you have a single game window with the OS inside

thats exactly what i meant=)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.