Archive for the 'windows mobile' Category

28th Apr 2008

PocketPyGUI: an intuitive, pythonic wrapper of the native Windows Mobile GUI

In playing around with my Dell Axim X51v, I have discovered PythonCE (the python distribution for windows mobile), and, more recently PocketPyGUI — a reliable, complete and easy to use GUI library. I stress easy to use because this library takes all the Windows out of Windows programming ;), while still providing the slick integration with the rest of the Windows Mobile operating system. I’ve also whipped up a few apps (some more complete than others) while getting to know the library. You can find them here on sourceforge all bundled into one zip file.
Here are a few screenshots of the demo program:

Posted in axim, pocketpc, python, windows mobile | No Comments »

14th Feb 2008

VensterCE: Hello World, again

In this tutorial, we are actually going to make a window, although we will still just be saying “Hello, World”

The Code

from venster.ce import *

class MyWindow(CeMainWindow):
    _window_title = u"Hello World, again"

    @msg_handler(WM_CREATE)
    def OnCreate(self,event):
        self.sizer = BoxSizer(VERTICAL)
        text = StaticCenter(u"Hello World", parent=self)
        self.sizer.append(text)
        CeMainWindow.OnCreate(self,event)

def main():
    mainForm = MyWindow()
    mainForm.ShowWindow()
    application = Application()
    appliation.Run()

if __name__ == "__main__": main()

Step by Step

class MyWindow(CeMainWindow):
    _window_title = u"Hello World, again"

This is the class definition of the main window. It inherits from CeMainWindow, which was imported from venster.ce at the top. “_window_title” is a class variable, and representing the title of your window. Once again, be sure to use unicode (prepend the string literal with a “u” or convert with the unicode(str) function), or it will come out looking like garbage.

    @msg_handler(WM_CREATE)
    def OnCreate(self,event):
        self.sizer = BoxSizer(VERTICAL)
        text = StaticCenter(u"Hello World", parent=self)
        self.sizer.append(text)
        CeMainWindow.OnCreate(self,event)

the @msg_handler(WM_CREATE) is a decorator function, setting this function up as the message handler for the WM_CREATE function; the effect being that this function is called as soon as the window is created.
self.sizer (the name is important) is our main widget sizer — all widgets we create should be appended to it, or one of its children.
There are 4 classes of static text: Static, StaticLeft, StaticCenter, and StaticRight. They all take the same arguments.
Finally we call the parent class’ OnCreate to finish setting up the window.

def main():
    mainForm = MyWindow()
    mainForm.ShowWindow()
    application = Application()
    appliation.Run()

if __name__ == "__main__": main()

These lines of code will probably be at the end of all your programs; they “create” the window and start th eapplication running.

Posted in axim, how-to, pocketpc, python, windows mobile | No Comments »

06th Feb 2008

Sync Windows Mobile with Ubuntu

time-saving tip: if you don’t want this all explained to you, you can just download and execute this bash script.

First you need to install SynCE:
Add these lines to your apt sources (type “sudo kate /etc/apt/source.list” and paste these at the bottom)

deb http://ppa.launchpad.net/synce/ubuntu gutsy main
deb-src http://ppa.launchpad.net/synce/ubuntu gutsy main

Install the USB Driver

sudo apt-get install usb-rndis-source cdbs
sudo module-assistant auto-install usb-rndis

Install ODCCM (the connection manager)

sudo apt-get install odccm librra0-tools librapi2-tools

Now we need to install MultiSync (a gui that manages the syncing process)

sudo apt-get install multisync libmultisync-plugin-backup libmultisync-plugin-irmc libmultisync-plugin-evolution synce-multisync-plugin

Now that you’re done installing everything, type “sudo odccm -f” into the konsole to start the connection manager, and plug in device (your device should now recognize that it is connected). To manage the syncing, open up MultiSync (Start Menu->Utilities->MultiSync) and create a new sync pair with the plugins “SynCE Plugin” and “Ximan Evolution 2″. Press sync, and you’re done!

If you dont use evolution, you can get other plugins for MultiSync at their website.

Posted in axim, how-to, pocketpc, ubuntu, windows mobile | No Comments »

05th Feb 2008

CeGCC Hello World

First, copy this into a file “hello.c”

#include <windows.h>
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
{
          MessageBox(0, L"Hello!", L"CeGCC says...", MB_OK);
}

Here we have the generic MessageBox function, but with one twist: because we are in unicode, we need to prepend all string literals with ‘L’ (we could use the _T(”mystring”) macro, but I think it looks more ugly). If you try do compile

MessageBox(0, "Hello!", "CeGCC says...", MB_OK);

You will get an error complaining something about converting to LPCWSTR (meaning it wants unicode and didn’t get it).
To compile this source (you need to have first installed CeGCC), enter this at command line:

arm-wince-mingw32ce-gcc hello.c -o hello.exe

You can then copy the .exe file over to your Windows Mobile device and double click on it in the file manager to run your first program!

Posted in axim, c, how-to, ubuntu, windows mobile | No Comments »

30th Jan 2008

VensterCE: Hello World

In keeping with tradition, lets start off with a simple “hello world”

