Fredrik Lundh | 1 Oct 16:13 2005

Re: winfo_width problem

evgeny fadeev wrote:

> i am trying to use winfo_width to determine widget's size
> and it always returns me 1 regardless of wheter widget is
> packed/gridded or not.
>
> in native Tcl/Tk
> winfo width .widget
> works fine, i.e. returns actual width in pixels
>
> direct tk call from python tk.call('winfo','width',widget._w) still returns
> 1

the actual width and height is set by an idle task when the widget
is prepared for drawing.  idle tasks are executed by the event loop,
so you will usually have to call "update_idletasks" or "update" before
querying the size (event handlers are one exception to that rule).

reqwidth/reqheight is often a good alternative (see Gustavo's reply).

> i guess it points to some bug in tkinter  ......  what do you think?

it's the way things work under Tkinter.  if you want Tkinter to process
events, you have to give it a chance to do that.

</F>
jepler | 2 Oct 21:11 2005
Picon

tkinter wiki is down

The tkinter wiki is down at the moment.  I attempted to migrate it to
moinmoin 1.3.5 without understanding the consequences.  I hope to have it fixed
soon, probably by downgrading the moinmoin version.
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Olivier Feys | 5 Oct 16:15 2005
Picon

Python Tk Bwidget Tree problem with drag and drop

Hello,

I'm working at a Tk Python gui with a Bwidget tree.

Here is the code for the creation of the tree :

self.tree = bw.Tree(self,
                            bg='lightblue3',
                            opencmd=self.open_folder,
                            closecmd=self.close_folder,
                            selectbackground='indianred3',
                            selectforeground='white',
                            deltax=10,
                            deltay=23,
                            dropenabled=1,
                            dragenabled=1,
                            dropovermode='n',
                            crossfill='red4',
                            dropcmd=self.drop,
                            dragendcmd=self.drag,
                            *args, **kw)

the problem is that when i use the dropcmd, self.drop is called with  the target node as argument with other stuff, but nothing is passed about the source node. And when I use the dragendcmd, source and target "pathnames" are passed, but I can't do anything with it. When I print these pathnames I get :

.11072656.11073776


Can anyone help me out  ?

Thanks

Olivier



_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Stewart Midwinter | 5 Oct 16:26 2005
Picon

Fwd: Python Tk Bwidget Tree problem with drag and drop



---------- Forwarded message ----------
From: Stewart Midwinter <stewart.midwinter <at> gmail.com>
Date: Oct 5, 2005 8:25 AM
Subject: Re: [Tkinter-discuss] Python Tk Bwidget Tree problem with drag and drop
To: Olivier Feys <olivier.feys <at> gmail.com>

Olivier, I haven't used that widget, so this may be of little help, but it looks like you are referering an object name rather than one of its attributes.

On 10/5/05, Olivier Feys < olivier.feys <at> gmail.com> wrote:
the problem is that when i use the dropcmd, self.drop is called with  the target node as argument with other stuff, but nothing is passed about the source node. And when I use the dragendcmd, source and target "pathnames" are passed, but I can't do anything with it. When I print these pathnames I get :

.11072656.11073776


S
--
Stewart Midwinter
stewart <at> midwinter.ca
stewart.midwinter <at> gmail.com
Skype, GoogleTalk, iChatAV, MSN, Yahoo: midtoad
AIM:midtoad1



--
Stewart Midwinter
stewart <at> midwinter.ca
stewart.midwinter <at> gmail.com
Skype, GoogleTalk, iChatAV, MSN, Yahoo: midtoad
AIM:midtoad1

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
jepler | 5 Oct 19:37 2005
Picon

Re: Python Tk Bwidget Tree problem with drag and drop

I haven't used bwidget drag and drop myself.

You can get the widget object for a string path by using bwidget.nametowidget
but I had trouble with this since often the name of an internal widget, such as 
(in my case) '.1077785676.c', is returned.  Perhaps by chopping off parts until
a recognized widget is found will work.

Here's a small program I just wrote which demonstrates drag&drop between two
ListBox (not Tree) widgets.

from Tkinter import *
from bwidget import *
import bwidget

def nametowidget(name):
    while name:
        try:
            return bwidget.nametowidget(app, name)
        except KeyError:
            i = name.rindex('.')
            name = name[:i]

def draginit(a, b, c): return ('LISTBOX_ITEM', 'move', b)   

def do_drop(src, dest, where, op, kind, data):
    src = nametowidget(src)
    dest = nametowidget(dest)
    src.insert(END, text=dest.itemcget(data, "text"))

def do_drag(src, dest, op, kind, data, result):
    if result:
        src = nametowidget(src)
        src.delete(data)

common_args = {'dropcmd': do_drop, 'dragendcmd': do_drag, 'dragenabled': 1,
    'dropenabled': 1, 'dropovermode': 'w'} 

app = Tk()

t = ListBox(app, **common_args)
t.pack(side=LEFT)
for text in "abcde":
    t.insert(END, text=text*3)

u = ListBox(app, **common_args)
u.pack(side=LEFT)
for text in "12345":
    u.insert(END, text=text*3)

app.mainloop()

Jeff
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Michael Lange | 10 Oct 22:07 2005
Picon

pybwidget dialog bug

Hello all,

I found a bug in some of pybwidget's dialog classes.
The affected classes are MessageDialog, PasswordDialog, SelectFont and SelectColor;
it seems like there is no way to get the result the dialog box returns.

The problem is the call to Tkinter.Widget.__init__() , which itself calls
Tkinter.BaseWidget.__init__(), where the result of self.tk.call() gets lost.

I tried to avoid this by creating a separate constructor class for these dialogs
where self.tk.call() is called by a separate show() method, which allows to catch the
return value (see the code below).
It's probably not perfect, but as far as I have tried, it seems to work.

However, the resulting syntax looked a little weird to me, so I added shortcut functions
that turn e.g

        dialog = SelectFont(master)
        newfont = dialog.show()
resp.:
        newfont = SelectFont(master).show()

into

        newfont = selectfont(master)
.

BTW, the SelectColorMenu() function doesn't seem to work either, however if
I haven't missed something, it is the same as SelectColor(master, type='popup'),
so I'm not sure if it is necessary at all.

Regards

Michael

################################################################################################

class _QuestionDialog(ButtonBox, _Frame):
    '''Internal class for use in dialog boxes that should return the result of the
    corresponding tk command. This is mostly copied from Tkinter.BaseWidget.__init__(),
    but the tk command is only called if explicitely requested by calling self.show().'''
    def __init__(self, master, widgetName, cnf={}, **kw):
        self.widgetName = widgetName
        self.master = master
        if kw:
            self._cnf = Tkinter._cnfmerge((cnf, kw))
        else:
            self._cnf = cnf
        Tkinter.BaseWidget._setup(self, master, self._cnf)
        classes = []
        for k in self._cnf.keys():
            if type(k) is Tkinter.ClassType:
                classes.append((k, self._cnf[k]))
                del self._cnf[k]

    def show(self):
        result = self.tk.call((self.widgetName, self._w) + self._options(self._cnf))
        return result

class MessageDialog(_QuestionDialog):
    def __init__(self, master, cnf={}, **kw):
        self._require(master)
        _QuestionDialog.__init__(self, master, "MessageDlg", cnf, **kw)

def messagedialog(master, cnf={}, **kw):
    return MessageDialog(master, cnf, **kw).show()

class PasswordDialog(_QuestionDialog):
    def __init__(self, master, cnf={}, **kw):
        self._require(master)
        _QuestionDialog.__init__(self, master, "PasswdDlg", cnf, **kw)

def passworddialog(master, cnf={}, **kw):
    return PasswordDialog(master, cnf, **kw).show()

class SelectFont(_QuestionDialog):
    def __init__(self, master, cnf={}, **kw):
        _QuestionDialog.__init__(self, master, "SelectFont", cnf, **kw)
        if kw.has_key('type') and kw['type'] == 'toolbar':
            # create the toolbar widget 
            self.show()

    def loadfont(self):
        return self.tk.call("SelectFont::loadfont")

def selectfont(master, cnf={}, **kw):
    kw['type'] = 'dialog'
    return SelectFont(master, cnf, **kw).show()

class SelectColor(_QuestionDialog):
    def __init__(self, master, cnf={}, **kw):
        _QuestionDialog.__init__(self, master, "SelectColor", cnf, **kw)

    def setcolor(self, index, color):
        self.tk.call("SelectColor::setcolor", index, color)

def selectcolor(master, cnf={}, **kw):
    return SelectColor(master, cnf, **kw).show()

#########################################################################################
Olivier Feys | 15 Oct 16:36 2005
Picon

Re: Python Tk Bwidget Tree problem with drag and drop

Thanks a lot Jeff, i think this is really going to help me.



On 05/10/05, jepler <at> unpythonic.net <jepler <at> unpythonic.net> wrote:
I haven't used bwidget drag and drop myself.

You can get the widget object for a string path by using bwidget.nametowidget
but I had trouble with this since often the name of an internal widget, such as
(in my case) '.1077785676.c', is returned.  Perhaps by chopping off parts until
a recognized widget is found will work.

Here's a small program I just wrote which demonstrates drag&drop between two
ListBox (not Tree) widgets.

from Tkinter import *
from bwidget import *
import bwidget

def nametowidget(name):
    while name:
        try:
            return bwidget.nametowidget(app, name)
        except KeyError:
            i = name.rindex('.')
            name = name[:i]

def draginit(a, b, c): return ('LISTBOX_ITEM', 'move', b)

def do_drop(src, dest, where, op, kind, data):
    src = nametowidget(src)
    dest = nametowidget(dest)
    src.insert(END, text=dest.itemcget(data, "text"))

def do_drag(src, dest, op, kind, data, result):
    if result:
        src = nametowidget(src)
        src.delete(data)

common_args = {'dropcmd': do_drop, 'dragendcmd': do_drag, 'dragenabled': 1,
    'dropenabled': 1, 'dropovermode': 'w'}

app = Tk()

t = ListBox(app, **common_args)
t.pack(side=LEFT)
for text in "abcde":
    t.insert(END, text=text*3)

u = ListBox(app, **common_args)
u.pack(side=LEFT)
for text in "12345":
    u.insert(END, text=text*3)

app.mainloop()


Jeff





--
                                                    
Olivier Feys                                      

Ringlaan 20
B-3080 Tervuren - BELGIUM
mailto:olivier.feys <at> gmail.com
Mobile phone : +32486/41.65.81

                                                    

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Fredrik Lundh | 16 Oct 22:58 2005

ANN: WCK for Tkinter 1.1 beta 1 (october 15, 2005)

(new, improved, and with the correct date in the subject line!)

The Widget Construction Kit (WCK) is an extension API that allows
you to implement custom widgets in pure Python.  The WCK can be
(and is being) used for everything from light-weight display widgets
to full-blown editor frameworks.

The Tkinter3000 implementation of the WCK supports all recent
versions of Python and Tk/Tkinter.

The 1.1 beta 1 release adds improved controller support, resource
caching for pens, brushes, and fonts, and support for creating image
objects from data in strings.

Introduction:
    http://www.effbot.org/zone/wck-1.htm

Downloads:
    http://www.effbot.org/downloads#tkinter3000

Documentation:
    http://www.effbot.org/zone/wck.htm
    http://www.effbot.org/zone/pythondoc-api.htm

Using WCK and AggDraw to draw anti-aliased graphics:
    http://www.effbot.org/zone/wck-aggview.htm

enjoy /F
Mohammad Tayseer | 21 Oct 22:08 2005
Picon

GUI designer for Tkinter

dear friends
 does anyone know about a *free* gui designer for
Tkinter? I found SpecTix, but its support for Python
is not stable.
thanks in advance

	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com
Stewart Midwinter | 21 Oct 23:23 2005
Picon

Re: GUI designer for Tkinter

---------- Forwarded message ----------
From: Stewart Midwinter <stewart.midwinter <at> gmail.com>
Date: Oct 21, 2005 3:23 PM
Subject: Re: [Tkinter-discuss] GUI designer for Tkinter
To: Mohammad Tayseer <m_tayseer82 <at> yahoo.com>

Mohammad, have you tried Notepad?  It's free!  :-)

Most of us that work with Tkinter do actually use a text editor for
our GUI interface design.

But when you are just starting out it might be nice to use a graphical
designer.  I don't know of any that are permanently free, but here's
an idea.  ActiveState's Komodo Pro editor does include a Tkinter
designer, and you can try the product free for 30 days.  That might be
long enough to get you past the steep part of the learning curve.  And
you might find that Komodo is a good enough editor to be worth the $$.
  I sure enjoy using it myself.

cheers
s

On 10/21/05, Mohammad Tayseer <m_tayseer82 <at> yahoo.com> wrote:
>  does anyone know about a *free* gui designer for
> Tkinter?

--
Stewart Midwinter
stewart <at> midwinter.ca
stewart.midwinter <at> gmail.com
Skype, GoogleTalk, iChatAV, MSN, Yahoo: midtoad
AIM:midtoad1

--
Stewart Midwinter
stewart <at> midwinter.ca
stewart.midwinter <at> gmail.com
Skype, GoogleTalk, iChatAV, MSN, Yahoo: midtoad
AIM:midtoad1

Gmane