Re: pythoncom.CoInitialize() not recognised in Eclipse
Quoting KB : I am getting an error from the IDE saying it does not recognise CoInitialize(): import pythoncom pythoncom.CoInitialize() pythoncom.CoUninitialize() It works out of the box with PyDev 1.5.5.2010030420 on Eclipse 3.5.2 on Windows XP. If nothing seems to work for you, you could try adding pythoncom to the "Forced Builtins" tab of your Python interpreter configuration to see if it helps (restart eclipse after you've done that, sometimes changes to the symbols database don't get picked up without restarting eclipse...) mvg, Dieter This message was sent using IMP, the Internet Messaging Program. -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGTK localisation on Win32
On Thu, 2008-03-27 at 05:21 -0700, Sukhov Dmitry wrote: > I have the same problem. I did all as you wrote. gettext translations > do work fine. But translations in glade does not work. > > The only way to turn it on is to set environment variable LANG > explicitly before program run: > set LANG=ru_RU > python test.py Yep, from python 2.4 on, os.environ changes only work within python and no longer apply to low level c stuff on win32. Luckily, it's still possible to force environment variables through the kernel32.SetEnvironmentVariableW and msvcrt._putenv functions. Put the attached locale module in a libi18n package and use like this: #!/usr/bin/env python from libi18n import locale locale.fix_locale() del locale hth, Dieter # -*- coding: utf-8 -*- # # locale.py - libi18n # Copyright (C) 2007-2008 Dieter Verfaillie <[EMAIL PROTECTED]> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. import os import sys def _isofromlangid(langid): # ISO 639-1 #http://www.loc.gov/standards/iso639-2/ # List of existing mui packs: #http://www.microsoft.com/globaldev/reference/win2k/setup/Langid.mspx # List of known id's #http://www.microsoft.com/globaldev/reference/lcid-all.mspx lcid = {1078:'af',# Afrikaans - South Africa 1052:'sq',# Albanian - Albania 1118:'am',# Amharic - Ethiopia 1025:'ar',# Arabic - Saudi Arabia 5121:'ar',# Arabic - Algeria 15361: 'ar',# Arabic - Bahrain 3073:'ar',# Arabic - Egypt 2049:'ar',# Arabic - Iraq 11265: 'ar',# Arabic - Jordan 13313: 'ar',# Arabic - Kuwait 12289: 'ar',# Arabic - Lebanon 4097:'ar',# Arabic - Libya 6145:'ar',# Arabic - Morocco 8193:'ar',# Arabic - Oman 16385: 'ar',# Arabic - Qatar 10241: 'ar',# Arabic - Syria 7169:'ar',# Arabic - Tunisia 14337: 'ar',# Arabic - U.A.E. 9217:'ar',# Arabic - Yemen 1067:'hy',# Armenian - Armenia 1101:'as',# Assamese 2092:None,# Azeri (Cyrillic) 1068:None,# Azeri (Latin) 1069:'eu',# Basque 1059:'be',# Belarusian 1093:'bn',# Bengali (India) 2117:'bn',# Bengali (Bangladesh) 5146:'bs',# Bosnian (Bosnia/Herzegovina) 1026:'bg',# Bulgarian 1109:'my',# Burmese 1027:'ca',# Catalan 1116:None,# Cherokee - United States 2052:'zh',# Chinese - People's Republic of China 4100:'zh',# Chinese - Singapore 1028:'zh',# Chinese - Taiwan 3076:'zh',# Chinese - Hong Kong SAR 5124:'zh',# Chinese - Macao SAR 1050:'hr',# Croatian 4122:'hr',# Croatian (Bosnia/Herzegovina) 1029:'cs',# Czech 1030:'da',# Danish 1125:'dv',# Divehi 1043:'nl',# Dutch - Netherlands 2067:'nl',# Dutch - Belgium 1126:None,# Edo 1033:'en',# English - United States 2057:'en',# English - United Kingdom 3081:'en',# English - Australia 10249: 'en',# English - Belize 4105:'en',# English - Canada 9225:'en',# English - Caribbean 15369: 'en',# English - Hong Kong SAR 16393:
Re: Volume id
On Thu, 2007-11-15 at 17:05 +0100, Gabor Urban wrote: > OK, you are right... Problem was not precise enough. I need to process > CDs to create a list. Does it ring a bell for you? > > Thanks Hello, The method below will work on linux systems (it uses dbus to communicate with HAL). You'll maybe have to expand the filter on line 37, but I'm not sure... hth, Dieter #!/usr/bin/env python import dbus def discover(): disks = [] volumes = [] # get a connection to the system bus bus = dbus.SystemBus () # get a HAL object and an interface to HAL to make function calls hal_obj = bus.get_object ('org.freedesktop.Hal', '/org/freedesktop/Hal/Manager') hal = dbus.Interface (hal_obj, 'org.freedesktop.Hal.Manager') # find all devices that have the capability 'volume' udis = hal.FindDeviceByCapability('volume') for udi in udis: # get volume info dev_obj = bus.get_object('org.freedesktop.Hal', udi) dev = dbus.Interface(dev_obj, 'org.freedesktop.Hal.Device') volume = str(dev.GetProperty('block.device')) volume_label = str(dev.GetProperty('volume.label')) volume_mount_point = str(dev.GetProperty('volume.mount_point')) volume_fstype = str(dev.GetProperty('volume.fstype')) # get storage info parent_udi = dev.GetProperty('info.parent') dev_obj = bus.get_object('org.freedesktop.Hal', parent_udi) dev = dbus.Interface(dev_obj, 'org.freedesktop.Hal.Device') storage = str(dev.GetProperty('block.device')) storage_product = str(dev.GetProperty('info.product')) # filter out hard disks if dev.GetProperty('storage.drive_type') == 'disk': continue # store disk if not storage in disks: disks.append(storage) # store volume volumes.append((storage, volume, volume_label, volume_mount_point, volume_fstype)) return disks, volumes if __name__ == '__main__': disks, volumes = discover() for disk in disks: print 'found disk', disk for volume in volumes: if volume[0] == disk: print 'with volume', volume[1] print 'label', volume[2] print 'mount point is', volume[3] print 'fstype is', volume[4] signature.asc Description: This is a digitally signed message part -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie in the deep - some PyGTK questions
On Mon, 2007-02-26 at 20:58 +, nmp wrote: > I did that and it works now :) Thank you, I had indeed been playing with > those options but not being entirely sure what they did I also forgot > about them... Happy it worked out :) > Yes, I found that a short time after I posted my question and this seems > to be the way to go indeed. I already copied some code from somewhere that > worked. Now, it could just be me but I *still* find the Gtk/TreeView thing > confusing. To master it will take me a bit more time than I thought, but > it seems to be one of the most important pieces of the toolkit so I see I > will pretty much have to invest that time. Thank you for mentioning it too. Yep, it can be confusing at first, but once you get your head wrapped around it, it's a really powerful system. I've dug up some bookmarks about the GtkTree(View|Model|Store) and its Model/View/Controller approach. They might help you understand the big picture - a short overview: http://liw.iki.fi/liw/texts/gtktreeview-tutorial.html - and as noted on that page, Tim Müller's tutorial: http://scentric.net/tutorial/ This one uses C, but is still very informative, even for a python programmer. There's also a lot of information in section 13 of the pygtk faq: http://www.async.com.br/faq/pygtk/index.py?req=index hth, Dieter -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie in the deep - some PyGTK questions
Hi, On Fri, 2007-02-23 at 11:36 +, nmp wrote: > First "problem": when I insert the glade file in my application the way > some tutorials have shown me: > > self.wTree = gtk.glade.XML("autostart.glade", "mainWindow") > > ... Python is consistently giving me this warning: > > /home//Projecten/autostart/autostart.py:18: GtkWarning: > gtk_widget_grab_default: assertion `GTK_WIDGET_CAN_DEFAULT (widget)' > failed > self.wTree = gtk.glade.XML("autostart.glade", "mainWindow") I think you've set the "Has default" property to Yes on some widget, but you forgot to set the "Can default" property to Yes on that same widget. In short, you created a default widget that can't be the default and gtk happily complains about that. Check your glade file to fix it. > Now I want the user of my program to be able to just double click a row or > hit Enter to flip the boolean, so FALSE becomes TRUE and vice versa. See the answer to your third "problem" :) > The third "problem" (for now...) is really just a cosmetic thing. The > representation of the boolean in the list is fine for me, but in time I > would like to make it prettier by replacing it with a graphical checkbox. > Does anyone have an example of this that I can use? Use a CellRendererToggle. There's a tutorial on the pygtk website: http://pygtk.org/pygtk2tutorial/sec-CellRenderers.html (scroll all the way down that page to "Figure 14.6. Editable and Activatable Cells") > Thank you for your patience. I can already see how all this is going to > keep me busy for weeks and it will be fun ;) You'll probably get faster/better answers to you pygtk questions on the pygtk mailing list: http://www.daa.com.au/mailman/listinfo/pygtk Have fun, Dieter -- http://mail.python.org/mailman/listinfo/python-list
Re: Module for SVG?
On Thu, 2007-01-25 at 15:58 -0300, Sebastian Bassi wrote: > Hello, > > I found http://www2.sfk.nl/svg as a Python module for writing SVG. > Last update was in 2004 and I am not sure if there is something > better. > Any recommendation for generating SVG graphics? > Best, > SB. Cairo ( http://cairographics.org/pycairo ), using cairo.SVGSurface(). As a bonus, if you'd ever need it, you can switch to a different Surface (for example ps or pdf) and use the same drawing code with it. There's a good tutorial on http://www.tortall.net/mu/wiki/CairoTutorial hth, Dieter -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGTK
On Thu, 09 Feb 2006 12:38:26 +, Dave Cook wrote: > > particularly the last section on how to create an EXE from your pygtk program. > That recipe isn't optimal with newer gtk versions (starting from 2.8 if I remember correctly). Look here instead: http://starship.python.net/crew/theller/moin.cgi/Py2exeAndPyGTK Dieter -- http://mail.python.org/mailman/listinfo/python-list
Re: Using XML w/ Python...
On Sat, 10 Dec 2005 21:12:04 -0800, Jay wrote: > OK, I have this XML doc, i dont know much about XML, but what i want > to do is take certain parts of the XML doc the most simple module I've found to do that is xmltramp from http://www.aaronsw.com/2002/xmltramp/ for example: #!/usr/bin/env python import xmltramp note = xmltramp.load('http://www.w3schools.com/xml/note.xml') print note.body -- http://mail.python.org/mailman/listinfo/python-list