why is the button sunken when called through a bind method, and not
with the command attribute?
Thank you!
## Cut'nPaste example
from Tkinter import *
import tkMessageBox
class Vue(object):
def __init__(self):
self.root=Tk()
self.root.title ("test button visual state")
self.b1=Button( self.root,text= "tkMessageBox.s howinfo with bind
:-(") #,command=self. showMsg)
self.b1.bind("< Button>",self.s howMsg)
self.b2=Button( self.root,text= "tkMessageBox.s howinfo with
command :-)",command=self .showMsg)
self.b1.pack()
self.b2.pack()
self.root.mainl oop()
def showMsg(self,ev t=1):
if evt==1:
txt="From button with command"
else:
txt="From button with bind"
tkMessageBox.sh owinfo("Test of button", txt)
if __name__=="__ma in__":
v=Vue() 4 3180
<jm*********@gm ail.comwrote:
To: <py*********@py thon.org>
| why is the button sunken when called through a bind method, and not
| with the command attribute?
| Thank you!
|
|
| ## Cut'nPaste example
| from Tkinter import *
| import tkMessageBox
|
| class Vue(object):
| def __init__(self):
| self.root=Tk()
| self.root.title ("test button visual state")
| self.b1=Button( self.root,text= "tkMessageBox.s howinfo with bind
| :-(") #,command=self. showMsg)
| self.b1.bind("< Button>",self.s howMsg)
8<---------------------------------------------------------------------------
change this to :
self.b1.bind("< ButtonRelease>" ,self.showMsg)
Problem is that a button "sinks in" when you press it and "springs back" when
you release it...
and the "Button" leaves it sunken.... - because when you release, the control is
no longer there
- Hendrik
Hendrik van Rooyen wrote:
<jm*********@gm ail.comwrote:
To: <py*********@py thon.org>
| why is the button sunken when called through a bind method, and not
| with the command attribute?
| Thank you!
|
|
| ## Cut'nPaste example
| from Tkinter import *
| import tkMessageBox
|
| class Vue(object):
| def __init__(self):
| self.root=Tk()
| self.root.title ("test button visual state")
| self.b1=Button( self.root,text= "tkMessageBox.s howinfo with bind
| :-(") #,command=self. showMsg)
| self.b1.bind("< Button>",self.s howMsg)
8<---------------------------------------------------------------------------
change this to :
self.b1.bind("< ButtonRelease>" ,self.showMsg)
Problem is that a button "sinks in" when you press it and "springs back" when
you release it...
and the "Button" leaves it sunken.... - because when you release, the control is
no longer there
- Hendrik
Thanks Hendrik - is the command attribute connected to the bindable
events?
jm
<jm*********@gm ail.comWrote:
|
| Hendrik van Rooyen wrote:
| <jm*********@gm ail.comwrote:
| >
| To: <py*********@py thon.org>
| >
| >
| | why is the button sunken when called through a bind method, and not
| | with the command attribute?
| | Thank you!
| |
| |
| | ## Cut'nPaste example
| | from Tkinter import *
| | import tkMessageBox
| |
| | class Vue(object):
| | def __init__(self):
| | self.root=Tk()
| | self.root.title ("test button visual state")
| | self.b1=Button( self.root,text= "tkMessageBox.s howinfo with bind
| | :-(") #,command=self. showMsg)
| | self.b1.bind("< Button>",self.s howMsg)
| >
| >
8<---------------------------------------------------------------------------
| >
| change this to :
| >
| self.b1.bind("< ButtonRelease>" ,self.showMsg)
| >
| Problem is that a button "sinks in" when you press it and "springs back"
when
| you release it...
| >
| and the "Button" leaves it sunken.... - because when you release, the
control is
| no longer there
| >
| - Hendrik
| Thanks Hendrik - is the command attribute connected to the bindable
| events?
| jm
I don't have a clue - you are either asking about advanced magic here,
or I don't understand your question - I believe the lower level routines
are common, but I don't *Know* this - so its a pity that some people
who shall be nameless have beaten their brains out in a thread about
a directory name here..
You may have noticed that there is another subtle bug with what I have
suggested to you - when you press the offending button, then move the
mouse to move the cursor off the screen button, - the button
"springs back" as expected - but then when you release the mouse
button, off the screen button, the call back is done anyway, instead of
being cancelled when the cursor moves off the screen button.
- for the command case, the sequence is different, and the call back is done
only if the release is done on the screen button...
- But this may just be my setup - does yours do the same?
I don't know how to fix that - you could look at sequences of events - button
push followed by release - But I doubt whether this will help, as its doing
something like that anyway (haven't tried it)
- Hendrik
Hendrik van Rooyen wrote:
<jm*********@gm ail.comWrote:
|
| Hendrik van Rooyen wrote:
| <jm*********@gm ail.comwrote:
| >
| To: <py*********@py thon.org>
| >
| >
| | why is the button sunken when called through a bind method, and not
| | with the command attribute?
| | Thank you!
| |
| |
| | ## Cut'nPaste example
| | from Tkinter import *
...
| and the "Button" leaves it sunken.... - because when you release, the
control is
| no longer there
| >
| - Hendrik
| Thanks Hendrik - is the command attribute connected to the bindable
| events?
| jm
I don't have a clue - you are either asking about advanced magic here,
or I don't understand your question - I believe the lower level routines
are common, but I don't *Know* this - so its a pity that some people
who shall be nameless have beaten their brains out in a thread about
a directory name here..
You may have noticed that there is another subtle bug with what I have
suggested to you - when you press the offending button, then move the
mouse to move the cursor off the screen button, - the button
"springs back" as expected - but then when you release the mouse
button, off the screen button, the call back is done anyway, instead of
being cancelled when the cursor moves off the screen button.
- for the command case, the sequence is different, and the call back is done
only if the release is done on the screen button...
- But this may just be my setup - does yours do the same?
I don't know how to fix that - you could look at sequences of events - button
push followed by release - But I doubt whether this will help, as its doing
something like that anyway (haven't tried it)
- Hendrik
Same behavior here - Also, I added a bind to Button event and another
to ButtonRelease, and also had the command attribute. All three
*events* are processed, in similar fashion that you describe above.
Finally, the command attribute seems to works like a ButtonRelease BUT
still permits a binding to another function on a ButtonRelease event
(and only one) so if the lower level functions might be the same the
path to them seem different.
I found this article that pertains to the question: http://www.ferg.org/thinking_in_tkinter/tt075.py
but I'll postpone my own investigation at this time to return to my
program ;-)
Thanks again,
Jean-Marc This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ajay |
last post by:
hi!
my application consists of a GUI with a number of functions. One of these
runs a server in a separate thread. the thread is started and given the
function start_server to execute
the problem is when within start_server i try to display anything using
tkMessageBox, nothing gets displayed and my application crashes. Any ideas
what i am...
|
by: Club-B42 |
last post by:
when i start opt_newlogin.py directly it works fine(outputs '1 1 1 1'),
but if i start it from options.py there is an error(outputs '').
========
opt_newlogin.py
========
from config import *
from Tkinter import *
from opt_newlogin import newlogin
|
by: Peter Kleiweg |
last post by:
I have an application written in Tkinter. There is a menu item
'quit' that calls the function 'quit'. If 'quit' is called, it
first checks if there is unsaved data. If there is, it won't let
the application exit unless you confirm to disregard the
changes.
So far, so good.
I want the program to behave identical if the 'close' button of...
|
by: Glen |
last post by:
Is it possible to to detect a Tkinter top-level window being closed with the
close icon/button (top right), for example to call a function before the
window actually closes?
Python 2.4 / Linux (2.6 kernel) if that makes any difference.
Any info would be greatly appreciated.
Thanks
Glen
|
by: Stewart Midwinter |
last post by:
I have a Tkinter app running on cygwin. It includes a Test menu item
that does nothing more than fetch a directory listing and display it
in a Toplevel window (I'd use a tkMessageBox showinfo widget, but for
some reason the text is invisible on cygwin).
After I close the Toplevel widget, all of the menus in my app behave
as though they...
| |
by: Gigs_ |
last post by:
class MenuDemo(Frame):
def __init__(self, parent=None):
Frame.__init__(self, parent)
self.pack(expand=YES, fill=BOTH)
self.createWidgets()
def createWidgets(self):
self.makeMenuBar()
self.makeToolBar()
L = Label(self, text='Menu and Toolbar demo')
|
by: rahulnag22 |
last post by:
I have created a button widget with a button click binding. The button
initially has a state=disabled. I can see the greyed out version of
the button in the GUI. But If I click on the button it still invokes
the callback/binding function.
Any suggestions as to why the callback is being invoked even though
the button has a disabled state. It...
|
by: Guilherme Polo |
last post by:
On Thu, Aug 28, 2008 at 10:29 AM, <dudeja.rajat@gmail.comwrote:
It is good to post a short code sample that demonstrates the problem,
but it has to run by itself at least.
tkMessageBox blocks till you finish it, maybe that is what is causing
your problem but it is hard to tell what you are doing wrong in that
myAppGui without seeing it...
|
by: Haiyan |
last post by:
Dear experts:
I am trying to add one xy-scrollbar on the canvas, then put lots of check buttons on the canvas. I got at least following 2 problems:
1.I can see the y-scroll bar but contents on canvas didn't move together when scroll y-scrollbar.
2.The x-scrollbar didn't show up as expected.
Do you have any idea? Thank you very much in...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |