Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Newbie : Greek letters

Reply
Thread Tools

Newbie : Greek letters

 
 
Oh Kyu Yoon
Guest
Posts: n/a
 
      05-07-2004
Is there an easy way to include greek letter symbols in TextCtrl of
wxPython?

--


 
Reply With Quote
 
 
 
 
asdf sdf
Guest
Posts: n/a
 
      05-07-2004
Oh Kyu Yoon wrote:
> Is there an easy way to include greek letter symbols in TextCtrl of
> wxPython?
>



this is only a idea. no experience with it myself. Try using SetFont
to get Symbol font. Symbol font is available on WinPCs. Couldn't say
about any other platforms though.

Just tried it and it works on my Win2000 machine in PyCrust.

frame = wx.Frame(None, -1, 'title')
tc = wx.TextCtrl(frame, -1, 'D')
tc.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, face='SYMBOL'))
frame.Show(True)

A window popped up showing a Delta.

Then in PyCrust with the window still showing, I did

tc.SetLabel('G')

and the frame updated to show a Gamma.

Man, I have hardly any gui experience, not to mention hardly any python
experience, and I just started wxPython.

Bottom line: wxPython is _easy_. It's the lack of newbdoc that is the
problem.

Epsilon looks pretty much the same as E, Rho looks like P. Chi (X) is
wierd looking. Printing the rest of the alphabet is left as an exercise
for the reader.



 
Reply With Quote
 
 
 
 
asdf sdf
Guest
Posts: n/a
 
      05-07-2004
You reminded me that I would find this handy myself so I set up a
program to display greek letters. Pay no attention to the sizer
handling. Working on that.

sorry if the mailer munges the linewrapping. shouldn't be a biggie in
a script this small.

good luck.

#
# greek.py
#

import wx
import string

class Greek(wx.Frame):
''' greek alphabet '''

alphabet = string.ascii_letters

def __init__ (self, parent, id, title):
wx.Frame.__init__(self, parent, id, title)

# wx.Font(points, family, style, weight, face='')
romanfont = wx.Font(16, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
greekfont = wx.Font(16, wx.DEFAULT, wx.NORMAL, wx.NORMAL,
face='SYMBOL')

gs = wx.GridSizer(-1, 10, 5, 5)

roman = []
greek = []

textstyle = wx.ALIGN_CENTER|wx.ST_NO_AUTORESIZE
cellstyle = wx.EXPAND

for x in range(len(Greek.alphabet)):
letter = Greek.alphabet[x]

roman.append(wx.StaticText(self, -1, letter
,wx.Point(-1,-1), wx.Size(-1,-1), textstyle))
roman[x].SetFont(romanfont)
roman[x].SetBackgroundColour('Yellow')

greek.append(wx.StaticText(self, -1, letter
,wx.Point(-1,-1), wx.Size(-1,-1), textstyle))
greek[x].SetFont(greekfont)
greek[x].SetBackgroundColour('White')

gs.Add(roman[x], 1, cellstyle, 10)
gs.Add(greek[x], 1, cellstyle, 10)

# layout sizers
self.SetSizer(gs)
self.SetAutoLayout(1)
gs.Fit(self)

self.Show(True)

app = wx.PySimpleApp()
frame = Greek(None, -1, 'Greek Alphabet')

app.MainLoop()

# -------------------------------------
# greek.py - end of file
# -------------------------------------
 
Reply With Quote
 
Christopher Culver
Guest
Posts: n/a
 
      05-07-2004
On Fri, 07 May 2004 03:52:36 +0000, asdf sdf wrote:
> Oh Kyu Yoon wrote:
>> Is there an easy way to include greek letter symbols in TextCtrl of
>> wxPython?
>>
>>

> this is only a idea. no experience with it myself. Try using SetFont
> to get Symbol font. Symbol font is available on WinPCs. Couldn't say
> about any other platforms though.


That is a bad idea. Not only does it break cross-platform compatibility
(the goal of wxWindows) by using a proprietary font, it totally ignores
Python's excellent Unicode support. Greek has it's own block in Unicode,
you just have to create the characters from there. Using special fonts to
overcome character sets is sooooo 1998.

Christopher Culver
 
Reply With Quote
 
asdf sdf
Guest
Posts: n/a
 
      05-07-2004
Christopher Culver wrote:
> On Fri, 07 May 2004 03:52:36 +0000, asdf sdf wrote:
>
>>Oh Kyu Yoon wrote:
>>
>>>Is there an easy way to include greek letter symbols in TextCtrl of
>>>wxPython?
>>>
>>>

>>
>>this is only a idea. no experience with it myself. Try using SetFont
>>to get Symbol font. Symbol font is available on WinPCs. Couldn't say
>>about any other platforms though.

>
>
> That is a bad idea. Not only does it break cross-platform compatibility
> (the goal of wxWindows) by using a proprietary font, it totally ignores
> Python's excellent Unicode support. Greek has it's own block in Unicode,
> you just have to create the characters from there. Using special fonts to
> overcome character sets is sooooo 1998.
>
> Christopher Culver



well, i'm edified. how about a code example? isn't there some issue
about whether a given wxpython build has unicode support? how do you
tell? how do you add it if you don't have it?

if i may paraphrase the OP's question... "can i do greek letters in
python?".

if i may paraphrase your helpful response..."yes".

cool 'tude though.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
making all letters Caps/Small Letters Merrigan Python 4 12-14-2007 10:10 AM
sending greek from a textbox interuser@hotmail.com ASP .Net 1 04-20-2004 06:53 PM
Changing from capital letters to small letters using perl Venugopal Perl Misc 11 11-05-2003 06:07 PM
greek font in Applet Java 0 09-12-2003 04:42 PM
my problem with Java Plugin 1.4.1_02 & java.awt.TextArea & Greek char Thang Nguyen Java 0 08-07-2003 09:02 AM



Advertisments