From gnernest at yahoo.com Thu Aug 3 10:33:59 2006 From: gnernest at yahoo.com (Mezesh) Date: Thu, 3 Aug 2006 01:33:59 -0700 (PDT) Subject: [Tkinter-discuss] Changing title bar color in Tkinter Message-ID: <5628747.post@talk.nabble.com> Hey, Does anyone know if it's possible to change the bluish color of a Tkinter window title bar to some other color (especially on linux)? Thanks, Ernest -- View this message in context: http://www.nabble.com/Changing-title-bar-color-in-Tkinter-tf2044364.html#a5628747 Sent from the Python - tkinter-discuss forum at Nabble.com. From bwmetz at att.com Thu Aug 3 18:56:03 2006 From: bwmetz at att.com (Metz, Bobby W, WWCS) Date: Thu, 3 Aug 2006 11:56:03 -0500 Subject: [Tkinter-discuss] Changing title bar color in Tkinter In-Reply-To: <5628747.post@talk.nabble.com> Message-ID: <01D5341D04A2E64AB9B34576904733670236A5CF@OCCLUST01EVS1.ugd.att.com> On Windows it's controlled by your desktop theme/settings, i.e. just every other windows program. I don't know about Linux as I don't use tkinter there. B -----Original Message----- From: tkinter-discuss-bounces at python.org [mailto:tkinter-discuss-bounces at python.org]On Behalf Of Mezesh Sent: Thursday, August 03, 2006 1:34 AM To: tkinter-discuss at python.org Subject: [Tkinter-discuss] Changing title bar color in Tkinter Hey, Does anyone know if it's possible to change the bluish color of a Tkinter window title bar to some other color (especially on linux)? Thanks, Ernest -- View this message in context: http://www.nabble.com/Changing-title-bar-color-in-Tkinter-tf2044364.html #a5628747 Sent from the Python - tkinter-discuss forum at Nabble.com. _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss at python.org http://mail.python.org/mailman/listinfo/tkinter-discuss From jepler at unpythonic.net Thu Aug 3 20:04:48 2006 From: jepler at unpythonic.net (Jeff Epler) Date: Thu, 3 Aug 2006 13:04:48 -0500 Subject: [Tkinter-discuss] Changing title bar color in Tkinter In-Reply-To: <5628747.post@talk.nabble.com> References: <5628747.post@talk.nabble.com> Message-ID: <20060803180447.GB11414@unpythonic.net> No. It is not Tkinter that draws the title bar of the window, but the window manager. You can cause the window manager not to draw any decorations on the window by setting the wm_override() but this also means you lose the ability to move and resize the window in the normal way. Usually this is a bad choice for application windows. Jeff From jrcagle at juno.com Sat Aug 12 23:13:53 2006 From: jrcagle at juno.com (Jeff Cagle) Date: Sat, 12 Aug 2006 17:13:53 -0400 Subject: [Tkinter-discuss] Dialog placement relative to main window or frame Message-ID: <44DE4491.10406@juno.com> Hi all, I'm just learning, so I apologize in advance for a possibly dumb question. I want to create an interface that has info at the top, buttons down the left side, and then a large space on the bottom right. When the user presses a button, the appropriate dialog box pops into the large space. I believe I want a dialog, rather than a simple frame, in order to be able to have a nice title bar, make use of the "Close" button, etc. Problem: How can I configure the dialog box so that it moves if the main window also moves? I thought I might use an event trigger, somthing like: mainw.bind("",func=mydialog.reconfig) ... def mydialog.reconfig(event): get coords of mainw set new coords of mydialog However, I can't find a "When the window moves" event in the docs. Thoughts? Thanks, Jeff Cagle From klappnase at web.de Sun Aug 13 02:06:52 2006 From: klappnase at web.de (Michael Lange) Date: Sun, 13 Aug 2006 02:06:52 +0200 Subject: [Tkinter-discuss] Dialog placement relative to main window or frame In-Reply-To: <44DE4491.10406@juno.com> References: <44DE4491.10406@juno.com> Message-ID: <20060813020652.10b597e8.klappnase@web.de> On Sat, 12 Aug 2006 17:13:53 -0400 Jeff Cagle wrote: > Hi all, > > I'm just learning, so I apologize in advance for a possibly dumb > question. I want to create an interface that has info at the top, > buttons down the left side, and then a large space on the bottom right. > When the user presses a button, the appropriate dialog box pops into the > large space. I believe I want a dialog, rather than a simple frame, in > order to be able to have a nice title bar, make use of the "Close" > button, etc. > > Problem: How can I configure the dialog box so that it moves if the main > window also moves? I thought I might use an event trigger, somthing like: > > mainw.bind("",func=mydialog.reconfig) > ... > > def mydialog.reconfig(event): > get coords of mainw > set new coords of mydialog > > > However, I can't find a "When the window moves" event in the docs. > Hi Jeff, the '' event seems to do what you want (at least on my linux box with IceWm). I hope this helps Michael From peru at esrf.fr Fri Aug 18 15:11:00 2006 From: peru at esrf.fr (Michel Peru) Date: Fri, 18 Aug 2006 15:11:00 +0200 Subject: [Tkinter-discuss] Cascade menu issue Message-ID: <5.2.0.9.1.20060818150824.022c74c0@pcmp2.esrf.fr> Hi all, Is there a way to make a cascade menu open when the mouse pointer simply stays on the corresponding menu entry? That works "naturally" under Windows, but under Linux one must click on the menu entry in order to make the cascade menu open. Thank you for helping. Michel ----------------------------------------------------------- Michel PERU peru at esrf.fr tel:04-76-88-22-46 ESRF 6 rue J.Horowitz 38043 Grenoble Cedex 09 ----------------------------------------------------------- From jrcagle at juno.com Sun Aug 20 07:31:51 2006 From: jrcagle at juno.com (Jeff Cagle) Date: Sun, 20 Aug 2006 01:31:51 -0400 Subject: [Tkinter-discuss] Entry widget max size In-Reply-To: References: Message-ID: <44E7F3C7.3040206@juno.com> I would like to be able to cap the size of an entry so that the user can only type a max of n characters. In practice, it may not matter, but it seems like good programming practice to have a cap on input buffers. :-) Is there any way to do such a thing? Thanks, Jeff Cagle From jrcagle at juno.com Sun Aug 20 07:35:32 2006 From: jrcagle at juno.com (Jeff Cagle) Date: Sun, 20 Aug 2006 01:35:32 -0400 Subject: [Tkinter-discuss] listbox formatting In-Reply-To: References: Message-ID: <44E7F4A4.4070604@juno.com> I have strings that are composed of multiple properties within an object. I wanted to format the strings so that they came out nicely in a listbox. However, listbox widgets choke on the '\t' character, so I tried to roll my own: def get_lbstring(self): s = self.datestring return s + " " * (20 - len(s)) + self.name unfortunately, listboxes *also* have variable-width fonts (at least as the default). Short of changing to Courier font, is there a way to get items to line up in a listbox? Thanks, Jeff Cagle From chris at niekel.net Sun Aug 20 08:57:22 2006 From: chris at niekel.net (Chris Niekel) Date: Sun, 20 Aug 2006 08:57:22 +0200 Subject: [Tkinter-discuss] listbox formatting In-Reply-To: <44E7F4A4.4070604@juno.com> References: <44E7F4A4.4070604@juno.com> Message-ID: <20060820065722.GH13685@kira.niekel.net> On Sun, Aug 20, 2006 at 01:35:32AM -0400, Jeff Cagle wrote: > unfortunately, listboxes *also* have variable-width fonts (at least as > the default). Short of changing to Courier font, is there a way to get > items to line up in a listbox? If you want to have columns in your list, it's called a table. Unfortunately, that's not standard in Tkinter. tktable.sourceforge.net gets pointed to a lot. Good luck! Chris Niekel From jrcagle at juno.com Sun Aug 20 18:42:02 2006 From: jrcagle at juno.com (Jeff Cagle) Date: Sun, 20 Aug 2006 12:42:02 -0400 Subject: [Tkinter-discuss] Tkinter-discuss Digest, Vol 30, Issue 4 In-Reply-To: References: Message-ID: <44E890DA.2070405@juno.com> I got this reply from Cameron Laird and thought it would be worth passing on. Thanks to all for their input on this and the other question. On Sun, Aug 20, 2006 at 01:31:51AM -0400, Jeff Cagle wrote: . . . >> I would like to be able to cap the size of an entry so that the user can >> only type a max of n characters. In practice, it may not matter, but >> it seems like good programming practice to have a cap on input buffers. :-) >> >> Is there any way to do such a thing? > > . . . Yes. You can use PMW; an example would be Pmw.EntryField(validate = {'max': 13}) Alternatively, you can write you own validatecommand for the Entry. Also, it might interest you that an Entry *can* be multi-line, with built-in wrapping. From Cameron at phaseit.net Sun Aug 20 18:28:24 2006 From: Cameron at phaseit.net (Cameron Laird) Date: Sun, 20 Aug 2006 16:28:24 +0000 Subject: [Tkinter-discuss] Entry widget max size In-Reply-To: <44E7F3C7.3040206@juno.com> References: <44E7F3C7.3040206@juno.com> Message-ID: <20060820162824.GA8806@lairds.us> On Sun, Aug 20, 2006 at 01:31:51AM -0400, Jeff Cagle wrote: . . . > I would like to be able to cap the size of an entry so that the user can > only type a max of n characters. In practice, it may not matter, but > it seems like good programming practice to have a cap on input buffers. :-) > > Is there any way to do such a thing? . . . Yes. You can use PMW; an example would be Pmw.EntryField(validate = {'max': 13}) Alternatively, you can write you own validatecommand for the Entry. Also, it might interest you that an Entry *can* be multi-line, with built-in wrapping. From Cameron at phaseit.net Mon Aug 21 00:15:03 2006 From: Cameron at phaseit.net (Cameron Laird) Date: Sun, 20 Aug 2006 22:15:03 +0000 Subject: [Tkinter-discuss] listbox formatting In-Reply-To: <44E7F4A4.4070604@juno.com> References: <44E7F4A4.4070604@juno.com> Message-ID: <20060820221503.GC28613@lairds.us> On Sun, Aug 20, 2006 at 01:35:32AM -0400, Jeff Cagle wrote: . . . > I have strings that are composed of multiple properties within an > object. I wanted to format the strings so that they came out nicely in > a listbox. However, listbox widgets choke on the '\t' character, so I > tried to roll my own: > > def get_lbstring(self): > s = self.datestring > return s + " " * (20 - len(s)) + self.name > > unfortunately, listboxes *also* have variable-width fonts (at least as > the default). Short of changing to Courier font, is there a way to get > items to line up in a listbox? . . . Let's be precise: do listboxes treat \t as ' '? Is that what you mean by "choke"? To get items to line up in a listbox ... well, the easiest way is to use someone else's work. Look into one of the table widgets or extensions. I like the tablelist for Tk work; I haven't had occasion yet to wrap it for use in Tkinter. From jrcagle at juno.com Tue Aug 22 05:03:57 2006 From: jrcagle at juno.com (Jeff Cagle) Date: Mon, 21 Aug 2006 23:03:57 -0400 Subject: [Tkinter-discuss] validating an entry In-Reply-To: References: Message-ID: <44EA741D.8030509@juno.com> So it turned out that validating was not too hard, but you had to Google for the documentation. Your name, Cameron, showed up a couple of times... Here's the code: # Testing an edit box with validation from Tkinter import * class MyEntry(Entry): def __init__(self, master, maxchars): Entry.__init__(self, master, validate = "key", validatecommand=self.validatecommand) self.MAX = maxchars def validatecommand(self, *args): return len(self.get()) < self.MAX if __name__ == '__main__': tkmain = Tk() e = MyEntry(tkmain, 5) e.grid() tkmain.mainloop() The validatecommand has to return a Boolean. I have no idea of the following, and haven't been able to find answers yet online: 1) what args are passed to validatecommand? Obviously *args scoops them up, but would one ever want to use them? 2) what values other than "key" are acceptable to validate? Thanks, Jeff Cagle From klappnase at web.de Tue Aug 22 11:49:28 2006 From: klappnase at web.de (Michael Lange) Date: Tue, 22 Aug 2006 11:49:28 +0200 Subject: [Tkinter-discuss] validating an entry In-Reply-To: <44EA741D.8030509@juno.com> References: <44EA741D.8030509@juno.com> Message-ID: <20060822114928.6268e128.klappnase@web.de> On Mon, 21 Aug 2006 23:03:57 -0400 Jeff Cagle wrote: > So it turned out that validating was not too hard, but you had to Google > for the documentation. Your name, Cameron, showed up a couple of times... > > Here's the code: > > # Testing an edit box with validation > > from Tkinter import * > > > class MyEntry(Entry): > > def __init__(self, master, maxchars): > Entry.__init__(self, master, validate = "key", > validatecommand=self.validatecommand) > self.MAX = maxchars > > def validatecommand(self, *args): > return len(self.get()) < self.MAX > > > if __name__ == '__main__': > tkmain = Tk() > e = MyEntry(tkmain, 5) > e.grid() > tkmain.mainloop() > > The validatecommand has to return a Boolean. I have no idea of the > following, and haven't been able to find answers yet online: > > 1) what args are passed to validatecommand? Obviously *args scoops them > up, but would one ever want to use them? > 2) what values other than "key" are acceptable to validate? > Hi Jeff, unfortunately these things do not seem to be documented for Tkinter, the Tk manpages are your friend. From the entry man page: Command-Line Name:-validate Database Name: validate Database Class: Validate Specifies the mode in which validation should operate: none, focus, focusin, focusout, key, or all. It defaults to none. When you want validation, you must explicitly state which mode you wish to use. See Validation below for more. VALIDATION Validation works by setting the validateCommand option to a script which will be evaluated according to the validate option as follows: none Default. This means no validation will occur. focus validateCommand will be called when the entry receives or loses focus. focusin validateCommand will be called when the entry receives focus. focusout validateCommand will be called when the entry loses focus. key validateCommand will be called when the entry is edited. all validateCommand will be called for all above conditions. It is possible to perform percent substitutions on the validateCommand and invalidCommand, just as you would in a bind script. The following substitutions are recognized: %d Type of action: 1 for insert, 0 for delete, or -1 for focus, forced or textvariable validation. %i Index of char string to be inserted/deleted, if any, otherwise -1. %P The value of the entry if the edit is allowed. If you are config- uring the entry widget to have a new textvariable, this will be the value of that textvariable. %s The current value of entry prior to editing. %S The text string being inserted/deleted, if any, {} otherwise. %v The type of validation currently set. %V The type of validation that triggered the callback (key, focusin, focusout, forced). %W The name of the entry widget. Passing these percent substitutions in Tkinter is a little tricky. Here is a code snippet I used to validate a Spinbox widget, it should work with an Entry just the same I think: vcmd = (self.register(self._validate), '%s', '%P') self.config(vcmd=vcmd) def _validate(self, old, new): (...) Remember that Tk will pass any values to the validatecommand as strings, even if you would expect an integer (as in '%i'). I hope this helps Michael From jepler at unpythonic.net Wed Aug 23 04:28:32 2006 From: jepler at unpythonic.net (Jeff Epler) Date: Tue, 22 Aug 2006 21:28:32 -0500 Subject: [Tkinter-discuss] Cascade menu issue In-Reply-To: <5.2.0.9.1.20060818150824.022c74c0@pcmp2.esrf.fr> References: <5.2.0.9.1.20060818150824.022c74c0@pcmp2.esrf.fr> Message-ID: <20060823022832.GC4330@unpythonic.net> The "activate_cascade" code seems to accomplish what you want. I tested it only on Ubuntu 5.10, so your mileage may vary with different Linux distributions and Tk versions. Jeff # ---------------------------------------------------------------------- import Tkinter app = Tkinter.Tk() menubar = Tkinter.Menu(app) app.configure(menu=menubar) # ---------------------------------------------------------------------- # Here's the important bit activate_cascade = """\ if {[%W cget -type] != {menubar} && [%W type active] == {cascade}} { %W postcascade active } """ app.bind_class("Menu", "<>", activate_cascade) # ---------------------------------------------------------------------- # Some testing code filemenu = Tkinter.Menu(menubar) menubar.add_cascade(label="File", menu=filemenu) newmenu = Tkinter.Menu(filemenu) filemenu.add_cascade(label="New", menu=newmenu) newmenu.add_command(label="Text") newmenu.add_command(label="Image") newmenu.add_command(label="Folder") filemenu.add_command(label="Quit", command=app.destroy) app.mainloop() # ---------------------------------------------------------------------- From rstoss at online.de Thu Aug 31 23:02:31 2006 From: rstoss at online.de (Reiner M. Stoss) Date: Thu, 31 Aug 2006 23:02:31 +0200 Subject: [Tkinter-discuss] How to get DIB into Tkinter frame? Message-ID: <44F76A87.15751.277F60@localhost> Folks, I have a problem. I have a scriptable software that works with images in FITS format (astronomical images). It can generate Windows device-independent bitmaps (DIB) and paint them as picture into any device context including Picture controls in Visual Basic, etc. Here is VB sample code that works for me: --- Private Sub Command1_Click() Set p = CreateObject("PinPoint.Plate") p.AttachFITS "M:\Images\LaSagra\20060828\012128+170000-sagra21-S001-R001.fts" Set m = p.NewPlateDIB() m.Create 1, 1, 1, 1 m.Render 60000, 0 m.PaintPicture Picture1.hDC p.DetachFITS End Sub --- The PaintPicture method sends the picture into the PictureBox Picture1. Now how to do the same in Python/Tkinter? I have something as this: --- p = win32com.client.dynamic.Dispatch('PinPoint.Plate') p.AttachFITS('M:/Images/LaSagra/20060828/012128+170000-sagra21-S001-R001.fts') m = p.NewPlateDIB() m.Create(1, 1, 1, 1) m.Render(60000, 0) m.PaintPicture(im) #Here some Tkinter lines like root = Tk() etc. def expose(event): dib = ImageWin.Dib(im) dib.expose(ImageWin.HDC(left_frame.winfo_id())) left_frame.bind("", expose) p.DetachFITS() --- But it crashes with this message: --- Traceback (most recent call last): File "L:\pin.py", line 91, in ? m.PaintPicture(im) NameError: name 'im' is not defined --- Clearly the problem is the argument I provide when I call PaintPicture(). So how to get the picture painted by PaintPicture() into a Tkinter frame? Thanks, Reiner