Re: [Tutor] Creating arbitrary numbers of destinations. (GUI)

2011-12-07 Thread Mic
Thanks, although you actually missed a step somewhere - the bit where the user selects how many chairs... But ignoring that... Where do we select how many destinations you want? If we stick to 3 for now: Actually, the user never selects how many destinations that he wants. It is in the code y

Re: [Tutor] Creating arbitrary numbers of destinations. (GUI program)

2011-12-06 Thread Mic
at is clicked, two if the button labeled destination2 is clicked and so on. A is the number of the seat that is clicked. This is already working fine though! I really hope I made my intentions clearer now. Tell me if it is still unclear or confusing

[Tutor] Creating arbitrary number of destinations. (GUI program)

2011-12-06 Thread Mic
vmod(index, 4) button.grid(row=row, column=column) root=Tk() root.title("Booking Window") app=Destination1_Chairs(root) root.mainloop() root=Tk() root.title("Choose your destinati

Re: [Tutor] How to write lines in a text file (GUI)

2011-11-29 Thread Mic
Note: I'm struggling to follow your code whilst reading on my phone so the following suggestions make no reference to your particular codebase Okay I understand. Perhaps it doesn't matter. Let's first assume that all buttons could be pressed in any order, therefore given the following press

Re: [Tutor] How to write lines in a text file (GUI)

2011-11-29 Thread Mic
ou living if you are waiting for lunch? It's past dinner here, so that's why I got mails in the middle of the night! I thought most people were from UK! Mic ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] How to write lines in a text file (GUI)

2011-11-29 Thread Mic
Hey again. I figured I would first post this piece of code and then ask my questions. FREE = "green" OCCUPIED = "red" class Mainwindow(Frame): def __init__(self,master): super(Mainwindow,self).__init__(master) self.grid() self.create_mainwidgets() def create_mai

Re: [Tutor] Making a function run every second.

2011-11-29 Thread Mic
Mic wrote: I want a function to run every second , how do I do that? Say that the function look like this: def hi(): print("hi") For a script that uses tkinter there's the after() method. Example: root = Tk() def hi(): >print("ho")

Re: [Tutor] Making a function run every second.

2011-11-29 Thread Mic
-Ursprungligt meddelande- From: Dave Angel Sent: Tuesday, November 29, 2011 4:33 PM To: bod...@googlemail.com Cc: Mic ; Tutor - python List Subject: Re: [Tutor] Making a function run every second. (You put your response in the wrong place; it belongs after the part you're qu

Re: [Tutor] How to handle try and except in this case

2011-11-29 Thread Mic
-Ursprungligt meddelande- From: Dave Angel Sent: Tuesday, November 29, 2011 4:25 PM To: Mic Cc: tutor@python.org Subject: Re: [Tutor] How to handle try and except in this case (You top-posted again. Try to put your remarks AFTER the part you're quoting, so that the messa

Re: [Tutor] Making a function run every second.

2011-11-29 Thread Mic
-Ursprungligt meddelande- From: bod...@googlemail.com Sent: Tuesday, November 29, 2011 4:19 PM To: Mic ; tutor-bounces+bodsda=googlemail@python.org ; Tutor - python List Subject: Re: [Tutor] Making a function run every second. You won't get it exactly on because the ti

Re: [Tutor] How to handle try and except in this case

2011-11-29 Thread Mic
t syntax, and the only time you can have more than one of them in one statement, is the chained assignments, where they all get bound to the same object. You wouldn't want to do this anyway, since it would leave all those open files in an unspecified state. Thanks for th

[Tutor] Creating a line in a text file every time a button is pressed.

2011-11-29 Thread Mic
Hey again. I figured I would first post this piece of code and then ask my questions. FREE = "green" OCCUPIED = "red" class Mainwindow(Frame): def __init__(self,master): super(Mainwindow,self).__init__(master) self.grid() self.create_mainwidgets() def create_mai

[Tutor] Making a function run every second.

2011-11-29 Thread Mic
Hi I want a function to run every second , how do I do that? Say that the function look like this: def hi(): print("hi") Thanks! Mic ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription opt

Re: [Tutor] How to handle try and except in this case

2011-11-29 Thread Mic
On 2011-11-27 17:58, Mic wrote: Say that I want to try and open 10 files. If none of these exists, I want an error message to appear. But only if NONE of these files exists. I know how to handle this with one file. But I don't know how to do that with more than one. So the program s

Re: [Tutor] How to use try and except in this case?

2011-11-27 Thread Mic
Mic wrote: class SeatButton(tk.Button): def __init__(self, master, index): text = str(index+1) super(SeatButton, self).__init__(master, text=text, bg=FREE, command=self.clicked

Re: [Tutor] Shorten this code

2011-11-27 Thread Mic
k object while I used more. Hmm, otherwise I can see that you have bound the button in the main window to the function def uppdatera(self): SeatWindow(root) which opens the SeatWindow right? I probably missed things, but I noticed that this is much smoother than my alternative! Thanks ! Mic

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 Mic
how I can do this in your piece of code? Is it possible to do without any trouble? While this piece of code is very good, I feel that I have it easier to understand your code. Perhaps it was I who misunderstood you, sorry if that is the case, but otherwise this is what I want the code to do!

Re: [Tutor] Shortening the code

2011-11-26 Thread Mic
came to the conlcusion that if I should add the textfiles we discussed earlier on, would I somehow put them in the list, list_chair? Assuming you feel that it is time for do this, how do I implement the creation of these text files into the code that we discussed earlier? Thanks for your

Re: [Tutor] Shortening the code

2011-11-26 Thread Mic
e button features. UI means user interface, right? You should only ever have one Tk() object in a Tkinter program. Why is that? Because thats how Tkinter expects to work! It builds a tree of all the windows and widgets in your program. If you have two trees in the same program it can g

Re: [Tutor] Shortening the code of a finsihed program.

2011-11-25 Thread Mic
very confusing with events winding up in the wrong windows event queue etc. Alright, my teacher never mentioned that when he examined my program. Thanks for your input! Your help is as always appreciated and my apologize for making confusing posts! Mic ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Shortening the code.

2011-11-25 Thread Mic
k. Why is it not recommended to to mix the styles if you put the respective imports at the beginning of the module? Thanks again for your help and insightful suggestions. It is really appreciated :) Mic ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] Shortening the code of a finsihed program.

2011-11-24 Thread Mic
Good afternoon! I have previously asked questions about how I can shorten my code. I have recieved a lot of good answers, but there is one thing that never works. I can never implement the suggestions into my code, and that is my fault. I have in my previous questions only asked how to shorte

Re: [Tutor] How to shorten this code using classes?

2011-11-23 Thread Mic
I chose to ignore the "using classes" part. If you like you can turn the button_clicked() function into a method of a subclass of Button. You can also move the Button configuration done in create_widgets() into the __init__() method of that subclass. import tkinter as tk from functools import pa

[Tutor] How to shorten this code using classes?

2011-11-23 Thread Mic
now. It would be a lot of functions then, one for each button. How do I accomplish the same thing as my code does now, but using one function for all buttons instead of one function for each button? Is it possible? I hope these questions aren't stupid. Thank you for your time! Mic

Re: [Tutor] Shortening the code

2011-11-22 Thread Mic
uggestions for a couple of hours and hopefully get it to work. If I fail at that, perhaps we could "break it down into more manageable chunks". Thanks for your help once again! Mic ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Shorten Code

2011-11-22 Thread Mic
Button1 is supposed to represent chair one in the train. So call it chair_1 or put it in a list called chairs so that you can access them as chairs[0] or whatever. But get a name that reflects what its actually used for. Yes, perhaps that is a good way to go. I didn't think about that. at

[Tutor] Shortening code.

2011-11-22 Thread Mic
file with the chair's number, price and so on. I have managed to create this file without any problem. But the thing is that I have written a function for each of the chairs that does nearly the same thing. That is not good, because I want one function to do this for all chairs. I know you

Re: [Tutor] Tutor Digest, Vol 93, Issue 117

2011-11-20 Thread Mic
Message: 4 Date: Sat, 19 Nov 2011 23:18:01 + From: Alan Gauld To: tutor@python.org Subject: Re: [Tutor] Can I shorten this code? Message-ID: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Most peoples code could be shortened. And most of it would be the worse for it. There ar

[Tutor] Can I shorten this code?

2011-11-19 Thread Mic
Hi! I am new to programming and it have recently come to my attention that alot of my code could be shortened. I have managed to shorten some of the code, but I ran into a problem with this piece of code: #Testing changing color and text on two buttons in a GUI. from tkinter import* value1=

[Tutor] Shorten Code.

2011-11-18 Thread Mic
From: Wayne Werner Sent: Thursday, November 17, 2011 8:30 PM To: Mic Cc: tutor@python.org Subject: Re: [Tutor] Clock in tkinter? Say that I have a class and I want to make 100 objects. Then it could look like this: class Chairs(object): #Create the objects chair1

Re: [Tutor] Clock in tkinter?

2011-11-17 Thread Mic
If you're going to put a function inside your class (since you're using self in there, I'm sure that's what you meant to do), you should change it to: def change_value_the_time(self): and call it with self.display_time.after(20, self.change_value_the_time) But your program also has un

