From spooky.ln at tbs-software.com Mon Jan 2 18:58:21 2012 From: spooky.ln at tbs-software.com (Martin B) Date: Mon, 2 Jan 2012 18:58:21 +0100 Subject: [Tkinter-discuss] Just for example Message-ID: <20120102185821.6aaa857b@tbs-software.com> Hi all, Now i have some time and i want to write simple text game engine using tkinter. I searching some ideas for GUI. Have anybody your own widgets, style or something. I know how to use ttk.Style but i'm not graphician. I'm very interested with TkZinc which is absolute amazing. But i dont want use it :) I found only some pyttk samples for beginning. thanks for ideas. From jasonveldicott at gmail.com Fri Jan 13 03:24:14 2012 From: jasonveldicott at gmail.com (Jason Veldicott) Date: Fri, 13 Jan 2012 13:24:14 +1100 Subject: [Tkinter-discuss] Error msg running Tcl demos for Tix 8.4.3 ("Can't find package Tix") Message-ID: Hi, I am trying to run the (Tcl) Tix 8.4.3 demos which reside in /tcl/tix8.4.3/demos. But running the main demo file, "widget", using the following command in the wish85 shell: wish C:/Python26/tcl/tix8.4.3/demos/widget produces this error message: "Can't find package Tix while executing "package require Tix" In an attempt to resolve the problem I added the Tix folder to the path, and also the Tix dll and lib files to the respective folders in python (DDLs and libs). I also tried copying the demo files into the Tix folder. Nothing seems to work. Any suggestions? Thanks Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From RLAdams at AdamsInfoServ.Com Wed Jan 25 01:17:07 2012 From: RLAdams at AdamsInfoServ.Com (Russell Adams) Date: Tue, 24 Jan 2012 18:17:07 -0600 Subject: [Tkinter-discuss] Autocompletion of Combobox Message-ID: <20120125001707.GI3438@x201> I took the liberty of updating the wiki entry on autocompletion, attached below. This version performs case insensitive searches both box Entry and Combobox, and the combobox sets it's popup menu from the completion list. It seems to work fairly well to date. Given I couldn't find an example for an autocompleting combobox, I figured I would share the version I cobbled together from the existing example so others might find it useful. Thanks. ---------------------------------------------------------------------- #!/usr/bin/env python # encoding: utf-8 """ tkentrycomplete.py A tkinter widget that features autocompletion. Created by Mitja Martini on 2008-11-29. Updated by Russell Adams, 2011/01/24 to support Python 3 and Combobox. Licensed same as original (not specified?), or public domain, whichever is less restrictive. """ import sys import os import tkinter import tkinter.ttk __version__ = "1.1" # I may have broken the unicode... tkinter_umlauts=['odiaeresis', 'adiaeresis', 'udiaeresis', 'Odiaeresis', 'Adiaeresis', 'Udiaeresis', 'ssharp'] class AutocompleteEntry(tkinter.Entry): """ Subclass of Tkinter.Entry that features autocompletion. To enable autocompletion use set_completion_list(list) to define a list of possible strings to hit. To cycle through hits use down and up arrow keys. """ def set_completion_list(self, completion_list): self._completion_list = sorted(completion_list, key=str.lower) # Work with a sorted list self._hits = [] self._hit_index = 0 self.position = 0 self.bind('', self.handle_keyrelease) def autocomplete(self, delta=0): """autocomplete the Entry, delta may be 0/1/-1 to cycle through possible hits""" if delta: # need to delete selection otherwise we would fix the current position self.delete(self.position, tkinter.END) else: # set position to end so selection starts where textentry ended self.position = len(self.get()) # collect hits _hits = [] for element in self._completion_list: if element.lower().startswith(self.get().lower()): # Match case-insensitively _hits.append(element) # if we have a new hit list, keep this in mind if _hits != self._hits: self._hit_index = 0 self._hits=_hits # only allow cycling if we are in a known hit list if _hits == self._hits and self._hits: self._hit_index = (self._hit_index + delta) % len(self._hits) # now finally perform the auto completion if self._hits: self.delete(0,tkinter.END) self.insert(0,self._hits[self._hit_index]) self.select_range(self.position,tkinter.END) def handle_keyrelease(self, event): """event handler for the keyrelease event on this widget""" if event.keysym == "BackSpace": self.delete(self.index(tkinter.INSERT), tkinter.END) self.position = self.index(tkinter.END) if event.keysym == "Left": if self.position < self.index(tkinter.END): # delete the selection self.delete(self.position, tkinter.END) else: self.position = self.position-1 # delete one character self.delete(self.position, tkinter.END) if event.keysym == "Right": self.position = self.index(tkinter.END) # go to end (no selection) if event.keysym == "Down": self.autocomplete(1) # cycle to next hit if event.keysym == "Up": self.autocomplete(-1) # cycle to previous hit if len(event.keysym) == 1 or event.keysym in tkinter_umlauts: self.autocomplete() class AutocompleteCombobox(tkinter.ttk.Combobox): def set_completion_list(self, completion_list): """Use our completion list as our drop down selection menu, arrows move through menu.""" self._completion_list = sorted(completion_list, key=str.lower) # Work with a sorted list self._hits = [] self._hit_index = 0 self.position = 0 self.bind('', self.handle_keyrelease) self['values'] = self._completion_list # Setup our popup menu def autocomplete(self, delta=0): """autocomplete the Combobox, delta may be 0/1/-1 to cycle through possible hits""" if delta: # need to delete selection otherwise we would fix the current position self.delete(self.position, tkinter.END) else: # set position to end so selection starts where textentry ended self.position = len(self.get()) # collect hits _hits = [] for element in self._completion_list: if element.lower().startswith(self.get().lower()): # Match case insensitively _hits.append(element) # if we have a new hit list, keep this in mind if _hits != self._hits: self._hit_index = 0 self._hits=_hits # only allow cycling if we are in a known hit list if _hits == self._hits and self._hits: self._hit_index = (self._hit_index + delta) % len(self._hits) # now finally perform the auto completion if self._hits: self.delete(0,tkinter.END) self.insert(0,self._hits[self._hit_index]) self.select_range(self.position,tkinter.END) def handle_keyrelease(self, event): """event handler for the keyrelease event on this widget""" if event.keysym == "BackSpace": self.delete(self.index(tkinter.INSERT), tkinter.END) self.position = self.index(tkinter.END) if event.keysym == "Left": if self.position < self.index(tkinter.END): # delete the selection self.delete(self.position, tkinter.END) else: self.position = self.position-1 # delete one character self.delete(self.position, tkinter.END) if event.keysym == "Right": self.position = self.index(tkinter.END) # go to end (no selection) if len(event.keysym) == 1: self.autocomplete() # No need for up/down, we'll jump to the popup # list at the position of the autocompletion def test(test_list): """Run a mini application to test the AutocompleteEntry Widget.""" root = tkinter.Tk(className=' AutocompleteEntry demo') entry = AutocompleteEntry(root) entry.set_completion_list(test_list) entry.pack() entry.focus_set() combo = AutocompleteCombobox(root) combo.set_completion_list(test_list) combo.pack() combo.focus_set() # I used a tiling WM with no controls, added a shortcut to quit root.bind('', lambda event=None: root.destroy()) root.bind('', lambda event=None: root.destroy()) root.mainloop() if __name__ == '__main__': test_list = ('apple', 'banana', 'CranBerry', 'dogwood', 'alpha', 'Acorn', 'Anise' ) test(test_list) ---------------------------------------------------------------------- ------------------------------------------------------------------ Russell Adams RLAdams at AdamsInfoServ.com PGP Key ID: 0x1160DCB3 http://www.adamsinfoserv.com/ Fingerprint: 1723 D8CA 4280 1EC9 557F 66E8 1154 E018 1160 DCB3 From mr at ramendik.ru Thu Jan 26 04:22:31 2012 From: mr at ramendik.ru (Mikhail Ramendik) Date: Thu, 26 Jan 2012 03:22:31 +0000 Subject: [Tkinter-discuss] TkTableWrapper: Column width questions Message-ID: Hello, TkTableWrapper column width questions Postby ramendik ? Thu Jan 26, 2012 4:14 am Windows, Python 2.6, tktable downloaded from sourceforge and TkTableWrapper from their wiki. I can successfully create a table, but all its columns are the same width. Can I somehow set different widths for different columns? Here's how I can get a table: root=Tkinter.Tk() array=TkTableWrapper.ArrayVar(root) table=TkTableWrapper.Table(root,variable=array,state="disabled",cols=4) #try to set width here? table.pack() root.mainloop() But when I tried to use the table.width() instead of that comment, I fail. table.width(1,20) and table.width("1,20") just fail on wrong parameters table.width(1,kwargs="width=20") and table.width(1,kwargs="20") do nothing apparently, nor does width(1,col=1,width=20) do anything. WIthout the first integer I get an exception. I would appreciate a way to set the column width. Also, when text in the array is bigger than the row it is not truncated - can I truncate it somehow, or failing that can I align it left not center (so I can truncate by window border as the column is rightmost anyhow)? -- Yours, Mikhail Ramendik Unless explicitly stated, all opinions in my mail are my own and do not reflect the views of any organization