From ragecreations at gmail.com Wed Nov 19 22:20:16 2008 From: ragecreations at gmail.com (Rage Creation) Date: Wed, 19 Nov 2008 15:20:16 -0600 Subject: [Texas] Changing the font of the Console module Message-ID: <84c629f80811191320p483d1466j36354d11024af1b5@mail.gmail.com> Hello everyone, I am a new Python coder using the Console module with a (hopefully simple) question: I want to use a fixed-width font for my program, but the Console module seems to lack a font attribute. I tried using sys.font = "White Rabbit" (my fixed width font) and it ran with no errors but the output did not change. I also looked inside of Console.py but there was no setting of a font there, either. Any advice? -Anthony -------------- next part -------------- An HTML attachment was scrubbed... URL: From walker.hale.iv at gmail.com Thu Nov 20 18:06:23 2008 From: walker.hale.iv at gmail.com (Walker Hale IV) Date: Thu, 20 Nov 2008 11:06:23 -0600 Subject: [Texas] Changing the font of the Console module In-Reply-To: <84c629f80811191320p483d1466j36354d11024af1b5@mail.gmail.com> References: <84c629f80811191320p483d1466j36354d11024af1b5@mail.gmail.com> Message-ID: <312f43620811200906x59349a63rab6039edb41658a7@mail.gmail.com> Are you referring to the console module for Jython or something else? In general, adding an attribute that does not already exist to a module will have no effect. -- Walker Hale On Wed, Nov 19, 2008 at 3:20 PM, Rage Creation wrote: > Hello everyone, I am a new Python coder using the Console module with a > (hopefully simple) question: > I want to use a fixed-width font for my program, but the Console module > seems to lack a font attribute. I tried using sys.font = "White Rabbit" (my > fixed width font) and it ran with no errors but the output did not change. I > also looked inside of Console.py but there was no setting of a font there, > either. > Any advice? > > -Anthony From ragecreations at gmail.com Sat Nov 22 04:58:31 2008 From: ragecreations at gmail.com (Rage Creation) Date: Fri, 21 Nov 2008 21:58:31 -0600 Subject: [Texas] Changing the font of the Console module In-Reply-To: <312f43620811200906x59349a63rab6039edb41658a7@mail.gmail.com> References: <84c629f80811191320p483d1466j36354d11024af1b5@mail.gmail.com> <312f43620811200906x59349a63rab6039edb41658a7@mail.gmail.com> Message-ID: <84c629f80811211958x1b28925djd6f17e15c085c2a4@mail.gmail.com> Using the Console module as described here: http://effbot.org/zone/console-handbook.htm Is there a way to change the system font so that all fonts used within the program follow that? Or a way to modify the Console module to adjust what font its using (it has to be reading a font from somewhere, right?) Thanks, Anthony On Thu, Nov 20, 2008 at 11:06 AM, Walker Hale IV wrote: > Are you referring to the console module for Jython or something else? > > In general, adding an attribute that does not already exist to a > module will have no effect. > > -- > Walker Hale > > On Wed, Nov 19, 2008 at 3:20 PM, Rage Creation > wrote: > > Hello everyone, I am a new Python coder using the Console module with a > > (hopefully simple) question: > > I want to use a fixed-width font for my program, but the Console module > > seems to lack a font attribute. I tried using sys.font = "White Rabbit" > (my > > fixed width font) and it ran with no errors but the output did not > change. I > > also looked inside of Console.py but there was no setting of a font > there, > > either. > > Any advice? > > > > -Anthony > -- http://ragecreations.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From walker.hale.iv at gmail.com Mon Nov 24 01:08:07 2008 From: walker.hale.iv at gmail.com (Walker Hale IV) Date: Sun, 23 Nov 2008 18:08:07 -0600 Subject: [Texas] Changing the font of the Console module In-Reply-To: <84c629f80811211958x1b28925djd6f17e15c085c2a4@mail.gmail.com> References: <84c629f80811191320p483d1466j36354d11024af1b5@mail.gmail.com> <312f43620811200906x59349a63rab6039edb41658a7@mail.gmail.com> <84c629f80811211958x1b28925djd6f17e15c085c2a4@mail.gmail.com> Message-ID: <312f43620811231608p48632f25ld1573ac602739a49@mail.gmail.com> Short Answer: Give up. You are so deep into Windows API nastiness that you can't see daylight. Long Answer: You can't do anything in Python that you can't do in C. Fredrik Lundh's Console module does not support setting the font. This module is mostly some C code that accesses a few of the console functions in Win32. http://msdn.microsoft.com/en-us/library/ms682073(VS.85).aspx Any deficiencies in this module might be overcome by calling Win32 functions directly using either the ctypes module or using the pywin32 library: http://docs.python.org/library/ctypes.html http://docs.python.org/using/windows.html http://sourceforge.net/projects/pywin32/ http://docs.activestate.com/activepython/2.6/pywin32/PyWin32.HTML http://docs.activestate.com/activepython/2.6/pywin32/win32console.html In fact you could use either ctypes or pywin32 as a replacement for the Console module, but the API wouldn't be as nice. Now pywin32/win32console does not contain all of the functions in Win32. In particular, the one function for dealing with fonts is missing... Microsoft discourages using custom fonts in consoles. http://blogs.msdn.com/oldnewthing/archive/2007/05/16/2659903.aspx The only way a font can appear in a console is if that font has been added to a magic spot in the registry. This makes the font available in the Properties page for the console (when you open the menu in the upper-left). http://www.windowsnetworking.com/kbase/WindowsTips/WindowsNT/RegistryTips/Miscellaneous/ConsoleFonts.html Theoretically, C code can set a console to use one of those specially registered fonts, but I haven't found any examples of people successfully doing it. Bottom Line: You are at the beginning of a long, hard road. Python will neither help nor hurt you. The problems you face are the same as for a C programmer. If you still want to attempt this you will need to: * Add your font to the magic spot in the registry, giving it a number. * Verify that you can use that font in a standard console window by selecting it in the properties dialog. * Write special code using ctypes to ** create a new console buffer ** set the font number for the buffer to the corresponding font number in the registry using SetCurrentConsoleFontEx ** install the new buffer into your console Or something like that. And it still might not work! -- Walker Hale On Fri, Nov 21, 2008 at 9:58 PM, Rage Creation wrote: > Using the Console module as described here: > http://effbot.org/zone/console-handbook.htm > Is there a way to change the system font so that all fonts used within the > program follow that? > Or a way to modify the Console module to adjust what font its using (it has > to be reading a font from somewhere, right?) > Thanks, > > Anthony > > On Thu, Nov 20, 2008 at 11:06 AM, Walker Hale IV > wrote: >> >> Are you referring to the console module for Jython or something else? >> >> In general, adding an attribute that does not already exist to a >> module will have no effect. >> >> -- >> Walker Hale >> >> On Wed, Nov 19, 2008 at 3:20 PM, Rage Creation >> wrote: >> > Hello everyone, I am a new Python coder using the Console module with a >> > (hopefully simple) question: >> > I want to use a fixed-width font for my program, but the Console module >> > seems to lack a font attribute. I tried using sys.font = "White Rabbit" >> > (my >> > fixed width font) and it ran with no errors but the output did not >> > change. I >> > also looked inside of Console.py but there was no setting of a font >> > there, >> > either. >> > Any advice? From ragecreations at gmail.com Tue Nov 25 16:04:37 2008 From: ragecreations at gmail.com (Rage Creation) Date: Tue, 25 Nov 2008 09:04:37 -0600 Subject: [Texas] Changing the font of the Console module In-Reply-To: <312f43620811231608p48632f25ld1573ac602739a49@mail.gmail.com> References: <84c629f80811191320p483d1466j36354d11024af1b5@mail.gmail.com> <312f43620811200906x59349a63rab6039edb41658a7@mail.gmail.com> <84c629f80811211958x1b28925djd6f17e15c085c2a4@mail.gmail.com> <312f43620811231608p48632f25ld1573ac602739a49@mail.gmail.com> Message-ID: <84c629f80811250704r76286339sf0e0aa6e176c20e9@mail.gmail.com> Thanks =) On Sun, Nov 23, 2008 at 6:08 PM, Walker Hale IV wrote: > Short Answer: > > Give up. You are so deep into Windows API nastiness that you can't see > daylight. > > > Long Answer: > > You can't do anything in Python that you can't do in C. > > Fredrik Lundh's Console module does not support setting the font. This > module is mostly some C code that accesses a few of the console > functions in Win32. > > http://msdn.microsoft.com/en-us/library/ms682073(VS.85).aspx > > Any deficiencies in this module might be overcome by calling Win32 > functions directly using either the ctypes module or using the pywin32 > library: > > http://docs.python.org/library/ctypes.html > > http://docs.python.org/using/windows.html > http://sourceforge.net/projects/pywin32/ > http://docs.activestate.com/activepython/2.6/pywin32/PyWin32.HTML > http://docs.activestate.com/activepython/2.6/pywin32/win32console.html > > In fact you could use either ctypes or pywin32 as a replacement for > the Console module, but the API wouldn't be as nice. > > Now pywin32/win32console does not contain all of the functions in > Win32. In particular, the one function for dealing with fonts is > missing... > > Microsoft discourages using custom fonts in consoles. > > http://blogs.msdn.com/oldnewthing/archive/2007/05/16/2659903.aspx > > The only way a font can appear in a console is if that font has been > added to a magic spot in the registry. This makes the font available > in the Properties page for the console (when you open the menu in the > upper-left). > > > http://www.windowsnetworking.com/kbase/WindowsTips/WindowsNT/RegistryTips/Miscellaneous/ConsoleFonts.html > > Theoretically, C code can set a console to use one of those specially > registered fonts, but I haven't found any examples of people > successfully doing it. > > > Bottom Line: > > You are at the beginning of a long, hard road. Python will neither > help nor hurt you. The problems you face are the same as for a C > programmer. > > If you still want to attempt this you will need to: > > * Add your font to the magic spot in the registry, giving it a number. > * Verify that you can use that font in a standard console window by > selecting it in the properties dialog. > * Write special code using ctypes to > ** create a new console buffer > ** set the font number for the buffer to the corresponding font number > in the registry using SetCurrentConsoleFontEx > ** install the new buffer into your console > > Or something like that. And it still might not work! > > -- > Walker Hale > > On Fri, Nov 21, 2008 at 9:58 PM, Rage Creation > wrote: > > Using the Console module as described here: > > http://effbot.org/zone/console-handbook.htm > > Is there a way to change the system font so that all fonts used within > the > > program follow that? > > Or a way to modify the Console module to adjust what font its using (it > has > > to be reading a font from somewhere, right?) > > Thanks, > > > > Anthony > > > > On Thu, Nov 20, 2008 at 11:06 AM, Walker Hale IV < > walker.hale.iv at gmail.com> > > wrote: > >> > >> Are you referring to the console module for Jython or something else? > >> > >> In general, adding an attribute that does not already exist to a > >> module will have no effect. > >> > >> -- > >> Walker Hale > >> > >> On Wed, Nov 19, 2008 at 3:20 PM, Rage Creation > > >> wrote: > >> > Hello everyone, I am a new Python coder using the Console module with > a > >> > (hopefully simple) question: > >> > I want to use a fixed-width font for my program, but the Console > module > >> > seems to lack a font attribute. I tried using sys.font = "White > Rabbit" > >> > (my > >> > fixed width font) and it ran with no errors but the output did not > >> > change. I > >> > also looked inside of Console.py but there was no setting of a font > >> > there, > >> > either. > >> > Any advice? > -- http://ragecreations.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: