[Tutor] Tk question

lonetwin_SubD lonetwin@subdimension.com
Tue, 11 Jun 2002 18:58:05 +0530


Hi ppl,
     For convenience sake, I wrote a wrapper around the 'cal' command on my 
linux box (and bound it to a shortcut keystroke on my Window manager). There 
is one problem tho', I just can't figure out how to get the first and last 
lines aligned properly. I tried passing anchor="w" while initialising the 
Label but that does not seem to help .....any pointers ??

Here's the code (maybe someone else might find it useful too :)). 

Note : I specifically set the font to "fixed" b'cos with variable width fonts 
spaces are "thinner" than characters and that screws up the display.

---------------------------------------
#!/usr/bin/python
import os

cal="/usr/bin/cal.orig"
args = ''.join(os.sys.argv[1:])
out = os.popen('%s %s' % (cal, args)).read()

if os.environ.has_key('DISPLAY'):
	from Tkinter import *
	Master = Frame()
	Master.master.title("Tkcal")
	Sub = Label(Master, font='fixed', text=out)
	Master.grid(ipadx=2, ipady=2)
	Sub.grid()
	Master.mainloop()
else:
	print out
----------------------------------------

Peace
Steve

PS: Maybe you are wondering why I did this, well I can only say that I find 
myself using the keyboard 95% of the time when in windowmaker (my preferred 
wm). Also, I've got a similar (shortcut) "front-end" to "ispell -a", I'll 
send it across if anybody is interested.

-- 
The prettiest women are almost always the most boring, and that is why
some people feel there is no God.
		-- Woody Allen, "Without Feathers"