Re: tkinter, canvas, get color of image?

2008-04-18 Thread skanemupp
On 16 Apr, 00:46, Bryan Oakley [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On 13 Apr, 19:19, Bryan Oakley [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\elmapovic.gif') w.create_image(10, 10, image = mapq, anchor = NW) after

Tkinter, getting canvas-object, how?

2008-04-18 Thread skanemupp
so i load a gif onto a canvas and when i click the canvs i want to get the color of the pixel that is clicked. so i need to ge the object im clicking. i was told in another thread to use find_withtag or find_closest but it is not working, maybe im using the method on the wrong object. how do i do

Easiest way to get started with WebApps?

2008-04-18 Thread skanemupp
which is the easiest module to use to just get started with webapps quicklya nd starting getting things up and running, not advanced stuff just basic. -- http://mail.python.org/mailman/listinfo/python-list

Re: def power, problem when raising power to decimals

2008-04-17 Thread skanemupp
actually that 0**0 statement was wrong. 0**0 = 1 and should be. -- http://mail.python.org/mailman/listinfo/python-list

Re: py2exe, program has stoped working!?

2008-04-16 Thread skanemupp
On 14 Apr, 14:11, John Machin [EMAIL PROTECTED] wrote: On Apr 14, 7:24 pm, [EMAIL PROTECTED] wrote: Is it a console program or a gui program? GUI What happens when you run it without py2exe? it works perfectly, both from within python and launching from windows Have you

Profiling very small/quick functions, help!?

2008-04-16 Thread skanemupp
i use this code to profile. however for small standard functions it just says 0 seconds. so one solution is to run the function a very big number of times(how big?). but the bottom code doesnt work, it just runs the same profiling 1 times insetad of running the fucntion 10K times and evaluate

Profiling, recursive func slower than imperative, normal?

2008-04-16 Thread skanemupp
the 0.409 vs 0.095 is the total times right? so the imperative function is 4 times faster than the recursive. or what does tottime stand for? is this always the case that the recursive function is slower? the gain is less code? are some functions only implementable recursively? def power(nbr,

def power, problem when raising power to decimals

2008-04-16 Thread skanemupp
how do i solve power(5,1.3)? def power(nbr, po): if po==0: return 1 if po0: return nbr*power(nbr, po-1) if po0: return 1/power(nbr, -1*po) also i found a link which states 0^0 isnt 1 even though every calculator ive tried says it is. it doesnt say what it is

Re: tkinter, canvas, get color of image?

2008-04-15 Thread skanemupp
On 13 Apr, 19:19, Bryan Oakley [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\elmapovic.gif') w.create_image(10, 10, image = mapq, anchor = NW) after doing this is there any possibility of getting the characteristics of the

tkinter, event.widget, what do i get?

2008-04-15 Thread skanemupp
when calling function hmm here, what do i get? the widget i clicked on? if i have a canvs on wich i have a bitmap and i click on the bitmap, is the event.widget then the bitmap? can i get info about the bitmap then? like color of the pixel i clicked. if so, how? w.bind(Key, key) w.bind(Button-1,

Re: tkinter, event.widget, what do i get?

2008-04-15 Thread skanemupp
On 16 Apr, 00:24, Gabriel Genellina [EMAIL PROTECTED] wrote: En Tue, 15 Apr 2008 17:45:08 -0300, [EMAIL PROTECTED] escribió: when calling function hmm here, what do i get? the widget i clicked on? if i have a canvs on wich i have a bitmap and i click on the bitmap, is the event.widget

Re: py2exe, program has stoped working!?

2008-04-14 Thread skanemupp
Is it a console program or a gui program? GUI What happens when you run it without py2exe? it works perfectly, both from within python and launching from windows Have you searched for has stopped working in (a) your source code yes no such message there (b) the py2exe source code? no, will do

Re: Game design : Making computer play

2008-04-14 Thread skanemupp
On 14 Apr, 09:13, v4vijayakumar [EMAIL PROTECTED] wrote: In computer based, two player, board games, how to make computer play? Are there any formal ways to _teach_ computer, to choose best possible move? I know this is kind of off-topic here. Please redirect me, if there are more

latest command from toplevel?

2008-04-13 Thread skanemupp
windows vista and python 2.5, is there a way to get the latest command entered? would be very useful. if not by default, anything i could download or write myself? -- http://mail.python.org/mailman/listinfo/python-list

py2exe, program has stoped working!?

2008-04-13 Thread skanemupp
so i used py2exe and i have the build and the dist-folders. in the distfolder there is a Calculator.exe file. when i run it it just says Calculator.exe has stopped working in a popup but the program itself never shows up. wtf!? and when im distributing my program i have to include both

Tkinter, image not appearing in function but without function

2008-04-13 Thread skanemupp
why is the first program not working? when i click the screen the map is not appearing. the second program works. from Tkinter import * master = Tk() w = Canvas(master, width=700, height=600) w.pack(expand = YES, fill = BOTH) def mapper(): mapq = PhotoImage(file =

tkinter, canvas, get color of image?

2008-04-13 Thread skanemupp
mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\elmapovic.gif') w.create_image(10, 10, image = mapq, anchor = NW) after doing this is there any possibility of getting the characteristics of the GIF-picture(or bitmap if i use that)? it would be very helpfull if i for example could do something

tkinter, editing an entry, int-value of insert?

2008-04-12 Thread skanemupp
in this program when using the c-button it deletes the last token entered. i want to delete the token after the mousecursor. lets say the string is: 12*(81**.5+12) and i put the cursor between the * and * because i want times .5 not root. now if i press c it deletes ) which is not what i want.

Re: tkinter, editing an entry, int-value of insert?

2008-04-12 Thread skanemupp
solved this: def Backspace(): st = e.index(INSERT) e.delete(st-1,st) -- http://mail.python.org/mailman/listinfo/python-list

toplevel, get latest entry?

2008-04-12 Thread skanemupp
windows vista and python 2.5, is there a way to get the latest command entered? would be very useful. if not by default, anything i could download or write myself? -- http://mail.python.org/mailman/listinfo/python-list

Re: tkinter, overwrite Label-text?

2008-04-11 Thread skanemupp
On 10 Apr, 18:03, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Thu, 10 Apr 2008 07:37:08 -0700, skanemupp wrote: i know how to do this already. the problem is i want the text to stay in the windowa nd not start overwriting Answer:. Then don't use `place()` but let Tkinter handle

Profiling programs/scripts?

2008-04-11 Thread skanemupp
how do i profile a program? i found out that there are some profilers included in the standard library but couldnt really figure out how to access/use them -- http://mail.python.org/mailman/listinfo/python-list

tkinter, annoying grid-problem

2008-04-11 Thread skanemupp
so my little calculator works perfectly now. just having some trouble with the layout. this whole tkinter-thing seems to be more tricky than it should be. how can i make the 4 column of buttons have the same distance and size between them as the other 3 columns? and how can i make the top entry

questions about Exceptions?

2008-04-10 Thread skanemupp
is there a general philosophy as to when to use exceptions and when not to? like here: def Calc(): global nbr try: print eval(nbr) except: print Not computable nbr = i have a calculator and nbr is a string that contains '0123456789+-*/' if the string ends on

Re: questions about Exceptions?

2008-04-10 Thread skanemupp
On 10 Apr, 12:38, [EMAIL PROTECTED] wrote: def Calc(): global nbr try: print eval(nbr) #a = Label(mygui, text=eval(nbr)) #a.place(relx=0.4, rely=0.1, anchor=CENTER) except: print Not computable nbr = def Erase(): global

Re: questions about Exceptions?

2008-04-10 Thread skanemupp
On 10 Apr, 10:51, [EMAIL PROTECTED] wrote: In general you should only catch the exceptions you want to catch, therefore avoiding the issue of catching unexpected ones, for instances the programming unexpectandly closing. Well, exception handling is expensive (when it catches one) so it

Re: questions about Exceptions?

2008-04-10 Thread skanemupp
here is the whole code: from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title(Calculator) w = Label(mygui, text=Answer: ) w.place(relx=0.15, rely=0.1, anchor=CENTER) nbr = def Disp(nstr): global nbr nbr=nbr+nstr print You need to

Re: questions about Exceptions?

2008-04-10 Thread skanemupp
On 10 Apr, 13:15, [EMAIL PROTECTED] wrote: the erase() id alwys need if u wanna abort whilst u wrote something. But if it is meant to only evaluate once you've pressed the enter key (I take it?) you shouldn't need that. And if you are to abort while evaluating it will not do that. CHANGED

Re: questions about Exceptions?

2008-04-10 Thread skanemupp
from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title(Calculator) l = Label(mygui, text=Answer: ) l.place(relx=0.15, rely=0.2, anchor=CENTER) e = Entry(mygui) e.place(relx=0.4, rely=0.1, anchor=CENTER) def Disp(nstr): e.insert(END, nstr) def

tkinter, overwrite Label-text?

2008-04-10 Thread skanemupp
using python And tkinter. i have a GUI that outputs a text among other things. after input form user i want this text to be *)cleared and/or *)overwritten. what is the best way to achieve that? also, how do i make Label-text expand to the right and not to the left? --

Re: questions about Exceptions?

2008-04-10 Thread skanemupp
On 10 Apr, 12:38, [EMAIL PROTECTED] wrote: def Calc(): global nbr try: print eval(nbr) #a = Label(mygui, text=eval(nbr)) #a.place(relx=0.4, rely=0.1, anchor=CENTER) except: print Not computable nbr = def Erase(): global

Re: tkinter, overwrite Label-text?

2008-04-10 Thread skanemupp
On 10 Apr, 15:28, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Apr 10, 2:35 pm, [EMAIL PROTECTED] wrote: using python And tkinter. i have a GUI that outputs a text among other things. after input form user i want this text to be *)cleared and/or *)overwritten. what is the best way

Re: tkinter, overwrite Label-text?

2008-04-10 Thread skanemupp
On 10 Apr, 16:29, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Apr 10, 3:47 pm, [EMAIL PROTECTED] wrote: [...] i use the Label-widget. Then you should be able to connect a variable to your widget like I wrote in my previous post. Just try out the example from the Python documentation.

Tkinter: Entry, how to get INSERTpos?

2008-04-10 Thread skanemupp
in this function i want to be able to use the cursor and delete in the middle of a number. how do i get the value of anchor or insert? i want to write: e.delete(pos-1,pos) def Backspace(): a=len(e.get()) e.delete(a-1,END) #e.delete(INSERT, END) #e.delete(ANCHOR,END) the complete

Tkinter, resize window, keep widgets relative placements?

2008-04-10 Thread skanemupp
the code is down below. when i click maximize window it looks terrible since the widgets are not keeping their relative size. i guess i could use pack or grid to do that instead of place? but i tried with pack and grid before and had trouble making it looking good. is it possible to have the

Re: Tkinter, resize window, keep widgets relative placements?

2008-04-10 Thread skanemupp
here i didi it with pack() but when i try to use the answerwidget it gtes all f* up. any suggestions? from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title(Calculator) ##l = Label(mygui, text=Answer: ) ##l.grid(row=2, column=1, columnspan=2)

Tkinter, repaint?, keep size?

2008-04-06 Thread skanemupp
so my calculator is almost done for u that have read my previous posts. i have some minor problems i have to fix though. *one is i need to repaint once i have performed a calculation so that the old results are not left on the screen. cant find a method for that. *another is now when i write the

Prevent GUI layout from changing?

2008-04-06 Thread skanemupp
when i added the results-LABEL the buttons have changed place. meh why cant i just put buttons and stuff on a specific coordinate and have them staying there? #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): This is the GUI def

Tkinter, a lot of buttons, make prog shorter?

2008-04-06 Thread skanemupp
is there anyway to make this shorter? i hate having these big blocks of similar-looking code, very unaesthetic. maybe doesnt matter good-code-wise? anyway can i make some function that makes this shorter? like put the etiquettes on the button froma string of '123+456-789*0Cr/' ? problem is the

How to create an exe-file?

2008-04-06 Thread skanemupp
how do you create exe-files of your python-code? is it different depending on what libraries, GUI-frameworks you use? i want to create an exe-file of a pythonscript that uses Tkinter. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to create an exe-file?

2008-04-06 Thread skanemupp
On 6 Apr, 22:50, Fredrik Lundh [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: how do you create exe-files of your python-code? is it different depending on what libraries, GUI-frameworks you use? i want to create an exe-file of a pythonscript that uses Tkinter. assuming windows only,

Re: Prevent GUI layout from changing?

2008-04-06 Thread skanemupp
On 6 Apr, 22:15, Gabriel Genellina [EMAIL PROTECTED] wrote: En Sun, 06 Apr 2008 15:12:55 -0300, [EMAIL PROTECTED] escribió: I can't help with your sizing problem, I don't know grids. But don't do this: def Display(self, number): self.expr = self.expr + number

Re: Tkinter, a lot of buttons, make prog shorter?

2008-04-06 Thread skanemupp
should i not use self. in Clean() and Calculate() either? anyway i had changed it before. must have copied the wrong program. #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): This is the GUI def __init__(self, master=None):

Re: TKinter, buttonwidget response problem(1) and all btns the same size(2)!

2008-04-05 Thread skanemupp
am i not doing that then? did u look at the code? where do i add the bind if this: btnDisplay = Button(self, text=1, command=self.Display) btnDisplay.grid(row=3, column=0, padx=5, pady=5) is not enough? def Display(self, event_obj): button = event_obj.widget text =

Re: TKinter, buttonwidget response problem(1) and all btns the same size(2)!

2008-04-05 Thread skanemupp
def __init__(self): # ... button = Button(self, text='1', command=lambda n=1: self.display(n)) # ... def display(self, number): print number should this really be inside the __init__ function? --

Re: TKinter, buttonwidget response problem(1) and all btns the same size(2)!

2008-04-05 Thread skanemupp
On 5 Apr, 17:09, Fredrik Lundh [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: def __init__(self): # ... button = Button(self, text='1', command=lambda n=1: self.display(n)) # ... def display(self,

Tkinter: making buttons the same size?

2008-04-05 Thread skanemupp
on windows vista these buttons dont have the same size, the / shrinks a little. how do i make them the same size or prevent shrinking? a mac-user told me they look the same to him so maybe it doesnt shrink on macs but it does when using VISTA. i tried some .propagate and extend-stuff but didnt

Re: Tkinter: making buttons the same size?

2008-04-05 Thread skanemupp
how do i do that? i get this error: self.btnDisplay = Button(self,text='1',command=lambda n=1:self.Display(n)) self.btnDisplay.grid(row=3, column=0, padx=5, pady=5, width=1) self.btnDisplay = Button(self,text='/',command=lambda n=/:self.Display(n))

Re: TKinter, buttonwidget response problem(1) and all btns the same size(2)!

2008-04-05 Thread skanemupp
it works now. here is all the code: #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): This is the GUI def __init__(self, master=None): Initialize yourself Initialise the base class Frame.__init__(self,master)

Tkinter, add pressed buttons onto string display string, how to?

2008-04-05 Thread skanemupp
using tkinter and python i now have a small App (that will hopefully soon be a fully functioning calculator) where u can push buttons and the corresponding number or operator is shown. when u press 1, 1 appears on the screen, pres + and + appears etc. at the moment every output overwrites the

Re: Tkinter, add pressed buttons onto string display string, how to?

2008-04-05 Thread skanemupp
input = hello input += world print input this i know. im wondering how to handle the variable in the actual program. this exception i get: Exception in Tkinter callback Traceback (most recent call last): File C:\Python25\lib\lib-tk\Tkinter.py, line 1403, in __call__ return

Re: Tkinter, add pressed buttons onto string display string, how to?

2008-04-05 Thread skanemupp
Just like the message says: You are trying to use `str` (on the right hand side of the assignment) before anything is bound to that name. Ciao, Marc 'BlackJack' Rintsch i know but i want the variable str(which i found out is a reserved word so i changed it) to be accessible all over

Best way to check if string is an integer?

2008-04-05 Thread skanemupp
which is the best way to check if a string is an number or a char? could the 2nd example be very expensive timewise if i have to check a lot of strings? this value = raw_input() try: value = int(value) except ValueError: print value is not an integer or: c=raw_input(yo: ) if c in

while-loops enter the last time after condition is filled?

2008-04-05 Thread skanemupp
it seems to me from my results that when i use a while-loop it will execute once after the condition is met. ie the conditions is met the code executes one time more and then quits. -- http://mail.python.org/mailman/listinfo/python-list

TKinter, buttonwidget response problem(1) and all btns the same size(2)!

2008-04-04 Thread skanemupp
1st question: when i run this program 1 will be printed into the interpreter when i run it BUT without me clicking the actual button. when i then click the button 1, nothing happens. obv i dont want any output when i dont push the button but i want it when i do. what am i doing wrong here?

Re: TKinter, buttonwidget response problem(1) and all btns the same size(2)!

2008-04-04 Thread skanemupp
On 5 Apr, 05:26, 7stud [EMAIL PROTECTED] wrote: On Apr 4, 7:06 pm, [EMAIL PROTECTED] wrote: 1st question: when i run this program 1 will be printed into the interpreter when i run it BUT without me clicking the actual button. when i then click the button 1, nothing happens. obv i

Re: TKinter, buttonwidget response problem(1) and all btns the same size(2)!

2008-04-04 Thread skanemupp
On 5 Apr, 05:57, [EMAIL PROTECTED] wrote: On 5 Apr, 05:26, 7stud [EMAIL PROTECTED] wrote: On Apr 4, 7:06 pm, [EMAIL PROTECTED] wrote: 1st question: when i run this program 1 will be printed into the interpreter when i run it BUT without me clicking the actual button. when i

Re: TKinter, buttonwidget response problem(1) and all btns the same size(2)!

2008-04-04 Thread skanemupp
On 5 Apr, 07:02, [EMAIL PROTECTED] wrote: On 5 Apr, 05:57, [EMAIL PROTECTED] wrote: On 5 Apr, 05:26, 7stud [EMAIL PROTECTED] wrote: On Apr 4, 7:06 pm, [EMAIL PROTECTED] wrote: 1st question: when i run this program 1 will be printed into the interpreter when i run it BUT