Re: [Tutor] Clock in tkinter?

2011-11-17 Thread Mic
From: Wayne Werner Sent: Wednesday, November 16, 2011 8:38 PM To: Mic Cc: tutor@python.org Subject: Re: [Tutor] Clock in tkinter? On Wed, Nov 16, 2011 at 11:44 AM, Mic wrote: I wonder if you have any suggestions regarding how to place widgets in my window. Even though I try to

Re: [Tutor] Clock in tkinter?

2011-11-16 Thread Mic
also place the function call there? self.update_time() as you refered to? Oh, by top-posting you mean that I include everything I have written before in my post, and that it is no good to do? So I just post what I wrote, and nothing from earlier on in

Re: [Tutor] Clock in tkinter?

2011-11-16 Thread Mic
I write an if statement that says that the computer should print “Hi” if clock>1: print (“hi”) Did I understand that correctly? Thanks for your answers! Mic From: Wayne Werner Sent: Wednesday, November 16, 2011 5:17 PM To: Mic Cc: tutor@python.org Subject: Re: [Tutor] Clock in tkin

Re: [Tutor] Clock in tkinter?

2011-11-16 Thread Mic
Thank you Yes, wise statement. Mic From: Asokan Pichai Sent: Wednesday, November 16, 2011 5:17 AM To: Mic Cc: tutor@python.org Subject: Re: [Tutor] Clock in tkinter? > On Wed, Nov 16, 2011 at 1:30 AM, Mic wrote: > Hi! > I am new to programming WELCOME! >and I hop this qu

Re: [Tutor] Clock in tkinter?

2011-11-16 Thread Mic
I thought that I could just write an if statement. Like: if the_time>15:00:00: print (“Hi, how are you?”) But it is obviously not working. Thank you for your help! Another question, am I supposed to add tutor@python.orgtu...@python.org; as copy? You did that, right? Regards Mic From:

[Tutor] Clock in tkinter?

2011-11-15 Thread Mic
Hi! I am new to programming and I hop this question isn’t stupid. I am making a small GUI program. It is supposed to have a button and a clock in it that displays the same time as it is according to the computer. So as far as I am concerned both the clock and the are supposed to be widgets? So