Megawidget Syntax (Tix)

2006-07-31 Thread Al in Dallas
I'm new to Python*. I am having trouble with the Tix NoteBook
megawidget. When I use a simpler megawidget, such as a ButtonBox, I can
add buttons by invoking

.add ('button3', text='Retry')

Unfortunately, with the Notebook, I need access to a subwidget, and all
my attempts have led to error messages. When I try to look up the
megawidget documentation, I can only find example in Tcl, so I'm
confident that if someone explains the syntax of the TixNoteBook
megawidget to me, I should be able to figure it out for all the other
megawidgets on my own. Here's an attempt to add something to the hlist
subwidget:

>>> lnotebook.hlist.add ('wrongsyntax')
Traceback (most recent call last):
  File "", line 1, in ?
  File "C:\Python24\lib\lib-tk\Tix.py", line 863, in add
return self.tk.call(self._w, 'add', entry, *self._options(cnf, kw))
_tkinter.TclError: invalid command name
".12204992.pane.p1.shlist.f1.hlist"

*I evaluated it many years ago (1996) when the only other choices
seemed to be Perl, Tcl, and VB. Unfortunately, my various employers
chose which scripting language would be used, and none of them ever
chose Python. Oddly, I ended up using all of the others.

-- 
http://mail.python.org/mailman/listinfo/python-list


Working with Widget after Instance loses the reference

2006-07-31 Thread Al in Dallas
I made the mistake of creating an instance of a widget and assigning it
to a name I'd already used. Now, if I use root.children or
root.slaves(), I can see the "lost" widget, but can I do anything else
with the string of numbers that shows up when I use root.children? I'd
like to destory the widget, for example. it would be even better if I
could create a new name and have it reference the "lost" widget.

Of course, I can just kill my toplevel and start over.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Working with Widget after Instance loses the reference

2006-08-01 Thread Al in Dallas
John McMonagle wrote:
> On Mon, 2006-07-31 at 11:15 -0700, Al in Dallas wrote:

[example of "losing" a widget]

> Consider the following code run in the python shell:
>
> >>> from Tkinter import *
> >>> r = Tk()
> >>> b1 = Button(r, text='test')
> >>> b1.pack()
> >>> b2 = Button(r, text='test2')
> >>> b2.pack()
> >>> r.children
> {'-1210160564': , '-1210225748':
> }
> >>> r.slaves()
> [,  0xb7de6a4c>]
> >>> b1 = 'xxx'
> >>> b1.destroy()
> Traceback (most recent call last):
>   File "", line 1, in ?
> AttributeError: 'str' object has no attribute 'destroy'
> >>> b1 = r.slaves()[0]
> >>> b1.destroy()
> >>>
>
>
> So, as long as you know what your widget instance is in root.slaves() or
> root.children you can assign it to a new name.

Since I've been leaving my shell open, I jumped in and tried:

recoveredlabel = root.slaves()[6]

And after I verified I could manipulate the widget with that
name, I executed:

 = recoveredlabel

Now the only difference between where I was (before I screwed up)
and where I am is that I've got this extra variable named
"recoveredlabel."

Thanks.

Now, do you have any advice on learning the syntax for dealing
with Tix megawidgets in Python? I guess my alternative is to
learn how to use Elmer or SWIG so I can hide all the Python
I've inherited "under the hood" and write my GUI in Tcl/Tk.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Megawidget Syntax (Tix)

2006-08-03 Thread Al in Dallas
Al in Dallas wrote:
> I'm new to Python*. I am having trouble with the Tix NoteBook
> megawidget. When I use a simpler megawidget, such as a ButtonBox, I can
> add buttons by invoking
>
> .add ('button3', text='Retry')
>
> Unfortunately, with the Notebook, I need access to a subwidget, and all
> my attempts have led to error messages. When I try to look up the
> megawidget documentation, I can only find example in Tcl, so I'm
> confident that if someone explains the syntax of the TixNoteBook
> megawidget to me, I should be able to figure it out for all the other
> megawidgets on my own. Here's an attempt to add something to the hlist
> subwidget:
>
> >>> lnotebook.hlist.add ('wrongsyntax')
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "C:\Python24\lib\lib-tk\Tix.py", line 863, in add
> return self.tk.call(self._w, 'add', entry, *self._options(cnf, kw))
> _tkinter.TclError: invalid command name
> ".12204992.pane.p1.shlist.f1.hlist"
>
> *I evaluated it many years ago (1996) when the only other choices
> seemed to be Perl, Tcl, and VB. Unfortunately, my various employers
> chose which scripting language would be used, and none of them ever
> chose Python. Oddly, I ended up using all of the others.

Well, I've found a partial answer for a slightly less complicated
megawidget:

>>> nbpage1 = notebook.add ('first',label="First")
>>> nbpage2 = notebook.add ('second',label="Second")
>>> notebook.pages()
[, ]
>>> notebook.subwidget_list
{'nbframe': , 'second':
, 'first': }
>>> nblab = Tix.Label(nbpage1,text="Test First Tab")
>>> nblab.pack()
>>> nbbtn = Tix.Button(nbpage2,text="Test Second Tab")
>>> nbbtn.pack()
>>> nbbbox = Tix.ButtonBox(nbpage1)
>>> nbbbox.add ('nbbxb1',text='Yeah!')
'.12236560.nbframe.first.12237760.nbbxb1'
>>> nbbbox.pack()
>>> nbbbox.add ('nbbxb2',text='Nah...')
'.12236560.nbframe.first.12237760.nbbxb2'
>>> nbp2lab1 = Tix.Label(nbpage2,text='This is the second most\ncomplicated widg
et that has been mastered\nCome over some day maybe play poker')
>>>
>>> nbp2lab1.pack()

I still don't have ListNoteBook widgets sussed, but I'm on the road.

-- 
http://mail.python.org/mailman/listinfo/python-list