Re: Tkinter text widget
On Oct 6, 11:18 pm, goldtech <[EMAIL PROTECTED]> wrote:
> I thought the "DISABLED" made it so I could not edit it. But it also
> makes it so I can not scroll down. If you make the window smaller than
> the content then try to put a cursor in there to use up/down arrow you
> can't.
>
> What I want is not to be able to change text content, but no other
> action is disabled. Is this complicated to do?
>
> Thanks.
>
> from Tkinter import *
> root = Tk()
> text = Text(root, font=("Courier"))
> text.pack()
> i='123456789abcdefghijklmnopqrstuvwxyz\n'
> for x in range(30):
> text.insert(END, i)
> text.config(state=DISABLED)
> mainloop()
You can scroll, but you can't see the cursor. Use
for x in range(30):
text.insert(END, "%3d " % x + i)
to check.
ED
--
http://mail.python.org/mailman/listinfo/python-list
Re: TKinter problem
C D Wood wrote:
> To whom this may concern,
> Below is the source code, which
>
> demonstrates a
> problem I am having making a GUI for my python project work.
> 'table.txt'
> is a file that is read from the same folder.
>
> My code writes to a text file 'table.txt', and 'table.txt' is displayed
> in
> the GUI. The user can generate new data at the click of a button
> which re-writes 'table.txt', but I can only add the new table to the
> GUI
> window rather than 'update' the existing one.
>
> Any assistance would be much appreciated,
>
> Regards,
> Christian Wood.
> Part III Aerospace Engineering
> University of Southampton, UK.
>
> ##
> from Tkinter import *
>
> #Tkinter User Interface
> class MoC:
> def __init__(self, master):
> frame = Frame(master, width=600, height=800, bd=1)
> frame.pack()
>
> #Button frame
> iframe4 = Frame(frame, bd=2, relief=SUNKEN)
> #Using this button below, I want to update the text box in iframe5.
> Button(iframe4, text='Display table.txt',
> command=self.DisplayUpdate).pack(side=LEFT, padx=5)
> Button(iframe4, text='Quit', command=self.quit).pack(side=LEFT,
> padx=5)
> iframe4.pack(expand=1, fill=X, pady=10, padx=5)
>
> #Text box frame
> iframe5 = Frame(frame, bd=2, relief=SUNKEN)
> text=Text(iframe5, height=10, width =70)
> fd = open('table.txt') #table.txt must be in the same folder
> lines = fd.read()
> fd.close()
> text.insert(END, lines)
> text.pack(side=LEFT, fill=X, padx=5)
> sb = Scrollbar(iframe5, orient=VERTICAL, command=text.yview)
> sb.pack(side=RIGHT, fill=Y)
> text.configure(yscrollcommand=sb.set)
> iframe5.pack(expand=1, fill=X, pady=10, padx=5)
>
> #Command definitions
> def quit(self):
> root.destroy()
>
> def DisplayUpdate(self): #The command definition used to update the
> display.
> #Could I insert a line here to remove the existing frame/text
> box first? <<<<<=
> iframe5 = Frame(root, bd=2, relief=SUNKEN)
> text = Text(iframe5, height=10, width =70)
> fd = open('table.txt')
> lines = fd.read()
> fd.close()
> text.insert(END, lines)
> text.pack(side=LEFT, fill=X, padx=5)
> sb = Scrollbar(iframe5, orient=VERTICAL, command=text.yview)
> sb.pack(side=RIGHT, fill=Y)
> text.configure(yscrollcommand=sb.set)
> iframe5.pack(expand=1, fill=X, pady=10, padx=5)
>
> root = Tk()
> root.option_add('*font', ('arial', 10))
> all = MoC(root)
> root.title('2D Method of Characteristics')
> root.update
> root.mainloop()
What you want probably looks like this:
from Tkinter import *
class MoC:
def __init__(self, master):
frame = Frame(master, width=600, height=800, bd=1)
frame.pack()
iframe4 = Frame(frame, bd=2, relief=SUNKEN)
Button(iframe4, text='Display table.txt',
command=self.DisplayUpdate).pack(side=LEFT, padx=5)
Button(iframe4, text='Quit',
command=self._quit).pack(side=LEFT, padx=5)
iframe4.pack(expand=1, fill=X, pady=10, padx=5)
iframe5 = Frame(frame, bd=2, relief=SUNKEN)
self.text=Text(iframe5, height=10, width =70)
# read the file in the update function; create Text & Scrollbar
only once
self.text.pack(side=LEFT, fill=X, padx=5)
sb = Scrollbar(iframe5, orient=VERTICAL,
command=self.text.yview)
sb.pack(side=RIGHT, fill=Y)
self.text.configure(yscrollcommand=sb.set)
iframe5.pack(expand=1, fill=X, pady=10, padx=5)
self.DisplayUpdate()
def _quit(self): # quit is a keyword in python 2.4 IDE
root.destroy()
def DisplayUpdate(self):
fd = open('table.txt')
lines = fd.read()
fd.close()
self.text.config(state=NORMAL)
self.text.delete(1.0, END)
self.text.insert(END, lines)
self.text.config(state=DISABLED)
# previous 4 lines are to make the text READONLY, see more in:
#
http://www.pythonware.com/library/tkinter/introduction/x8309-patterns.htm
root = Tk()
root.option_add('*font', ('arial', 10))
all = MoC(root)
root.title('2D Method of Characteristics')
root.update
root.mainloop()
ezd
--
http://mail.python.org/mailman/listinfo/python-list
Command line arguments question (Windows XP)
Hi, I run simple script # u.py import sys print 'args',sys.argv in "Command Prompt" window, with 2 command lines on 2 PCs: # Case (1L): C:\tmp> u.py a b c args ['C:\\tmp\\u.py'] # Case (1D): C:\tmp> u.py a b c args ['C:\\tmp\\u.py', 'a', 'b', 'c'] # Cases (2L) & (2D): C:\tmp> C:\Python24\python u.py a b c args ['u.py', 'a', 'b', 'c'] How to explain this ? Particularly case (1L) without arguments. Both PCs have Python 2.4.2 and Windows XP SP2. The only difference I see is XP 'Home Edition' on Desktop (D) and XP 'Professional' on Laptop (L). Eugene -- http://mail.python.org/mailman/listinfo/python-list
Re: Tablelist 4.3
Arne Meissner wrote: > Hello everybody! > > I have downloaded the Tablelist 4.3 from http://www.nemethi.de/. > > Now I want to install it on my system Win XP. > > From the distribution I have got the following information: > " > On Windows, use WinZip or some other program capable of unpacking the > distribution file tablelist4_3.zip into the directory tablelist4.3, with the > subdirectories demos, doc, and scripts. > > Note that the file tablelistEdit.tcl in the scripts directory is only needed > for applications making use of interactive cell editing. Similarly, the > file tablelistMove.tcl in the same directory is only required for scripts > invoking the move or movecolumn command. Finally, the file > tablelistThemes.tcl is only needed for applications using the package > Tablelist_tile (see next section). > > Next, you should check the exact version number of your Tcl/Tk distribution, > given by the tcl_patchLevel and tk_patchLevel variables. If you are using > Tcl/Tk version 8.2.X, 8.3.0 - 8.3.2, or 8.4a1, then you should upgrade your > Tcl/Tk distribution to a higher release. This is because a bug in these Tcl > versions (fixed in Tcl 8.3.3 and 8.4a2) causes excessive memory use when > calling info exists on non-existent array elements, and Tablelist makes a > lot of invocations of this command. > > " > > But I don't know who to do it. > I have copied the files to my python directory. By calling the package I get > an error. > Would somebody please so kind and explain me the installtion step by step. > E.g. Where to copy the files?, Who can I obtain the tcl_patchLevel > information?, How can I invoke the tableliste in a python programm. > > Thank you! I use TableList_4.1 on Win XP. 1. put the whole directory tablelist4.1 of the zip-file into C:\Python24\tcl\tablelist4.1\ (i.e. all the archive into the directory). 2. put TableList.py from http://mfranklin.is-a-geek.org/docs/TableList/index.html anywhere as usual .py file. The documentation in the script is only a part of original tcl documentation, you may need more. 3. import & enjoy 4. there are some annoying errors in the version (like inconsistent returned types of some methods,...) ezd -- http://mail.python.org/mailman/listinfo/python-list
Re: converting latitude and longitude
On Nov 13, 2:25 pm, MRAB wrote: > Ronn Ross wrote: > > > I'm attempting to convert latitude and longitude coordinates from ... > > Does anyone know of a library or some existing out their to help with > > this conversion? > Some time ago I saw file named LLUTM... for such conversions with more than 20 ellipsoids. Language of the file - C or Python, not sure. Try Google for LLUTM to find more. Regards, Eugene -- http://mail.python.org/mailman/listinfo/python-list
