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 = self.make_entry(self.p

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, highligh

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, everyth

Re: Tkinter question

2010-04-23 Thread Rotwang
eb303 wrote: On Apr 23, 1:58 pm, Rotwang 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, there is already one

Re: Tkinter question

2010-04-23 Thread eb303
On Apr 23, 1:58 pm, Rotwang wrote: > eb303 wrote: > > On Apr 22, 5:55 pm, Rotwang 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 wei

Re: Tkinter question

2010-04-23 Thread Rotwang
eb303 wrote: On Apr 22, 5:55 pm, Rotwang 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 way, did you try to

Re: Tkinter question

2010-04-23 Thread eb303
On Apr 22, 5:55 pm, Rotwang wrote: > James Mills wrote: > > On Wed, Apr 21, 2010 at 8:45 PM, Rotwang 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 > >

Re: Tkinter question

2010-04-22 Thread Rotwang
eb303 wrote: On Apr 21, 12:45 pm, Rotwang 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 the suggestion, but I

Re: Tkinter question

2010-04-22 Thread Rotwang
James Mills wrote: On Wed, Apr 21, 2010 at 8:45 PM, Rotwang 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 system...). Thanks, I don't

Re: Tkinter question

2010-04-21 Thread eb303
On Apr 21, 12:45 pm, Rotwang 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. Anyway... > > I'v

Re: Tkinter question

2010-04-21 Thread James Mills
On Wed, Apr 21, 2010 at 8:45 PM, Rotwang 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 with IDLE unti

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 dimen

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 dimen

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 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, w

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 dou

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 se

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

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. -

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 TRU

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 i

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: > > 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 op

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 norma

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 windo

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 b

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... -- http://mail.python.org/mailman

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=: fn(v)).grid() > > and then the function: > > d

Re: Tkinter question

2006-10-23 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=: fn(v)).grid() and then the function: def fn(v): v['bg']='BLUE' # or maybe nametowidget(v)['bg']='BLUE' Thanks, Sorin - just give the t

Re: Tkinter question.

2006-06-17 Thread ak
Update: I found a way to do what I want with RadioButton with option indicatoron=0 which creates a bunch of what looks like regular buttons except that when one is pressed the other one is depressed and the value of the same variable is changed. Thanks dear me. [EMAIL PROTECTED] wrote: > Hi, I'd

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
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

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 (excep

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-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 "ses

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 t

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

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! -- http://mail.python.org/mailman/listinfo/python-list

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'

Re: Tkinter Question

2005-06-15 Thread Fredrik Lundh
[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 9 variables with

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", "*"

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 >>> "1".isdigit() # True only

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

Re: Tkinter question

2005-06-14 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", "*