[Tutor] changing font

2018-07-13 Thread Talia Koch via Tutor
Hi, I am trying to figure out a code that would change my text output to 
'Arial' font. How would I do this? Thanks.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] changing font

2018-07-13 Thread Cameron Simpson

On 13Jul2018 17:42, Talia Koch  wrote:

Hi, I am trying to figure out a code that would change my text output to 
'Arial' font. How would I do this? Thanks.


You will need to provide far more context for this question.

What are you using to display your text? HTML (eg a web browser)? Then the 
 tag might help you. Some other document format such as roff or LaTeX? A 
terminal?  If this is possible it will be entirely terminal dependent. A GUI of 
some kind, such as Tk or Qt?  You will need to consult its documentation for 
its text widgets.


Cheers,
Cameron Simpson  (formerly c...@zip.com.au)

in rec.moto, jsh wrote:

Dan Nitschke wrote:
> Ged Martin wrote:
> > On Sat, 17 May 1997 16:53:33 +, Dan Nitschke scribbled:
> > >(And you stay *out* of my dreams, you deviant little
> > >weirdo.)
> > Yeah, yeah, that's what you're saying in _public_
> Feh. You know nothing of my dreams. I dream entirely in text (New Century
> Schoolbook bold oblique 14 point), and never in color. I once dreamed I
> was walking down a flowchart of my own code, and a waterfall of semicolons
> was chasing me. (I hid behind a global variable until they went by.)
You write code in a proportional serif? No wonder you got extra
semicolons falling all over the place.

No, I *dream* about writing code in a proportional serif font.
It's much more exciting than my real life.
/* dan: THE Anti-Ged -- Ignorant Yank (tm) #1, none-%er #7 */
Dan Nitschke  pedan...@best.com  nitsc...@redbrick.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] changing font

2018-07-13 Thread Alan Gauld via Tutor
On 13/07/18 18:42, Talia Koch via Tutor wrote:
> Hi, I am trying to figure out a code that would change my text output to 
> 'Arial'

It all depends on how you are displaying your text.

If it is in a GUI such as Tkinter or WxPython you can
change the font in yor program. But the technique is
completely different in each GUI toolkit.

For example here is how to set it in Tkinter:
(Using Pyton 2.7...)

import Tkinter as tk
sans = "SansSerif 10"
serif = "Garamond 12 italic"
top = tk.Tk()
tk.Label(top, text="Hello", font=sans).pack()
tk.Label(top, text="Hello", font=serif).pack()
top.mainloop()


Note, I'm on Linux so can't use Arial, but you
should be able to change the font line to suit
your OS...


Whereas here is how to do it in wxPython:

import wx

# --- Define a custom Frame, this will become the main window ---
class FontsFrame(wx.Frame):
   def __init__(self, parent, id, title, pos, size):
wx.Frame.__init__(self,parent, id, title, pos, size)

# wxPython defines its own system dependant fonts
sans = wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL)
serif = wx.Font(12, wx.ROMAN, wx.ITALIC, wx.NORMAL)

panel = wx.Panel(self)
t1 = wx.StaticText(panel, -1, "Hello", (10,10))
t1.SetFont(sans)
t2 = wx.StaticText(panel, -1, "Hello", (10, 30))
t2.SetFont(serif)

class HelloApp(wx.App):
   def OnInit(self):
   frame = FontsFrame(None, -1, "Hello", (50,50), (80,90) )
   frame.Show(True)
   self.SetTopWindow(frame)
   return True

# create instance and start the event loop
HelloApp().MainLoop()

As you see its completely different and much more work.

But if you are not using a GUI then its not something
you as a programmer can do (at least not easily).
The font the console window uses depends on your
users settings, not on your program.

You may be able to control things like underline, bold,
italic etc, but even that depends on the terminal emulator
in use.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor