Re: [Tutor] Tkinter questions

2005-05-17 Thread Alberto Troiano
Thanks for the reply

I read the link and I think I've got all what I need (at least for now)

Thanks again

Regards

Alberto

>From: [EMAIL PROTECTED]
>To: Tutor Tutor 
>Subject: Re: [Tutor] Tkinter questions
>Date: Tue, 17 May 2005 11:03:45 +1200 (NZST)
>
>Quoting Alberto Troiano <[EMAIL PROTECTED]>:
>
> > How can I change the background color of a label??
> > How can I change the font-size and make it BOLD??
>
>Check out Fredrik Lundh's _Introduction to Tkinter_:
>http://www.pythonware.com/library/tkinter/introduction/
>
>In particular, the section on widget customization/styling:
>http://www.pythonware.com/library/tkinter/introduction/widget-styling.htm
>
>If you are using Pmw, you can also use Pmw.logicalfont() to change the 
>font.
>
>(eg:
>
>tk = Tk()
>fixed = Pmw.logicalfont(name='Fixed', weight='bold')
>Label(tk, background='blue', font=fixed, text='Hello world!').pack()
>
>)
>
>--
>John.
>___
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor


Gaucho


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tkinter questions

2005-05-16 Thread jfouhy
Quoting Alberto Troiano <[EMAIL PROTECTED]>:

> How can I change the background color of a label??
> How can I change the font-size and make it BOLD??

Check out Fredrik Lundh's _Introduction to Tkinter_:
http://www.pythonware.com/library/tkinter/introduction/

In particular, the section on widget customization/styling:
http://www.pythonware.com/library/tkinter/introduction/widget-styling.htm

If you are using Pmw, you can also use Pmw.logicalfont() to change the font.

(eg: 

tk = Tk()
fixed = Pmw.logicalfont(name='Fixed', weight='bold')
Label(tk, background='blue', font=fixed, text='Hello world!').pack()

)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tkinter questions

2005-02-02 Thread Michael Lange
On Tue, 1 Feb 2005 19:08:41 +0200
Mark Kels <[EMAIL PROTECTED]> wrote:

Hi Mark,

> Hello,
> I got some Tkinter questions that I need the answer for to complete a
> little project of mine:
> 1. How can I make the program to open in a X*Y sized window ?

from Tkinter import *
root = Tk()
root.geometry('600x400+0+0')

This makes a window of 600x400 pixels placed in the upper left corner of the 
screen (+0+0 is the x- and y- offset;
both of the window size and the offset may be omitted, so you can use '600x400' 
or '+0+0' as arguments for geometry()
as well).

> 2. How can I open another window from the first one (without closing it) ?

Use instances of Toplevel() to create new windows as children of the root 
(Tk()) window.

> 3. How can I add a file browser for my app (like the one you get when
> you press "Save as..." in windows apps) ?

import tkFileDialog
filename = tkFileDialog.asksaveasfilename()
if filename:
# save the file...; if the user presses the 'Cancel' button, filename 
should be set to an empty string.

> 4. How do I configure the font size on the Text widget (its realy
> huge, and I would like to change it to somthing like 12).

text = Text(parent, font=('helvetica', '-12', 'normal'))# "negative" size -> 
pixel size
or:
text.configure(font=('helvetica', '12', 'normal'))# "positive" size -> point 
size

You can use any 3-tuple of the form (family, size, weight) as font descriptor; 
if the requested font is not
found, the widget should fall back to some (probably ugly) default; tk 
guarantees that at least 'times',
'helvetica' and 'courier' font families are available, the availability of 
other fonts depends on your system.

I hope this helps

Michael
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tkinter questions

2005-02-01 Thread Jacob S.
I suggest looking at Introduction to Tkinter.
http://www.pythonware.com/library/tkinter/introduction/index.htm
HTH,
Jacob
Hello,
I got some Tkinter questions that I need the answer for to complete a
little project of mine:
1. How can I make the program to open in a X*Y sized window ?
2. How can I open another window from the first one (without closing it) ?
3. How can I add a file browser for my app (like the one you get when
you press "Save as..." in windows apps) ?
4. How do I configure the font size on the Text widget (its realy
huge, and I would like to change it to somthing like 12).
5. [OT] Do you know any web-sites that I can store my project at (like
sourceforge and others) ?
This is all for now :)
Thanks in advence .
--
1. The day Microsoft makes something that doesn't suck is probably the
day they start making vacuum cleaners.
2. Unix is user friendly - it's just picky about it's friends.
3. Documentation is like sex: when it is good, it is very, very good.
And when it is bad, it is better than nothing. - Dick Brandon
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tkinter questions

2004-12-20 Thread Mark Kels
On Mon, 20 Dec 2004 18:21:13 +1300, Liam Clarke <[EMAIL PROTECTED]> wrote:

> from Tkinter import *
> import Image, ImageTk
> root = Tk()
> img = Image.open('SonicCruiser.gif')
> phi = ImageTk.PhotoImage(img)
> button = Button(root, image=phi)
> button.pack()
> root.mainloop()

Thank you !!
But I don't have the Image module...
Is it a part of the PIL toolkit ?
If not, where can I get it ?

> 
> > Again, a practical explanation will be more helpful...
> 
> Cross platform easy printing? wxPython, which is totally different to Tkinter.
> 
> http://mail.python.org/pipermail/python-list/2004-January/205116.html
> 
> >Printing is not easy, it is a complicated matter.
> 
> >You can find 4 simplifications:
> 
> >1) wxPython has a print-framework, wxPython is cross platform (alas, I only
> used it in win32)
> 
> >2) print postscript. Ghostscript is available on "every" platform.
> (printing on PDAs and watches is  really different). Postscript is
> documented
> 
> >3) create PDF. PDF viewers & printers are available on "every" platform.
> PDF can be created by (free) ReportLab toolkit, and I'm sure there are more
> PDF-Classes
> 
> >4) create XHTML & a Print.CSS. HTML viewers are available on every
> Plattform, .CSS allows fairly good styling of printouts.
> 

Is it so hard if I only want to print plain text ?
Because I don't need anything special (only black text on white paper...).

> You mean like IE's really good reasons to insist on being my default
> browser for everything? You're putting a lot of faith in software
> developers.

Maybe I do... =)

> You do realise that -
> 
> no-one here is paid to answer queries?
> Alan Gauld is a very knowledgable person?
> Any knowledge is good knowledge?
> If at first you don't succeed, rephrase or Google?

Yes, I do.
Actually, I don't understand why you don't think its obvious to me (
must be because of my bad English =).

Thanks allot !

-- 
1. The day Microsoft makes something that doesn't suck is probably the
day they start making vacuum cleaners.
2. Unix is user friendly - it's just picky about it's friends.
3. Documentation is like sex: when it is good, it is very, very good.
And when it is bad, it is better than nothing. - Dick Brandon
___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tkinter questions

2004-12-20 Thread Alan Gauld
> > I find the easiest way is to create an PhotoImage object attach
> > the graphic file(jpg,bmp,gif) to that and assign the PhotoImage
> > object to the Button.image property. You can "animate" the image
> > by simply reassigning the file to the underlying PhotoImage
onject.

> Thanks, but a practical explanation will be more helpful.

OK, I assume you mean code? :-)

Here is an example modified from some experiments using
the >>> prompt.  It should work but might need a tweak
along the way...


from Tkinter import *

state = 0

def changeIt(img, fname):
   global state
   if state == 0:
   img['file']='img0.gif'
   state = 1
   else:
   img['file'] = 'img1.gif'
   state=0

top = Tk()

# now create an image object and a button
theImg = PhotoImage(file='spam.gif')
b = Button(top, command = changeIt, image=theImg)

b.pack()
top.mainloop()
#

You'll need to provide your own image files :-)
You can also see this in action with a Text box in
my book chapter on building a games framework,
the commented code for which is on the Useless
Python website as hmgui.zip

> > You mean print as in to a printer?
> > Personally I tend to generate an HTML file and use the
> > native OS Tools to print that. You can get fancy and
> > use the native OS printing libraries but since its
> > very OS specific I find HTML is easier! OUtside Tkinter
> > you may well find the GUI libraries have done the cross
> > platform stuff for you, but not in Tkinter.
> Again, a practical explanation will be more helpful...

HTML generation is just a case of creating a text file with
appropriate HTML tags inserted. There are some modules around
that can help.

Printing the file then becomes a matter of finding the
appropriate commands in your OS and using the os.system()
call to execute them. For example Windows explorer uses
this command to print HTML on my system:

"D:\msoffice\OFFICE11\msohtmed.exe" /p %1

You'll need to look to find whats in use on yours...

> > Define a full window? You mean full screen?
> > Thats usually better done as a parameter that the user can
> > set unless there is a very good reason not to. (Personally
> > I refuse to use any program that insists on opening full screen!)

> Full window or full screen is when the window of the program is all
> over the screen except the start bar

Nope, Full Window means that something fills the current window,
which could be any size. Since that didn't fit your explanation
I asked for clarity. Full screen is where a single window fills
the currently available screen.

> And why you refuse to use any program that insists on opening full
screen ?
> If it does then there must be a good reason for that...

No, quite often its simply a fascist minded programmer who thinks
his application is so important that I won't want to do anything
else while it's running - games programmers are bad for this.
But since I very rarely do only one thing at a time on my PC
I want control of the window size thankyou very much - that's
why I have a 21 inch monitor running at 1600x1200!

There are very few valid situations for an application taking
over the whole screen univited! Normally the user should be able
to make that choice. (For example when editing video I usually
do go full screen, but I decide, not the program!)

HTH,

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld

___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tkinter questions

2004-12-18 Thread Mark Kels
 > I find the easiest way is to create an PhotoImage object attach
> the graphic file(jpg,bmp,gif) to that and assign the PhotoImage
> object to the Button.image property. You can "animate" the image
> by simply reassigning the file to the underlying PhotoImage onject.
Thanks, but a practical explanation will be more helpful.

> You mean print as in to a printer?
> Personally I tend to generate an HTML file and use the
> native OS Tools to print that. You can get fancy and
> use the native OS priniting libraries but since its
> very OS specific I find HTML is easier! OUtside Tkinter
> you may well find the GUI libraries have done the cross
> platform stuff for you, but not in Tkinter.
Again, a practical explanation will be more helpful...

> Define a full window? You mean full screen?
> Thats usually better done as a parameter that the user can
> set unless there is a very good reason not to. (Personally
> I refuse to use any program that insists on opening full screen!)
Full window or full screen is when the window of the program is all
over the screen except the start bar (or whatever the blue line in the
bottom of a windows xp called).
And why you refuse to use any program that insists on opening full screen ?
If it does then there must be a good reason for that... 

> If OTOH you mean that you don't want the DOS box in the background
> thats easy, just rename the .py file to .pyw. But I suspect,
> since you talk about cross platform you mean full screen.
I did wanted a full screen, but this is very helpful too :) .

Thanks allot .

-- 
1. The day Microsoft makes something that doesn't suck is probably the
day they start making vacuum cleaners.
2. Unix is user friendly - it's just picky about it's friends.
3. Documentation is like sex: when it is good, it is very, very good.
And when it is bad, it is better than nothing. - Dick Brandon
___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tkinter questions

2004-12-17 Thread Alan Gauld
> I got some Tkinter related questions for a project that I'm making:
> 1. How to add an image to a button ?

I find the easiest way is to create an PhotoImage object attach
the graphic file(jpg,bmp,gif) to that and assign the PhotoImage
object to the Button.image property. You can "animate" the image
by simply reassigning the file to the underlying PhotoImage onject.

> 2. How can I print text using Tkinter (I want it to be cross
platform,
> so I cant use modules like win32print ) ?

You mean print as in to a printer?
Personally I tend to generate an HTML file and use the
native OS Tools to print that. You can get fancy and
use the native OS priniting libraries but since its
very OS specific I find HTML is easier! OUtside Tkinter
you may well find the GUI libraries have done the cross
platform stuff for you, but not in Tkinter.

> 3. How to I make the program to always open in a full window ?

Define a full window? You mean full screen?
Thats usually better done as a parameter that the user can
set unless there is a very good reason not to. (Personally
I refuse to use any program that insists on opening full screen!)

If OTOH you mean that you don't want the DOS box in the background
thats easy, just rename the .py file to .pyw. But I suspect,
since you talk abouit cross platform you mean full screen.

HTH,

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld

___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor