From klappnase at web.de Thu Aug 15 20:58:57 2013 From: klappnase at web.de (Michael Lange) Date: Thu, 15 Aug 2013 20:58:57 +0200 Subject: [Tkinter-discuss] tkFileDialog In-Reply-To: <20130730150116.9c3d932e2028642fd9968ec2@web.de> References: <51F78F3D.4000605@tartan.co.za> <20130730150116.9c3d932e2028642fd9968ec2@web.de> Message-ID: <20130815205857.96622658e9fce1cec98b550b@web.de> On Tue, 30 Jul 2013 15:01:16 +0200 Michael Lange wrote: > Hmm... the "center on screen" gimmick works only with the first dialog, > can someone fix that ;) > Anyway, unless we come up with something better, I'd classify this as > strictly "don't try this at home"-ish :) Just for the fun of it I've been playing with this for a few more minutes and finally found something that seems almost usable ;) The trick seems to be that we must use a timer to make sure the geometry is set only after the dialog window shows up, which however causes an ugly "flashing" effect. Besides that this code snippet seems to work ok, the geometry is set to one third of the screen's width and height and the dialog is centered on the screen. Regards Michael ################################################################# from Tkinter import * import tkFileDialog root=Tk() def set_filedialog_geometry(): w, h = root.winfo_screenwidth(), root.winfo_screenheight() w0, h0 = w / 3, h / 3 x, y = w / 2 - w0 / 2, h / 2 - h0 / 2 try: root.tk.call('wm', 'geometry', '.__tk_filedialog', '%dx%d+%d+%d' % (w0, h0, x, y)) except TclError: print('TclError') #root.after(100, set_filedialog_geometry) def ask_open_filename(**kw): root.after(100, set_filedialog_geometry) tkFileDialog.askopenfilename(**kw) def ask_saveas_filename(**kw): root.after(100, set_filedialog_geometry) tkFileDialog.asksaveasfilename(**kw) def test1(ev): ask_open_filename() def test2(ev): ask_saveas_filename() root.bind('', test1) root.bind('', test2) root.mainloop() .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. Witch! Witch! They'll burn ya! -- Hag, "Tomorrow is Yesterday", stardate unknown From paul at tartan.co.za Fri Aug 16 09:23:54 2013 From: paul at tartan.co.za (Paul Malherbe) Date: Fri, 16 Aug 2013 09:23:54 +0200 Subject: [Tkinter-discuss] tkFileDialog In-Reply-To: <20130815205857.96622658e9fce1cec98b550b@web.de> References: <51F78F3D.4000605@tartan.co.za> <20130730150116.9c3d932e2028642fd9968ec2@web.de> <20130815205857.96622658e9fce1cec98b550b@web.de> Message-ID: <520DD38A.8030106@tartan.co.za> Hi Michael Thanks. this does the trick for me. Regards Paul Malherbe On 15/08/2013 20:58, Michael Lange wrote: > On Tue, 30 Jul 2013 15:01:16 +0200 > Michael Lange wrote: > >> Hmm... the "center on screen" gimmick works only with the first dialog, >> can someone fix that ;) >> Anyway, unless we come up with something better, I'd classify this as >> strictly "don't try this at home"-ish :) > Just for the fun of it I've been playing with this for a few more minutes > and finally found something that seems almost usable ;) > The trick seems to be that we must use a timer to make sure the geometry > is set only after the dialog window shows up, which however causes an ugly > "flashing" effect. Besides that this code snippet seems to work ok, the > geometry is set to one third of the screen's width and height and the > dialog is centered on the screen. > > Regards > > Michael > > ################################################################# > from Tkinter import * > import tkFileDialog > > root=Tk() > > def set_filedialog_geometry(): > w, h = root.winfo_screenwidth(), root.winfo_screenheight() > w0, h0 = w / 3, h / 3 > x, y = w / 2 - w0 / 2, h / 2 - h0 / 2 > try: > root.tk.call('wm', 'geometry', '.__tk_filedialog', > '%dx%d+%d+%d' % (w0, h0, x, y)) > except TclError: > print('TclError') > #root.after(100, set_filedialog_geometry) > > def ask_open_filename(**kw): > root.after(100, set_filedialog_geometry) > tkFileDialog.askopenfilename(**kw) > > def ask_saveas_filename(**kw): > root.after(100, set_filedialog_geometry) > tkFileDialog.asksaveasfilename(**kw) > > def test1(ev): > ask_open_filename() > def test2(ev): > ask_saveas_filename() > > root.bind('', test1) > root.bind('', test2) > > root.mainloop() > > > .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. > > Witch! Witch! They'll burn ya! > -- Hag, "Tomorrow is Yesterday", stardate unknown > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss at python.org > http://mail.python.org/mailman/listinfo/tkinter-discuss > From zaazbb at 163.com Mon Aug 19 07:54:53 2013 From: zaazbb at 163.com (zaazbb) Date: Mon, 19 Aug 2013 13:54:53 +0800 Subject: [Tkinter-discuss] python33 self tix do not support all the tix widgets? Message-ID: <3aba2c15.2d41.1409523e872.Coremail.zaazbb@163.com> when i run my test coe as below, i meet a error "_tkinter.TclError: invalid command name "tixControl". who can tell me, which tix widgets could used in python33? and which are not suppported by python33?? thanks. from tkinter import * from tkinter.tix import * root = Tk() c = Control(root, label = 'Number:') c.pack() root.mainloop() 2013-08-19 zaazbb -------------- next part -------------- An HTML attachment was scrubbed... URL: From klappnase at web.de Mon Aug 19 11:24:02 2013 From: klappnase at web.de (Michael Lange) Date: Mon, 19 Aug 2013 11:24:02 +0200 Subject: [Tkinter-discuss] python33 self tix do not support all the tix widgets? In-Reply-To: <3aba2c15.2d41.1409523e872.Coremail.zaazbb@163.com> References: <3aba2c15.2d41.1409523e872.Coremail.zaazbb@163.com> Message-ID: <20130819112402.d6f2660de6b9fc02c4c15945@web.de> Hi, On Mon, 19 Aug 2013 13:54:53 +0800 "zaazbb" wrote: > when i run my test coe as below, i meet a error "_tkinter.TclError: > invalid command name "tixControl". who can tell me, which tix widgets > could used in python33? and which are not suppported by python33?? > > thanks. > > > from tkinter import * > from tkinter.tix import * > > root = Tk() > > c = Control(root, label = 'Number:') > c.pack() > > root.mainloop() This looks like it does not have anything particular to do with Python, but results from a missing tix binary. I don't know which platform you use, on windows systems the tix binary should be included in the Python installer, so I guess it is some kind of unix system? If it's linux, probably the tix package has not been installed yet, about OSX I am not sure if it comes with tix by default or if it must be installed by hand. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. There are certain things men must do to remain men. -- Kirk, "The Ultimate Computer", stardate 4929.4 From zaazbb at 163.com Mon Aug 19 12:01:02 2013 From: zaazbb at 163.com (zaazbb) Date: Mon, 19 Aug 2013 18:01:02 +0800 Subject: [Tkinter-discuss] python33 self tix do not support all the tix widgets? In-Reply-To: <20130819112402.d6f2660de6b9fc02c4c15945@web.de> References: <3aba2c15.2d41.1409523e872.Coremail.zaazbb@163.com><20130819112402.d6f2660de6b9fc02c4c15945@web.de> Message-ID: <41956ef5.50ae.14096053ef2.Coremail.zaazbb@163.com> I am under windows xp sp3 platform. 2013-08-19 zaazbb ????Michael Lange ?????2013-08-19 17:24 ???Re: [Tkinter-discuss] python33 self tix do not support all the tix widgets? ????"tkinter-discuss" ??? Hi, On Mon, 19 Aug 2013 13:54:53 +0800 "zaazbb" wrote: > when i run my test coe as below, i meet a error "_tkinter.TclError: > invalid command name "tixControl". who can tell me, which tix widgets > could used in python33? and which are not suppported by python33?? > > thanks. > > > from tkinter import * > from tkinter.tix import * > > root = Tk() > > c = Control(root, label = 'Number:') > c.pack() > > root.mainloop() This looks like it does not have anything particular to do with Python, but results from a missing tix binary. I don't know which platform you use, on windows systems the tix binary should be included in the Python installer, so I guess it is some kind of unix system? If it's linux, probably the tix package has not been installed yet, about OSX I am not sure if it comes with tix by default or if it must be installed by hand. Regards Michael .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-. There are certain things men must do to remain men. -- Kirk, "The Ultimate Computer", stardate 4929.4 _______________________________________________ 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 srinivas.rambha at gmail.com Mon Aug 19 12:14:22 2013 From: srinivas.rambha at gmail.com (Srinivas Rao) Date: Mon, 19 Aug 2013 15:44:22 +0530 Subject: [Tkinter-discuss] How to display the values of dictionary to tk window. Message-ID: This code is to receive and display the text on the tk window.But what i want to achieve here is: When the character is sent from master to slave. Receive the character on the slave, look up the character in the dict, display the value that corresponds to the key. I tried but couldn't succeed, can any one help me with the correct code. for example: when slave received a key called 'hw' from master,It has to display "hello world" on slave pc , when '0' received from master, should display "how are you?" on slave pc. thanks in advance. import serialimport threadingimport Queueimport Tkinter as tkfrom Tkinter import *import timeimport sys class SerialThread(threading.Thread): def __init__(self, queue): threading.Thread.__init__(self) self.queue = queue def run(self): s = serial.Serial('COM11',9600) while True: if s.inWaiting(): text = s.readline(s.inWaiting()) self.queue.put(text) class App(tk.Tk): def __init__(self): tk.Tk.__init__(self) self.geometry("1360x750") self.time = '' self.clock = tk.Label(self, font=('times', 50, 'bold'), fg='black', bg='yellow') self.clock.pack(side='bottom', anchor='se') frameLabel = tk.Frame(self, padx=10, pady =50) self.text = tk.Text(frameLabel, wrap='word', bg=self.cget('bg'), relief='flat') frameLabel.pack() self.text.pack() self.queue = Queue.Queue() thread = SerialThread(self.queue) thread.start() self.process_serial() self.msgs = { 'hw':"hello world", 'wpp':"welcome to python programming", 'h':"hello", 0:"how are you?", 1:"bye....", 'egm': "english general message how are you", 'egm2':"If the world is flat be carefull not to fall off" } def process_serial(self): self.time = time.strftime('%H:%M:%S') self.clock.config(text=self.time) firstitem = True while self.queue.qsize(): try: new = self.queue.get() size = sys.getsizeof(new) if size<40: self.text.config(font='TimesNewRoman 100') elif size>=40 and size<70: self.text.config(font='TimesNewRoman 75') else: self.text.config(font='TimesNewRoman 50') if firstitem: self.text.delete(1.0, 'end') firstitem = False self.text.tag_configure("tag-center", justify='center') #self.text.tag_add("center", 1.0, "end") self.text.insert('end', my_dictionary.setdefault(signal, 'wrong signal')) #self.text.insert('end', new, 'tag-center') except Queue.Empty: pass self.after(1000, self.process_serial) app = App() app.mainloop() -------------- next part -------------- An HTML attachment was scrubbed... URL: From zaazbb at 163.com Wed Aug 21 05:38:34 2013 From: zaazbb at 163.com (zaazbb) Date: Wed, 21 Aug 2013 11:38:34 +0800 Subject: [Tkinter-discuss] How to display the values of dictionary to tk window. In-Reply-To: References: Message-ID: what about this code. I change it to python3 version. as i am using python33 under windows xp. import serial import threading import queue import tkinter as tk from tkinter import * import time import sys class SerialThread(threading.Thread): def __init__(self, queue): threading.Thread.__init__(self) self.queue = queue def run(self): s = serial.Serial('COM9',9600) while True: ## if s.inWaiting(): ## text = s.readline(s.inWaiting()) ## print(text) ## self.queue.put(text) text = s.readline() self.queue.put(text.splitlines()) class App(tk.Tk): def __init__(self): tk.Tk.__init__(self) self.geometry("1360x750") self.time = '' self.clock = tk.Label(self, font=('times', 50, 'bold'), fg='black', bg='yellow') self.clock.pack(side='bottom', anchor='se') frameLabel = tk.Frame(self, padx=10, pady =50) self.text = tk.Text(frameLabel, wrap='word', bg=self.cget('bg'), relief='flat') frameLabel.pack() self.text.pack() self.queue = queue.Queue() thread = SerialThread(self.queue) thread.start() self.process_serial() self.msgs = { 'hw':"hello world", 'wpp':"welcome to python programming", 'h':"hello", 0:"how are you?", 1:"bye....", 'egm': "english general message how are you", 'egm2':"If the world is flat be carefull not to fall off" } def process_serial(self): self.time = time.strftime('%H:%M:%S') self.clock.config(text=self.time) firstitem = True while self.queue.qsize(): try: new = self.queue.get() size = sys.getsizeof(new) if size<40: self.text.config(font='TimesNewRoman 100') elif size>=40 and size<70: self.text.config(font='TimesNewRoman 75') else: self.text.config(font='TimesNewRoman 50') if firstitem: self.text.delete(1.0, 'end') firstitem = False self.text.tag_configure("tag-center", justify='center') #self.text.tag_add("center", 1.0, "end") #self.text.insert('end', my_dictionary.setdefault(signal, 'wrong signal')) self.text.insert('end', self.msgs.setdefault(new[0].decode(), 'wrong signal')) #self.text.insert('end', new, 'tag-center') except queue.Empty: pass self.after(1000, self.process_serial) app = App() app.mainloop() 2013-08-21 zaazbb ????Srinivas Rao ?????2013-08-19 23:44 ???[Tkinter-discuss] How to display the values of dictionary to tk window. ????"Tkinter-discuss" ??? This code is to receive and display the text on the tk window.But what i want to achieve here is: When the character is sent from master to slave. Receive the character on the slave, look up the character in the dict, display the value that corresponds to the key. I tried but couldn't succeed, can any one help me with the correct code. for example: when slave received a key called 'hw' from master,It has to display "hello world" on slave pc , when '0' received from master, should display "how are you?" on slave pc. thanks in advance. import serial import threading import Queue import Tkinter as tk from Tkinter import * import time import sys class SerialThread(threading.Thread): def __init__(self, queue): threading.Thread.__init__(self) self.queue = queue def run(self): s = serial.Serial('COM11',9600) while True: if s.inWaiting(): text = s.readline(s.inWaiting()) self.queue.put(text) class App(tk.Tk): def __init__(self): tk.Tk.__init__(self) self.geometry("1360x750") self.time = '' self.clock = tk.Label(self, font=('times', 50, 'bold'), fg='black', bg='yellow') self.clock.pack(side='bottom', anchor='se') frameLabel = tk.Frame(self, padx=10, pady =50) self.text = tk.Text(frameLabel, wrap='word', bg=self.cget('bg'), relief='flat') frameLabel.pack() self.text.pack() self.queue = Queue.Queue() thread = SerialThread(self.queue) thread.start() self.process_serial() self.msgs = { 'hw':"hello world", 'wpp':"welcome to python programming", 'h':"hello", 0:"how are you?", 1:"bye....", 'egm': "english general message how are you", 'egm2':"If the world is flat be carefull not to fall off" } def process_serial(self): self.time = time.strftime('%H:%M:%S') self.clock.config(text=self.time) firstitem = True while self.queue.qsize(): try: new = self.queue.get() size = sys.getsizeof(new) if size<40: self.text.config(font='TimesNewRoman 100') elif size>=40 and size<70: self.text.config(font='TimesNewRoman 75') else: self.text.config(font='TimesNewRoman 50') if firstitem: self.text.delete(1.0, 'end') firstitem = False self.text.tag_configure("tag-center", justify='center') #self.text.tag_add("center", 1.0, "end") self.text.insert('end', my_dictionary.setdefault(signal, 'wrong signal')) #self.text.insert('end', new, 'tag-center') except Queue.Empty: pass self.after(1000, self.process_serial) app = App() app.mainloop() -------------- next part -------------- An HTML attachment was scrubbed... URL: From sjs at sonic.net Fri Aug 23 22:38:29 2013 From: sjs at sonic.net (s smith) Date: Fri, 23 Aug 2013 13:38:29 -0700 Subject: [Tkinter-discuss] CJK input/python 3/ibus Message-ID: <5217C845.9080404@sonic.net> Hi. I'm having issues using ibus and am trying to figure out where to go from here. This was on the ibus site where the ibus reply is essentially "not my problem": http://code.google.com/p/ibus/issues/detail?id=1391 I didn't find any mention on the python.org site Under Mint 14(Ubuntu 12.10)/python3.3/ibus1.4 I get core dumps when reseting ibus with focus in an entry widget. Under Mint 15(Ubuntu 13.04 I think)/python3.3/ibus1.5 the interface just doesn't change. I've attached the gdb output from the core file on the mint 14 machine. Where should I go from here??? Thank you Steve Smith -------------- next part -------------- GNU gdb (GDB) 7.5-ubuntu Copyright (C) 2012 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". For bug reporting instructions, please see: ... Reading symbols from /usr/local/bin/python3.3...done. [New LWP 29995] [New LWP 29996] warning: Can't read pathname for load map: Input/output error. [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by `/usr/local/bin/python3.3 ../tkinter/kanji_practice.py'. Program terminated with signal 11, Segmentation fault. #0 0x00000000000003e1 in ?? () (gdb) #0 0x00000000000003e1 in ?? () #1 0x00007fa2c16c8955 in Tk_HandleEvent () from /usr/lib/libtk8.5.so.0 #2 0x00007fa2c16c91b0 in ?? () from /usr/lib/libtk8.5.so.0 #3 0x00007fa2c141098f in Tcl_ServiceEvent () from /usr/lib/libtcl8.5.so.0 #4 0x00007fa2c1410c05 in Tcl_DoOneEvent () from /usr/lib/libtcl8.5.so.0 #5 0x00007fa2c1cf253d in Tkapp_MainLoop (selfptr=0x7fa2c1fa28b8, args=) at /home/sjs/Python-3.3.2/Modules/_tkinter.c:2542 #6 0x0000000000482b57 in call_function (oparg=, pp_stack=0x7fff996080e0) at Python/ceval.c:4063 #7 PyEval_EvalFrameEx (f=f at entry=0x7fa2c37ffc90, throwflag=throwflag at entry=0) at Python/ceval.c:2679 #8 0x000000000047c35e in PyEval_EvalCodeEx (_co=, globals=, locals=locals at entry=0x0, args=, argcount=argcount at entry=1, kws=0x1115880, kwcount=0, defs=0x7fa2c1f8dce8, defcount=1, kwdefs=kwdefs at entry=0x0, closure=0x0) at Python/ceval.c:3433 #9 0x00000000004825c8 in fast_function (nk=, na=1, n=, pp_stack=0x7fff99608380, func=0x7fa2c1f95170) at Python/ceval.c:4161 #10 call_function (oparg=, pp_stack=0x7fff99608380) at Python/ceval.c:4084 #11 PyEval_EvalFrameEx (f=f at entry=0x1115700, throwflag=throwflag at entry=0) at Python/ceval.c:2679 #12 0x000000000047c35e in PyEval_EvalCodeEx (_co=_co at entry=0x7fa2c2029db0, globals=globals at entry=0x7fa2c38286c8, locals=locals at entry=0x7fa2c38286c8, args=args at entry=0x0, argcount=argcount at entry=0, kws=kws at entry=0x0, kwcount=kwcount at entry=0, defs=defs at entry=0x0, defcount=defcount at entry=0, kwdefs=kwdefs at entry=0x0, closure=closure at entry=0x0) at Python/ceval.c:3433 #13 0x000000000047c40b in PyEval_EvalCode (co=co at entry=0x7fa2c2029db0, globals=globals at entry=0x7fa2c38286c8, locals=locals at entry=0x7fa2c38286c8) at Python/ceval.c:771 #14 0x00000000004a7329 in run_mod (arena=0x1154ef0, flags=0x7fff99608630, locals=0x7fa2c38286c8, globals=0x7fa2c38286c8, filename=, mod=) at Python/pythonrun.c:1981 #15 PyRun_FileExFlags (fp=0x114f6e0, filename=, start=, globals=0x7fa2c38286c8, locals=0x7fa2c38286c8, closeit=1, flags=0x7fff99608630) at Python/pythonrun.c:1937 #16 0x00000000004a84e9 in PyRun_SimpleFileExFlags (fp=fp at entry=0x114f6e0, filename=, closeit=closeit at entry=1, flags=flags at entry=0x7fff99608630) at Python/pythonrun.c:1447 #17 0x00000000004a8eb9 in PyRun_AnyFileExFlags (fp=fp at entry=0x114f6e0, filename=, closeit=closeit at entry=1, flags=flags at entry=0x7fff99608630) at Python/pythonrun.c:1169 #18 0x00000000004bf21a in run_file (p_cf=0x7fff99608630, filename=0x10a22a0 L"../tkinter/kanji_practice.py", fp=0x114f6e0) at Modules/main.c:306 #19 Py_Main (argc=argc at entry=2, argv=argv at entry=0x10a1010) at Modules/main.c:743 #20 0x00000000004195f9 in main (argc=2, argv=) at ./Modules/python.c:58 (gdb) quit From micko.madrid at gmail.com Sat Aug 31 19:09:08 2013 From: micko.madrid at gmail.com (Michael O'Donnell) Date: Sat, 31 Aug 2013 19:09:08 +0200 Subject: [Tkinter-discuss] Accessibility issues and Tkinter Message-ID: Hi All, Does anyone know about issues related to getting Tkinter interfaces working with a "screen reader" (these programs that speak interface text for the sight impaired). Mick