from venster.ce import *
msg = MessageBox(None,u"Hello World",u"Venster Says",MB_OK);

First line:

from venster.ce import *

This merely includes the basic functions and classes from the venster library. We will use this in every program.

msg = MessageBox(None,u"Hello World",u"Venster Says",MB_OK);

Here create a simple messagebox and store the return value in the variable “msg”. The function definition for MessageBox is MessageBox(window,message,title,buttons). Here the parent window is None, as we haven’t created one (It’s ok, windows can handle that). Next are the Message and Title strings, but make sure you keep them unicode (bad things can happen if you dont). The “buttons” variable is combination of flags. A few popular ones are MB_OK, MB_OKCANCEL, and MB_HELP for buttons, and MB_ICONWARNING and MB_ICONINFORMATION for the icon. For a full reference of the different flags, go Here.

Posted in axim, c, how-to, pocketpc, ubuntu, windows mobile | No Comments »

24th Jan 2008

VensterCE: installation

To use the vensterce library you first need python, so (If you haven’t already) go ahead to the PythonCE Download Page and get either the installer or the CAB file (you choose :). Then you can fetch VensterCE zip archive from here. Inside that zip file you will find several things:

  • “venster”: this folder is the actual library. Copy it into your python library (Usually \Program Files\Python25\Lib\
  • “tutorial”: here is contained 5 “tutorial” files along with an html page describing them, although I’ve found this “tutorial” to be more of a quick-start for those already proficient with C++ win32 programming
  • the contents of the “shared” folder need to be copied into the \Windows directory on your device.
  • “pyceide”: this is an advanced python IDE, built in VensterCE. All you need to do is double-click on the “pyceide.pyw” file and it will run.

That should be all that’s necessary. From now on you can “import venster”.

Posted in how-to, pocketpc, python, windows mobile | No Comments »

22nd Jan 2008

VensterCE: Native Win32 Api for PythonCE

VensterCE is an open source wrapper of the native win32 controls on a windows mobile device (i believe its also available for regular windows…but its not as good as the win32api module). Its a cool project, but the tutorials provided give a good idea of what it can do, but don’t actually help you understand how to make your own. This can be a big challenge for those win32 noobs out there (hey, i was one too…about a month ago ;), so i decided to start a tutorial series to help out, and teach myself something in the process.

Posted in axim, pocketpc, python, windows mobile | No Comments »

31st Dec 2007

Installing CeGCC on Ubuntu

On the CeGCC sourceforge download page, they give linux binaries, but in rpm format (not the .deb’s that Ubuntu uses), so to make this work, we need to install the rmps with alien:

sudo alien -i cegcc-cegcc-0.51.0-1.i586.rpm mandriva-cegcc-mingw32ce-0.51.0-1.i586.rpm

Once those are installed, we still aren’t finished, because the package installs to /opt/ so the binaries (arm-wince-cegcc-gcc etc.) aren’t available to us without using long complicated prefixes. So we just need to symlink the the binaries to our /usr/bin/.

sudo ln -s /opt/mingw32ce/bin/* /usr/bin/
sudo ln -s /opt/cegcc/bin/* /usr/bin/

(thanks to Pablo Rogina for the tip on symlinking)
After that, you’re all set!

Posted in axim, c, pocketpc, windows mobile | 3 Comments »

28th Dec 2007

Cross-Compiling for Windows Mobile on Ubuntu

There are a few compilers I’ve found that will do this:

  • the (only for windows) Pelles C compiler through WINE
  • the PocketPC-GCC ubuntu package
  • the CeGCC cross-compiler for pocketpc

Pelles C

Pelles C is a great IDE, not only for windows mobile, but also for windows smart phone and regular old windows. My only objection to it is that it takes really, really long to compile even the simplest programs. Now, this might seem a small failing to some, but having to wait up to a minute for hello world to compile drives me nuts, especially since the others compile soo much faster.
Links:

PocketPC-GCC

This package is great for general C, and (though I haven’t tried this) might be excellent for porting linux apps to the PocketPC. Unfortunately, It doesn’t come with the windows headers/libs (these can probably be added, but I’m lazy, and CeGCC comes with them pre-loaded). In a few days I will probably experiment with getting Win32 programming to work with this compiler, so check back to see if I’m successful ;).
To install this, just do “sudo apt-get install pocketpc-gcc”. You might want to install pocketpc-g++ and pocketpc-sdk as well. I haven’t found any docs/tutorials/etc. for this package, witch is part of the reason I’m hesitant to use it.

Update: On closer inspection, I’ve found that this compiler results in massively bigger files: For the standard “helloworld.c”, the resulting exe was 338kb! in contrast to the 10kb exe compiled by CeGCC ;). Thats it, I’m definitely sticking w/ cegcc.

CeGCC

This is my champion for the moment, and the one I’m leaning win32 c on. It comes with the windows and pocketpc specific headers (though no directx or opengl). This will be the one that I will be using in my upcoming tutorials.
Links:

My CeGCC Tutorials:

Posted in axim, c, how-to, pocketpc, ubuntu, windows mobile | No Comments »