From sierra_mtnview at sbcglobal.net Wed Apr 1 16:20:04 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Wed, 01 Apr 2009 07:20:04 -0700 Subject: [Tkinter-discuss] Default Tkinter Structure of a 640x480 PIL BMP File? Message-ID: <49D37814.2090502@sbcglobal.net> An HTML attachment was scrubbed... URL: From michael.odonnell at uam.es Wed Apr 1 19:10:19 2009 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Wed, 1 Apr 2009 19:10:19 +0200 Subject: [Tkinter-discuss] Default Tkinter Structure of a 640x480 PIL BMPFile? In-Reply-To: <49D37814.2090502@sbcglobal.net> References: <49D37814.2090502@sbcglobal.net> Message-ID: <47e491110904011010j7b39a212r80a5b40ab2589d97@mail.gmail.com> Dear Wayne, Probably better directed at the PIL/Image list: http://mail.python.org/mailman/listinfo/image-sig In any case a BMP file has a structure independent of the software which reads it, do a google for bmp to find information on it. Once an image is loaded into PIL, PIL offers methods to access the image. See PIL documentation for these methods: http://www.pythonware.com/library/pil/handbook/index.htm Mick 2009/4/1 Wayne Watson : > See Subject. Does it have a header, DIB,? palette, and data section? What is > the default depth? > -- > > Wayne Watson (Watson Adventures, Prop., Nevada City, CA) > > (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) > > > The Obama Administration plans to double the production > in solar energy from 1% to 2% of the total energy > supply in the next few years. One nuclear reaction > would do the same. Heard on Bill Wattenburg, KGO-AM > > "Less than all cannot satisfy Man." -- William Blake > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > From sierra_mtnview at sbcglobal.net Wed Apr 1 21:43:25 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Wed, 01 Apr 2009 12:43:25 -0700 Subject: [Tkinter-discuss] Default Tkinter Structure of a 640x480 PIL BMPFile? In-Reply-To: <47e491110904011010j7b39a212r80a5b40ab2589d97@mail.gmail.com> References: <49D37814.2090502@sbcglobal.net> <47e491110904011010j7b39a212r80a5b40ab2589d97@mail.gmail.com> Message-ID: <49D3C3DD.4090404@sbcglobal.net> An HTML attachment was scrubbed... URL: From igor.e.novikov at gmail.com Wed Apr 1 22:08:38 2009 From: igor.e.novikov at gmail.com (Igor Novikov) Date: Wed, 1 Apr 2009 23:08:38 +0300 Subject: [Tkinter-discuss] Default Tkinter Structure of a 640x480 PIL BMPFile? In-Reply-To: <49D3C3DD.4090404@sbcglobal.net> References: <49D37814.2090502@sbcglobal.net> <47e491110904011010j7b39a212r80a5b40ab2589d97@mail.gmail.com> <49D3C3DD.4090404@sbcglobal.net> Message-ID: <23f7fc190904011308l40aa4904jc2c73dde6705f19b@mail.gmail.com> Hi Wayne, I think you can find an answer in PIL source code. Take look at Imaging.h The header contains Imaging object definition. Loaded image is not BMP, PNG, TIFF or any other storage format because it's impossible to process image in memory using storage format structure (for example, they often use compression). Sincerely, Igor Novikov sK1 Project http://sk1project.org 2009/4/1 Wayne Watson > Thanks, but there seem to be an unending # of mail lists for Python. > I've rummaged around the link before you gave, but zippo. I just tried this > on Google: > > bmp bits site:http://www.pythonware.com/library/pil/handbook/index.htm > > It searches the entire site. Zippo again. > > I guess it's another mail list to join. > > Whoops, this a better search: > bmp bits site: http://www.pythonware.com/library/pil/ > > Nothing of interest. Well, maybe I stuck in 24 and one hit discusses > decoder. > > Michael O'Donnell wrote: > > Dear Wayne, > > Probably better directed at the PIL/Image list: > http://mail.python.org/mailman/listinfo/image-sig > > In any case a BMP file has a structure independent of the software which > reads it, do a google for bmp to find information on it. > > Once an image is loaded into PIL, PIL offers methods to access > the image. See PIL documentation for these methods: > http://www.pythonware.com/library/pil/handbook/index.htm > > Mick > > 2009/4/1 Wayne Watson : > > > See Subject. Does it have a header, DIB, palette, and data section? What is > the default depth? > -- > > Wayne Watson (Watson Adventures, Prop., Nevada City, CA) > > (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) > > > The Obama Administration plans to double the production > in solar energy from 1% to 2% of the total energy > supply in the next few years. One nuclear reaction > would do the same. Heard on Bill Wattenburg, KGO-AM > > "Less than all cannot satisfy Man." -- William Blake > > > _______________________________________________ > Tkinter-discuss mailing listTkinter-discuss at python.orghttp://mail.python.org/mailman/listinfo/tkinter-discuss > > > > -- > > Wayne Watson (Watson Adventures, Prop., Nevada City, CA) > > (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)** > The Obama Administration plans to double the production > in solar energy from 1% to 2% of the total energy > supply in the next few years. One nuclear reaction > would do the same. Heard on Bill Wattenburg, KGO-AM > > "Less than all cannot satisfy Man." -- William Blake > > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From sierra_mtnview at sbcglobal.net Wed Apr 1 22:21:40 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Wed, 01 Apr 2009 13:21:40 -0700 Subject: [Tkinter-discuss] Default Tkinter Structure of a 640x480 PIL BMP File? Message-ID: <49D3CCD4.4090504@sbcglobal.net> An HTML attachment was scrubbed... URL: From sierra_mtnview at sbcglobal.net Wed Apr 1 22:29:29 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Wed, 01 Apr 2009 13:29:29 -0700 Subject: [Tkinter-discuss] Default Tkinter Structure of a 640x480 PIL BMPFile? In-Reply-To: <23f7fc190904011308l40aa4904jc2c73dde6705f19b@mail.gmail.com> References: <49D37814.2090502@sbcglobal.net> <47e491110904011010j7b39a212r80a5b40ab2589d97@mail.gmail.com> <49D3C3DD.4090404@sbcglobal.net> <23f7fc190904011308l40aa4904jc2c73dde6705f19b@mail.gmail.com> Message-ID: <49D3CEA9.9020707@sbcglobal.net> An HTML attachment was scrubbed... URL: From igor.e.novikov at gmail.com Wed Apr 1 22:54:31 2009 From: igor.e.novikov at gmail.com (Igor Novikov) Date: Wed, 1 Apr 2009 23:54:31 +0300 Subject: [Tkinter-discuss] Default Tkinter Structure of a 640x480 PIL BMPFile? In-Reply-To: <49D3CEA9.9020707@sbcglobal.net> References: <49D37814.2090502@sbcglobal.net> <47e491110904011010j7b39a212r80a5b40ab2589d97@mail.gmail.com> <49D3C3DD.4090404@sbcglobal.net> <23f7fc190904011308l40aa4904jc2c73dde6705f19b@mail.gmail.com> <49D3CEA9.9020707@sbcglobal.net> Message-ID: <23f7fc190904011354t6bf8f1d8gd4c35dbda89a97a3@mail.gmail.com> Sorry you have mixed in question three different instances: BMP, PIL and Tkinter. PIL can works without Tkinter. So PIL image objects don't depend on Tkinter. But PIL can generates tcl/tk image objects for UI use cases. BMP is a storage format. It's just an image file but not an image object in memory. So please clarify your question. Which information you need or which code you wish implementing? On Wed, Apr 1, 2009 at 11:29 PM, Wayne Watson wrote: > I'm using Win Python, and have some small familiarity with library > compents. How do I find Imaging.h? > > > Igor Novikov wrote: > > Hi Wayne, > > I think you can find an answer in PIL source code. Take look at Imaging.h > The header contains Imaging object definition. Loaded image is not BMP, > PNG, TIFF > or any other storage format because it's impossible to process image in > memory > using storage format structure (for example, they often use compression). > > Sincerely, > > Igor Novikov > sK1 Project > http://sk1project.org > > 2009/4/1 Wayne Watson > >> Thanks, but there seem to be an unending # of mail lists for Python. >> I've rummaged around the link before you gave, but zippo. I just tried >> this on Google: >> >> bmp bits site:http://www.pythonware.com/library/pil/handbook/index.htm >> >> It searches the entire site. Zippo again. >> >> I guess it's another mail list to join. >> >> Whoops, this a better search: >> bmp bits site: http://www.pythonware.com/library/pil/ >> >> Nothing of interest. Well, maybe I stuck in 24 and one hit discusses >> decoder. >> >> Michael O'Donnell wrote: >> >> Dear Wayne, >> >> Probably better directed at the PIL/Image list: >> http://mail.python.org/mailman/listinfo/image-sig >> >> In any case a BMP file has a structure independent of the software which >> reads it, do a google for bmp to find information on it. >> >> Once an image is loaded into PIL, PIL offers methods to access >> the image. See PIL documentation for these methods: >> http://www.pythonware.com/library/pil/handbook/index.htm >> >> Mick >> >> 2009/4/1 Wayne Watson : >> >> >> See Subject. Does it have a header, DIB, palette, and data section? What is >> the default depth? >> -- >> >> Wayne Watson (Watson Adventures, Prop., Nevada City, CA) >> >> (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) >> >> >> The Obama Administration plans to double the production >> in solar energy from 1% to 2% of the total energy >> supply in the next few years. One nuclear reaction >> would do the same. Heard on Bill Wattenburg, KGO-AM >> >> "Less than all cannot satisfy Man." -- William Blake >> >> >> _______________________________________________ >> Tkinter-discuss mailing listTkinter-discuss at python.orghttp://mail.python.org/mailman/listinfo/tkinter-discuss >> >> >> >> -- >> >> Wayne Watson (Watson Adventures, Prop., Nevada City, CA) >> >> (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)** >> The Obama Administration plans to double the production >> in solar energy from 1% to 2% of the total energy >> supply in the next few years. One nuclear reaction >> would do the same. Heard on Bill Wattenburg, KGO-AM >> >> "Less than all cannot satisfy Man." -- William Blake >> >> >> >> _______________________________________________ >> Tkinter-discuss mailing list >> Tkinter-discuss at python.org >> http://mail.python.org/mailman/listinfo/tkinter-discuss >> >> > > -- > > Wayne Watson (Watson Adventures, Prop., Nevada City, CA) > > (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)** > The Obama Administration plans to double the production > in solar energy from 1% to 2% of the total energy > supply in the next few years. One nuclear reaction > would do the same. Heard on Bill Wattenburg, KGO-AM > > "Less than all cannot satisfy Man." -- William Blake > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From sierra_mtnview at sbcglobal.net Thu Apr 2 03:53:58 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Wed, 01 Apr 2009 18:53:58 -0700 Subject: [Tkinter-discuss] Default Tkinter Structure of a 640x480 PIL BMPFile? In-Reply-To: <23f7fc190904011354t6bf8f1d8gd4c35dbda89a97a3@mail.gmail.com> References: <49D37814.2090502@sbcglobal.net> <47e491110904011010j7b39a212r80a5b40ab2589d97@mail.gmail.com> <49D3C3DD.4090404@sbcglobal.net> <23f7fc190904011308l40aa4904jc2c73dde6705f19b@mail.gmail.com> <49D3CEA9.9020707@sbcglobal.net> <23f7fc190904011354t6bf8f1d8gd4c35dbda89a97a3@mail.gmail.com> Message-ID: <49D41AB6.3000409@sbcglobal.net> An HTML attachment was scrubbed... URL: From madhu.subramaniam at gmail.com Tue Apr 7 11:37:03 2009 From: madhu.subramaniam at gmail.com (Madhu Subramaniam) Date: Tue, 7 Apr 2009 11:37:03 +0200 Subject: [Tkinter-discuss] Font change does reflect window size when executed without debugging Message-ID: <8e794c8a0904070237r39f2a650y583bec5e9def7463@mail.gmail.com> Hi, Below is an application with a scrollable frame. There is an option to change the font size of the text, (using tkFont) thereby changing the size of the widgets and the containers. this is done by the function 'fontctrl'. The thing i am not able to figure out is that the change in window size works when i put a breakpoint/debugger (pdb.set_trace()) and exceute them manually in the shell. But when i run w/o debugging, then the print statements do not show me the change in window size. for example, when the font is medium: self2.winfo_height() shows 840 with debugging but 600 without the debugger in place. Python version 2.5.2, Tkinter 8.4, OS: Linux, Ubuntu ----------------------------------------------------------------- (see code below) from Tkinter import * import math import tkColorChooser import pdb import os import string import threading from tkFileDialog import * from tkMessageBox import * import sys import tkFont def window2(fr1,root): #Structure # root window #------------------------------------- # | # | # | # fr1 (frame) #------------------------------------------------------------------------- # | | | # | | | # | | | # Menu Button can(Canvas) Scrollbars (vertical and horizontal) #----------------------------------------------------------------------------------- # | | # | | # | | #menu with radiobuttons fr2(Frame-create_window) # for font change | # | # 2 rows of labels, optionmenu def fontctrl( rval,self1,self2, can_fr2=0, can=0,fr1=0): # Change in size (viewed with help of the print statements) found, only when implemented with debugging!!, # if pdb.set_trace() is removed, then the change in size is not reflected in the print statements! #pdb.set_trace() self2.minsize(width = 10, height = 10) self2.maxsize(width = 4000, height = 2000) if rval == 1: self1.configure(size=10) self2.update_idletasks() self2.minsize(width = self2.winfo_width(), height = 640) self2.maxsize(width = self2.winfo_width(), height = 640) self2.update_idletasks() print '#----------------------------------' print 'Schrift G: small' print 'self2.winfo_height(): ', self2.winfo_height() print 'fr1.winfo_height(): ', fr1.winfo_height() print 'can.winfo_height(): ' , can.winfo_height() print 'can_fr2.winfo_height(): ' , can_fr2.winfo_height() print '#----------------------------------' if rval == 2: self1.configure(size=14) self2.update_idletasks() self2.minsize(width = self2.winfo_width(), height = 840) self2.maxsize(width = self2.winfo_width(), height = 840) self2.update_idletasks() print '#----------------------------------' print 'Schrift G: Medium' print 'self2.winfo_height(): ', self2.winfo_height() print 'fr1.winfo_height(): ', fr1.winfo_height() print 'can.winfo_height(): ' , can.winfo_height() print 'can_fr2.winfo_height(): ' , can_fr2.winfo_height() print '#----------------------------------' if rval == 3: self1.configure(size=16) self2.update_idletasks() self2.minsize(width = self2.winfo_width(), height = 940) self2.maxsize(width = self2.winfo_width(), height = 940) self2.update_idletasks() print '#----------------------------------' print 'Schrift G: Big' print 'self2.winfo_height(): ', self2.winfo_height() print 'fr1.winfo_height(): ', fr1.winfo_height() print 'can.winfo_height(): ' , can.winfo_height() print 'can_fr2.winfo_height(): ' , can_fr2.winfo_height() print '#----------------------------------' try: can_fr2.update_idletasks() can.update_idletasks() can.config(scrollregion=(0,0,max(can.winfo_width(), can_fr2.winfo_width()),max(can.winfo_height(), can_fr2.winfo_height()))) scrollx.update_idletasks() scrolly.update_idletasks() except: pass global content #font and grid options for fr1 #------------------------------------------------------------------------------------------------- fonts = tkFont.Font(family="MS Sans Serif",size=12, weight="bold") fr1.grid_columnconfigure(0,weight=1) fr1.grid_rowconfigure(1,weight=1) fr_menu= Frame(fr1, bg= 'turquoise') fr_menu.grid_propagate(1) root.grid_rowconfigure(0,weight=1) root.grid_columnconfigure(0,weight=1) fr_menu.grid(row=0,column=0, sticky = 'news') #Canvas, scrollbars #---------------------------------------------------------------------------------------------------------------------------------------------------------- can= Canvas(fr1, relief='groove') can.grid(row=1, column=0, sticky = 'news') can.fr2 = Frame(can, width = 100, height = 50) var1= StringVar() var1.set('1') scrollx= Scrollbar(fr1, orient=HORIZONTAL) scrolly= Scrollbar(fr1, orient=VERTICAL) scrollx.config(command=can.xview) scrolly.config(command=can.yview) scrollx.grid(row=2,column=0, sticky= S+E+W,columnspan=3) scrolly.grid(row=0,column=2, sticky= N+S+E, rowspan=2) can.config(xscrollcommand=scrollx.set) # Frame fr2 created om the canvas , holding widgets #---------------------------------------------------------------------------------------------------------------------------------------------------------- font=fonts om1 = OptionMenu(can.fr2, var1, '1', '2', '3') lbl = Label(can.fr2, text= content[0], justify = 'left', font=fonts) lbl1 = Label(can.fr2, text= 'Hello', font=fonts) lbl2 = Label(can.fr2, text= content[1], justify = 'left', font=fonts) lbl.grid(row=0, column=0, padx = 15) lbl1.grid(row=0, column=1, padx = 15) om1.grid(row=0, column=2, padx = 15) lbl2.grid(row=0, column=3, padx = 15) var1_a= StringVar() var1_a.set('A') om1_a = OptionMenu(can.fr2, var1_a, 'A', 'B', 'C') lbl_a = Label(can.fr2, text= content[0], justify = 'left', font=fonts) lbl1_a = Label(can.fr2, text= 'Hello', font=fonts) lbl2_a= Label(can.fr2, text= content[1], justify = 'left', font=fonts) lbl_a.grid(row=1, column=0, padx = 15) lbl1_a.grid(row=1, column=1, padx = 15) om1_a.grid(row=1, column=2, padx = 15) lbl2_a.grid(row=1, column=3, padx = 15) can.fr2.m1=can.create_window(0,0, window= can.fr2, anchor = 'nw') print can.coords(can.fr2.m1) can.config(yscrollcommand=scrolly.set) can.xview(MOVETO, 0.0) can.yview(MOVETO, 1.0) can.fr2.update_idletasks() can.update_idletasks() can.config(scrollregion=(0,0,can.winfo_width(),max(can.winfo_height(), can.fr2.winfo_height()))) can.grid_propagate(0) can.update_idletasks() #Menu button and radiobuttons for font change #--------------------------------------------------- fr_menu_but=Menubutton(fr1, text="Optionen", font = fonts , underline=0) fr_menu_but.menu = Menu(fr_menu_but, tearoff=0) fr_menu_but.menu.font = Menu(fr_menu_but.menu, tearoff=0) rval = IntVar() rval.set(2) winsize = ['Small','Medium','Big'] for i,x in enumerate(winsize): fr_menu_but.menu.font.add_radiobutton(label=x, font = fonts, var= rval, val=i+1, command = (lambda: fontctrl(rval.get(),fonts,root,can.fr2,can,fr1))) fr_menu_but.menu.add_cascade(label="Schrift-Groesse", font = fonts, menu=fr_menu_but.menu.font, underline=0) fr_menu_but['menu'] = fr_menu_but.menu fr_menu_but.update_idletasks() fr_menu_but.grid(row=0, column=0) fontctrl(rval.get(),fonts,root,can.fr2,can,fr1) root.update_idletasks() #MAIN ROUTINE #------------------------------------------ global content content=[ '/xxx/yyyyyy/aaa/bbbb/tttttt/rrrrrrrr/', '/xxx/yyyyyy/aaa/bbbb/tttttt/rrrrrrrr/', '/xxx/yyyyyy/aaa/bbbb/tttttt/rrrrrrrr/', '/xxx/yyyyyy/aaa/bbbb/tttttt/rrrrrrrr/'] root= Tk() root.tk.call('tk', 'scaling', 1) fr1= Frame(root, width= 900, height= 600, bg='red') fr1.grid(row=0,column=0, sticky='news') fr1.grid_propagate(0) window2(fr1,root) root.mainloop() -------------- next part -------------- An HTML attachment was scrubbed... URL: From sierra_mtnview at sbcglobal.net Tue Apr 7 12:12:23 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 07 Apr 2009 03:12:23 -0700 Subject: [Tkinter-discuss] Default Tkinter Structure of a 640x480 PIL BMPFile? In-Reply-To: <23f7fc190904020216g669e470clb5db9c270c7b5c23@mail.gmail.com> References: <49D37814.2090502@sbcglobal.net> <47e491110904011010j7b39a212r80a5b40ab2589d97@mail.gmail.com> <49D3C3DD.4090404@sbcglobal.net> <23f7fc190904011308l40aa4904jc2c73dde6705f19b@mail.gmail.com> <49D3CEA9.9020707@sbcglobal.net> <23f7fc190904011354t6bf8f1d8gd4c35dbda89a97a3@mail.gmail.com> <49D41AB6.3000409@sbcglobal.net> <23f7fc190904020216g669e470clb5db9c270c7b5c23@mail.gmail.com> Message-ID: <49DB2707.7030404@sbcglobal.net> An HTML attachment was scrubbed... URL: From igor.e.novikov at gmail.com Tue Apr 7 13:06:57 2009 From: igor.e.novikov at gmail.com (Igor Novikov) Date: Tue, 7 Apr 2009 14:06:57 +0300 Subject: [Tkinter-discuss] Default Tkinter Structure of a 640x480 PIL BMPFile? In-Reply-To: <49DB2707.7030404@sbcglobal.net> References: <49D37814.2090502@sbcglobal.net> <47e491110904011010j7b39a212r80a5b40ab2589d97@mail.gmail.com> <49D3C3DD.4090404@sbcglobal.net> <23f7fc190904011308l40aa4904jc2c73dde6705f19b@mail.gmail.com> <49D3CEA9.9020707@sbcglobal.net> <23f7fc190904011354t6bf8f1d8gd4c35dbda89a97a3@mail.gmail.com> <49D41AB6.3000409@sbcglobal.net> <23f7fc190904020216g669e470clb5db9c270c7b5c23@mail.gmail.com> <49DB2707.7030404@sbcglobal.net> Message-ID: <23f7fc190904070406y2db0fefbr5e66286b52858c4d@mail.gmail.com> There should be index.html in root folder PIL. The file redirects your browser inside pil folder to simplify doc searching. But this file uses JavaScript for redirecting, so JS should be allowed in your default browser. Regards, Igor Novikov sK1 Project http://sk1pro 2009/4/7 Wayne Watson > I downloaded the tar.gz file to Win and tried to open the hmtl and css(?) > files there. The css file shows a tangle of words and characters. The html > file I tried produces an invalid page. > > Igor Novikov wrote: > > If you need to change Imaging object directly or create it from s?ratch > such way requires low level programming, i.e. either > C-extension or ctypes module usage. Another way is standard PIL API usage. > The API is a python wrapper for Imaging > objects and according processing methods. I think your issue can be > resolved by usual PIL API without low level tricks. > Detailed PIL html docs you can download here: > > http://sk1project.org/downloads/PIL.tar.gz > > I hope this helps. > > On Thu, Apr 2, 2009 at 4:53 AM, Wayne Watson > wrote: > >> Yes, three items, format, memory, etc. That's not the issue. >> >> My question was directed specifically to your comment about Imaging.h. >> Imaging.h looks like a C-program header file. I use Python with Windows XP. >> Where do I look in Python to find the equivalent of Imaging.h. >> >> I think my answer requires a post to the PIL mail list. >> >> Igor Novikov wrote: >> >> Sorry you have mixed in question three different instances: BMP, PIL and >> Tkinter. >> PIL can works without Tkinter. So PIL image objects don't depend on >> Tkinter. >> But PIL can generates tcl/tk image objects for UI use cases. >> BMP is a storage format. It's just an image file but not an image object >> in memory. >> So please clarify your question. Which information you need or which code >> you >> wish implementing? >> >> >> On Wed, Apr 1, 2009 at 11:29 PM, Wayne Watson < >> sierra_mtnview at sbcglobal.net> wrote: >> >>> I'm using Win Python, and have some small familiarity with library >>> compents. How do I find Imaging.h? >>> >>> Igor Novikov wrote: >>> >>> Hi Wayne, >>> >>> I think you can find an answer in PIL source code. Take look at Imaging.h >>> The header contains Imaging object definition. Loaded image is not BMP, >>> PNG, TIFF >>> or any other storage format because it's impossible to process image in >>> memory >>> using storage format structure (for example, they often use compression). >>> >>> Sincerely, >>> >>> Igor Novikov >>> sK1 Project >>> http://sk1project.org >>> >>> 2009/4/1 Wayne Watson >>> >>>> Thanks, but there seem to be an unending # of mail lists for Python. >>>> I've rummaged around the link before you gave, but zippo. I just tried >>>> this on Google: >>>> >>>> bmp bits site:http://www.pythonware.com/library/pil/handbook/index.htm >>>> >>>> It searches the entire site. Zippo again. >>>> >>>> I guess it's another mail list to join. >>>> >>>> Whoops, this a better search: >>>> bmp bits site: http://www.pythonware.com/library/pil/ >>>> >>>> Nothing of interest. Well, maybe I stuck in 24 and one hit discusses >>>> decoder. >>>> >>>> Michael O'Donnell wrote: >>>> >>>> Dear Wayne, >>>> >>>> Probably better directed at the PIL/Image list: >>>> http://mail.python.org/mailman/listinfo/image-sig >>>> >>>> In any case a BMP file has a structure independent of the software which >>>> reads it, do a google for bmp to find information on it. >>>> >>>> Once an image is loaded into PIL, PIL offers methods to access >>>> the image. See PIL documentation for these methods: >>>> http://www.pythonware.com/library/pil/handbook/index.htm >>>> >>>> Mick >>>> >>>> 2009/4/1 Wayne Watson : >>>> >>>> >>>> See Subject. Does it have a header, DIB, palette, and data section? What is >>>> the default depth? >>>> -- >>>> >>>> Wayne Watson (Watson Adventures, Prop., Nevada City, CA) >>>> >>>> (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) >>>> >>>> >>>> The Obama Administration plans to double the production >>>> in solar energy from 1% to 2% of the total energy >>>> supply in the next few years. One nuclear reaction >>>> would do the same. Heard on Bill Wattenburg, KGO-AM >>>> >>>> "Less than all cannot satisfy Man." -- William Blake >>>> >>>> >>>> _______________________________________________ >>>> Tkinter-discuss mailing listTkinter-discuss at python.orghttp://mail.python.org/mailman/listinfo/tkinter-discuss >>>> >>>> >>>> >>>> -- >>>> >>>> Wayne Watson (Watson Adventures, Prop., Nevada City, CA) >>>> >>>> (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)** >>>> The Obama Administration plans to double the production >>>> in solar energy from 1% to 2% of the total energy >>>> supply in the next few years. One nuclear reaction >>>> would do the same. Heard on Bill Wattenburg, KGO-AM >>>> >>>> "Less than all cannot satisfy Man." -- William Blake >>>> >>>> >>>> >>>> _______________________________________________ >>>> Tkinter-discuss mailing list >>>> Tkinter-discuss at python.org >>>> http://mail.python.org/mailman/listinfo/tkinter-discuss >>>> >>>> >>> >>> -- >>> >>> Wayne Watson (Watson Adventures, Prop., Nevada City, CA) >>> >>> (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)** >>> The Obama Administration plans to double the production >>> in solar energy from 1% to 2% of the total energy >>> supply in the next few years. One nuclear reaction >>> would do the same. Heard on Bill Wattenburg, KGO-AM >>> >>> "Less than all cannot satisfy Man." -- William Blake >>> >>> >>> >> >> -- >> >> Wayne Watson (Watson Adventures, Prop., Nevada City, CA) >> >> (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)** >> The Obama Administration plans to double the production >> in solar energy from 1% to 2% of the total energy >> supply in the next few years. One nuclear reaction >> would do the same. Heard on Bill Wattenburg, KGO-AM >> >> "Less than all cannot satisfy Man." -- William Blake >> >> >> > > -- > > Wayne Watson (Watson Adventures, Prop., Nevada City, CA) > > (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)** > > > "Less than all cannot satisfy Man." -- William Blake > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rowen at u.washington.edu Tue Apr 7 21:25:19 2009 From: rowen at u.washington.edu (Russell E. Owen) Date: Tue, 07 Apr 2009 12:25:19 -0700 Subject: [Tkinter-discuss] Redefine quit menu item on Mac to quit from a Twisted/Tkinter application? Message-ID: Anyone know how to redefine what the File>Quit menu item does on MacOS X using Aqua Tcl/Tk? I am trying to convert a cross-platform application to use Twisted, and unfortunately this seems to make the pre-existing Quit menu item on MacOS X do *nothing*. I can't quit the application without using ctrl-C or closing the root window (not an option for this application). I have tried to configure that menu item, but tk does not seem to know that it exists (the index of the last menu item is too small). Any suggestions would be most welcome. -- Russell P.S. configuration: MacOS X 10.5.6 Python 2.5.2 from python.org Twisted 8.2.0 Aqua Tcl/Tk 8.4.19 From kw at codebykevin.com Tue Apr 7 22:08:14 2009 From: kw at codebykevin.com (Kevin Walzer) Date: Tue, 07 Apr 2009 16:08:14 -0400 Subject: [Tkinter-discuss] Redefine quit menu item on Mac to quit from a Twisted/Tkinter application? In-Reply-To: References: Message-ID: <49DBB2AE.6080309@codebykevin.com> Russell E. Owen wrote: > Anyone know how to redefine what the File>Quit menu item does on MacOS X > using Aqua Tcl/Tk? > > I am trying to convert a cross-platform application to use Twisted, and > unfortunately this seems to make the pre-existing Quit menu item on > MacOS X do *nothing*. I can't quit the application without using ctrl-C > or closing the root window (not an option for this application). > > I have tried to configure that menu item, but tk does not seem to know > that it exists (the index of the last menu item is too small). > > Any suggestions would be most welcome. > > -- Russell The pre-defined "Quit" menu entry that comes with Tk/Aqua is in the application menu, not the file menu. In my two Python/Tk apps, hitting "Command-Q" quits them without any code on my part--Tk is invoking the standard "quit" event. If "Quit" is in the "File" menu, then it's not the pre-existing one--you'l have to handle that yourself. If I'm misreading you, and you are talking about the "Quit" entry in the app menu, try something like this: self.bind('Command-Key-Q', lamdba event: sys.exit()) --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From kalman_g at msn.com Tue Apr 7 22:34:08 2009 From: kalman_g at msn.com (GKalman) Date: Tue, 7 Apr 2009 13:34:08 -0700 (PDT) Subject: [Tkinter-discuss] integrating a matplotlib window onto a tkinter frame Message-ID: <22937725.post@talk.nabble.com> Hi, Is it possible to place a matplotlib window (i.e. a matplotlib plot) onto (i.e. inside) a tkinter frame and/or canvas? If yes, are there any references, examples, etc. -- View this message in context: http://www.nabble.com/integrating-a-matplotlib-window-onto-a-tkinter-frame-tp22937725p22937725.html Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. From rowen at u.washington.edu Tue Apr 7 22:35:39 2009 From: rowen at u.washington.edu (Russell Owen) Date: Tue, 7 Apr 2009 13:35:39 -0700 Subject: [Tkinter-discuss] Redefine quit menu item on Mac to quit from a Twisted/Tkinter application? In-Reply-To: <49DBB2AE.6080309@codebykevin.com> References: <49DBB2AE.6080309@codebykevin.com> Message-ID: <4C05F3A5-1225-4960-9B2E-FB602D3C09B1@u.washington.edu> On Apr 7, 2009, at 1:08 PM, Kevin Walzer wrote: > Russell E. Owen wrote: >> Anyone know how to redefine what the File>Quit menu item does on >> MacOS X using Aqua Tcl/Tk? >> I am trying to convert a cross-platform application to use Twisted, >> and unfortunately this seems to make the pre-existing Quit menu >> item on MacOS X do *nothing*. I can't quit the application without >> using ctrl-C or closing the root window (not an option for this >> application). >> I have tried to configure that menu item, but tk does not seem to >> know that it exists (the index of the last menu item is too small). >> Any suggestions would be most welcome. >> -- Russell > > The pre-defined "Quit" menu entry that comes with Tk/Aqua is in the > application menu, not the file menu. In my two Python/Tk apps, > hitting "Command-Q" quits them without any code on my part--Tk is > invoking the standard "quit" event. That is the one I meant (as you surmised). The normal Quit menu item has always worked fine for me until I switched to using Twisted framework. Now it does nothing. > If...you are talking about the "Quit" entry in the app menu, try > something like this: > > self.bind('Command-Key-Q', lamdba event: sys.exit()) What should self be to bind this application-wide (for all windows and widgets)? Root doesn't seem to accept key events. (Also, although this is much better than nothing, presumably it will not actually support the Quit menu item? If so, I hope to find a more thorough solution.) -- Russell P.S. here is a minimal Twisted/Tkinter application that cannot be quit normally: import Tkinter import twisted.internet.tksupport root = Tkinter.Tk() twisted.internet.tksupport.install(root) reactor = twisted.internet.reactor reactor.run() Whereas the following minimal non-Twisted application quits normally: import Tkinter root = Tkinter.Tk() root.mainloop() From kw at codebykevin.com Tue Apr 7 23:29:40 2009 From: kw at codebykevin.com (Kevin Walzer) Date: Tue, 07 Apr 2009 17:29:40 -0400 Subject: [Tkinter-discuss] Redefine quit menu item on Mac to quit from a Twisted/Tkinter application? In-Reply-To: <4C05F3A5-1225-4960-9B2E-FB602D3C09B1@u.washington.edu> References: <49DBB2AE.6080309@codebykevin.com> <4C05F3A5-1225-4960-9B2E-FB602D3C09B1@u.washington.edu> Message-ID: <49DBC5C4.9050305@codebykevin.com> Russell Owen wrote: > > The normal Quit menu item has always worked fine for me until I switched > to using Twisted framework. Now it does nothing. I wonder if it's a conflict between the Tk and Twisted event loops? Doesn't Twisted have its own event loop? (Never used Twisted myself.) > >> If...you are talking about the "Quit" entry in the app menu, try >> something like this: >> >> self.bind('Command-Key-Q', lamdba event: sys.exit()) > > > What should self be to bind this application-wide (for all windows and > widgets)? Root doesn't seem to accept key events. My apps inherit directly from Tk/Tkinter itself: class quickwhoApp(Tk): def __init__(self, parent): Tk.__init__(self, parent) try: self.tk.call('console', 'hide') except TclError: pass if __name__== '__main__': app = quickwhoApp(None) app.mainloop() Binding to self works for me under these circumstances. > > (Also, although this is much better than nothing, presumably it will not > actually support the Quit menu item? If so, I hope to find a more > thorough solution.) > > -- Russell Not sure--as I saisd, I think adding Twisted to the mix makes things more complex. Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From igor.e.novikov at gmail.com Wed Apr 8 00:09:31 2009 From: igor.e.novikov at gmail.com (Igor Novikov) Date: Wed, 8 Apr 2009 01:09:31 +0300 Subject: [Tkinter-discuss] integrating a matplotlib window onto a tkinter frame In-Reply-To: <23f7fc190904071505w9815ea2q6ccf72bff4510e82@mail.gmail.com> References: <22937725.post@talk.nabble.com> <23f7fc190904071349k33b86c1cr9b86ee0f05e2253a@mail.gmail.com> <23f7fc190904071505w9815ea2q6ccf72bff4510e82@mail.gmail.com> Message-ID: <23f7fc190904071509j8dc66fbnb34d8e9d3fd74a1f@mail.gmail.com> hmm... for XWin there is a ready solution - TkXext (http://wiki.tcl.tk/2116) but for win32 I cannot find similar package. pywin32 hasn't such functionality. Creating from scratch requires a lot of coding. May be Tkinter community knows an issue solution? :) But it seems you need studying carefully matplotlib manuals to resolve an issue. As I see on matplotlib site: "You can embed matplotlib into pygtk, wxpython, Tk, FLTK or Qt applications" i.e. matplotlib has binding to Tk widgetset. Try using: matplotlib-0.98.5.2.tar.gz/matplotlib-0.98.5.2/examples/user_interfaces/embedding_in_tk.py Regards, Igor Novikov sK1 Project http://sk1project.org On Tue, Apr 7, 2009 at 11:50 PM, Gabor Kalman wrote: > win32, vista > > ----- Original Message ----- > *From:* Igor Novikov > *To:* GKalman > *Sent:* Tuesday, April 07, 2009 1:49 PM > *Subject:* Re: [Tkinter-discuss] integrating a matplotlib window onto a > tkinter frame > > Hi, > > Please specify what window type (win32, XWindow, MacOS X) you need > integrating? > I can say that under win32 and XWin it's really possible, but window > reparenting requires > platform dependent C-extension or ctypes coding. > > Regards, > > Igor Novikov > sK1 Project > http://sk1project.org > > On Tue, Apr 7, 2009 at 11:34 PM, GKalman wrote: > >> >> Hi, >> >> Is it possible to place a matplotlib window (i.e. a matplotlib plot) onto >> (i.e. inside) a tkinter frame and/or canvas? >> If yes, are there any references, examples, etc. >> >> >> -- >> View this message in context: >> http://www.nabble.com/integrating-a-matplotlib-window-onto-a-tkinter-frame-tp22937725p22937725.html >> Sent from the Python - tkinter-discuss mailing list archive at Nabble.com. >> >> _______________________________________________ >> Tkinter-discuss mailing list >> Tkinter-discuss at python.org >> http://mail.python.org/mailman/listinfo/tkinter-discuss >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jmcmonagle at velseis.com.au Wed Apr 8 00:19:42 2009 From: jmcmonagle at velseis.com.au (John McMonagle) Date: Wed, 08 Apr 2009 08:19:42 +1000 Subject: [Tkinter-discuss] Font change does reflect window size when executed without debugging In-Reply-To: <8e794c8a0904070237r39f2a650y583bec5e9def7463@mail.gmail.com> References: <8e794c8a0904070237r39f2a650y583bec5e9def7463@mail.gmail.com> Message-ID: <49DBD17E.1080102@velseis.com.au> Madhu Subramaniam wrote: > Hi, > Below is an application with a scrollable frame. There is an option to > change the font size of the text, (using tkFont) thereby changing the > size of the widgets and the containers. > this is done by the function 'fontctrl'. The thing i am not able to > figure out is that the change in window size works when i put a > breakpoint/debugger (pdb.set_trace()) and exceute them manually in the > shell. But when i run w/o debugging, then the print statements do not > show me the change in window size. > > for example, when the font is medium: self2.winfo_height() shows 840 > with debugging but 600 without the debugger in place. You need to call winfo_reqheight() and winfo_reqwidth() if you want to get the size that a widget will be once the mainloop runs. I think the reason it works in the debugger, is that the mainloop has already started. You can see the same effect by testing Tkinter in an interactive interpreter session. The following code illustrates the difference between using winfo_height() and winfo_reqheight(): from Tkinter import * root = Tk() b = Button(root, text='test') b.pack() print b.winfo_height() print b.winfo_width() print b.winfo_reqheight() print b.winfo_reqwidth() root.mainloop() When run this yields: 1 1 34 66 Regards, John From rowen at u.washington.edu Thu Apr 9 00:17:09 2009 From: rowen at u.washington.edu (Russell E. Owen) Date: Wed, 08 Apr 2009 15:17:09 -0700 Subject: [Tkinter-discuss] Redefine quit menu item on Mac to quit from a Twisted/Tkinter application? References: <49DBB2AE.6080309@codebykevin.com> <4C05F3A5-1225-4960-9B2E-FB602D3C09B1@u.washington.edu> <49DBC5C4.9050305@codebykevin.com> Message-ID: In article <49DBC5C4.9050305 at codebykevin.com>, Kevin Walzer wrote: > Russell Owen wrote: > > > > > The normal Quit menu item has always worked fine for me until I switched > > to using Twisted framework. Now it does nothing. > > I wonder if it's a conflict between the Tk and Twisted event loops? > Doesn't Twisted have its own event loop? (Never used Twisted myself.) That is definitely the problem. Twisted has an event loop and somehow it runs tk's event loop. The result works just fine -- my application and tk work normally -- until it is time to quit. That's when the trouble strikes: my application will not quit. I suspect the heart of the problem is that halting tk's event loop is not enough to halt Twisted's event loop. The standard way to stop a Twisted application procedure is to halt Twisted's event loop (it's "reactor"). Normally that is easy to do. The problem is that MacOS X Aqua Tcl/Tk has a Quit menu item that seems hard-coded to something directly in tk (perhaps halt the event loop) and whatever it is, it is not enough to get Twisted's attention. So I would like to find some way to modify the behavior of the MacOS X Aqua Tcl/Tk Quit menu item. -- Russell From kw at codebykevin.com Thu Apr 9 01:02:20 2009 From: kw at codebykevin.com (Kevin Walzer) Date: Wed, 08 Apr 2009 19:02:20 -0400 Subject: [Tkinter-discuss] Redefine quit menu item on Mac to quit from a Twisted/Tkinter application? In-Reply-To: References: <49DBB2AE.6080309@codebykevin.com> <4C05F3A5-1225-4960-9B2E-FB602D3C09B1@u.washington.edu> <49DBC5C4.9050305@codebykevin.com> Message-ID: <49DD2CFC.7050901@codebykevin.com> > > So I would like to find some way to modify the behavior of the MacOS X > Aqua Tcl/Tk Quit menu item. > Russell, This requires some Tcl code. According to the Tcl/Tk Aqua FAQ at http://wiki.tcl.tk/12987, Command-Q (and the Quit menu item) trigger the kAEQuitApplication event, which is mapped to Tcl's "exit" (identical to sys.exit) command. The way to change this is to map the "exit" command to something else. This is so trivial to do in Tcl that it's actually dangerous (I've had apps crash on me because I named an image "exit"). I did a little experimentation in Wish, with this code: proc exit {} { puts "foo" } After entering this code during a Wish session in Terminal, hitting "Command-Q" printed "foo" to standard output. The only way to quit at that point was to close the toplevel window. The way to create custom Tcl commands from Python is with the "createcommand" function. I use this function to make the "preferences" menu item visible in my applications: self.createcommand('::tk::mac::ShowPreferences', self.setPrefs) Something like this would probably get close to what you're looking for: def printfoo: print "foo" self.createcommand('exit', printfoo) In other words, this should override the hard-coded "quit" function by mapping the "exit" Tcl command to something else. Then you could add your own event handler for Command-Q. If that doesn't work, I'm not sure what to suggest. This is probably more drilling down into Tcl's internals than you wanted, anyway. --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From kw at codebykevin.com Thu Apr 9 01:15:38 2009 From: kw at codebykevin.com (Kevin Walzer) Date: Wed, 08 Apr 2009 19:15:38 -0400 Subject: [Tkinter-discuss] Redefine quit menu item on Mac to quit from a Twisted/Tkinter application? In-Reply-To: References: <49DBB2AE.6080309@codebykevin.com> <4C05F3A5-1225-4960-9B2E-FB602D3C09B1@u.washington.edu> <49DBC5C4.9050305@codebykevin.com> <49DD2CFC.7050901@codebykevin.com> Message-ID: <49DD301A.3070201@codebykevin.com> Russell Owen wrote: > Thank you very much! > > That is exactly the information I needed. It worked perfectly. I already > had a module that added a Quit/Exit menu for unix/Windows and I just > modified it to map the "exit" command to my quit function on MacOS X. > Just one new line of code and my application now quits correctly! > > -- Russell Glad it worked! -- Kevin Walzer Code by Kevin http://www.codebykevin.com From rowen at u.washington.edu Thu Apr 9 01:51:33 2009 From: rowen at u.washington.edu (Russell Owen) Date: Wed, 8 Apr 2009 16:51:33 -0700 Subject: [Tkinter-discuss] Redefine quit menu item on Mac to quit from a Twisted/Tkinter application? In-Reply-To: <49DD301A.3070201@codebykevin.com> References: <49DBB2AE.6080309@codebykevin.com> <4C05F3A5-1225-4960-9B2E-FB602D3C09B1@u.washington.edu> <49DBC5C4.9050305@codebykevin.com> <49DD2CFC.7050901@codebykevin.com> <49DD301A.3070201@codebykevin.com> Message-ID: <7E155CDA-F943-4EC5-B194-5CE52F971144@u.washington.edu> One more bit of information from Daniel A. Steffen in response to a PR I submitted: === begin quote === Iif the tcl proc '::tk::mac::Quit' is defined, it gets called instead of exit upon receipt of a 'quit' apple event (which is what the standard quit menu item sends, as well as other entities in the system such as the dock menu quit item or the graceful Finder restart/ shutdown, this is why the quit menu item is special). If ::tk::mac::Quit returns false, the application is not quit. other default apple event handlers are also defined, c.f. tkMacOSXHLEvent.c ==== end quote ==== -- Russell On Apr 8, 2009, at 4:15 PM, Kevin Walzer wrote: > Russell Owen wrote: >> Thank you very much! >> That is exactly the information I needed. It worked perfectly. I >> already had a module that added a Quit/Exit menu for unix/Windows >> and I just modified it to map the "exit" command to my quit >> function on MacOS X. Just one new line of code and my application >> now quits correctly! >> -- Russell > > Glad it worked! > > -- > Kevin Walzer > Code by Kevin > http://www.codebykevin.com From kw at codebykevin.com Thu Apr 9 02:02:18 2009 From: kw at codebykevin.com (Kevin Walzer) Date: Wed, 08 Apr 2009 20:02:18 -0400 Subject: [Tkinter-discuss] Redefine quit menu item on Mac to quit from a Twisted/Tkinter application? In-Reply-To: <7E155CDA-F943-4EC5-B194-5CE52F971144@u.washington.edu> References: <49DBB2AE.6080309@codebykevin.com> <4C05F3A5-1225-4960-9B2E-FB602D3C09B1@u.washington.edu> <49DBC5C4.9050305@codebykevin.com> <49DD2CFC.7050901@codebykevin.com> <49DD301A.3070201@codebykevin.com> <7E155CDA-F943-4EC5-B194-5CE52F971144@u.washington.edu> Message-ID: <49DD3B0A.4090208@codebykevin.com> Russell Owen wrote: > One more bit of information from Daniel A. Steffen in response to a PR I > submitted: > > > > === begin quote === > > Iif the tcl proc '::tk::mac::Quit' is defined, it gets called instead of > exit upon receipt of a 'quit' apple event (which is what the standard > quit menu item sends, as well as other entities in the system such as > the dock menu quit item or the graceful Finder restart/shutdown, this is > why the quit menu item is special). If ::tk::mac::Quit returns false, > the application is not quit. > > other default apple event handlers are also defined, c.f. > tkMacOSXHLEvent.c > > ==== end quote ==== I forgot about ::tk::mac::Quit--Daniel's right, that's probably a cleaner way to go about this than my suggestion. -- Kevin Walzer Code by Kevin http://www.codebykevin.com From rowen at u.washington.edu Thu Apr 9 01:12:27 2009 From: rowen at u.washington.edu (Russell Owen) Date: Wed, 8 Apr 2009 16:12:27 -0700 Subject: [Tkinter-discuss] Redefine quit menu item on Mac to quit from a Twisted/Tkinter application? In-Reply-To: <49DD2CFC.7050901@codebykevin.com> References: <49DBB2AE.6080309@codebykevin.com> <4C05F3A5-1225-4960-9B2E-FB602D3C09B1@u.washington.edu> <49DBC5C4.9050305@codebykevin.com> <49DD2CFC.7050901@codebykevin.com> Message-ID: Thank you very much! That is exactly the information I needed. It worked perfectly. I already had a module that added a Quit/Exit menu for unix/Windows and I just modified it to map the "exit" command to my quit function on MacOS X. Just one new line of code and my application now quits correctly! -- Russell On Apr 8, 2009, at 4:02 PM, Kevin Walzer wrote: > >> So I would like to find some way to modify the behavior of the >> MacOS X Aqua Tcl/Tk Quit menu item. > > Russell, > > This requires some Tcl code. > > According to the Tcl/Tk Aqua FAQ at http://wiki.tcl.tk/12987, > Command-Q (and the Quit menu item) trigger the kAEQuitApplication > event, which is mapped to Tcl's "exit" (identical to sys.exit) > command. > > The way to change this is to map the "exit" command to something > else. This is so trivial to do in Tcl that it's actually dangerous > (I've had apps crash on me because I named an image > "exit"). ...Something like this would probably get close to what > you're looking for: > > def printfoo: > print "foo" > > self.createcommand('exit', printfoo) > > In other words, this should override the hard-coded "quit" function > by mapping the "exit" Tcl command to something else. Then you could > add your own event handler for Command-Q. From patermaximus at got2know.net Thu Apr 9 03:15:21 2009 From: patermaximus at got2know.net (PaterMaximus) Date: Thu, 9 Apr 2009 01:15:21 +0000 (UTC) Subject: [Tkinter-discuss] Viewing output to a ScrolledText widget as it is being output? Message-ID: Using python 2.5 I am outputting to a ScrolledText widget. The output takes several minutes. I am not able to view the output until the output is finished. How can I view it as it is being output? I don't have to view it immediately, just not wait for minutes to see it appear. From michael.odonnell at uam.es Thu Apr 9 13:52:27 2009 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Thu, 9 Apr 2009 13:52:27 +0200 Subject: [Tkinter-discuss] Viewing output to a ScrolledText widget as it isbeing output? In-Reply-To: References: Message-ID: <47e491110904090452j7e7d2af2sb9fc3736f4db2be6@mail.gmail.com> Hi PaterMaximus, Without seeing you code, I am not sure what you mean exactly. e.g., "outputting to a ScrolledText widget" - I guess you mean inserting text to the widget. If you call the update() method on the widget evey time some text is inserted, this should do the job. Alternatively, update_idletasks() Mick On Thu, Apr 9, 2009 at 3:15 AM, PaterMaximus wrote: > > Using python 2.5 I am outputting to a ScrolledText widget. The output takes > several minutes. I am not able to view the output until the output is finished. > How can I view it as it is being output? I don't have to view it immediately, > just not wait for minutes to see it appear. > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From rowen at u.washington.edu Thu Apr 9 18:30:08 2009 From: rowen at u.washington.edu (Russell Owen) Date: Thu, 9 Apr 2009 09:30:08 -0700 Subject: [Tkinter-discuss] Redefine quit menu item on Mac to quit from a Twisted/Tkinter application? In-Reply-To: <49DD3B0A.4090208@codebykevin.com> References: <49DBB2AE.6080309@codebykevin.com> <4C05F3A5-1225-4960-9B2E-FB602D3C09B1@u.washington.edu> <49DBC5C4.9050305@codebykevin.com> <49DD2CFC.7050901@codebykevin.com> <49DD301A.3070201@codebykevin.com> <7E155CDA-F943-4EC5-B194-5CE52F971144@u.washington.edu> <49DD3B0A.4090208@codebykevin.com> Message-ID: <561CFF17-4703-4771-A1BB-05B38327B2B8@u.washington.edu> Slightly cleaner, I agree, but your suggestion is very similar and works well. I switched. I had never heard of ::tk::mac::Quit before, but I see your wiki entry mentions it along with some others. -- Russell On Apr 8, 2009, at 5:02 PM, Kevin Walzer wrote: > Russell Owen wrote: >> One more bit of information from Daniel A. Steffen in response to a >> PR I submitted: >> > > === begin quote === >> Iif the tcl proc '::tk::mac::Quit' is defined, it gets called >> instead of exit upon receipt of a 'quit' apple event (which is what >> the standard quit menu item sends, as well as other entities in the >> system such as the dock menu quit item or the graceful Finder >> restart/shutdown, this is why the quit menu item is special). >> If ::tk::mac::Quit returns false, the application is not quit. >> other default apple event handlers are also defined, c.f. >> tkMacOSXHLEvent.c >> ==== end quote ==== > > I forgot about ::tk::mac::Quit--Daniel's right, that's probably a > cleaner way to go about this than my suggestion. > > -- > Kevin Walzer > Code by Kevin > http://www.codebykevin.com From sierra_mtnview at sbcglobal.net Sun Apr 12 21:40:52 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Sun, 12 Apr 2009 12:40:52 -0700 Subject: [Tkinter-discuss] Default Tkinter Structure of a 640x480 PIL BMPFile? In-Reply-To: <23f7fc190904070406y2db0fefbr5e66286b52858c4d@mail.gmail.com> References: <49D37814.2090502@sbcglobal.net> <47e491110904011010j7b39a212r80a5b40ab2589d97@mail.gmail.com> <49D3C3DD.4090404@sbcglobal.net> <23f7fc190904011308l40aa4904jc2c73dde6705f19b@mail.gmail.com> <49D3CEA9.9020707@sbcglobal.net> <23f7fc190904011354t6bf8f1d8gd4c35dbda89a97a3@mail.gmail.com> <49D41AB6.3000409@sbcglobal.net> <23f7fc190904020216g669e470clb5db9c270c7b5c23@mail.gmail.com> <49DB2707.7030404@sbcglobal.net> <23f7fc190904070406y2db0fefbr5e66286b52858c4d@mail.gmail.com> Message-ID: <49E243C4.8090205@sbcglobal.net> With some more study of PIL and file operations within Python, I manged to produce a 640x480 1 byte image as a 'raw', no header, file. With a few more Python file operations got the data into an array where I can then use it to produce a FITS format, not supported by PIL. -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose is 5.52*10**-6 meters. That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From sierra_mtnview at sbcglobal.net Mon Apr 13 03:00:16 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Sun, 12 Apr 2009 18:00:16 -0700 Subject: [Tkinter-discuss] Tkinter and Antialiasing Message-ID: <49E28EA0.5000004@sbcglobal.net> If I draw a fairly slanted line across an image using Tkinter, it looks a bit jagged. Is this typical of Tkinter graphics, or is there an option or mechanism that will antialias? Win XP, Python 2.5, Tkinter 8.4. -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose is 5.52*10**-6 meters. That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From ggpolo at gmail.com Mon Apr 13 12:09:57 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Mon, 13 Apr 2009 07:09:57 -0300 Subject: [Tkinter-discuss] Tkinter and Antialiasing In-Reply-To: <49E28EA0.5000004@sbcglobal.net> References: <49E28EA0.5000004@sbcglobal.net> Message-ID: On Sun, Apr 12, 2009 at 10:00 PM, Wayne Watson wrote: > If I draw a fairly slanted line across an image using Tkinter, it looks > a bit jagged. Is this typical of Tkinter graphics, or is there an option > or mechanism that will antialias? > I'm just copying & pasting my last answer Wayne, hopefully you won't ignore it again. " Tkinter is not really responsible for the drawing, it just passes the responsibility to tk. The standard tk canvas is not going to give you pretty results, but there is an option if you want to continue using tk for this. Last time I checked you could use the tkpath extension (can be found at http://tclbitprint.sourceforge.net/), and maybe there are other extensions to do the same. " > Win XP, Python 2.5, Tkinter 8.4. > > -- > ? ? ? ? ?Wayne Watson (Watson Adventures, Prop., Nevada City, CA) -- -- Guilherme H. Polo Goncalves From sierra_mtnview at sbcglobal.net Mon Apr 13 13:44:08 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Mon, 13 Apr 2009 04:44:08 -0700 Subject: [Tkinter-discuss] Tkinter and Antialiasing In-Reply-To: References: <49E28EA0.5000004@sbcglobal.net> Message-ID: <49E32588.9030102@sbcglobal.net> I wasn't ignoring it. I answered you. I must have posted somewhere else too (sig-int). Somewhere along the line someone suggested that I post here. It seemed quite logical, since the problem is in Tkinter (PIL too, I suppose), so I did. I find posts to these lists a little odd anyway. People are posting from outside the tkinter-discuss at python.org. Responding to them rather than the list tends to confuse matters (I'm referring to the fact their posts may not show tkinter-discuss at python.org, so one must supply it). Secondly, if one doesn't use plain text, then the post may not get to the list. This is not to mention that not using Reply All may seems not to prefer picking up the mail-list address. There are just a lot of bumps in the road. Guilherme Polo wrote: > On Sun, Apr 12, 2009 at 10:00 PM, Wayne Watson > wrote: > >> If I draw a fairly slanted line across an image using Tkinter, it looks >> a bit jagged. Is this typical of Tkinter graphics, or is there an option >> or mechanism that will antialias? >> >> > > I'm just copying & pasting my last answer Wayne, hopefully you won't > ignore it again. > > " > Tkinter is not really responsible for the drawing, it just passes the > responsibility to tk. The standard tk canvas is not going to give you > pretty results, but there is an option if you want to continue using > tk for this. Last time I checked you could use the tkpath extension > (can be found at http://tclbitprint.sourceforge.net/), and maybe there > are other extensions to do the same. > " > > >> Win XP, Python 2.5, Tkinter 8.4. >> >> -- >> Wayne Watson (Watson Adventures, Prop., Nevada City, CA) >> > > > > -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose is 5.52*10**-6 meters. That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From timj at tolisgroup.com Mon Apr 13 15:28:35 2009 From: timj at tolisgroup.com (Tim Jones) Date: Mon, 13 Apr 2009 06:28:35 -0700 Subject: [Tkinter-discuss] List Reply To: field - was: Tkinter and Antialiasing In-Reply-To: <49E32588.9030102@sbcglobal.net> References: <49E28EA0.5000004@sbcglobal.net> <49E32588.9030102@sbcglobal.net> Message-ID: <035740BF-824E-45B3-BBCF-DBC8FF38C3E5@tolisgroup.com> On Apr 13, 2009, at 4:44 AM, Wayne Watson wrote: > I find posts to these lists a little odd anyway. People are posting > from outside the tkinter-discuss at python.org. Responding to them > rather than the list tends to confuse matters (I'm referring to the > fact their posts may not show tkinter-discuss at python.org, so one > must supply it). Secondly, if one doesn't use plain text, then the > post may not get to the list. This is not to mention that not using > Reply All may seems not to prefer picking up the mail-list address. > There are just a lot of bumps in the road. On this point, I must agree. If I don't remember to hit "Reply All", any response that I send is sent ONLY to the From: address. And even when I do hit Reply All, the original From: address is the primary To: address. It seems to me that a proper list always has itself as the default Reply To: entry. Is it possible to get the list reconfigured to add a Reply To: field that defaults to the list? Sorry, Wayne, but I don't have a answer for your anti-aliasing query. Tim From sierra_mtnview at sbcglobal.net Thu Apr 16 15:51:46 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Thu, 16 Apr 2009 06:51:46 -0700 Subject: [Tkinter-discuss] after_cancel? Message-ID: <49E737F2.5070003@sbcglobal.net> I'm looking a program that I'm not real familiar with that uses an after_cancel method and after_id variable. Are they related to some particular widget and what is there function? Perhaps they are related to a Cancel button on a widget? -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From Cameron at phaseit.net Thu Apr 16 16:03:52 2009 From: Cameron at phaseit.net (Cameron Laird) Date: Thu, 16 Apr 2009 14:03:52 +0000 Subject: [Tkinter-discuss] after_cancel? In-Reply-To: <49E737F2.5070003@sbcglobal.net> References: <49E737F2.5070003@sbcglobal.net> Message-ID: <20090416140352.GA20331@lairds.us> On Thu, Apr 16, 2009 at 06:51:46AM -0700, Wayne Watson wrote: . . . > I'm looking a program that I'm not real familiar with that uses an > after_cancel method and after_id variable. Are they related to some > particular widget and what is there function? Perhaps they are related > to a Cancel button on a widget? . . . after() is a built-in that is NOT tied, in general, to a specific widget . Your description hints at some sort of time-out functionality. From ben.koopmanschap at gmail.com Sun Apr 19 17:41:34 2009 From: ben.koopmanschap at gmail.com (Ben Koopmanschap) Date: Sun, 19 Apr 2009 17:41:34 +0200 Subject: [Tkinter-discuss] How to distinguish canvas items? Message-ID: <260feaa60904190841s44c1e798sd2f31643d92e452f@mail.gmail.com> Hello everyone, According to one of the many examples brought with the Tkinter documentation, I am able to create some ovals on the canvas with: fred = self.draw.create_oval(40, 40, 60, 60, fill="green", tags="selected") followed by: wilma = self.draw.create_oval(40, 40, 60, 60, fill="green", tags="selected") and for creating the bindings: self.draw.tag_bind(fred, "", self.mouseEnter) self.draw.tag_bind(fred, "", self.mouseLeave) self.draw.tag_bind(wilma, "", self.mouseEnter) self.draw.tag_bind(wilma, "", self.mouseLeave) Once created, a "mouseEnter" event behaves like what it has to do, change the color of the CURRENT oval in this way: def mouseEnter(self, event): # the CURRENT tag is applied to the object the cursor is over. # this happens automatically. self.draw.itemconfig(CURRENT, fill="red") But what I want to know is how the individual ovals can distinguish from each other, can anyone please tell me how the value (in this case: Fred or Wilma) of one particular oval can be returned? Thanks in advance! Yours sincelery, - Ben From ben.koopmanschap at gmail.com Sun Apr 19 20:18:34 2009 From: ben.koopmanschap at gmail.com (Ben Koopmanschap) Date: Sun, 19 Apr 2009 20:18:34 +0200 Subject: [Tkinter-discuss] How to distinguish canvas items (2) Message-ID: <260feaa60904191118s53a82041q693d9421629e44e4@mail.gmail.com> Hello everyone! Just discovered the trick to bind and distinguish specific items on the canvas in Tkinter :) According to 'Programming python' from Mark Lutz, page 541 it is possible with the widget.find_closest method to bind a specific item on a canvas. Just what I've been looking for! So I can change my formerly posted snippet to: def mouseDown(self, event): # remember where the mouse went down self.lastx = event.x self.lasty = event.y print event.widget.find_closest(event.x, event.y) # <-- this does the trick Tested this out and it works very well! Hope this will others pointing in the right direction! With regards, - Ben From sierra_mtnview at sbcglobal.net Tue Apr 21 15:14:35 2009 From: sierra_mtnview at sbcglobal.net (Wayne Watson) Date: Tue, 21 Apr 2009 06:14:35 -0700 Subject: [Tkinter-discuss] after_cancel? In-Reply-To: <20090416140423.GA8819@unpythonic.net> References: <49E737F2.5070003@sbcglobal.net> <20090416140423.GA8819@unpythonic.net> Message-ID: <49EDC6BB.8090406@sbcglobal.net> Thanks. The code I'm looking at, not mine, has the concept of an "after" video event (it takes about 8 seconds) that added some confusion to what the code does. I wasn't sure if the after_cancel wasn't related to it and some Tk widget. Jeff Epler wrote: > after, after_idle, and after_cancel map to the 3 main forms of the tcl > "after" command. > > This command is used to delay execution of the program or to execute > a command in background sometime in the future. It has several forms, > depending on the first argument to the command: > > [...] > after cancel id > Cancels the execution of a delayed command that was previously > scheduled. Id indicates which command should be canceled; it > must have been the return value from a previous after command. If the > command given by id has already been executed then the after cancel > command has no effect. > > -- from http://www.tcl.tk/man/tcl8.4/TclCmd/after.htm > > One use of "after" is in autoscrolling or autorepeat. When the starting > event is seen, the repeat is scheduled with "after". Each time the > repeat runs, it schedules itself again with "after". When the ending > event is seen, the repeat is cancelled with "after cancel". To do this, > tue id returned by the last "after" is stored somewhere. > > Jeff > > -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39? 15' 7" N, 121? 2' 32" W, 2700 feet All the neutrons, and protons in the human body occupy a cube whose side is 5.52*10**-6 meters (tiny!). That adds up to a 150 pound person. It's not a surprise that we are mostly space. (Calculation by WTW) From patermaximus at got2know.net Thu Apr 23 16:21:43 2009 From: patermaximus at got2know.net (PaterMaximus) Date: Thu, 23 Apr 2009 14:21:43 +0000 (UTC) Subject: [Tkinter-discuss] looking for a multiline equivalent of tkSimpleDialog.askstring Message-ID: any help appreciated From michael.odonnell at uam.es Thu Apr 23 16:57:55 2009 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Thu, 23 Apr 2009 16:57:55 +0200 Subject: [Tkinter-discuss] looking for a multiline equivalent oftkSimpleDialog.askstring In-Reply-To: References: Message-ID: <47e491110904230757w568fe2b9h1e5ec7b20e036a75@mail.gmail.com> Hi PaterMaximus, Code a bit long, but it should do what you want: ------------------------------------------- from Tkinter import * import os class ModalDialog(Toplevel): def __init__(self, parent, x, y, title): Toplevel.__init__(self, parent) self.transient(parent) self.title(title) self.protocol( 'WM_DELETE_WINDOW', self.cancel) self.value=None self.x = x self.y = y # NEED TO HIDE UNTIL SHOWN # NEED TO POSITION REGARD TO X, Y def show( self ): self.position() oldFoc = self.focus_get() self.focus_set() self.grab_set() self.lift() self.deiconify() self.update() self.mainloop() self.grab_release() if oldFoc: oldFoc.focus_set() return self.value def returnValue(self): self.quit() def cancel(self): self.value=None self.quit() def position(self): # We want the window displayed hidden in case it is moved self.withdraw() self.update() # Position the window at x,y # Ensure the window will not go off screen # windims are like '30x40+50+50' # 30x40 is the size, the rest is startpos maxX, maxY = self.maxsize() maxY -= 40 windims = self.geometry().split('+')[0].split('x') width=int(windims[0]) height=int(windims[1]) if self.x == None or self.y == None: self.x=(maxX-width)/2 self.y=(maxY-height)/2 if (self.x+width) > maxX: self.x = maxX - width if (self.y+height) > maxY: self.y = maxY - height # Now position the window and show it. self.geometry("+"+str(self.x)+"+"+str(self.y)) self.update() def editString(par, prompt, startVal="", x=None, y=None): gframe = EditStringDialog(par, prompt, startVal, x, y) val = gframe.show() gframe.destroy() return val class EditStringDialog(ModalDialog): def __init__(self, parent, prompt, startValue, x, y): ModalDialog.__init__(self, parent, x, y, prompt) self.config(bg="white") self.value=startValue self.ew=Text(self, bg="white", width=60, borderwidth=0, height=6) if startValue: self.ew.insert("1.0", startValue) self.ew.pack(side="top", fill="both", padx=5, expand=True) bframe=Frame(self, bd=10) bframe.pack(side="top", fill="x") okBut=Button(bframe, text="OK", command=self.returnValue, underline=False, default="active") cancelBut = Button(bframe, text="Cancel", command=self.cancel, underline=False) okBut.pack(side="left") cancelBut.pack(side="right") def returnValue(self): self.value=self.ew.get("1.0", END) self.quit() if __name__ == '__main__': mywin = Tk() Button(mywin, text="Go", command=lambda win=mywin, prompt="Hello": editString(win, prompt)).pack() mywin.mainloop() On Thu, Apr 23, 2009 at 4:21 PM, PaterMaximus wrote: > > any help appreciated > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From luke at maurits.id.au Sat Apr 25 14:59:31 2009 From: luke at maurits.id.au (Luke Maurits) Date: Sat, 25 Apr 2009 22:29:31 +0930 Subject: [Tkinter-discuss] Changing the label of a tix.NoteBook tab Message-ID: <20090425222931.1ceea360.luke@maurits.id.au> Greetings all, I have a question about changing the label of a tab in a tix.NoteBook widget. Suppose I create a NoteBook and insert a tab (or "page", to use the proper Tk terminology) like this: nb = tix.NoteBook(master) page = nb.add("a_tab",label="Foo") and later I decide that I want to change the tab label from "Foo" to "Bar". How do I go about this? If I try: page.config(label="Bar") I receive the following complaint: Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.0/tkinter/__init__.py", line 1193, in configure return self._configure('configure', cnf, kw) File "/usr/lib/python3.0/tkinter/__init__.py", line 1184, in _configure self.tk.call(_flatten((self._w, cmd)) + self._options(cnf)) _tkinter.TclError: unknown option "-label" I haven't been able to find any examples of the correct way to change a tab label *anywhere* on the web. After reading the class definition for NoteBook in /usr/lib/python3.0/tkinter/tix.py, making a guess about the meaning of the tk.call method, and looking at this webpage: http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixNoteBook.htm I took a stab in the dark and tried the following bit of code: nb.tk.call(nb._w,"pageconfigure","tab",*nb._options({},{"label":"Bar"})) and, lo, it worked! The problem is that I have only the fuzziest understanding of *why* it worked and I'm pretty sure that this isn't the way I'm supposed to do it. Have I missed something stupid? The fact that the "pageconfigure" functionality provided by Tk is not exposed through a nice and friendly method on the NoteBook class suggests to me that either somebody just plain forgot to do it (unlikely) or (more likely) it was deemed unecessary because there is some other way to go about it, similar to my page.config attempt but a little different. Any information the list can provide me on this would be appreciated. If it helps, my Tk version is 8.5.6, my Python version is 3.0.1, and my Linux kernel version is 2.6.26. Thanks, Luke From klappnase at web.de Sat Apr 25 15:44:06 2009 From: klappnase at web.de (Michael Lange) Date: Sat, 25 Apr 2009 15:44:06 +0200 Subject: [Tkinter-discuss] Changing the label of a tix.NoteBook tab In-Reply-To: <20090425222931.1ceea360.luke@maurits.id.au> References: <20090425222931.1ceea360.luke@maurits.id.au> Message-ID: <20090425154406.cefe8094.klappnase@web.de> On Sat, 25 Apr 2009 22:29:31 +0930 Luke Maurits wrote: > After reading the class definition for NoteBook in /usr/lib/python3.0/tkinter/tix.py, making a guess about the meaning of the tk.call method, and looking at this webpage: > > http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixNoteBook.htm > > I took a stab in the dark and tried the following bit of code: > > nb.tk.call(nb._w,"pageconfigure","tab",*nb._options({},{"label":"Bar"})) > > and, lo, it worked! The problem is that I have only the fuzziest understanding of *why* it worked and I'm pretty sure that this isn't the way I'm supposed to do it. > > Have I missed something stupid? The fact that the "pageconfigure" functionality provided by Tk is not exposed through a nice and friendly method on the NoteBook class suggests to me that either somebody just plain forgot to do it (unlikely) or (more likely) it was deemed unecessary because there is some other way to go about it, similar to my page.config attempt but a little different. > Hi Luke, obviously the pageconfigure() method is missing from Tix.py, so this is perfectly what you are suposed to do :) If you wish you can do the same a bit shorter: nb.tk.call(nb._w,"pageconfigure","tab", "-label", "Bar") Michael From luke at maurits.id.au Sat Apr 25 16:01:00 2009 From: luke at maurits.id.au (Luke Maurits) Date: Sat, 25 Apr 2009 23:31:00 +0930 Subject: [Tkinter-discuss] Changing the label of a tix.NoteBook tab In-Reply-To: <20090425154406.cefe8094.klappnase@web.de> References: <20090425222931.1ceea360.luke@maurits.id.au> <20090425154406.cefe8094.klappnase@web.de> Message-ID: <20090425233100.54116fe2.luke@maurits.id.au> Hallo Michael, > obviously the pageconfigure() method is missing from Tix.py, so this is perfectly what you > are suposed to do :) > If you wish you can do the same a bit shorter: > > nb.tk.call(nb._w,"pageconfigure","tab", "-label", "Bar") Thank you for your very prompt reply. I am surprised that this is the only way to do what I want but am glad that I have stumbled upon the correct way. I will certainly use your shorter/neater version in my application since it is much easier to read. I wonder why the decision was made not to implement pageconfigure in Tix.py? It seems like this would be very easy: def pageconfigure(self, name, cnf={}, **kw): self.tk.call(self._w, "pageconfigure", name, *self._options(cnf, kw)) should do it perfectly, no? This would certainly be much more user friendly, I think a lot of people would give up before discovering how to call it through tk.call. Still, I don't suppose anybody on this list is likely to actually know what the author of Tix.py was thinking at the time, so it's not really something to be discussed here. Thanks again, very much! Luke From klappnase at web.de Sat Apr 25 16:54:21 2009 From: klappnase at web.de (Michael Lange) Date: Sat, 25 Apr 2009 16:54:21 +0200 Subject: [Tkinter-discuss] Changing the label of a tix.NoteBook tab In-Reply-To: <20090425233100.54116fe2.luke@maurits.id.au> References: <20090425222931.1ceea360.luke@maurits.id.au> <20090425154406.cefe8094.klappnase@web.de> <20090425233100.54116fe2.luke@maurits.id.au> Message-ID: <20090425165421.5176f20e.klappnase@web.de> On Sat, 25 Apr 2009 23:31:00 +0930 Luke Maurits wrote: > Hallo Michael, > > > > > obviously the pageconfigure() method is missing from Tix.py, so this is perfectly what you > > are suposed to do :) > > If you wish you can do the same a bit shorter: > > > > nb.tk.call(nb._w,"pageconfigure","tab", "-label", "Bar") > > Thank you for your very prompt reply. I am surprised that this is the only way to do what I want but am glad that I have stumbled upon the correct way. I will certainly use your shorter/neater version in my application since it is much easier to read. > > I wonder why the decision was made not to implement pageconfigure in Tix.py? It seems like this would be very easy: > > def pageconfigure(self, name, cnf={}, **kw): > self.tk.call(self._w, "pageconfigure", name, *self._options(cnf, kw)) > > should do it perfectly, no? This would certainly be much more user friendly, I think a lot of people would give up before discovering how to call it through tk.call. Still, I don't suppose anybody on this list is likely to actually know what the author of Tix.py was thinking at the time, so it's not really something to be discussed here. > Things are a little more complicated though; if you only pass the page name to pageconfigure, without any option, you want all options with their current values to be returned, if you pass one option without value the current value should be returned, as in Tkinter.Widget.configure(). The Tix way to achieve this seems to be (taken from Tix.PanedWindow.paneconfigure()): def pageconfigure(self, page, cnf={}, **kw): if cnf is None: return _lst2dict( self.tk.split( self.tk.call(self._w, 'pageconfigure', page._name))) self.tk.call(self._w, 'pageconfigure', page._name, *self._options(cnf, kw)) which appears to be broken, though; when I pass only a pagename to it I get None as return value, I need to call nb.pageconfigure(pagename, None) to get something returned, which is at least unintuitive, and passing an option as in nb.pageconfigure(pagename, 'label') causes an error. A better way to implement it might be the typical Tkinter way: def pageconfigure(self, page, cnf={}, **kw): return self._configure(('pageconfigure', page._name), cnf, kw) This allows at least partially to query current values, nb.pageconfigure(pagename, 'label') returns a tuple ('label', '', '', '', 'foobar'), nb.pageconfigure(pagename) still returns None if used without None as second argument. Michael From luke at maurits.id.au Sun Apr 26 08:27:16 2009 From: luke at maurits.id.au (Luke Maurits) Date: Sun, 26 Apr 2009 15:57:16 +0930 Subject: [Tkinter-discuss] Changing the label of a tix.NoteBook tab In-Reply-To: <20090425165421.5176f20e.klappnase@web.de> References: <20090425222931.1ceea360.luke@maurits.id.au> <20090425154406.cefe8094.klappnase@web.de> <20090425233100.54116fe2.luke@maurits.id.au> <20090425165421.5176f20e.klappnase@web.de> Message-ID: <20090426155716.d2f50c7a.luke@maurits.id.au> > Things are a little more complicated though; if you only pass the page name to pageconfigure, without any option, > you want all options with their current values to be returned, if you pass one option without > value the current value should be returned, as in Tkinter.Widget.configure(). Ah, of course. Tk configure methods aren't just setters, they're also two kinds of getter! A silly oversight on my behalf. > The Tix way to achieve this seems to be (taken from Tix.PanedWindow.paneconfigure()): > > def pageconfigure(self, page, cnf={}, **kw): > if cnf is None: > return _lst2dict( > self.tk.split( > self.tk.call(self._w, 'pageconfigure', page._name))) > self.tk.call(self._w, 'pageconfigure', page._name, *self._options(cnf, kw)) > > which appears to be broken, though; when I pass only a pagename to it I get None as return value, > I need to call nb.pageconfigure(pagename, None) to get something returned, which is at least > unintuitive, and passing an option as in nb.pageconfigure(pagename, 'label') causes an error. > > A better way to implement it might be the typical Tkinter way: > > def pageconfigure(self, page, cnf={}, **kw): > return self._configure(('pageconfigure', page._name), cnf, kw) > > This allows at least partially to query current values, nb.pageconfigure(pagename, 'label') > returns a tuple ('label', '', '', '', 'foobar'), nb.pageconfigure(pagename) still returns None if > used without None as second argument. Thank you very much for taking the time to explain / explore these variations. It feels like there's certainly some scope for a bit of polish in the Tix implementation, with NoteBook.pageconfigure not exposed and PanedWindow.paneconfigure broken! Perhaps it is a low priority because, as I understand, with upcomming versions of Tk, and something called Ttk, Tix may become somewhat obselete anyway. Thanks again for all your input. Luke From sxn02 at yahoo.com Mon Apr 27 17:15:49 2009 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Mon, 27 Apr 2009 08:15:49 -0700 (PDT) Subject: [Tkinter-discuss] ttk style dilema Message-ID: <453624.36773.qm@web56008.mail.re3.yahoo.com> Hi All, I installed recently tcl/tk 8.5.6, Python 2.6.2 and pyttk 0.3 on a Linux (Gentoo) machine. I would like to be able to change two things in entries: - the font should be the default, but in italics - selected text in an entry should have white background and gray foreground How can I accomplish that? How can I determine what is the actual TkDefaultFont? Thanks SxN __________________________________________________________________ Be smarter than spam. See how smart SpamGuard is at giving junk email the boot with the All-new Yahoo! Mail. Click on Options in Mail and switch to New Mail today or register for free at http://mail.yahoo.ca From michael.odonnell at uam.es Mon Apr 27 18:10:28 2009 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Mon, 27 Apr 2009 18:10:28 +0200 Subject: [Tkinter-discuss] ttk style dilema In-Reply-To: <453624.36773.qm@web56008.mail.re3.yahoo.com> References: <453624.36773.qm@web56008.mail.re3.yahoo.com> Message-ID: <47e491110904270910y22f42e3cle28e6bea10167510@mail.gmail.com> Hi Sorin, I think the following will do what you want (where tk is your main window): tk.option_add("*font", "-*-*-*-I-*--*-*-*-*-*-*") For example: from Tkinter import * tk = Tk() tk.option_add("*font", "-*-*-*-I-*--*-*-*-*-*-*") Label(tk, text="Hello").pack(side=TOP) Button(tk, text="Hello").pack(side=TOP) e1=Entry(tk) e1.pack(side=TOP) e1.insert(END, "Hello") tk.mainloop() For background, look at: http://infohost.nmt.edu/tcc/help/pubs/tkinter/option-database.html http://infohost.nmt.edu/tcc/help/pubs/tkinter/universal.html#option_add And on x fonts: http://www.pythonware.com/library/tkinter/introduction/x444-fonts.htm Mick On Mon, Apr 27, 2009 at 5:15 PM, Sorin Schwimmer wrote: > > Hi All, > > I installed recently tcl/tk 8.5.6, Python 2.6.2 and pyttk 0.3 on a Linux (Gentoo) machine. > > I would like to be able to change two things in entries: > - the font should be the default, but in italics > - selected text in an entry should have white background and gray foreground > > How can I accomplish that? How can I determine what is the actual TkDefaultFont? > > Thanks > SxN > > > ? ? ?__________________________________________________________________ > Be smarter than spam. See how smart SpamGuard is at giving junk email the boot with the All-new Yahoo! Mail. ?Click on Options in Mail and switch to New Mail today or register for free at http://mail.yahoo.ca > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From sxn02 at yahoo.com Mon Apr 27 18:53:01 2009 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Mon, 27 Apr 2009 09:53:01 -0700 (PDT) Subject: [Tkinter-discuss] ttk style dilema Message-ID: <228788.55564.qm@web56001.mail.re3.yahoo.com> Hi Mick, Thanks for your reply. It doesn't answer my question though, as your solution is for "classic" Tkinter, while my inquiry is for themed tk. What will be the approach in ttk? Thanks again, SxN __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From michael.odonnell at uam.es Mon Apr 27 19:38:11 2009 From: michael.odonnell at uam.es (Michael O'Donnell) Date: Mon, 27 Apr 2009 19:38:11 +0200 Subject: [Tkinter-discuss] ttk style dilema In-Reply-To: <228788.55564.qm@web56001.mail.re3.yahoo.com> References: <228788.55564.qm@web56001.mail.re3.yahoo.com> Message-ID: <47e491110904271038g23205b5bucbb1088394351119@mail.gmail.com> > It doesn't answer my question though, as your solution is for "classic" Tkinter, while my inquiry is > for themed tk. > > What will be the approach in ttk? Ooops, sorry, missed that. I don't use ttk myself. Given ttk is built on top of tk, perhaps my solution still works. Did you try it with ttk widgets? (I don't have time to install ttk etc. myself). Mick From ggpolo at gmail.com Mon Apr 27 22:35:59 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Mon, 27 Apr 2009 17:35:59 -0300 Subject: [Tkinter-discuss] ttk style dilema In-Reply-To: <453624.36773.qm@web56008.mail.re3.yahoo.com> References: <453624.36773.qm@web56008.mail.re3.yahoo.com> Message-ID: On Mon, Apr 27, 2009 at 12:15 PM, Sorin Schwimmer wrote: > > Hi All, > > I installed recently tcl/tk 8.5.6, Python 2.6.2 and pyttk 0.3 on a Linux (Gentoo) machine. > Hi Sorin, thanks for giving ttk a try. > I would like to be able to change two things in entries: > - the font should be the default, but in italics > - selected text in an entry should have white background and gray foreground > > How can I accomplish that? How can I determine what is the actual TkDefaultFont? > I will answer in the reverse order. The easier way to know what defines the actual TkDefaultFont is to use the tkFont module (it is included with tkinter): import Tkinter import tkFont Tkinter.Tk() print tkFont.Font(font='TkDefaultFont').configure() Now, to change the selection colors in a ttk.Entry, simply do: import ttk style = ttk.Style() style.map('TEntry', selectbackground=[('!disabled', 'white')], selectforeground=[('!disabled', 'grey')]) And to change the ttk.Entry font to italics you don't use themes actually. There is an option named 'font' for this widget, so you just have to change it. Follows the correct way to do what you are after: import ttk import tkFont entry = ttk.Entry() myfont = tkFont.Font(font=str(entry['font'])) myfont['slant'] = 'italic' entry['font'] = myfont entry.pack() > Thanks > SxN Regards, -- -- Guilherme H. Polo Goncalves From sxn02 at yahoo.com Mon Apr 27 23:07:40 2009 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Mon, 27 Apr 2009 14:07:40 -0700 (PDT) Subject: [Tkinter-discuss] ttk style dilema Message-ID: <156919.53779.qm@web56001.mail.re3.yahoo.com> Hi Guilherme, First of all, *I thank you* for providing pyttk. Next, your suggestions are exactly what I was looking for. The following prototype is showing what am I after (ugly, no classes, but take it as a prototype): #! /usr/bin/env python # -*- coding: iso-8859-1 -*- import ttk from ttk import Tkinter as tk import tkFont r=tk.Tk() vPcode=tk.StringVar() vPcode.set('Postal code') st=ttk.Style() st.configure('I.TEntry',foreground='gray',background='white') st.map('I.TEntry',selectforeground=[('!disabled','gray')],selectbackground=[('!d isabled','white')]) ePcode=ttk.Entry(r,textvariable=vPcode,style='I.TEntry',width=12) efn=tkFont.Font(font=str(ePcode['font'])) fn=tkFont.Font(font=str(ePcode['font'])) fn['slant']='italic' ePcode['font']=fn ePcode.grid() def postal(ev): global r,vPcode,ePcode if ev.keysym=='Return': ttk.Label(r,text='Done successfully').grid() elif vPcode.get()=='Postal code': ePcode['style']='I.TEntry' ePcode['font']=fn else: ePcode['style']='TEntry' ePcode['font']=efn ePcode.select_range(0,tk.END) ePcode.bind('',lambda ev: postal(ev)) ePcode.focus() r.mainloop() It works beautifully, thanks to your advice. How can I get rid of the rectangle surrounding the selected text (I suppose another style.map option)? Or, even better, where can I find some docs regarding the names of all these elements, and their expected values? Best regards, SxN __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From Cameron at phaseit.net Mon Apr 27 23:09:41 2009 From: Cameron at phaseit.net (Cameron Laird) Date: Mon, 27 Apr 2009 21:09:41 +0000 Subject: [Tkinter-discuss] Anti-procedural prejudice? (was: ttk style dilema) In-Reply-To: <156919.53779.qm@web56001.mail.re3.yahoo.com> References: <156919.53779.qm@web56001.mail.re3.yahoo.com> Message-ID: <20090427210941.GB9556@lairds.us> On Mon, Apr 27, 2009 at 02:07:40PM -0700, Sorin Schwimmer wrote: . . . > Next, your suggestions are exactly what I was looking for. The following > prototype is showing what am I after (ugly, no classes, but take it as a > prototype): . . . We're not saying that good Python code must be expressed with classes, are we? From sxn02 at yahoo.com Tue Apr 28 00:35:26 2009 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Mon, 27 Apr 2009 15:35:26 -0700 (PDT) Subject: [Tkinter-discuss] Anti-procedural prejudice? (was: ttk style dilema) Message-ID: <768658.45932.qm@web56006.mail.re3.yahoo.com> >> Next, your suggestions are exactly what I was looking for. The following >> prototype is showing what am I after (ugly, no classes, but take it as a >> prototype): > . > . > . > We're not saying that good Python code must be expressed > with classes, are we? No, we aren't. In fact, in many of my real-life applications I'm using procedural or functional code, according to what I feel suits better the given situation. Moreover, when I wrote "ugly", I wasn't meaning "classless", but rather using "r" instead of "root", "st" instead of "style", "a=b" instead of "a = b" and so on. "no classes" is just a reference to the traditional (and rationally justified) use of classes in a GUI context. I hope this clarifies things out :-) SxN __________________________________________________________________ Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now http://ca.toolbar.yahoo.com. From ggpolo at gmail.com Tue Apr 28 00:54:06 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Mon, 27 Apr 2009 19:54:06 -0300 Subject: [Tkinter-discuss] ttk style dilema In-Reply-To: <156919.53779.qm@web56001.mail.re3.yahoo.com> References: <156919.53779.qm@web56001.mail.re3.yahoo.com> Message-ID: On Mon, Apr 27, 2009 at 6:07 PM, Sorin Schwimmer wrote: > > Hi Guilherme, > > First of all, *I thank you* for providing pyttk. > > Next, your suggestions are exactly what I was looking for. The following > prototype is showing what am I after (ugly, no classes, but take it as a > prototype): > > #! /usr/bin/env python > # -*- coding: iso-8859-1 -*- > > import ttk > from ttk import Tkinter as tk > import tkFont > > r=tk.Tk() > > vPcode=tk.StringVar() > vPcode.set('Postal code') > st=ttk.Style() > st.configure('I.TEntry',foreground='gray',background='white') > st.map('I.TEntry',selectforeground=[('!disabled','gray')],selectbackground=[('!d > isabled','white')]) > ePcode=ttk.Entry(r,textvariable=vPcode,style='I.TEntry',width=12) > efn=tkFont.Font(font=str(ePcode['font'])) > fn=tkFont.Font(font=str(ePcode['font'])) > fn['slant']='italic' > ePcode['font']=fn > ePcode.grid() > > def postal(ev): > ?global r,vPcode,ePcode > ?if ev.keysym=='Return': > ? ?ttk.Label(r,text='Done successfully').grid() > ?elif vPcode.get()=='Postal code': > ? ?ePcode['style']='I.TEntry' > ? ?ePcode['font']=fn > ?else: > ? ?ePcode['style']='TEntry' > ? ?ePcode['font']=efn > > ePcode.select_range(0,tk.END) > ePcode.bind('',lambda ev: postal(ev)) > ePcode.focus() > > r.mainloop() > > It works beautifully, thanks to your advice. How can I get rid of the > rectangle surrounding the selected text (I suppose another style.map > option)? Yes, but in this specific case you could use style.configure which is a bit simpler to use: style.configure('TEntry', selectborderwidth=0) You could also uso style.map for this, but you have to specify the state(s) where the option applies for that style. Since the selectborderwidth is very likely to be the same in all the states, it is fine to use style.configure. > Or, even better, where can I find some docs regarding the names > of all these elements, and their expected values? > Actually the tk source is the best place for this, the C code. Documentation for ttk/tile is lacking, the widget introspection is not very nice too, so either Google can help you or you need to look into its code. > Best regards, > SxN > -- -- Guilherme H. Polo Goncalves From sxn02 at yahoo.com Tue Apr 28 04:45:04 2009 From: sxn02 at yahoo.com (Sorin Schwimmer) Date: Mon, 27 Apr 2009 19:45:04 -0700 (PDT) Subject: [Tkinter-discuss] ttk style dilema Message-ID: <592158.29030.qm@web56003.mail.re3.yahoo.com> Thanks everyone, SxN __________________________________________________________________ Reclaim your name @ymail.com or @rocketmail.com. Get your new email address now! Go to http://ca.promos.yahoo.com/jacko/