Newbie : Greek letters

Discussion in 'Python' started by Oh Kyu Yoon, May 7, 2004.

  1. Oh Kyu Yoon

    Oh Kyu Yoon Guest

    Is there an easy way to include greek letter symbols in TextCtrl of
    wxPython?

    --
    Oh Kyu Yoon, May 7, 2004
    #1
    1. Advertising

  2. Oh Kyu Yoon

    asdf sdf Guest

    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.
    asdf sdf, May 7, 2004
    #2
    1. Advertising

  3. Oh Kyu Yoon

    asdf sdf Guest

    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
    # -------------------------------------
    asdf sdf, May 7, 2004
    #3
  4. 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
    Christopher Culver, May 7, 2004
    #4
  5. Oh Kyu Yoon

    asdf sdf Guest

    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.
    asdf sdf, May 7, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    356
    Steve C. Orr [MVP, MCSD]
    Apr 20, 2004
  2. Thang Nguyen
    Replies:
    0
    Views:
    609
    Thang Nguyen
    Aug 7, 2003
  3. Merrigan
    Replies:
    4
    Views:
    558
    Chris
    Dec 14, 2007
  4. Venugopal
    Replies:
    11
    Views:
    1,500
    Tassilo v. Parseval
    Nov 5, 2003
  5. Replies:
    3
    Views:
    97
    Steven D'Aprano
    Nov 29, 2013
Loading...

Share This Page