Personal tools
You are here: Home Weblog Windows

Windows


2007-05-08

Software is lame

I may sound like a fanboy or something, but I'm starting to think that it's impossible to have a perfect piece of software, especially with larger systems. Two things that happened to me lately that made me think this:

  • How lame is that Windows doesn't automount USB sticks when they're present at boot time? Why would I have to remove+reinsert the stick just so Windows will see the bloody thing? My Kubuntu, of course, handles perfectly everything in this department (at least in my case).
  • How lame is that Prototype handles in a really stupid way forms that have multiple submit buttons and are submitted through Ajax? Not even Form.request() will do the proper thing, which is to only leave one of the submit inputs in the stream, the one that has been clicked on. The problem is with zope.formlib, which gets the action and the validation from the submit button that was pressed. More then one submit input in the request and things become uncontrollable.
    To fix this I have added the following onsubmit handler to my Javascript code:
my_form.onsubmit = function(event){
    button = document.activeElement || event.explicitOriginalTarget;    // IE, Mozilla, Opera
    this.getInputs('submit').each(function(el){
          if (el.name != button.name) {
                el.disable();
          }
}
}

This disables all the submit input controls before serializing the form and doing an ajax request with Form.request(), as disabled inputs are ignored by serialize().

UPDATE: I am told that Prototype 1.6 will support multiple submit buttons.

2007-05-03

Brettspielwelt - the free, online boardgame portal

Filed Under:

I live in Europe, I'm a geek, so I must also be a boardgame freak. I love games, and especially German style boardgames, with their intricate rules. Unfortunately, there's not much time to play, and not a lot of people that I can play with. Following a link on boardgamesgeek.com I've stumbled on this website, an online portal of boardgames that you can play, something similar to IGS (the Internet Go Server), but that implements loads of boardgames to be played in multiplayer style. The people are friendly and are willing to teach you to play (even in English). The client defaults to the German language, but this can be easily changed by changing the 'Nation = de' line to 'Nation = en' in the props file from the client download folder.

Being a Java application, it goes a long way to adding a few more entertainment choices to the ones available for the Linux platform, in terms of games.

UPDATE: There's a ton more of sites with online boardgames at the boargamegeek wiki

Some of these sites:

http://www.flexgames.com/ (2 games)

http://www.yucata.de/Default.aspx (several, growing)

games.asobrain.com (few, but has Settlers and Carcassonne)

http://www.spielbyweb.com/ (forum based)

http://yourturnmyturn.com/ (many, most classic)

http://hilinski.net/games/online/ (Taj Mahal and Tycoon)


2007-03-20

Freeciv rediscovered

Filed Under:

I've recently "rediscovered" Freeciv. I'm a very casual gamer (15 minutes/day), but also an old, addicted, Civilization fan. Lately I've been looking for a nice game to play on my Linux desktops and I've found that Freeciv is finally getting some good graphics, as this was my biggest turn off I've had with it before. I've tried first the SDL client on Windows, but it is buggy and tends to freeze its popup windows. The GTK Windows client is a lot better, works quite flawless as far as I can tell. I've compiled the Linux version (on Ubuntu Edgy), first I've tried the SDL client, but it complained (at configure time) about a missing sdl-image library, which I have (and no -dev version in my apt sources). Using the freeland-big tiles, the game had a huge memory footprint (40% of 1024 Mb RAM). The most apparent improvements are new tile graphics, with bigger size, new graphics for the city titles on the play screen, a new full-screen mode, even for the GTK version and a tree-based research screen. There is another tileset on the freeciv.org site, called Freeland-big. This has, IMHO, some improved tiles. Click on the image below to see the new graphics I'm talking about (this is the default tileset). And another one, this time on Linux, with Freeland-big tileset.

Freeciv 2.1 screenshot

UPDATE: Using the svn/trunk version the huge memory footprint problem of the Linux client is solved, but I can't use the freeland-big tileset anymore. To compile it on Ubuntu, I first had to apt-get install automake1.8 and libgtk2.0-dev. After that, run autoconf.sh to start the configure script generation and then make install.

2007-03-10

Embeding the Gecko engine in Python applications

Filed Under:

I've got to deploy a new desktop based application, created, of course, with Zope 3. When you've got a hammer, everything looks like a nail, indeed. This application uses HTML and CSS as its presentation layer (right, it's a web page), with a bit of Ajax thrown in. Due do time constraints, I'm not even trying to get it to work properly on Internet Explorer (although it looks about 90% right, but I have some problems with Javascript), so I won't be embeding the Internet Explorer this time engine in my Python application, I'll just try to get the Gecko rendering engine, the one used in Firefox.

First, I've installed the ActiveX control for the Gecko engine. Following some ActiveX migration details on wxpython.org, I've generated a wxpython "binding" class, using the genaxmodule.py tool (after a quick dig in the Windows registry to find out which is the Mozilla control class name):

C:\Python24\Lib\site-packages\wx-2.6-msw-unicode\wx\tools>genaxmodule.py "Mozilla.Browser" Gecko
Creating module in: .\Gecko.py
ProgID: Mozilla.Browser.1
CLSID: {1339B54C-3453-11D2-93B9-000000000000}

The python code would that would use the ActiveX control would be something like this:

# -*- coding: ISO-8859-1 -*-
# generated by wxGlade 0.4.1cvs on Sat Mar 10 16:40:22 2007 from C:\Work\CourseBuilder.wxg

import wx
import Gecko

def createGeckoControl(parent, id):
gecko = Gecko.Gecko(parent, id)
return gecko

# begin wxGlade: dependencies
# end wxGlade

class MainFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MainFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.panel_1 = wx.Panel(self, -1)
self.gecko = createGeckoControl(self.panel_1, -1)

self.__set_properties()
self.__do_layout()
# end wxGlade
self.gecko.SetFocus()
self.gecko.Navigate2('http://slashdot.org', 0)

def __set_properties(self):
# begin wxGlade: MainFrame.__set_properties
self.SetTitle("frame_1")
# end wxGlade

def __do_layout(self):
# begin wxGlade: MainFrame.__do_layout
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
sizer_2.Add(self.gecko, 1, wx.EXPAND, 0)
self.panel_1.SetSizer(sizer_2)
sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
self.SetSizer(sizer_1)
sizer_1.Fit(self)
self.Layout()
# end wxGlade

# end of class MainFrame

And the main app file:

#!/usr/bin/env python
# -*- coding: ISO-8859-1 -*-
# generated by wxGlade 0.4.1cvs on Sat Mar 10 16:40:22 2007 from C:\Work\CourseBuilder.wxg

import wx
from MainFrame import MainFrame

class CourseBuilderApp(wx.App):
def OnInit(self):
wx.InitAllImageHandlers()
main_frame = MainFrame(None, -1, "")
self.SetTopWindow(main_frame)
main_frame.Show()
return 1

# end of class CourseBuilderApp

if __name__ == "__main__":
CourseBuilderBrowser = CourseBuilderApp(0)
CourseBuilderBrowser.MainLoop()

Unfortunately I hit a problem that I can't find a solution for: this application crashes when I type something in the Gecko window. Blah :-( If anyone reading this know the answer, help me! :) Please! (tibi@life.org.ro)


My only option left is to go for the XULRunner and the MyBrowser demo. I'm not extremely happy about this, but at this point I don't see other options. Plus, it will be fun learning some about the Mozilla development platform.

Update: I've tested the Mozilla ActiveX Control using a simple Delphi 7 form and, while I don't get a crash, I still can't get it to accept keyboard input.

2006-10-04

Start Plone (or Zope) in debug mode under Windows

Filed Under:

Lifted from #plone:

bin/runzope.bat -X "debug-mode=on"

2006-09-06

Printing frameworks and wxPython

Filed Under:

As hard as I have tried to find, there's no good printing framework for wxPython. wxEasyPrinting sucks so much for anything more then simple text (for example, the table cells don't support specifying a height). Generating PDF files with a toolkit such as ReportLab (even with Platypus) is harder then it should be, especially when there's no ready made higher level framework. This page explores some of the common printing solutions on Windows.

My own solution to all these is a single-platform hack. Based on my previous experience of creating a "zope based desktop application" using an embeded Internet Explorer, I'm using Internet Explorer through ActiveX as a rendering and print preview engine. Building a new "form" is easy with any HTML GUI builder such as NVU or Dreamweaver and SimpleTAL bridges the gap between the application data and the presentation for printing. The trick is to display only the Print Preview dialog, which can't be done without going through Internet Explorer's back door.

In my generated HTML files I have the following snippet, which automatically calls the Print Preview dialog from Internet Explorer when the file is loaded.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
function printpr()
{
var OLECMDID = 7;
/* OLECMDID values:
* 6 - print
* 7 - print preview
* 1 - open window
* 4 - Save As
*/
var PROMPT = 1; // 2 DONTPROMPTUSER
var WebBrowser = "<OBJECT ID='WebBrowser1' WIDTH=0 HEIGHT=0 CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2' />";
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = "";
}
</script>
</head>
<body onload="printpr(); return false;">
</body>
</html>

Next, I have a frame with the IE ActiveX control embeded.

# -*- coding: ISO-8859-1 -*-
# generated by wxGlade 0.4.1 on Sun Apr 30 20:43:52 2006

import wx
import wx.lib.iewin as iewin

# begin wxGlade: dependencies
# end wxGlade

def ieWidget(parent, id):
ie = iewin.IEHtmlWindow(parent, -1)
return ie

class dlgIEFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: dlgIEFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.window_4 = ieWidget(self, -1)

self.__set_properties()
self.__do_layout()
# end wxGlade
self.ie = self.window_4
self.ie.SetClientSizeWH(300, 400)

def __set_properties(self):
# begin wxGlade: dlgIEFrame.__set_properties
self.SetTitle("frame_1")
self.SetSize((792, 755))
# end wxGlade

def __do_layout(self):
# begin wxGlade: dlgIEFrame.__do_layout
sizer_59 = wx.BoxSizer(wx.VERTICAL)
sizer_59.Add(self.window_4, 1, wx.EXPAND, 0)
self.SetAutoLayout(True)
self.SetSizer(sizer_59)
self.Layout()
self.Centre()
# end wxGlade

# end of class dlgIEFrame

To display the printing dialog I'm just dumping the generated HTML file to a temporary file and loading it into the IE control.

2006-09-01

Running Microsoft Word as a Windows service

Filed Under:

Apparently, this is not recommended by Microsoft, but they have some pointers on how to achieve this on their website.

I ran through the steps in the first article and I can attest that it's possible to use Microsoft Word to generate, for example, PDF files by printing them from a service. I have the feeling that most of those steps are not needed if Word is not accessed as a COM service, and all is needed is to create a new user, start and configure Word to have a running instance and then configure the service to run as that user.
Weblog
Atom
RDF
RSS 2.0
Powered by Quills
Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: