Bryan Oakley | 1 Mar 01:06 2012
Picon

Re: Tk*Font question



On Wednesday, February 29, 2012, Bob Greschke wrote:
What's the correct way to change the font size?  The "Change" button isn't doing what I thought it would.  The font changes size, but turns into some proportional font.  I'm kinda new (1 day) to using TkFixedFont and its friends.  I'm used to ("Monoco", 9) sort of stuff and I'm not sure I understand what's going on.

The best way is to use a named font. With that you can do 'myfont.configure(size=new_size)'. Then, every widget that uses that font will automatically see the change.


Named fonts are one of the true gems of tk. They have been part of the toolkit for probably a decade or more, and still to the best of my knowledge no popular toolkit has anything as powerful and easy to use.
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
jason watkins | 1 Mar 22:35 2012
Picon

Text box reveal directory path?

Is it possible to create a text box that will reveal the full path of a folder/file when that folder/file is dragged and dropped onto the text box?  I want it to function like terminal does on a Mac.  Thanks for any help, Jason
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Guido R. C Guerrero | 2 Mar 12:17 2012

Re: Tkinter-discuss Digest, Vol 96, Issue 13

Lion;

I'll very happy to help you. I use Python as my main developing language, and use Tkinter as my gui interface, so, having something that makes things easier and faster will be great.

Guido Carballo

On Feb 22, 2012, at 08:00 AM, tkinter-discuss-request <at> python.org wrote:

Send Tkinter-discuss mailing list submissions to
tkinter-discuss <at> python.org

To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/tkinter-discuss
or, via email, send a message with subject or body 'help' to
tkinter-discuss-request <at> python.org

You can reach the person managing the list at
tkinter-discuss-owner <at> python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Tkinter-discuss digest..."
Today's Topics:

1. Re: General Tkinter Assistance Module (python <at> bdurham.com)
2. Re: General Tkinter Assistance Module (Lion Kimbro)
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
fresher | 2 Mar 13:21 2012
Picon

[REQ] Tkinter programmer

Hello. I am looking for somebody who could help me to do some tasks with
Tkinter python programming? for sure $$

thanks.

--
View this message in context: http://python.6.n6.nabble.com/REQ-Tkinter-programmer-tp4539479p4539479.html
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.
Cameron Laird | 2 Mar 14:09 2012
Picon

Re: [REQ] Tkinter programmer

On Fri, Mar 02, 2012 at 04:21:14AM -0800, fresher wrote:
			.
			.
			.
> Hello. I am looking for somebody who could help me to do some tasks with
> Tkinter python programming? for sure $$
			.
			.
			.
Several of us are in a position to help.  Please say a
few more words of description so we can judge what to
propose to you.  It's possible that your needs can be
met with a (free!) explanation or two through the 
mailing list, OR you might want to engage one of us on
a long-term consulting agreement, OR there is a whole
range of possibilities between.
Michael Lange | 2 Mar 21:23 2012
Picon

Re: Text box reveal directory path?

Hi Jason,

Thus spoketh jason watkins <sofawatkins <at> hotmail.com> 
unto us on Thu, 1 Mar 2012 21:35:55 +0000:

> 
> Is it possible to create a text box that will reveal the full path of a
> folder/file when that folder/file is dragged and dropped onto the text
> box?  I want it to function like terminal does on a Mac.  Thanks for
> any help, Jason 

Drag and drop with Tkinter is a little tricky. If you only need to handle
DnD within your application you can try the Tkdnd module from Python's
standard library.

However, te above sounds like you want to drag from an external program,
like a file manager?
In this case you need the tkdnd extension to Tk from 
http://sourceforge.net/projects/tkdnd/ and the Python wrapper from
http://klappnase.bubble.org/TkinterDnD2/index.html .

With these your mileage may vary, on windows systems drags as well as
drops have been reported to work, on unix systems only drops are
supported and I myself have never managed to get it decently working at
all, however some people reported success on linux and OSX too.

Regards

Michael

.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

	"Life and death are seldom logical."
	"But attaining a desired goal always is."
		-- McCoy and Spock, "The Galileo Seven", stardate 2821.7
Lion Kimbro | 2 Mar 22:38 2012
Picon

Re: Tkinter-discuss Digest, Vol 96, Issue 13


  Great!  Thank you Guido.

  I've created a document that anyone who is interested can edit, so that we can lay out the basics of the project.

https://docs.google.com/document/d/1TCANkeaBYs_W7Sg9J1ce8Y1X4G6UR1PT3H-iMIuuNFY/edit

  For the time being, I have set the permissions very low, so that anyone can edit it.
  Spammers may force me to change that, but it should be fine for at least a week or two at least.

  I've laid out these basic goals:
  • Create a github repository for the project.
  • Create a dream specification for the project.  Imagine that we had the software already, and that we are writing the documentation for it.  What’s the software like?  What function calls are there?  What does the GUI look like?
  • Share our function libraries, pour through them, find the treasures within them, and pool them together into something that we like.
  • Get to know each other both in code and out of code.  Hear each others’ voice at least once.
  • Create a web presence for the project, and find people who should know about the project.  Tell them about it.

  I look forward to getting to know more about you!
  If you'd like to set up the github repository, or if you would like to make some suggestions, or if you'd like to start writing out what you would like the API to look like -- or if you have some ideas or observations -- by all means, please do it, share it, whatever..!

  We need a mailing list as well;  If you create that, that'd be great.  Alternatively, I'll create it within a week.



On Fri, Mar 2, 2012 at 3:17 AM, Guido R. C Guerrero <charras <at> me.com> wrote:
Lion;

I'll very happy to help you. I use Python as my main developing language, and use Tkinter as my gui interface, so, having something that makes things easier and faster will be great.

Guido Carballo

On Feb 22, 2012, at 08:00 AM, tkinter-discuss-request <at> python.org wrote:

Send Tkinter-discuss mailing list submissions to
tkinter-discuss <at> python.org

To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/tkinter-discuss
or, via email, send a message with subject or body 'help' to
tkinter-discuss-request <at> python.org

You can reach the person managing the list at
tkinter-discuss-owner <at> python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Tkinter-discuss digest..."
Today's Topics:

1. Re: General Tkinter Assistance Module (python <at> bdurham.com)
2. Re: General Tkinter Assistance Module (Lion Kimbro)
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
ed(LV | 4 Mar 08:38 2012
Picon

Tkinter variable sharing from function to function

*Hello!
Im beginner at Tkinter and this is my 1st project.
I want make programm that calculate resistor value from colors, but i can`t
get variables out of functions.
Here you can see all code:*

#fails 251.py
import Tkinter as tk
from Tkinter import *
import math

root=tk.Tk()
root.title("rezistoru aprekins")
w= tk.Canvas(root, width=700, height=550, bg="#abc")
w.pack()
linija = w.create_line(10, 100, 375, 100, width='10',fill='black')
linija = w.create_line(100, 50, 100, 150, width='50',fill='#FFCC99')
linija = w.create_line(300, 50, 300, 150, width='50',fill='#FFCC99')
linija = w.create_line(75, 100, 300, 100, width='80',fill='#FFCC99')
linija = w.create_line(110, 50, 110, 150, width='15',fill='red')
linija = w.create_line(150, 60, 150, 140, width='15',fill='red')
linija = w.create_line(180, 60, 180, 140, width='15',fill='red')
linija = w.create_line(260, 60, 260, 140, width='15',fill='red')
linija = w.create_line(30, 190, 110, 155, width='1',fill='black')
linija = w.create_line(150, 148, 200, 190, width='1',fill='black')
linija = w.create_line(180, 145, 350, 190, width='1',fill='black')
linija = w.create_line(260, 145, 500, 190, width='1',fill='black')

#x1=tk.IntVar()
#x2=tk.IntVar()

def fun2():
	linija = w.create_line(110, 50, 110, 150, width='15',fill='black')
	x=00
	w.itemconfig(t2,text=x)
	
def fun3():
	linija = w.create_line(110, 50, 110, 150, width='15',fill='brown')
	x=10
	w.itemconfig(t2,text=x)
	
	
	
	

def fun4():
	linija = w.create_line(110, 50, 110, 150, width='15',fill='red')
	x=20
	w.itemconfig(t2,text=x)
	
	
	

def fun5():
	linija = w.create_line(110, 50, 110, 150, width='15',fill='orange')
	x=30
	w.itemconfig(t2,text=x)
	
	
def fun6():
	linija = w.create_line(110, 50, 110, 150, width='15',fill='yellow')
	x=40
	w.itemconfig(t2,text=x)
def fun7():
	linija = w.create_line(110, 50, 110, 150, width='15',fill='green')
	x=50
	w.itemconfig(t2,text=x)
def fun8():
	linija = w.create_line(110, 50, 110, 150, width='15',fill='blue')
	x=60
	w.itemconfig(t2,text=x)
def fun9():
	linija = w.create_line(110, 50, 110, 150, width='15',fill='purple')
	x=70
	w.itemconfig(t2,text=x)
def fun10():
	linija = w.create_line(110, 50, 110, 150, width='15',fill='gray')
	x=80
	w.itemconfig(t2,text=x)
def fun11():
	linija = w.create_line(110, 50, 110, 150, width='15',fill='white')
	x=90
	w.itemconfig(t2,text=x)

def fun21():
	linija = w.create_line(150, 60, 150, 140, width='15',fill='black')
	x1=00
	w.itemconfig(t3,text=x1)

def fun31():
	linija = w.create_line(150, 60, 150, 140, width='15',fill='brown')
	x1=1
	w.itemconfig(t3,text=x1)

def fun41():
	linija = w.create_line(150, 60, 150, 140, width='15',fill='red')
	x1=2
	w.itemconfig(t3,text=x1)

def fun51():
	linija = w.create_line(150, 60, 150, 140, width='15',fill='orange')
	x1=3
	w.itemconfig(t3,text=x1)
def fun61():
	linija = w.create_line(150, 60, 150, 140, width='15',fill='yellow')
	x1=4
	w.itemconfig(t3,text=x1)
def fun71():
	linija = w.create_line(150, 60, 150, 140, width='15',fill='green')
	x1=5
	w.itemconfig(t3,text=x1)
def fun81():
	linija = w.create_line(150, 60, 150, 140, width='15',fill='blue')
	x1=6
	w.itemconfig(t3,text=x1)
def fun91():
	linija = w.create_line(150, 60, 150, 140, width='15',fill='purple')
	x1=7
	w.itemconfig(t3,text=x1)
def fun101():
	linija = w.create_line(150, 60, 150, 140, width='15',fill='gray')
	x1=8
	w.itemconfig(t3,text=x1)
def fun111():
	linija = w.create_line(150, 60, 150, 140, width='15',fill='white')
	x1=9
	w.itemconfig(t3,text=x1)

#3linija

def fun22():
	linija = w.create_line(180, 60, 180, 140, width='15',fill='black')
	x2=1
	w.itemconfig(t4,text=x2)

def fun32():
	linija = w.create_line(180, 60, 180, 140, width='15',fill='brown')
	x2=10
	w.itemconfig(t4,text=x2)

def fun42():
	linija = w.create_line(180, 60, 180, 140, width='15',fill='red')
	x2=100
	w.itemconfig(t4,text=x2)

def fun52():
	linija = w.create_line(180, 60, 180, 140, width='15',fill='orange')
	x2=1000
	w.itemconfig(t4,text=x2)
def fun62():
	linija = w.create_line(180, 60, 180, 140, width='15',fill='yellow')
	x2=10000
	w.itemconfig(t4,text=x2)
def fun72():
	linija = w.create_line(180, 60, 180, 140, width='15',fill='green')
	x2=100000
	w.itemconfig(t4,text=x2)
def fun82():
	linija = w.create_line(180, 60, 180, 140, width='15',fill='blue')
	x2=1000000
	w.itemconfig(t4,text=x2)
def fun92():
	linija = w.create_line(180, 60, 180, 140, width='15',fill='purple')
	x2=10000000
	w.itemconfig(t4,text=x2)
def fun102():
	linija = w.create_line(180, 60, 180, 140, width='15',fill='#EAC117')
	x2=0.01
	w.itemconfig(t4,text=x2)
def fun112():
	linija = w.create_line(180, 60, 180, 140, width='15',fill='#C0C0C0')
	x2=0.1
	w.itemconfig(t4,text=x2)
#4linija
def fun23():
	linija = w.create_line(260, 60, 260, 140, width='15',fill='brown')
	x3=1
	w.itemconfig(t5,text=x3)

def fun33():
	linija = w.create_line(260, 60, 260, 140, width='15',fill='red')
	x3=2
	w.itemconfig(t5,text=x3)

def fun43():
	linija = w.create_line(260, 60, 260, 140, width='15',fill='#EAC117')
	x3=5
	w.itemconfig(t5,text=x3)

def fun53():
	linija = w.create_line(260, 60, 260, 140, width='15',fill='#C0C0C0')
	x3=10
	w.itemconfig(t5,text=x3)

t1 = w.create_text(1, 200, text="first color: ",font="Courier 10 bold ",
fill ="black",anchor='w')
b1=tk.Button(root, text="black ", command=fun2,width=8)
b1.pack()
b1.place(x=5 ,y=220)
b2=tk.Button(root, text="brown", command=fun3,width=8)
b2.pack()
b2.place(x=5 ,y=250)
b3=tk.Button(root, text="red ", command=fun4,width=8)
b3.pack()
b3.place(x=5 ,y=280)
b4=tk.Button(root, text="orange", command=fun5,width=8)
b4.pack()
b4.place(x=5 ,y=310)
b5=tk.Button(root, text="yellow", command=fun6,width=8)
b5.pack()
b5.place(x=5 ,y=340)
b6=tk.Button(root, text="green", command=fun7,width=8)
b6.pack()
b6.place(x=5 ,y=370)
b7=tk.Button(root, text="blue", command=fun8,width=8)
b7.pack()
b7.place(x=5 ,y=400)
b8=tk.Button(root, text="purple", command=fun9,width=8)
b8.pack()
b8.place(x=5 ,y=430)
b9=tk.Button(root, text="gray", command=fun10,width=8)
b9.pack()
b9.place(x=5 ,y=460)
b10=tk.Button(root, text="white", command=fun11,width=8)
b10.pack()
b10.place(x=5 ,y=490)

t11 = w.create_text(150, 200, text="second color: ",font="Courier 10 bold ",
fill ="black",anchor='w')
b11=tk.Button(root, text="black ", command=fun21,width=8)
b11.pack()
b11.place(x=150 ,y=220)
b21=tk.Button(root, text="brown", command=fun31,width=8)
b21.pack()
b21.place(x=150 ,y=250)
b31=tk.Button(root, text="red  ", command=fun41,width=8)
b31.pack()
b31.place(x=150 ,y=280)
b41=tk.Button(root, text="orange", command=fun51,width=8)
b41.pack()
b41.place(x=150 ,y=310)
b51=tk.Button(root, text="yellow", command=fun61,width=8)
b51.pack()
b51.place(x=150 ,y=340)
b61=tk.Button(root, text="green", command=fun71,width=8)
b61.pack()
b61.place(x=150 ,y=370)
b71=tk.Button(root, text="blue", command=fun81,width=8)
b71.pack()
b71.place(x=150 ,y=400)
b81=tk.Button(root, text="purple", command=fun91,width=8)
b81.pack()
b81.place(x=150 ,y=430)
b91=tk.Button(root, text="gray", command=fun101,width=8)
b91.pack()
b91.place(x=150 ,y=460)
b101=tk.Button(root, text="white", command=fun111,width=8)
b101.pack()
b101.place(x=150 ,y=490)

t1 = w.create_text(300, 200, text="third color: ",font="Courier 10 bold ",
fill ="black",anchor='w')
b1=tk.Button(root, text="black ", command=fun22,width=8)
b1.pack()
b1.place(x=300 ,y=220)
b2=tk.Button(root, text="brown", command=fun32,width=8)
b2.pack()
b2.place(x=300 ,y=250)
b3=tk.Button(root, text="red  ", command=fun42,width=8)
b3.pack()
b3.place(x=300 ,y=280)
b4=tk.Button(root, text="orange", command=fun52,width=8)
b4.pack()
b4.place(x=300 ,y=310)
b5=tk.Button(root, text="yellow", command=fun62,width=8)
b5.pack()
b5.place(x=300 ,y=340)
b6=tk.Button(root, text="green", command=fun72,width=8)
b6.pack()
b6.place(x=300 ,y=370)
b7=tk.Button(root, text="blue", command=fun82,width=8)
b7.pack()
b7.place(x=300 ,y=400)
b8=tk.Button(root, text="purple", command=fun92,width=8)
b8.pack()
b8.place(x=300 ,y=430)
b9=tk.Button(root, text="gold", command=fun102,width=8)
b9.pack()
b9.place(x=300 ,y=460)
b10=tk.Button(root, text="silver", command=fun112,width=8)
b10.pack()
b10.place(x=300 ,y=490)

t1 = w.create_text(450, 200, text="fourth color: ",font="Courier 10 bold ",
fill ="black",anchor='w')

b2=tk.Button(root, text="brown", command=fun23,width=8)
b2.pack()
b2.place(x=450 ,y=220)
b3=tk.Button(root, text="red  ", command=fun33,width=8)
b3.pack()
b3.place(x=450 ,y=250)

b11=tk.Button(root, text="gold", command=fun43,width=8)
b11.pack()
b11.place(x=450 ,y=280)
b12=tk.Button(root, text="silver", command=fun53,width=8)
b12.pack()
b12.place(x=450 ,y=310)

t2=w.create_text(500, 20, text=" 44 ")

t3=w.create_text(500, 50, text=" 55 ")
t4=w.create_text(500, 80, text=" 66 ")
t5=w.create_text(500, 110, text=" 77 ")
t6=w.create_text(500, 140, text=" 88 ")

def funf():
	z=(x+x1)*x2
	w.itemconfig(t6,text=z)
	

bfin=tk.Button(root, text="CALCULATE", command=funf,font="24")
bfin.pack()
bfin.place(x=400 ,y=500)

w.mainloop()

*The main problem is that I can`t read variables x, x1, x2 on button
"CALCULATE" press.
Thank you for support!*

--
View this message in context: http://python.6.n6.nabble.com/Tkinter-variable-sharing-from-function-to-function-tp4544506p4544506.html
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.
Michael Lange | 4 Mar 13:42 2012
Picon

Re: Tkinter variable sharing from function to function

Hi,

Thus spoketh "ed(LV)" <ambed <at> inbox.lv> 
unto us on Sat, 3 Mar 2012 23:38:17 -0800 (PST):

> *Hello!
> Im beginner at Tkinter and this is my 1st project.
> I want make programm that calculate resistor value from colors, but i
> can`t get variables out of functions.
> Here you can see all code:*
> 
(...)
> *The main problem is that I can`t read variables x, x1, x2 on button
> "CALCULATE" press.
> Thank you for support!*

when I run you code I get each time I press The "Calculate" button the
error message:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1413, in __call__
    return self.func(*args)
  File "test7.py", line 326, in funf
    z=(x+x1)*x2
NameError: global name 'x' is not defined

which shows clearly what happens:
the callback

def funf():
    z=(x+x1)*x2
    w.itemconfig(t6,text=z)

tries to use a variable "x" which is not defined in the function's
namespace, which covers basically everything that is defined *globally*
plus anything defined within the function's *local* namespace, which
means in the body of the function itself.

I set up a minimal example to illustrate the difference between a local
and a global variable, I hope you see the point:

########### file test.py ###################
from Tkinter import *

root = Tk()
x = 1

def func1():
    x = 0
    print 'value of x:', x

def func2():
    global x
    print 'value of x:', x

def func3():
    global x
    x += 2
    print 'value of x:', x

Button(text='Func 1', command=func1).pack()
Button(text='Func 2', command=func2).pack()
Button(text='Func 3', command=func3).pack()

root.mainloop()
###########################################

So possible solutions for your problem might be:

* declare global variables in your functions ( I haven't properly
investigated all of your code, but I guess you would probably have to
declare globals in all of your button callbacks, which is most often
considered to be bad practice, although it will work without problems if
it is done carefully), or
* use Tkinter variables , as it seems was one of your first tries. Then
you can simply call something like var1.set(1) from within the function
body.

If you want to learn more about namespaces in Python and how they work, a
good starting point is:

http://www.freenetpages.co.uk/hp/alan.gauld/tutname.htm

I hope this helps

Michael

.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

One of the advantages of being a captain is being able to ask for
advice without necessarily having to take it.
		-- Kirk, "Dagger of the Mind", stardate 2715.2
ed(LV | 4 Mar 18:01 2012
Picon

Re: Tkinter variable sharing from function to function

Thank you for help and good samples!
for each x x1 x2 x3 I definate them global and now Its working.
Thank you!

--
View this message in context: http://python.6.n6.nabble.com/Tkinter-variable-sharing-from-function-to-function-tp4544506p4545427.html
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.

Gmane