class doesn't open its window - newbie question

2010-08-01 Thread Chris Hare
I am a newbie to python, but not programming. I have a menubar item displaySubMenu.add_command(label=External, command=externalDisplay) externalDisplay is a new class, which I have already imported. The class is here: from Tkinter import * from datetime import datetime, date, time import

image resize doesn't work

2010-08-01 Thread Chris Hare
I have the following chunk of code. Although it seems to execute fine, no errors, the image is never resized. What am I missing? imagePNG = Image.open(image.png) photo = ImageTk.PhotoImage(imagePNG canvasWidth = 300 canvasHeight

Re: image resize doesn't work

2010-08-01 Thread Chris Hare
On Aug 1, 2010, at 10:24 AM, rantingrick wrote: On Aug 1, 7:35 am, Chris Hare ch...@labr.net wrote: I have the following chunk of code. Although it seems to execute fine, no errors Not True! it contains syntax errors. Check the posted code and next time post all the code. -- http

Re: image resize doesn't work

2010-08-01 Thread Chris Hare
On Aug 1, 2010, at 1:08 PM, Peter Otten wrote: Chris Hare wrote: On Aug 1, 2010, at 10:24 AM, rantingrick wrote: On Aug 1, 7:35 am, Chris Hare ch...@labr.net wrote: I have the following chunk of code. Although it seems to execute fine, no errors Not True! it contains syntax errors

beginner python GUI question

2010-08-01 Thread Chris Hare
I hope I can explain this correctly. I have a GUI, which is already being processed by a mainloop. I want to be able to open a second window so the user can interact with specific information in the second window. I pulled together this code example from Tkinter import * class Net:

Re: image resize doesn't work

2010-08-01 Thread Chris Hare
And I see now what I did wrong - thanks for putting up with the questions. On Aug 1, 2010, at 4:32 PM, Peter Otten wrote: Chris Hare wrote: Thanks for the help. My one week of python is getting a workout. I have shortened it all down and made it a standalone example, using yours

Re: image resize doesn't work

2010-08-01 Thread Chris Hare
another beginner On Aug 1, 2010, at 4:32 PM, Peter Otten wrote: Chris Hare wrote: Thanks for the help. My one week of python is getting a workout. I have shortened it all down and made it a standalone example, using yours as a model. Your example, works, but it will take a lot

how best to clear objects from a frame

2010-08-01 Thread Chris Hare
Here is the situation: I have a window with a bunch of widgets in it. I want to clear the objects in a given frame and recreate them to update them. The example below destroys the top level frame, and so I can't recreate the widgets. I am likely doing this wrong. should I be doing this in

Re: beginner python GUI question

2010-08-02 Thread Chris Hare
On Aug 1, 2010, at 8:33 PM, rechardchen wrote: 于 2010-8-2 6:15, Chris Hare 写道: I hope I can explain this correctly. I have a GUI, which is already being processed by a mainloop. I want to be able to open a second window so the user can interact with specific information in the second

Re: beginner python GUI question

2010-08-02 Thread Chris Hare
On Aug 2, 2010, at 7:25 AM, Peter Otten wrote: Chris Hare wrote: root = Tk() root.title = test I should think it would work, but I don't understand why it doesn't. Try root.title(test) title() is a method that you are hiding with your attribute leading to problems later

namespaces, scoping and variables

2010-08-02 Thread Chris Hare
I am having a problem getting around this variable namespace thing. Consider these code bits File a.py from Tkinter import * import a1 def doAgain(): x = a1.Net() x.show(Again!) root = Tk() root.title(test) f = Frame(root,bg=Yellow) l = Button(root,text=window

Re: namespaces, scoping and variables

2010-08-02 Thread Chris Hare
Thanks to everyone for answering my question. I think its clear now. I'll just go the stuff 'em in a module and import that route. Chris On Aug 2, 2010, at 3:03 PM, MRAB wrote: Chris Hare wrote: I am having a problem getting around this variable namespace thing. Consider these code bits

Re: how best to clear objects from a frame

2010-08-02 Thread Chris Hare
On Aug 1, 2010, at 10:13 PM, rantingrick wrote: On Aug 1, 7:12 pm, Chris Hare ch...@labr.net wrote: Here is the situation: I have a window with a bunch of widgets in it. I want to clear the objects in a given frame and recreate them to update them. You need to check out the w.update

calling a class method from a menu in a different class

2010-08-02 Thread Chris Hare
What I am trying to do is call a class function from a menu, for example displaySubMenu.add_radiobutton(label=Medium, variable=radarPanelSize, command=radarWidgets.refresh) class radarWidgets: def __init__(self,root): self.window = root

Re: calling a class method from a menu in a different class

2010-08-03 Thread Chris Hare
No offense taken. I'll get getting the Google Python Style Guide today. I'll package up the code tonight and it to the group. Fortunately ( or unfortunately), it is all in one file right now. On Aug 2, 2010, at 10:31 PM, rantingrick wrote: Chris, It looks as if you are calling a class

Re: calling a class method from a menu in a different class

2010-08-03 Thread Chris Hare
Oh and Risk, I know I was calling the class object. class 1 creates the instance object class 2 tries to use the instance object so the problem is how to make class 2 knowledgable of instance object? I guess I could pass the instance object into the class, since class1 creates the instance

problem adding a scrollbar to a text widget

2010-08-04 Thread Chris Hare
Here is my chunk of code. I can't figure out what I am doing wrong to put my scrollbar on the right hand side of the text box. from Tkinter import * def showLogFile(): top = Toplevel() f = Frame(top, bd=0, bg=Gray) top.title = netcomm log file f.grid() sc = Scrollbar(top)

running a piece of code at specific intervals?

2010-08-04 Thread Chris Hare
Don't say cron : I want to have a section of my code executed at 15 minute intervals. I am using Threading.timer, but it is causing a problem sinxe I am using sqlite3 and the thread support gives me an error, which aborts part of my code. So, is there an alternative to threading.timer?

adding optionMenu items in code

2010-08-04 Thread Chris Hare
I have an option menu self.w = OptionMenu(self.frameNewNet, self.variable, one, two, three) Is there a way to add items to this programmatically, i.e. using values from a database? -- http://mail.python.org/mailman/listinfo/python-list

assigning variables from list data

2010-08-05 Thread Chris Hare
I have a database query result (see code below). In PHP, I would have said list(var1,var2,var) = $result and each element in the list would be assigned to each of the named variables. I have my data coming out of the database, and I can see it is a list. so my question is, instead of

defining, raising and catching exceptions

2010-08-05 Thread Chris Hare
I have a block of test code, where I am trying to raise and catch my own user defined exception class NetActiveError(RuntimeError): def __init__(self,error): self.args = error def a(): try: fh = open(me.txt, r) except Exception as (errno, errText): print

Re: defining, raising and catching exceptions

2010-08-05 Thread Chris Hare
, not the class: raise NetActiveError(net already running) And then catch the exception object except NetActiveError as err: print err.args On Thu, Aug 5, 2010 at 3:41 PM, Chris Hare ch...@labr.net wrote: I have a block of test code, where I am trying to raise and catch my own user

Re: defining, raising and catching exceptions

2010-08-05 Thread Chris Hare
On Aug 5, 2010, at 7:37 PM, MRAB wrote: Chris Hare wrote: okay - but why does the response come back like No such file or directory def b ('n', 'e', 't', ' ', 'a', 'l', 'r', 'e', 'a', 'd', 'y', ' ', 'r', 'u', 'n', 'n', 'i', 'n', 'g') The class Exception saves its arguments in the 'args

sched() function questions

2010-08-06 Thread Chris Hare
I am currently using threading.timer to execute an event in my big chunk of code. This is causing a problem with sqlite, so I am trying to figure out the sched function import sched import time def timerfunc(): print hello, time.time() return(time.time()) def delay(period):

Re: sched() function questions

2010-08-07 Thread Chris Hare
On Aug 7, 2010, at 1:30 AM, Dennis Lee Bieber wrote: On Fri, 06 Aug 2010 22:37:26 -0500, Chris Hare ch...@labr.net declaimed the following in gmane.comp.python.general: print str(s.queue()) I don't find a queue method defined for scheduler objects in the documentation for my

Tk window and contents will not display

2010-08-14 Thread Chris Hare
The scenario is this: I want to loop around all of the images in a given directory (which I know will be images, but I guess I should check), show an image in a window, wait 2 seconds and show the next one and repeat that indefinitley, which will be until the user closes the window. This is

Re: Tk window and contents will not display

2010-08-14 Thread Chris Hare
On Aug 14, 2010, at 3:14 PM, Peter Otten wrote: Chris Hare wrote: The scenario is this: I want to loop around all of the images in a given directory (which I know will be images, but I guess I should check), show an image in a window, wait 2 seconds and show the next one and repeat

Re: Tk window and contents will not display

2010-08-14 Thread Chris Hare
On Aug 14, 2010, at 5:49 PM, Peter Otten wrote: Chris Hare wrote: Thanks Peter. I threw away what I started with and merged your code into my class: class externalLoopDisplay: def show(self): main.logging.debug(externalLoopDisplay.show:,start) self.window = Tk

Re: Tk window and contents will not display

2010-08-14 Thread Chris Hare
On Aug 14, 2010, at 6:46 PM, Peter Otten wrote: Chris Hare wrote: On Aug 14, 2010, at 5:49 PM, Peter Otten wrote: Chris Hare wrote: Thanks Peter. I threw away what I started with and merged your code into my class: class externalLoopDisplay: def show(self

adding a windows item to a menu bar dynamically

2010-08-15 Thread Chris Hare
I want to add a Windows menu item to my menu bar, so when another Toplevel window is opened, I can add that to the menu bar in case the user accidentally clicks on a different window and moves the Toplevel under something else. Then when the window is closed, remove the window from the menu

python strings and {} in Tkinter entry widgets

2010-08-15 Thread Chris Hare
I have some code that pulls a value from a database. In this case, it is three space delimited words. When I display the value in a Tkinter.Entry widget, the text has curly braces around it, even when there are none in the surrounding the text in the database. Is this normal, and how do I

Re: python strings and {} in Tkinter entry widgets

2010-08-16 Thread Chris Hare
On Aug 16, 2010, at 11:40 AM, Jeff Hobbs wrote: On Aug 15, 4:41 pm, Chris Hare ch...@labr.net wrote: I have some code that pulls a value from a database. In this case, it is three space delimited words. When I display the value in a Tkinter.Entry widget, the text has curly braces around