[Tutor] Tkinter grid manager question

2011-11-26 Thread Chris Hare
Hi everyone. I am attempting to create a form for the user to complete. I have the basic layout and supporting code working, but I am having a problem with getting things to display in the grid the way I want them. self.label1 = Label(self.frame, text = "Double click o

Re: [Tutor] Shortening the code

2011-11-26 Thread Alan Gauld
On 26/11/11 16:16, Mic wrote: I will first post the entire program here, (not a lot of code) > and then ask the question. <---snipped ---> If you press the button in the first window, a new window open with all the “seats”. Say that you press one of the buttons so that it turns red. Then you

Re: [Tutor] Shortening the code

2011-11-26 Thread Peter Otten
Mic wrote: > text_file.close It has to be text_file.close() to actually do something. > text_file=open(self.filename,"w") > text_file.write(self.filename) > text_file.close() Pro-tip: this can be simplified to with open(self.filename, "w") as text_file: text_file.write(self.filename)

Re: [Tutor] Shortening the code

2011-11-26 Thread Mic
>IDLE sometimes slows things down and can occasionally lock >up with Tkinter (probably because it is itself written in Tkinter!). >It's usually better and faster to run Tkinter programs from a separate >console window. Okay, as a console window I assume the CMD terminal is OK? >What you a

Re: [Tutor] Shortening the code

2011-11-26 Thread ALAN GAULD
>> How are you running the code? > I am running it inside an IDLE. Does it matter IDLE sometimes slows things down and can occasionally lock up with Tkinter (probably because it is itself written in Tkinter!). It's usually better and faster to run Tkinter programs from a separate console wi

Re: [Tutor] Shortening the code

2011-11-26 Thread Mic
Alright! By the way, it seems like some people favour the use of pastebins, while others don?t, which is the way to go and why? I've stated my preference, Steven has stated his, so I guess you need to decide for yourself. However the best bet is not to paste long pieces of code at all, but s

Re: [Tutor] How to raise error without the stack trace

2011-11-26 Thread Rich Lovely
On 26 November 2011 11:41, Steven D'Aprano wrote: > Hugo Arts wrote: >> >> On Sat, Nov 26, 2011 at 11:16 AM, Karim wrote: >>> >>> Hello, >>> >>> I want to fire my own exception without having the (useful but ugly in my >>> case) stack trace display. >>> >>> How to modify a Exception type class fo

Re: [Tutor] Shortening the code

2011-11-26 Thread Alan Gauld
On 26/11/11 12:52, Mic wrote: Alright! By the way, it seems like some people favour the use of pastebins, while others don’t, which is the way to go and why? I've stated my preference, Steven has stated his, so I guess you need to decide for yourself. However the best bet is not to paste long

Re: [Tutor] Shortening the code

2011-11-26 Thread Mic
>Not really, but a list can handle any kind of data, even functions, >objects etc (but they are all types of data too) >I was just being specific that I meant the list of data used to >configure your widgets. I should probably just have used its name! Alright! By the way, it seems like some peop

Re: [Tutor] Shortening the code

2011-11-26 Thread ALAN GAULD
> > and text in your data list and configure each button directly: > Is there any difference between a list and a data list? Not really, but a list can handle any kind of data, even functions, objects etc (but they are all types of data too) I was just being specific that I meant the list of data

Re: [Tutor] Shortening the code

2011-11-26 Thread Peter Otten
Mic wrote: [Alan Gauld] > >def create_widgets(self): > >list_chair=[(0, 0, '01'), (0, 1, '02'), > (0, 3, '03'), (0, 4, '04'), > (1, 0, '05')] > >for row, column, name in list_chair: > >command = partial(button_clicked, button) > >bu

Re: [Tutor] How to raise error without the stack trace

2011-11-26 Thread Steven D'Aprano
Hugo Arts wrote: On Sat, Nov 26, 2011 at 11:16 AM, Karim wrote: Hello, I want to fire my own exception without having the (useful but ugly in my case) stack trace display. How to modify a Exception type class for that purpose which looks like: classs MyError(Exception): pass Cheers Ka

Re: [Tutor] Shortening the code

2011-11-26 Thread Mic
Alright! What is a fixed argument? Its onre that is the same every time the function is called. The lambda construct above is equivalent to the following which may make it clearer: def button_clicked(aButton): # do something with aButton here # that uses a lot of code and

Re: [Tutor] How to raise error without the stack trace

2011-11-26 Thread Peter Otten
Karim wrote: > I want to fire my own exception without having the (useful but ugly in > my case) stack trace display. Printing the stack trace is part of the standard exception handling. For an uncaught exception python will call sys.excepthook which in turn will print the traceback unless you

Re: [Tutor] How to raise error without the stack trace

2011-11-26 Thread Hugo Arts
On Sat, Nov 26, 2011 at 11:16 AM, Karim wrote: > > Hello, > > I want to fire my own exception without having the (useful but ugly in my > case) stack trace display. > > How to modify a Exception type class for that purpose which looks like: > > classs MyError(Exception): >       pass > > Cheers >

[Tutor] How to raise error without the stack trace

2011-11-26 Thread Karim
Hello, I want to fire my own exception without having the (useful but ugly in my case) stack trace display. How to modify a Exception type class for that purpose which looks like: classs MyError(Exception): pass Cheers Karim ___ Tutor mai

Re: [Tutor] Operation Speed Question

2011-11-26 Thread Peter Otten
Charles Karl Becker wrote: http://wiki.python.org/moin/PythonSpeed#Takeadvantageofinterpreteroptimizations%E2%80%8C%E2%80%8Bthis > is a link I found concerning optimizing the speed of python code. Is > anyone familiar with an article or wiki such as this that may cover the > changes that took pla