Re: [tkinter] question about correct use of validation

2019-01-17 Thread steve
Il 17/01/19 14:08, Peter Otten ha scritto: Alternatives: - If you know that you'll always just call pack() you can change the make_entry() method accordingly def make_entry(...): ... entry.pack() return entry - Write a helper function def pack(widget): widget.pack()

Re: [tkinter] question about correct use of validation

2019-01-17 Thread Peter Otten
steve wrote: > Il 17/01/19 14:08, Peter Otten ha scritto: > >> Two remarks: >> >>> self.id1_entry = self.make_entry(self.parent, maxlen=1).pack() >> >> You set all idX_entry attributes to None, as that's what pack() returns. > > you mean.. > > self.idx_entry =

Re: [tkinter] question about correct use of validation

2019-01-17 Thread steve
Il 17/01/19 14:08, Peter Otten ha scritto: Two remarks: self.id1_entry = self.make_entry(self.parent, maxlen=1).pack() You set all idX_entry attributes to None, as that's what pack() returns. you mean.. self.idx_entry = self.make_entry(self.parent, width=50, maxlen=30,

Re: [tkinter] question about correct use of validation

2019-01-17 Thread Peter Otten
steve wrote: > Il 16/01/19 08:51, Peter Otten ha scritto: > >> def make_ui(self): >> ''' create user interface ''' >> >> def vcmd(maxlength): >> return self.parent.register( >> partial(self.maxlength_validate, maxlength=maxlength) >>

Re: [tkinter] question about correct use of validation

2019-01-17 Thread steve
Il 16/01/19 08:51, Peter Otten ha scritto: def make_ui(self): ''' create user interface ''' def vcmd(maxlength): return self.parent.register( partial(self.maxlength_validate, maxlength=maxlength) ), "%P" ... ok following your

Re: [tkinter] question about correct use of validation

2019-01-16 Thread Peter Otten
steve wrote: > for determine the maximum number of characters in an entry > > I have read several interpretations for the solution of the problem, but > I wanted to find an alternative way (for convenience of the code) > > I kindly ask for an opinion on the use of validation in this way. > >

Re: [tkinter] question about correct use of validation

2019-01-15 Thread steve
On 15/01/2019 14:16, Rick Johnson wrote: steve wrote: Then it's just a matter of passing a keyword argument: myEntry = MyEntry(master, maxlen=20) What you have above is a tightly coiled, steaming dogpile that will litter your code base. Encapsulate that stench, would ya? sure,

Re: Tkinter question

2010-04-23 Thread eb303
On Apr 22, 5:55 pm, Rotwang sg...@hotmail.co.uk wrote: James Mills wrote: On Wed, Apr 21, 2010 at 8:45 PM, Rotwang sg...@hotmail.co.uk wrote: [...] From reading the documentation myself (pydoc)... It would seem your only option is to make a thread out of this (not my preferred way - I

Re: Tkinter question

2010-04-23 Thread Rotwang
eb303 wrote: On Apr 22, 5:55 pm, Rotwang sg...@hotmail.co.uk wrote: [...] From my experience, mixing Tkinter with threads is a bad idea. As most GUI toolkits, it really doesn't like to be manipulated from different threads, so you might end up getting weird problems or even crashes. By the

Re: Tkinter question

2010-04-23 Thread eb303
On Apr 23, 1:58 pm, Rotwang sg...@hotmail.co.uk wrote: eb303 wrote: On Apr 22, 5:55 pm, Rotwang sg...@hotmail.co.uk wrote: [...] From my experience, mixing Tkinter with threads is a bad idea. As most GUI toolkits, it really doesn't like to be manipulated from different threads, so you

Re: Tkinter question

2010-04-23 Thread Rotwang
eb303 wrote: On Apr 23, 1:58 pm, Rotwang sg...@hotmail.co.uk wrote: [...] I didn't. How do I get Python to display the draw window, other than by using mainloop()? Well, mainloop doesn't actually display anything. It's just the event loop for tk. So since you run your program within IDLE,

Re: Tkinter question

2010-04-22 Thread Rotwang
James Mills wrote: On Wed, Apr 21, 2010 at 8:45 PM, Rotwang sg...@hotmail.co.uk wrote: [...] From reading the documentation myself (pydoc)... It would seem your only option is to make a thread out of this (not my preferred way - I was hoping it was possible to poll the Tk event

Re: Tkinter question

2010-04-22 Thread Rotwang
eb303 wrote: On Apr 21, 12:45 pm, Rotwang sg...@hotmail.co.uk wrote: [...] Just run your program directly, either from a terminal or a DOS console or by double-clicking on it in a file manager if the proper file associations have been defined (they are by default on Windows). Thanks for

Re: Tkinter question

2010-04-21 Thread James Mills
On Wed, Apr 21, 2010 at 8:45 PM, Rotwang sg...@hotmail.co.uk wrote: def draw(self, w, h):        out = Tkinter.Canvas(width = w, height = h)        # a load of out.create_line(...)'s go here        out.pack()        out.mainloop() It works, but the problem is that I can't do anything else

Re: Tkinter question

2010-04-21 Thread eb303
On Apr 21, 12:45 pm, Rotwang sg...@hotmail.co.uk wrote: Apologies in advance if this is a totally stupid question, I've tried looking at the Tkinter documentation on the web but since I'm something of an ignoramus when it comes to programming generally I didn't understand what I was reading.

Re: tkinter question

2008-12-01 Thread [EMAIL PROTECTED]
On Oct 26, 7:02 am, Chuckk Hubbard [EMAIL PROTECTED] wrote: Hello. How about this?  I changed the if statements so the coordinates are always updated, but only changed if within the right limits, otherwise updated to the existing value.  Now if you drag outside the limits of one dimension, it

Re: tkinter question

2008-12-01 Thread [EMAIL PROTECTED]
On Oct 26, 7:02 am, Chuckk Hubbard [EMAIL PROTECTED] wrote: Hello. How about this?  I changed the if statements so the coordinates are always updated, but only changed if within the right limits, otherwise updated to the existing value.  Now if you drag outside the limits of one dimension, it

Re: tkinter question

2008-10-26 Thread Chuckk Hubbard
Hello. How about this? I changed the if statements so the coordinates are always updated, but only changed if within the right limits, otherwise updated to the existing value. Now if you drag outside the limits of one dimension, it still moves in the other dimension. Not sure if that's what you

Re: tkinter question

2007-10-08 Thread Eric Brunel
On Sun, 07 Oct 2007 18:09:16 +0200, Kevin Walzer [EMAIL PROTECTED] wrote: Hendrik van Rooyen wrote: Kevin Walzer [EMAIL PROTECTED] wrote: I find pack to be more flexible than grid, so I prefer it for complex layouts. grid is better for simple layouts. *does a double take* are you

RE: tkinter question

2007-10-08 Thread Hamilton, William
-Original Message- From: Kevin Walzer See http://www.codebykevin.com/blosxom/business/phynchronicity-new.png: this is an application I develop. The layout is all handled by pack and paned windows. Where you you use grid in a layout like this? I'd use a three row grid, with the

Re: tkinter question

2007-10-07 Thread Kevin Walzer
Hendrik van Rooyen wrote: Kevin Walzer [EMAIL PROTECTED] wrote: I find pack to be more flexible than grid, so I prefer it for complex layouts. grid is better for simple layouts. *does a double take* are you serious? - my experience is that pack is only good for simple single row or

Re: tkinter question

2007-10-07 Thread Kevin Walzer
Kevin Walzer wrote: Well, I guess it depends on your viewpoint. I find pack flexible because it allows me to think in terms of top, bottom, right, and left in terms of arranging UI elements--it's an elegant way to do it in my view. I tend to use grid if I have, say, a window with several

Re: tkinter question

2007-10-06 Thread Hendrik van Rooyen
Kevin Walzer [EMAIL PROTECTED] wrote: I find pack to be more flexible than grid, so I prefer it for complex layouts. grid is better for simple layouts. *does a double take* are you serious? - my experience is that pack is only good for simple single row or single column stuff. - Hendrik

Re: tkinter question

2007-10-05 Thread Eric Brunel
On Fri, 05 Oct 2007 05:16:14 +0200, goldtech [EMAIL PROTECTED] wrote: This works OK. But I notice that if I enlarge the window after the script has run, the white listbox only gets so big while the grey background enlarges. Is there a way to have it all white when I enlarge a window - like

Re: tkinter question

2007-10-05 Thread Michal Bozon
On Thu, 04 Oct 2007 20:16:14 -0700, goldtech wrote: This works OK. But I notice that if I enlarge the window after the script has run, the white listbox only gets so big while the grey background enlarges. Is there a way to have it all white when I enlarge a window - like what normally

Re: tkinter question

2007-10-05 Thread Kevin Walzer
Eric Brunel wrote: BTW, even for something that simple, using the grid geometry manager may be easier... It is at least easier to explain: don't ask me what the expand=1 option means, I never understood it... I just add or remove it when the pack doesn't do what I want. The sticky option

Re: tkinter question

2007-10-05 Thread Eric Brunel
On Fri, 05 Oct 2007 14:10:57 +0200, Kevin Walzer [EMAIL PROTECTED] wrote: expand = 1 == expand=TRUE--that means the widget resizes itself when the window is re-sized. That's the theory... But what does fill=BOTH means then? And why does expand=1 (or TRUE, or True) is only needed in some

Re: tkinter question

2007-10-05 Thread goldtech
try to change listbox.pack() to listbox.pack(expand=True, fill=BOTH) .. is it that you want ? Yes. -mykhal Worked with TRUE all uppercase. Exactly what I needed. Thank you. -- http://mail.python.org/mailman/listinfo/python-list

Re: tkinter question

2007-10-05 Thread Kevin Walzer
Eric Brunel wrote: On Fri, 05 Oct 2007 14:10:57 +0200, Kevin Walzer [EMAIL PROTECTED] wrote: expand = 1 == expand=TRUE--that means the widget resizes itself when the window is re-sized. That's the theory... But what does fill=BOTH means then? And why does expand=1 (or TRUE, or True) is

Re: Tkinter question

2006-10-25 Thread Hendrik van Rooyen
Fredrik Lundh [EMAIL PROTECTED] wrote: Eric Brunel wrote: But Hendrik's solution is better, since it avoids the use of lambda, which is often difficult to understand. storing the button reference in a variable doesn't help if you want to use the same callback for multiple buttons,

Re: Tkinter question

2006-10-24 Thread Hendrik van Rooyen
Sorin Schwimmer wrote: Hi All, Is it possible to have a widget id while it is created? Something like this: Button(root, text='...', command= lambda v=widget id: fn(v)).grid() and then the function: def fn(v): v['bg']='BLUE' # or maybe nametowidget(v)['bg']='BLUE' Thanks, Sorin - just

Re: Tkinter question

2006-10-24 Thread Eric Brunel
On Tue, 24 Oct 2006 07:48:51 +0200, Hendrik van Rooyen [EMAIL PROTECTED] wrote: Sorin Schwimmer wrote: Hi All, Is it possible to have a widget id while it is created? Something like this: Button(root, text='...', command= lambda v=widget id: fn(v)).grid() and then the function: def

Re: Tkinter question

2006-10-24 Thread Fredrik Lundh
Eric Brunel wrote: But Hendrik's solution is better, since it avoids the use of lambda, which is often difficult to understand. storing the button reference in a variable doesn't help if you want to use the same callback for multiple buttons, though... /F --

Re: Tkinter question

2006-05-31 Thread John McMonagle
On Wed, 2006-05-31 at 11:37 -0400, david brochu jr wrote: I am trying to create a GUI that will display a new window with information about my program when the user clicks on the info button (a green i bitmap). So far all I can get my program to do is show the new window (using Toplevel() )

Re: tkinter question

2006-03-30 Thread Eric Brunel
(Please quote a part of the message you're replying to; I had problems figuring out you were replying to my post...) On 29 Mar 2006 14:08:02 -0800, [EMAIL PROTECTED] wrote: Ultimately what I am trying to is create a public computer session manager. 1) User logs in and main application

Re: tkinter question

2006-03-30 Thread linuxnooby
If you just create a Toplevel and populate it with widgets, it will just display once the control is returned to the Tkinter mainloop and no user input will be needed. Thanks for explaining that. I borrowed the after method that you used in your first reply. It seems to do what I want (except for

Re: tkinter question

2006-03-30 Thread Eric Brunel
On 30 Mar 2006 15:11:19 -0800, [EMAIL PROTECTED] wrote: If you just create a Toplevel and populate it with widgets, it will just display once the control is returned to the Tkinter mainloop and no user input will be needed. Thanks for explaining that. I borrowed the after method that you

Re: tkinter question

2006-03-29 Thread linuxnooby
Ultimately what I am trying to is create a public computer session manager. 1) User logs in and main application window is withdrawn (easy) 2) After (for example) 55 minutes - a warning window/dialoguebox session will end in 5 minutes 3) With 30 seconds to go - a warning window/dialoguebox

Re: tkinter question

2006-03-27 Thread Eric Brunel
On 27 Mar 2006 15:15:05 -0800, [EMAIL PROTECTED] wrote: Hi I have a tkinter question. In the following script the window will not display until the script has finished executing. It appears at the same time as the output script finished. How can I make it appear immediately, with the output

Re: Tkinter Question

2005-06-16 Thread Martin Franklin
Fredrik Lundh wrote: [EMAIL PROTECTED] wrote: Thanks for all the help guys... I'm a bit confused as to the inner workings of the Tkinter system (I'm both a Python and a GUI n00b). I was hoping that by slapping the x on button python was doing some cool dynamic variable creation (i.e. creating

Re: Tkinter question

2005-06-15 Thread Martin Franklin
[EMAIL PROTECTED] wrote: I'm sure there must be a way to do this, but I can't figure it out for the life of me I'm writing a program where I would like to use a button's text field as part of an if statement. I set up my button like this: i = [ 7, 8,9, /, 4, 5, 6, *, 1, 2, 3, -, 0, .,

Re: Tkinter question

2005-06-15 Thread Martin Franklin
I realise I was a bit short on advice earlier... Martin Franklin wrote: [EMAIL PROTECTED] wrote: I'm sure there must be a way to do this, but I can't figure it out for the life of me I'm writing a program where I would like to use a button's text field as part of an if statement. I set up

Re: Tkinter question

2005-06-15 Thread Peter Otten
[EMAIL PROTECTED] wrote: [I didn't see the original post, so just in case noone mentioned it] if(self.buttonx.title.isdigit): Nicholas, the method is not called unless you add parentheses, e. g: 1.isdigit # a bound method *always* True in a boolean context built-in method isdigit of str

Re: Tkinter question

2005-06-15 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: I'm sure there must be a way to do this, but I can't figure it out for the life of me... I'm writing a program where I would like to use a button's text field as part of an if statement. I set up my button like this: i = [ 7, 8,9, /, 4, 5, 6, *, 1, 2, 3, -, 0, .,

Re: Tkinter question

2005-06-15 Thread Peter Otten
Fredrik Lundh wrote: note that you're assigning all buttons to the same instance variable, so even if the above did work, it would always return a plus. since the command callback doesn't know what widget it was called from, you need to create a separate callback for each widget.  here's

Re: Tkinter question

2005-06-15 Thread Fredrik Lundh
Peter Otten wrote: Change the above function to def callback(text=text): self.pressed(text) argh! /F -- http://mail.python.org/mailman/listinfo/python-list